Re: [PATCH] rebase: use reflog to find common base with upstream
From: Jonathan Nieder <hidden>
Date: 2016-06-15 22:59:01
Hi, John Keeping wrote:
Since commit d44e712 (pull: support rebased upstream + fetch + pull --rebase, 2009-07-19), pull has actually chosen the most recent reflog entry which is an ancestor of the current branch if it can find one. Change rebase so that it uses the same logic.
Nice idea. Could pull be made to rely on rebase for this as a follow-up? [...]
quoted hunk ↗ jump to hunk
--- a/git-rebase.sh +++ b/git-rebase.sh@@ -437,6 +437,14 @@ then error_on_missing_default_upstream "rebase" "rebase" \ "against" "git rebase <branch>" fi + for reflog in $(git rev-list -g "$upstream_name" 2>/dev/null) + do + if test "$reflog" = "$(git merge-base "$reflog" HEAD)"
"git merge-base --is-ancestor" is faster. What should happen if HEAD is not a valid commit? (Tested with: $ git checkout --orphan foo $ cat >>.git/config <<EOF [branch "foo"] remote = origin merge = refs/heads/master EOF $ bin-wrappers/git rebase 2>&1 | wc -l 83 ).
diff --git i/git-rebase.sh w/git-rebase.sh
index fd36cf7..d2e2c2e 100755
--- i/git-rebase.sh
+++ w/git-rebase.sh@@ -439,7 +439,7 @@ then fi for reflog in $(git rev-list -g "$upstream_name" 2>/dev/null) do - if test "$reflog" = "$(git merge-base "$reflog" HEAD)" + if git merge-base --is-ancestor "$reflog" HEAD then upstream_name=$reflog break