Re: --function-context shows wrong function in chunk

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Zach Riggle <zachriggle@xxxxxxxxx> 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.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux