* git show -m with a parent number
@ 2016-03-27 20:46 Anatoly Borodin
2016-03-28 19:16 ` Jeff King
0 siblings, 1 reply; 5+ messages in thread
From: Anatoly Borodin @ 2016-03-27 20:46 UTC (permalink / raw)
To: git
Hi All,
is there a good reason for `git show -m` to not accept the number of a
parent of a merge commit? I can run `git show --first-parent COMMIT`,
but need to write `git diff COMMIT^2 COMMIT` every time I want to diff
with the second parent!
`git cherry-pick -m 2 COMMIT` works, so why can't `git log` work like
that?
--
Mit freundlichen Grüßen,
Anatoly Borodin
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: git show -m with a parent number
2016-03-27 20:46 git show -m with a parent number Anatoly Borodin
@ 2016-03-28 19:16 ` Jeff King
2016-03-28 19:31 ` Junio C Hamano
2016-03-30 12:31 ` Anatoly Borodin
0 siblings, 2 replies; 5+ messages in thread
From: Jeff King @ 2016-03-28 19:16 UTC (permalink / raw)
To: Anatoly Borodin; +Cc: git
On Sun, Mar 27, 2016 at 08:46:02PM +0000, Anatoly Borodin wrote:
> is there a good reason for `git show -m` to not accept the number of a
> parent of a merge commit? I can run `git show --first-parent COMMIT`,
> but need to write `git diff COMMIT^2 COMMIT` every time I want to diff
> with the second parent!
I think it could, but nobody has yet found it useful enough to
implement.
I am not sure of the workflow it would help. Personally, I use "-m" in
two situations:
1. To puzzle out issues where "-c" or "--cc" do not show what I
expected.
2. With "--first-parent", to follow the linear history of a mainline
branch, showing merged topic branches as a single diff.
For the first one, showing all diffs is what I want. For the second, it
only makes sense to for the first parent case, as following other
parents would zig-zag through history.
But perhaps you have some other use case in mind. In cases like these, I
think it is a good idea to implement the feature, and run with it for a
while, seeing how it can be used. And then if it proves useful, post the
patch to the list describing your experiences.
-Peff
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: git show -m with a parent number
2016-03-28 19:16 ` Jeff King
@ 2016-03-28 19:31 ` Junio C Hamano
2016-03-30 12:31 ` Anatoly Borodin
1 sibling, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2016-03-28 19:31 UTC (permalink / raw)
To: Jeff King; +Cc: Anatoly Borodin, git
Jeff King <peff@peff.net> writes:
> On Sun, Mar 27, 2016 at 08:46:02PM +0000, Anatoly Borodin wrote:
>
>> is there a good reason for `git show -m` to not accept the number of a
>> parent of a merge commit? I can run `git show --first-parent COMMIT`,
>> but need to write `git diff COMMIT^2 COMMIT` every time I want to diff
>> with the second parent!
>
> I think it could, but nobody has yet found it useful enough to
> implement.
For "git show" that does not traverse the history, there may be
occasions where showing a diff with the second parent might make
sense (e.g. the user merged two histories in a wrong direction in
the past and it is too late to rewrite).
I think there are two reasons behind the current state. Because it
does not make any sense for "git log -m 2" to show diff with its
second parent while traversing many commits, the "git log" codepath
is not prepared to show diff with only nth parent. Because "git
show" started its life merely as a thin wrapper around "git log",
"git show" does not use such an underlying machinery to show diff
with only nth parent that does not exist.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: git show -m with a parent number
2016-03-28 19:16 ` Jeff King
2016-03-28 19:31 ` Junio C Hamano
@ 2016-03-30 12:31 ` Anatoly Borodin
2016-03-30 16:55 ` Andreas Schwab
1 sibling, 1 reply; 5+ messages in thread
From: Anatoly Borodin @ 2016-03-30 12:31 UTC (permalink / raw)
To: git
Hi!
Jeff King <peff@peff.net> wrote:
> For the first one, showing all diffs is what I want. For the second, it
> only makes sense to for the first parent case, as following other
> parents would zig-zag through history.
Lucky you! :) You probably don't need to inspect 9 month old ex-svn
branches with sync (i.e. 'trunk'->'feature') merges
*-...-*-...-*-...-*-.......-*---trunk
\ \ \ \ /
*-...-*-...-*-...-*-...-*---feature
(Not to forget some funny legacy inter-feature merges.)
It's not like `git diff X^2 X` is a big problem, but too much of a
copypaste.
The other thing that bugs me is that you can easily `git cherry-pick -m 2 X`,
but to see the diff that you are going to apply is not that trivial.
> But perhaps you have some other use case in mind. In cases like these, I
> think it is a good idea to implement the feature, and run with it for a
> while, seeing how it can be used. And then if it proves useful, post the
> patch to the list describing your experiences.
I'll try. BTW, should it be like '-m[=parent]' for consistency,
or '-m [parent]' is ok?
PS Another idea:
'-m parent' makes sence in a normal, 2-branch merge. But what to do in a
case of an octopus merge? In a normal case I can treat '-m 2' as 'the
diff regarding the second parent', but also as 'the changes contributed
by the first parent (plus "evil")'. But with 3 and more branches '-m 3'
means 'the changes from 1 and 2'. Would it be possible to get only the
contribution from the second or third parent in this case?
Yeah, I know, there is `git diff parent1...parent3` etc, but not all the
changes from parent3 will always get to the merge commit.
--
Mit freundlichen Grüßen,
Anatoly Borodin
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: git show -m with a parent number
2016-03-30 12:31 ` Anatoly Borodin
@ 2016-03-30 16:55 ` Andreas Schwab
0 siblings, 0 replies; 5+ messages in thread
From: Andreas Schwab @ 2016-03-30 16:55 UTC (permalink / raw)
To: Anatoly Borodin; +Cc: git
Anatoly Borodin <anatoly.borodin@gmail.com> writes:
> It's not like `git diff X^2 X` is a big problem, but too much of a
> copypaste.
Brace expansion helps a bit: git diff X{^2,}
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-03-30 16:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-27 20:46 git show -m with a parent number Anatoly Borodin
2016-03-28 19:16 ` Jeff King
2016-03-28 19:31 ` Junio C Hamano
2016-03-30 12:31 ` Anatoly Borodin
2016-03-30 16:55 ` Andreas Schwab
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 NNTP newsgroup(s).