mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-09 14:14:59 +00:00
Handle diffs on a detached head #520
This commit is contained in:
parent
5c10944054
commit
c2b8b2355d
2 changed files with 40 additions and 4 deletions
|
@ -137,11 +137,17 @@ class GitRepo:
|
|||
|
||||
def get_diffs(self, fnames=None):
|
||||
# We always want diffs of index and working dir
|
||||
|
||||
current_branch_has_commits = False
|
||||
try:
|
||||
commits = self.repo.iter_commits(self.repo.active_branch)
|
||||
current_branch_has_commits = any(commits)
|
||||
except git.exc.GitCommandError:
|
||||
current_branch_has_commits = False
|
||||
active_branch = self.repo.active_branch
|
||||
try:
|
||||
commits = self.repo.iter_commits(active_branch)
|
||||
current_branch_has_commits = any(commits)
|
||||
except git.exc.GitCommandError:
|
||||
pass
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
if not fnames:
|
||||
fnames = []
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue