We always want diffs of working-dir + index versus repo #184

This commit is contained in:
Paul Gauthier 2023-08-08 08:48:48 -03:00
parent af854182dc
commit 589e7eefea

View file

@ -126,19 +126,11 @@ class GitRepo:
return commit_message return commit_message
def get_diffs(self, pretty, *args): def get_diffs(self, pretty, *args):
try: # we always want diffs of working-dir + index versus repo
commits = self.repo.iter_commits(self.repo.active_branch) args = ["--cached"] + list(args)
current_branch_has_commits = any(commits)
except git.exc.GitCommandError:
current_branch_has_commits = False
if not current_branch_has_commits:
return ""
if pretty: if pretty:
args = ["--color"] + list(args) args = ["--color"] + list(args)
if not args:
args = ["HEAD"]
diffs = self.repo.git.diff(*args) diffs = self.repo.git.diff(*args)
return diffs return diffs