diff options
author | SZEDER Gábor <szeder@ira.uka.de> | 2016-06-03 22:42:35 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-06-06 15:06:44 -0700 |
commit | 71abeb753fa835642acb952316266dde21d7cec6 (patch) | |
tree | 1600ef9f3f1fe231412a3a8d05759f6e803cabff /reflog-walk.c | |
parent | 49fa3dc76179e04b0833542fa52d0f287a4955ac (diff) | |
download | git-71abeb753fa835642acb952316266dde21d7cec6.tar.gz |
reflog: continue walking the reflog past root commits
If a repository contains more than one root commit, then its HEAD
reflog may contain multiple "creation events", i.e. entries whose
"from" value is the null sha1. Listing such a reflog currently stops
prematurely at the first such entry, even when the reflog still
contains older entries. This can scare users into thinking that their
reflog got truncated after 'git checkout --orphan'.
Continue walking the reflog past such creation events based on the
preceeding reflog entry's "new" value.
The test 'symbolic-ref writes reflog entry' in t1401-symbolic-ref
implicitly relies on the current behavior of the reflog walker to stop
at a root commit and thus to list only the reflog entries that are
relevant for that test. Adjust the test to explicitly specify the
number of relevant reflog entries to be listed.
Reported-by: Patrik Gustafsson <pvn@textalk.se>
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'reflog-walk.c')
-rw-r--r-- | reflog-walk.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/reflog-walk.c b/reflog-walk.c index 0ebd1da5ce..a246af2767 100644 --- a/reflog-walk.c +++ b/reflog-walk.c @@ -241,6 +241,12 @@ void fake_reflog_parent(struct reflog_walk_info *info, struct commit *commit) logobj = parse_object(reflog->osha1); } while (commit_reflog->recno && (logobj && logobj->type != OBJ_COMMIT)); + if (!logobj && commit_reflog->recno >= 0 && is_null_sha1(reflog->osha1)) { + /* a root commit, but there are still more entries to show */ + reflog = &commit_reflog->reflogs->items[commit_reflog->recno]; + logobj = parse_object(reflog->nsha1); + } + if (!logobj || logobj->type != OBJ_COMMIT) { commit_info->commit = NULL; commit->parents = NULL; |