git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCHv4 2/2] pull --rebase: Avoid spurious conflicts and reapplying unnecessary patches

From
SBSanti Béjar <santi@agolina.net>
Date
Aug 12, 2010, 14:37 UTC
Message-ID
<AANLkTikLhe9+6ovLT99qG9wwDjXVmT8_81xuN8P31eve@mail.gmail.com>
In-Reply-To
<AANLkTimHiYUPyNTtT4SwapqN8YZGB1wjxJPwTTaPZhEa@mail.gmail.com>
On Thu, Aug 12, 2010 at 3:34 PM, Santi Béjar <santi@agolina.net> wrote:
> On Thu, Aug 12, 2010 at 7:56 AM, Elijah Newren <newren@gmail.com> wrote:
[...]
Show 60 quoted lines
>>
>> Signed-off-by: Elijah Newren <newren@gmail.com>
>> ---
>>  git-pull.sh     |   34 ++++++++++++++++++++++------------
>>  t/t5520-pull.sh |    4 ++--
>>  2 files changed, 24 insertions(+), 14 deletions(-)
>>
>> diff --git a/git-pull.sh b/git-pull.sh
>> index a09a44e..54da07b 100755
>> --- a/git-pull.sh
>> +++ b/git-pull.sh
>> @@ -206,18 +206,6 @@ test true = "$rebase" && {
>>                git diff-index --ignore-submodules --cached --quiet HEAD -- ||
>>                die "refusing to pull with rebase: your working tree is not up-to-date"
>>        fi
>> -       oldremoteref= &&
>> -       . git-parse-remote &&
>> -       remoteref="$(get_remote_merge_branch "$@" 2>/dev/null)" &&
>> -       oldremoteref="$(git rev-parse -q --verify "$remoteref")" &&
>> -       for reflog in $(git rev-list -g $remoteref 2>/dev/null)
>> -       do
>> -               if test "$reflog" = "$(git merge-base $reflog $curr_branch)"
>> -               then
>> -                       oldremoteref="$reflog"
>> -                       break
>> -               fi
>> -       done
>>  }
>>  orig_head=$(git rev-parse -q --verify HEAD)
>>  git fetch $verbosity $progress $dry_run --update-head-ok "$@" || exit 1
>> @@ -273,6 +261,28 @@ then
>>        exit
>>  fi
>>
>> +if test true = "$rebase"
>> +then
>> +       oldremoteref= &&
>> +       . git-parse-remote &&
>> +       remoteref="$(get_remote_merge_branch "$@" 2>/dev/null)" &&
>> +       oldremoteref="$(git rev-parse -q --verify "$remoteref")" &&
>> +       for reflog in $(git rev-list -g $remoteref 2>/dev/null)
>> +       do
>> +               if test "$reflog" = "$(git merge-base $reflog $curr_branch)"
>> +               then
>> +                       oldremoteref="$reflog"
>> +                       break
>> +               fi
>> +       done
>> +
>> +       o=$(git show-branch --merge-base $curr_branch $merge_head $oldremoteref)
>> +       if test "$oldremoteref" = "$o"
>> +       then
>> +               unset oldremoteref
>> +       fi
>> +fi
>> +
>
> You've moved all the lines after the call to "git fetch". It changes
> the behavior when the reflog is not enabled, as the old value of
> remoteref is lost.
Something like this?

Fix the non-rebased upstream case by only setting $old_remote_ref with commits not ancestors of $remoteref or $merge_head. This should have no affect on the rebased upstream case.

diff --git c/git-pull.sh w/git-pull.sh
index a09a44e..c1617d5 100755
--- c/git-pull.sh
+++ w/git-pull.sh
@@ -214,7 +214,10 @@ test true = "$rebase" && {
        do
                if test "$reflog" = "$(git merge-base $reflog $curr_branch)"
                then
-                       oldremoteref="$reflog"
+                       if test "$reflog" != $(git merge-base $reflog
$remoteref)
+                       then
+                               oldremoteref="$reflog"
+                       fi
                        break
                fi
        done
@@ -273,6 +276,14 @@ then
        exit
 fi

+if test true = "$rebase"
+then
+       if test "$oldremoteref" = $(git merge-base $oldremoteref $merge_head)
+       then
+               unset oldremoteref
+       fi
+fi
+
 merge_name=$(git fmt-merge-msg $log_arg <"$GIT_DIR/FETCH_HEAD") || exit
 case "$rebase" in
 true)

(also attached because of whitespace damage)

HTH,
Santi
Previous: Santi BéjarNext: Santi Béjar
Message 5 of 13 in “[PATCHv4 0/2] Fix spurious conflicts with pull --rebase”
  1. Elijah NewrenAug 12, 2010
  2. 1/2 t5520-pull: Add testcases showing spurious conflicts from git pull --rebaseElijah Newren, Aug 12, 2010
  3. 2/2 pull --rebase: Avoid spurious conflicts and reapplying unnecessary patchesElijah Newren, Aug 12, 2010
  4. Santi BéjarAug 12, 2010
  5. Santi BéjarAug 12, 2010
  6. Santi BéjarAug 12, 2010
  7. Elijah NewrenAug 12, 2010
  8. Santi BéjarAug 12, 2010
  9. Elijah NewrenAug 12, 2010
  10. Santi BéjarAug 12, 2010
  11. Santi BéjarAug 12, 2010
  12. Junio C HamanoAug 12, 2010
  13. Elijah NewrenAug 13, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.