Jeff King <peff@xxxxxxxx> writes: > There's some magic in fake_reflog_parent() when we hit an entry with a > ... > This whole fake-parents things does just feel like a gigantic hack, > though. > ... > It seems like we should be able to just walk backwards down the > reflog list and show the entries. The revision machinery already > special-cases a bunch of reflog-walk bits; I don't know that adding one > or two more would be the end of the world. Unfortunate but I tend to agree that at least such an addition would make the "gigantic hack" a bit more complete one ;-) > diff --git a/reflog-walk.c b/reflog-walk.c > index ed99437ad..b7e489ad3 100644 > --- a/reflog-walk.c > +++ b/reflog-walk.c > @@ -259,6 +259,8 @@ void fake_reflog_parent(struct reflog_walk_info *info, struct commit *commit) > /* a root commit, but there are still more entries to show */ > reflog = &commit_reflog->reflogs->items[commit_reflog->recno]; > logobj = parse_object(&reflog->noid); > + if (!logobj) > + logobj = parse_object(&reflog->ooid); > } > > if (!logobj || logobj->type != OBJ_COMMIT) { We already have a loop to find an entry that is a commit that discards any non-commit object before the pre-context of this hunk. This "oops, old side is NULL so let's cover it up by using the new side" kicks in after that. I wonder if we can roll that cover-up logic into the loop, perhaps like do { reflog = &commit_reflog->...[recno]; commit_reflog->recno--; - logobj = parse_object(&reflog->ooid); + logobj = parse_object(is_null_oid(&reflog->ooid) + ? &reflog->noid : &reflog->ooid); - } while (commit_reflog->recno && (logobj && logobj->type != OBJ_COMMIT)); + } while (commit_reflog->recno && (!logobj || logobj->type != OBJ_COMMIT)); - - if (!logobj && commit_reflog->recno >= 0 && is_null_oid(&reflog->ooid)) { - /* a root commit ... */ - reflog = &commit_reflog->...[recno]; - logobj = parse_object(&reflog->noid); - } which may deal with your "both old and new sides were NULL" case better.