diff --git a/aider/commands.py b/aider/commands.py index bd2fb274b..94af9e380 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -477,9 +477,9 @@ class Commands: return if len(self.coder.commit_before_message) < 2: - return - - commit_before_message = self.coder.commit_before_message[-2] + commit_before_message = current_head + "^" + else: + commit_before_message = self.coder.commit_before_message[-2] if not commit_before_message or commit_before_message == current_head: self.io.tool_error("No changes to display since the last message.") diff --git a/aider/repo.py b/aider/repo.py index cefb12fca..45857c1d4 100644 --- a/aider/repo.py +++ b/aider/repo.py @@ -227,6 +227,8 @@ class GitRepo: args = [] if pretty: args += ["--color"] + else: + args += ["--color=never"] args += [from_commit, to_commit] diffs = self.repo.git.diff(*args) diff --git a/tests/basic/test_commands.py b/tests/basic/test_commands.py index 4cffd4043..c981418ea 100644 --- a/tests/basic/test_commands.py +++ b/tests/basic/test_commands.py @@ -818,7 +818,7 @@ class TestCommands(TestCase): # Mock repo.get_commit_message to return a canned commit message with mock.patch.object( - repo, "get_commit_message", return_value="Canned commit message" + coder.repo, "get_commit_message", return_value="Canned commit message" ): # Run cmd_commit commands.cmd_commit()