From 55d55c32b262250318cb7024213918b7bf064b8b Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Fri, 9 Aug 2024 19:38:12 -0400 Subject: [PATCH] fix: Catch ValueError when getting current commit in cmd_diff --- aider/commands.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/aider/commands.py b/aider/commands.py index 7a27cfbbd..400098ef2 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -471,7 +471,12 @@ class Commands: self.io.tool_error("No git repository found.") return - current_head = self.coder.repo.repo.head.commit.hexsha + try: + current_head = self.coder.repo.repo.head.commit.hexsha + except ValueError: + self.io.tool_error("Unable to get current commit. The repository might be empty.") + return + commit_before_message = self.coder.commit_before_message if not commit_before_message or commit_before_message == current_head: