From: Junio C Hamano <gitster@pobox.com>
To: "Đoàn Trần Công Danh" <congdanhqx@gmail.com>
Cc: Thomas De Zeeuw <thomas@slight.dev>, git@vger.kernel.org
Subject: Re: Bug: Segmentation fault in git diff
Date: Wed, 18 Aug 2021 13:30:05 -0700 [thread overview]
Message-ID: <xmqq5yw25wdu.fsf@gitster.g> (raw)
In-Reply-To: <YR0CkdVNVKa65vbo@danh.dev> ("Đoàn Trần Công Danh"'s message of "Wed, 18 Aug 2021 19:52:33 +0700")
Đoàn Trần Công Danh <congdanhqx@gmail.com> writes:
> This diff could fix the issue, and the test suite still passes:
>
> ---- 8< ----
>
> diff --git a/diff-lib.c b/diff-lib.c
> index f9eadc4fc1..8f303958dd 100644
> --- a/diff-lib.c
> +++ b/diff-lib.c
> @@ -192,7 +192,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
> * from the desired stage.
> */
> pair = diff_unmerge(&revs->diffopt, ce->name);
> - if (wt_mode)
> + if (pair && wt_mode)
> pair->two->mode = wt_mode;
> if (ce_stage(ce) != diff_unmerged_stage)
> continue;
> ---- >8 -----
Looks sensible.
The bug is the result of a bad interaction between cd676a51 (diff
--relative: output paths as relative to the current subdirectory,
2008-02-12) that decided to return NULL from diff_unmerge for an
irrelevant path outside the --relative area, and 095ce953
(diff-files: show unmerged entries correctly, 2011-04-22) that
assumed diff_unmerge() would always yield a usable unmerged pair.
As the NULL pair would never be added to the diff_queue(), when the
big loop around this area of code finishes and hands the processing
off to diffcore_std(), the mode futzing the original code was
attempting to do would have affected absolutely nothing, so I do not
think there would be any subtle breakage coming from this fix.
When you submit an "git am"-able patch, please have my Acked-by.
Thanks.
next prev parent reply other threads:[~2021-08-18 20:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-18 8:42 Bug: Segmentation fault in git diff Thomas De Zeeuw
2021-08-18 10:44 ` Đoàn Trần Công Danh
2021-08-18 12:52 ` Đoàn Trần Công Danh
2021-08-18 20:30 ` Junio C Hamano [this message]
2021-08-19 8:29 ` [PATCH] diff-lib: ignore all outsider if --relative asked Đoàn Trần Công Danh
2021-08-19 9:02 ` Carlo Arenas
2021-08-19 16:58 ` Junio C Hamano
2021-08-19 16:55 ` Junio C Hamano
2021-08-21 4:03 ` [PATCH v2] " Đoàn Trần Công Danh
2021-08-22 8:49 ` [PATCH v3] " Đoàn Trần Công Danh
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=xmqq5yw25wdu.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=congdanhqx@gmail.com \
--cc=git@vger.kernel.org \
--cc=thomas@slight.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.