From 82cefe2b42300224ad3c148f8b1a569757cc617a Mon Sep 17 00:00:00 2001 From: Roman Perepelitsa Date: Thu, 22 Oct 2020 09:42:04 +0200 Subject: [PATCH] git commit -m 'fix a bug that prevents revwalking in shallow repos - https://github.com/romkatv/gitstatus/issues/179 - https://github.com/romkatv/powerlevel10k/issues/787 --- src/revwalk.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/revwalk.c b/src/revwalk.c index 1efb938bd3e..1536ef49360 100644 --- a/src/revwalk.c +++ b/src/revwalk.c @@ -373,9 +373,11 @@ static int add_parents_to_list(git_revwalk *walk, git_commit_list_node *commit, git_commit_list_node *p = commit->parents[i]; p->uninteresting = 1; - /* git does it gently here, but we don't like missing objects */ - if ((error = git_commit_list_parse(walk, p)) < 0) - return error; + if ((error = git_commit_list_parse(walk, p)) < 0) { + if (error != GIT_ENOTFOUND) return error; + /* this triggers on shallow repositories (e.g., cloned with --depth=0) */ + error = 0; + } if (p->parents) mark_parents_uninteresting(p);