git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* diff.renames not working?
@ 2019-09-13 20:24 Robert Dailey
  2019-09-13 22:36 ` Bryan Turner
  2019-09-14  3:30 ` Jeff King
  0 siblings, 2 replies; 5+ messages in thread
From: Robert Dailey @ 2019-09-13 20:24 UTC (permalink / raw)
  To: Git

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-09-16 17:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-13 20:24 diff.renames not working? Robert Dailey
2019-09-13 22:36 ` Bryan Turner
2019-09-14  3:30 ` Jeff King
2019-09-16 14:25   ` Robert Dailey
2019-09-16 17:35   ` Junio C Hamano

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).