git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Robert Dailey <rcdailey.lists@gmail.com>
To: Git <git@vger.kernel.org>
Subject: diff.renames not working?
Date: Fri, 13 Sep 2019 15:24:06 -0500	[thread overview]
Message-ID: <CAHd499BT35jvPtsuD9gfJB0HJ=NxtzyQOaiD7-=sHJbFYhphpg@mail.gmail.com> (raw)

I'm using Git version 2.23. I have the `diff.renames` setting set to
`copies`. My code base has a file named `JniPaymentManager.hpp` (and
`cpp`) that had too much code in it, so I refactored this file by
splitting out a significant portion of the code in it to another file,
named `ZPayClient.hpp` (and `cpp`). When I diff the topic branch
against the mainline, it shows it as a copy with a percentage:

```
$ git diff --name-status master...topic
C055    Jni/JniPaymentManager.cpp    ZPay/ZPayClient.cpp
C070    Jni/JniPaymentManager.hpp    ZPay/ZPayClient.hpp
```

Now my goal is to diff `ZPayClient.hpp` and see the changes to the
moved-out portion of code as it relates to the original state of that
code in `JniPaymentManager.hpp`. To do this, I tried this command:

```
$ git diff master...topic -- ZPay/ZPayClient.hpp
```

The unified diff header I got back is:

```
diff --git ZPay/ZPayClient.hpp ZPay/ZPayClient.hpp
new file mode 100644
index 00000000..6ebc2a9a
--- /dev/null
+++ ZPay/ZPayClient.hpp
```

Hmm, it's treating it as a new file. Even though I have `diff.renames`
set to `copies`? Even though `diff --name-status` acknowledges the
relationship with the original file for the code on `master`? This is
confusing...

Out of curiosity, I thought I'd try this command:

```
git diff --follow master...topic -- ZPay/ZPayClient.hpp
```

And I get this unified diff header:

```
diff --git Jni/JniPaymentManager.hpp ZPay/ZPayClient.hpp
similarity index 70%
copy from Jni/JniPaymentManager.hpp
copy to ZPay/ZPayClient.hpp
index fc18e2d2..6ebc2a9a 100644
--- Jni/JniPaymentManager.hpp
+++ ZPay/ZPayClient.hpp
```

Now this looks more like it. I can actually see a useful diff here,
instead of everything looking like a new file. But there is a lot of
confusion here:

1. `diff --follow` is not a documented[1] option. Why does it work?
2. `diff -M` doesn't actually work either. It should, though. In fact,
I expected it to work as `--follow` does. But it doesn't.
3. The `diff.renames` config doesn't seem to be working here, when it should.

Can someone explain the behavior I'm seeing? I really am confused
about all this...

[1]: https://git-scm.com/docs/git-diff

             reply	other threads:[~2019-09-13 20:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-13 20:24 Robert Dailey [this message]
2019-09-13 22:36 ` diff.renames not working? Bryan Turner
2019-09-14  3:30 ` Jeff King
2019-09-16 14:25   ` Robert Dailey
2019-09-16 17:35   ` 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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHd499BT35jvPtsuD9gfJB0HJ=NxtzyQOaiD7-=sHJbFYhphpg@mail.gmail.com' \
    --to=rcdailey.lists@gmail.com \
    --cc=git@vger.kernel.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).