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