From: Junio C Hamano <gitster@pobox.com>
To: Zach Riggle <zachriggle@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: --function-context shows wrong function in chunk
Date: Fri, 10 Jul 2020 14:12:55 -0700 [thread overview]
Message-ID: <xmqqimevrs4o.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <CAMP9c5kzRoVKEQMMVt_tnRMrayP+yT0c+Q2xxewbrZN8piCbHQ@mail.gmail.com> (Zach Riggle's message of "Fri, 10 Jul 2020 15:14:31 -0500")
Zach Riggle <zachriggle@gmail.com> writes:
[administrivia: do not top-post]
>> I think it is possible to modify the "find the line that match
>> xfuncname pattern" logic to start scanning backwards from the first
>> actual change (i.e. the blank line in the preimage of the patch
>> inside "int main() {" function in your example) and make the hunk
>> header say "int main() {" instead of "int other_routine() {".
>>
>> I however doubt that such a change makes any sense. In fact, I find
>> the sample output above both quite logical and also even desirable.
> This happens even with -U0 which does not include the e.g. trailing
> bit of other_routine.
Sure, it does not change the equation, though. We are finding the
line that matches the xfuncname pattern before the first line of the
hunk, which is "int other_routine() {" in your example.
> $ git diff -U0 -b --function-context
> diff --git i/example.c w/example.c
> index d87b59b..346e2a7 100644
> --- i/example.c
> +++ w/example.c
> @@ -6,3 +6,3 @@ int other_routine() {
> int main() {
> -
> + puts("Hello, world!");
> }
In your updated example, the line "int main() {" is the first line
of the hunk, and not a line before it.
If we said "int main() {" there, it would send a wrong signal that
there is another such line before the "int main() {" we see in the
hunk.
prev parent reply other threads:[~2020-07-10 21:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-10 18:38 --function-context shows wrong function in chunk Zach Riggle
2020-07-10 20:12 ` Junio C Hamano
2020-07-10 20:14 ` Zach Riggle
2020-07-10 21:12 ` Junio C Hamano [this message]
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=xmqqimevrs4o.fsf@gitster.c.googlers.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=zachriggle@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).