diff options
author | Junio C Hamano <gitster@pobox.com> | 2012-05-07 13:29:16 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-05-07 13:29:16 -0700 |
commit | 5543501ced8e3303b7612b068831a111af0ab8b7 (patch) | |
tree | 4b97699842f6f81a38e34235ed85a8041623e2c0 /sequencer.c | |
parent | fc1320bfe2419e5eb3f43761e27ffa4f42a81825 (diff) | |
parent | 4b580061b350ae9d27ab7c3936a45828a33624c6 (diff) | |
download | git-5543501ced8e3303b7612b068831a111af0ab8b7.tar.gz |
Merge branch 'nh/empty-rebase'
By Neil Horman
* nh/empty-rebase:
git cherry-pick: do not dereference a potential NULL pointer
Diffstat (limited to 'sequencer.c')
-rw-r--r-- | sequencer.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/sequencer.c b/sequencer.c index f83cdfd637..3c384b94d2 100644 --- a/sequencer.c +++ b/sequencer.c @@ -261,9 +261,17 @@ static int is_index_unchanged(void) return error(_("Could not resolve HEAD commit\n")); head_commit = lookup_commit(head_sha1); - if (!head_commit || parse_commit(head_commit)) - return error(_("could not parse commit %s\n"), - sha1_to_hex(head_commit->object.sha1)); + + /* + * If head_commit is NULL, check_commit, called from + * lookup_commit, would have indicated that head_commit is not + * a commit object already. parse_commit() will return failure + * without further complaints in such a case. Otherwise, if + * the commit is invalid, parse_commit() will complain. So + * there is nothing for us to say here. Just return failure. + */ + if (parse_commit(head_commit)) + return -1; if (!active_cache_tree) active_cache_tree = cache_tree(); |