public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Tim Chase <git@tim•thechases.com>
To: git@vger•kernel.org
Subject: misleading diff-hunk header
Date: Tue, 21 Aug 2012 08:21:04 -0500	[thread overview]
Message-ID: <50338B40.9050606@tim.thechases.com> (raw)

[posted originally to git-users@ but advised this would be a better
forum]

diff.{type}.xfuncname seems to start searching backwards in
from the beginning of the hunk, not the first differing line.

To reproduce:

  $ mkdir tmp
  $ cd tmp
  $ git init
  $ cat > foo.c <<EOF
  int call_me(int maybe)
  {
  }

  int main()
  {
  }
  EOF
  $ git add foo.c
  $ git commit -m "Initial checkin"
  $ ed foo.c
  # main() should return 0
  $i
    return 0;
  .
  wq
  $ git diff

The diff returns a header line of

  @@ -4,4 +4,5 @@ int call_me(int maybe)

   int main()
   {
  +  return 0;
   }

misleadingly suggesting that the change occurred in the call_me()
function, rather than in main()

I'm running 1.7.2.5 from Debian Stable if that makes a difference.

Is this expected/proper behavior?

-tkc

FWIW, I stumbled across this tinkering with
diff.{typename}.xfuncname detailed in gitattributes(5)

             reply	other threads:[~2012-08-21 13:19 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-21 13:21 Tim Chase [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-08-21 12:57 misleading diff-hunk header Tim Chase
2012-08-21 15:22 ` Thomas Rast
2012-08-21 15:42   ` Tim Chase
2012-08-21 17:39     ` Johannes Sixt
2012-08-21 22:29       ` Junio C Hamano
2012-08-21 17:52     ` Junio C Hamano
2012-08-24 14:29       ` Jeff King
2012-08-24 15:05         ` Tim Chase
2012-08-24 16:44         ` Jeff King
2012-08-25  0:41           ` Tim Chase
2012-08-25  4:29             ` Junio C Hamano
2012-08-25 12:56               ` Tim Chase
2012-08-26 10:43                 ` Stefano Lattarini
2012-08-26 18:53                   ` 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=50338B40.9050606@tim.thechases.com \
    --to=git@tim$(echo .)thechases.com \
    --cc=git@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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