From: Junio C Hamano <junkio@cox.net>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Jim Meyering <jim@meyering.net>, git@vger.kernel.org
Subject: Re: "git-diff -p :/anything" always segfaults
Date: Sun, 11 Mar 2007 13:58:18 -0700 [thread overview]
Message-ID: <7vslcbv6ol.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <Pine.LNX.4.64.0703111322180.9690@woody.linux-foundation.org> (Linus Torvalds's message of "Sun, 11 Mar 2007 13:25:33 -0700 (PDT)")
Linus Torvalds <torvalds@linux-foundation.org> writes:
> On Sun, 11 Mar 2007, Jim Meyering wrote:
>>
>> I like the idea of the new ':/<oneline prefix>' notation, and gave it
>> a try, but all I could get was a segfault. It was dereferencing a NULL
>> commit list. Fix below. With it, this example now works:
>
> The fix is correct, but not complete.
>
>> - while ((commit = pop_most_recent_commit(&list, ONELINE_SEEN))) {
>> + while (list && (commit = pop_most_recent_commit(&list, ONELINE_SEEN))) {
>
> The old code was broken, but the new one isn't much better.
>
> "pop_most_recent_commit()" simply doesn't work that way. It *never*
> returns NULL. So having it as part of a while-loop was buggy to begin
> with, and you fixed the test, but the thing is, it should just look like
>
> while (list) {
> struct commit *commit;
>
> commit = pop_most_recent_commit(&list, ONELINE_SEEN);
> ..
>
> and the "pop_most_recent_commit()" simply shouldn't be part of the
> conditional at all.
That's what I did in my tentative commit based on Jim's patch
(except "commit" is also used to determine the return value from
the function).
next prev parent reply other threads:[~2007-03-11 20:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-11 18:49 "git-diff -p :/anything" always segfaults Jim Meyering
2007-03-11 19:08 ` Johannes Schindelin
2007-03-11 20:25 ` Linus Torvalds
2007-03-11 20:58 ` Junio C Hamano [this message]
2007-03-12 16:14 ` Linus Torvalds
2007-03-12 16:22 ` Linus Torvalds
2007-03-12 18:42 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vslcbv6ol.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
--cc=jim@meyering.net \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox