On Sun, 2021-01-03 at 19:02:24 +0100, Helge Oldach wrote:
Hi all,

I have deep cloned main from https://git.freebsd.org/src.git as
described in the mini primer and started pulling updates. Now I'm
stumbling over a bit of confusion:

| hmo@p48 /usr/src $ git log -p e35a01eec6926bfb5c088ca8961079b51a067bf3
| commit e35a01eec6926bfb5c088ca8961079b51a067bf3
| Merge: 2ff66a91552 96b88ac701b
| Author: Philip Paeps <phi...@freebsd.org>
| Date:   Wed Dec 30 12:50:26 2020 +0800
|
|     contrib/tzdata: import tzdata 2020f
|
|     Merge commit '96b88ac701b35ce68425046d4be8f51cb75b5d5b' into main
|
|     Changes: https://github.com/eggert/tz/blob/2020f/NEWS
|
|     MFC after:    1 day
|
| commit 96b88ac701b35ce68425046d4be8f51cb75b5d5b
| Author: Philip Paeps <phi...@freebsd.org>
| Date:   Wed Dec 30 12:45:24 2020 +0800
|
|     Import tzdata 2020f
|
| diff --git a/Makefile b/Makefile
| index 5064a190c5a..1136af9298f 100644
| --- a/Makefile
| +++ b/Makefile
| @@ -945,7 +945,10 @@ check_public: $(VERSION_DEPS)
|                 mkdir public.dir
|                 ln $(VERSION_DEPS) public.dir

What confuses me is that the diff refers to just "Makefile". Same for
the other files in this commit. The diff just looks like the vendor
commit and not like the merged commit. This is kind of confusing as
clearly this commit does not refer to the main source Makefile, but just
to contrib/tzdata/Makefile.

Well, you're looking at the diff of the vendor import, not the diff of the merge commit. The vendor area doesn't have a prefix in its tree, see the output of
git ls-tree -r 96b88ac701b35ce68425046d4be8f51cb75b5d5b
That is the vendor area tree for tzdata.

What trips you up is that git log -p does _not_ show diffs for merge commits by default, because with 2 parents for a commit, what's the diff really? Look carefully at the 2nd line, it says "Merge: 2ff66a91552 96b88ac701b" indicating that this is a merge commit.

To get a meaningful diff output, you sadly have to hand-hold git. What always works is comparing 2 trees directly, so (add -p to see full diff):
% git diff-tree 2ff66a91552 e35a01eec6926bfb5c088ca8961079b51a067bf3
:040000 040000 8feda71c4bc2d2deb3a6c3dcf19ca1272ef51c71 
6e6f976db44b4430645b0c6d7a169d5e5564acec M      contrib

This has to assume that the first parent shown was the previous commit on main, but it could well have been the other way round. But you also list the commit for 96b88ac701b35ce68425046d4be8f51cb75b5d5b so it's clear that this had to be the one.

You can short-cut this, assuming that the first parent will always be on main (I think this is true in the conversion).

% git diff e35a01eec^1..e35a01eec

(^1 means first parent of the commit, and is often equivalent to ~1 which means "go 1 back").

At which point you can read git-log(1) and see that there's also a --first-parent option, which will only walk the first parent and properly works in tandem with -p.

hth
Uli
_______________________________________________
freebsd-stable@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "freebsd-stable-unsubscr...@freebsd.org"

Reply via email to