Thread (3 messages) flat view 3 messages, 2 authors, 2016-06-15

Re: [PATCHv2 2/2] pull: support rebased upstream + fetch + pull --rebase

From: Santi Béjar <hidden>
Date: 2016-06-15 22:47:04

2009/7/17 Santi Béjar [off-list ref]:
2009/7/16 Junio C Hamano [off-list ref]:
quoted
Johannes Schindelin [off-list ref] writes:
quoted
How about

      oldremoteref="$(git rev-list --boundary HEAD --not \
                      $(git rev-list -g $remoteref | sed 's/$/^@/') |
              sed -e '/^[^-]/d' -e q)"

Explanation: the "git rev-list -g $remoteref" lists the previous commits
the remote ref pointed to, and the ^@ appended to them means all their
parents.  Now, the outer rev-list says to take everything in HEAD but
_not_ in those parents, showing the boundary commits.  The "sed" call
lists the first such boundary commit (which must, by construction, be one
of the commits shown by the first rev-list).
Hmm, I am not sure about that "(which must..." part.
Unfortunatly you are right with the "(which must..." part. Even
without the ^@. Normally gives the right answer, but it is not
sure that the first commit boundary is the correct one. For
example:

         o--C
        /
 A--x--y--B--o--z
     \      /
      o----o

A, B, C are upstream@{n}

It involves a merge with a branch forked before the fork commit
for the current branch, and it will not work neither with git
pull --rebase. We could say that it is not supported, but
nevertheless it gives the wrong answer.

The right answer is B, but:
$ git rev-list --boundary z --not C B A
z
o
o
o
-x
-B

in this case we could take the boundaries commits and filter the
commits that are ancestor of some other boundary commit, and
would get B (git show-branch --independent x B -> B).

Here it is a test case to see the above.

rm -rf test
mkdir test
cd test
git init
echo A > file
git add .
git commit -mA
git tag A
echo o > file
git commit -a -mo
git tag fork1
echo z > file
git commit -a -mz
git tag fork2
echo B > file
git commit -a -mB
git tag B
git checkout -b topic fork1
echo oo > filetopic
git add .
git commit -moo
echo ooo > filetopic
git commit -a -mooo
git checkout master
git merge topic
echo c > file
git commit -a -mc
git checkout -b upstream fork2
echo o > fileupstream
git add .
git commit -a -mo5
echo C > fileupstream
git commit -a -mo
git tag C
git rev-list --boundary master --not C B A
echo answer: $(git rev-parse B^{})

HTH,
Santi
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help