* Howto get the merge-base ?
@ 2006-05-14 17:21 Bertrand Jacquin
2006-05-14 17:44 ` Junio C Hamano
2006-05-14 18:40 ` Linus Torvalds
0 siblings, 2 replies; 5+ messages in thread
From: Bertrand Jacquin @ 2006-05-14 17:21 UTC (permalink / raw)
To: Git Mailing List
Hi,
I'm trying to know which commit it the parent of a merge.
For exemple if I do that :
o Merge
/ \
/ \
| |
| o Commit D
| |
| o Commit C
| |
o | Commit B
\ /
\/
o Commit A
|
o Init
How could I know that ``Commit A'' is the merge-base of ``Merge'' ?
I try to get this git-merge-base but result is strange and quiet
mysterious as he return me always second args I passed to. I'm using
git 1.3.2
--
Beber
#e.fr@freenode
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Howto get the merge-base ?
2006-05-14 17:21 Howto get the merge-base ? Bertrand Jacquin
@ 2006-05-14 17:44 ` Junio C Hamano
2006-05-14 18:04 ` Bertrand Jacquin
2006-05-14 18:40 ` Linus Torvalds
1 sibling, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2006-05-14 17:44 UTC (permalink / raw)
To: Bertrand Jacquin; +Cc: git
"Bertrand Jacquin" <beber.mailing@gmail.com> writes:
> I'm trying to know which commit it the parent of a merge.
> For exemple if I do that :
>
> o Merge
> / \
> / \
> | |
> | o Commit D
> | |
> | o Commit C
> | |
> o | Commit B
> \ /
> \/
> o Commit A
> |
> o Init
>
> How could I know that ``Commit A'' is the merge-base of ``Merge'' ?
> I try to get this git-merge-base but result is strange and quiet
> mysterious as he return me always second args I passed to.
It is mysterious to me because you did not say what you gave as
arguments ;-).
If I am reading you correctly, you already have a "Merge"
commit, made by you or somebody else, and are trying to figure
out where the merge base was. If that is the case:
git-merge-base Merge^1 Merge^2
in other words
git-merge-base CommitB CommitD
is what you are looking for?
But what do you need that information for? To reproduce
somebody else's merge?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Howto get the merge-base ?
2006-05-14 17:44 ` Junio C Hamano
@ 2006-05-14 18:04 ` Bertrand Jacquin
2006-05-14 18:12 ` Junio C Hamano
0 siblings, 1 reply; 5+ messages in thread
From: Bertrand Jacquin @ 2006-05-14 18:04 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
On 5/14/06, Junio C Hamano <junkio@cox.net> wrote:
> "Bertrand Jacquin" <beber.mailing@gmail.com> writes:
>
> > I'm trying to know which commit it the parent of a merge.
> > For exemple if I do that :
> >
> > o Merge
> > / \
> > / \
> > | |
> > | o Commit D
> > | |
> > | o Commit C
> > | |
> > o | Commit B
> > \ /
> > \/
> > o Commit A
> > |
> > o Init
> >
> > How could I know that ``Commit A'' is the merge-base of ``Merge'' ?
>
> > I try to get this git-merge-base but result is strange and quiet
> > mysterious as he return me always second args I passed to.
>
> It is mysterious to me because you did not say what you gave as
> arguments ;-).
I was using git-merge-base ``merge-ish'' ``comit-ish''. Docs about it
is atrocious so was trying many but not the one good. Blam me.
> If I am reading you correctly, you already have a "Merge"
> commit, made by you or somebody else, and are trying to figure
> out where the merge base was. If that is the case:
>
> git-merge-base Merge^1 Merge^2
>
> in other words
>
> git-merge-base CommitB CommitD
That's ok :)
> is what you are looking for?
Yes ! Thanks :)
> But what do you need that information for? To reproduce
> somebody else's merge?
No, that's just on the following of git-send-mail-commit.sh thread (or
something near). To make a readable merge mail with diffstat and
summury.
--
Beber
#e.fr@freenode
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Howto get the merge-base ?
2006-05-14 18:04 ` Bertrand Jacquin
@ 2006-05-14 18:12 ` Junio C Hamano
0 siblings, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2006-05-14 18:12 UTC (permalink / raw)
To: Bertrand Jacquin; +Cc: git
"Bertrand Jacquin" <beber.mailing@gmail.com> writes:
> On 5/14/06, Junio C Hamano <junkio@cox.net> wrote:
>> "Bertrand Jacquin" <beber.mailing@gmail.com> writes:
>>
>> > I'm trying to know which commit it the parent of a merge.
>> > For exemple if I do that :
>> >
>> > o Merge
>> > / \
>> > / \
>> > | |
>> > | o Commit D
>> > | |
>> > | o Commit C
>> > | |
>> > o | Commit B
>> > \ /
>> > \/
>> > o Commit A
>> > |
>> > o Init
>> >
> No, that's just on the following of git-send-mail-commit.sh thread (or
> something near). To make a readable merge mail with diffstat and
> summury.
For that you do not want merge-base. If your mainline was A-B
and you merged a side branch B-C-D with the merge, then to
people who tracked your head (that's the audience of "merge
mail", I presume) they just need to see:
git diff --stat M^1..M
git rev-list --no-merges --pretty M^1..M | git shortlog
The diffstat is "what damage was inflicted on the branch you
have been following with this merge", so the diff between the
trees before and after the merge is what you want. And the
rev-list piped to shortlog is to show "what commits were _not_
present on this branch before the merge, but are present after
the merge" (it could be spelled M^1..M^2 but the above would
handle octopus as well).
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Howto get the merge-base ?
2006-05-14 17:21 Howto get the merge-base ? Bertrand Jacquin
2006-05-14 17:44 ` Junio C Hamano
@ 2006-05-14 18:40 ` Linus Torvalds
1 sibling, 0 replies; 5+ messages in thread
From: Linus Torvalds @ 2006-05-14 18:40 UTC (permalink / raw)
To: Bertrand Jacquin; +Cc: Git Mailing List
On Sun, 14 May 2006, Bertrand Jacquin wrote:
>
> I'm trying to know which commit it the parent of a merge.
> For exemple if I do that :
>
> o Merge
> / \
> / \
> | |
> | o Commit D
> | |
> | o Commit C
> | |
> o | Commit B
> \ /
> \/
> o Commit A
> |
> o Init
>
> How could I know that ``Commit A'' is the merge-base of ``Merge'' ?
Well, Junio already answered, but I'd like to comment a bit further.
There may not be "one" merge-base. There can be several:
Merge
|
A
/ \
B C
|\ /|
| X |
|/ \|
D E
\ /
F
|
Here the merge (A) has two equally good merge bases: D and E.
If you want all of these merge-bases, you need to add the "--all" flag to
git-merge-base.
On the git archive, try this trivia shell pipeline:
git-rev-list --parents HEAD |
sed -n '/^[0-9a-f]* [0-9a-f]* [0-9a-f]*$/ p' |
while read a b c
do
echo $a: $(git merge-base --all $b $c)
done | less -S
and you'll be able to easily pick up examples of where there are real
multiple merge bases. For example, commit 4da8cbc2.. has that.
If you want to examine _why_ it has multiple merge-bases, do:
gitk 4da8cbc2 --not 5910e997 52b70d56
(where the two "not" commits are the merge bases for it) which shows that
merge and the criss-crossing nature of the history leading up to it.
NOTE! Most of the time, multiple merge bases do not really matter all that
much, and you'd get the same merge regardless of which one you would
choose as the base. Still, they _can_ matter.
Linus
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-05-14 18:40 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-14 17:21 Howto get the merge-base ? Bertrand Jacquin
2006-05-14 17:44 ` Junio C Hamano
2006-05-14 18:04 ` Bertrand Jacquin
2006-05-14 18:12 ` Junio C Hamano
2006-05-14 18:40 ` Linus Torvalds
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).