From 543227f6bd31647ded31ddd1c4d78fb147952853 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Fri, 9 Aug 2024 19:36:38 -0400 Subject: [PATCH] feat: Change cmd_diff to show diff since last message --- aider/commands.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/aider/commands.py b/aider/commands.py index f318bfd4a..7a27cfbbd 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -466,21 +466,21 @@ class Commands: return prompts.undo_command_reply def cmd_diff(self, args=""): - "Display the diff of the last aider commit" + "Display the diff of changes since the last message" if not self.coder.repo: self.io.tool_error("No git repository found.") return - last_commit_hash = self.coder.repo.repo.head.commit.hexsha[:7] + current_head = self.coder.repo.repo.head.commit.hexsha + commit_before_message = self.coder.commit_before_message - if last_commit_hash not in self.coder.aider_commit_hashes: - self.io.tool_error(f"Last commit {last_commit_hash} was not an aider commit.") - self.io.tool_error("You could try `/git diff` or `/git diff HEAD^`.") + if not commit_before_message or commit_before_message == current_head: + self.io.tool_error("No changes to display since the last message.") return diff = self.coder.repo.diff_commits( self.coder.pretty, - "HEAD^", + commit_before_message, "HEAD", )