Subject: Re: git-rev-list: add "--dense" flag

From: Jonas Fonseca <[email-masked]>
Date: Tue, 25 Oct 2005 20:40:30 +0200

Linus Torvalds <[email-masked]> wrote Tue, Oct 25, 2005:
> On Tue, 25 Oct 2005, Jonas Fonseca wrote:
> > 
> > Is the initial commit supposed to be listed when the file has been added
> > later?
> 
> Right now --dense will _always_ show the root commit. I didn't do the 
> logic that does the diff against an empty tree. I was lazy.
> 
> This patch does that, and may or may not work.

Without the workaround below it segfaults.

> Does this match what you expected?

Yes, thanks.

diff --git a/rev-list.c b/rev-list.c
index 5f125fd..82ec656 100644
--- a/rev-list.c
+++ b/rev-list.c
@@ -87,6 +87,7 @@ static void rewrite_one(struct commit **
 		struct commit *p = *pp;
 		if (p->object.flags & (TREECHANGE | UNINTERESTING))
 			return;
+		if (!p->parents) return;
 		/* Only single-parent commits don't have TREECHANGE */
 		*pp = p->parents->item;
 	}

-- 
Jonas Fonseca