git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Santi Béjar" <santi@agolina.net>
To: Elijah Newren <newren@gmail.com>
Cc: git@vger.kernel.org, gitster@pobox.com,
	Johannes.Schindelin@gmx.de,
	martinvz <martin.von.zweigbergk@gmail.com>
Subject: Re: [PATCHv4 2/2] pull --rebase: Avoid spurious conflicts and reapplying unnecessary patches
Date: Thu, 12 Aug 2010 16:37:25 +0200	[thread overview]
Message-ID: <AANLkTikLhe9+6ovLT99qG9wwDjXVmT8_81xuN8P31eve@mail.gmail.com> (raw)
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:

[...]

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

  reply	other threads:[~2010-08-12 14:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-12  5:56 [PATCHv4 0/2] Fix spurious conflicts with pull --rebase Elijah Newren
2010-08-12  5:56 ` [PATCHv4 1/2] t5520-pull: Add testcases showing spurious conflicts from git " Elijah Newren
2010-08-12  5:56 ` [PATCHv4 2/2] pull --rebase: Avoid spurious conflicts and reapplying unnecessary patches Elijah Newren
2010-08-12 13:34   ` Santi Béjar
2010-08-12 14:37     ` Santi Béjar [this message]
2010-08-12 14:40       ` Santi Béjar
2010-08-12 21:02       ` Elijah Newren
2010-08-12 22:51         ` Santi Béjar
2010-08-12 20:19     ` Elijah Newren
2010-08-12 22:08       ` Santi Béjar
2010-08-12 23:17         ` Santi Béjar
2010-08-12 22:29       ` Junio C Hamano
2010-08-13  1:47         ` Elijah Newren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AANLkTikLhe9+6ovLT99qG9wwDjXVmT8_81xuN8P31eve@mail.gmail.com \
    --to=santi@agolina.net \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=martin.von.zweigbergk@gmail.com \
    --cc=newren@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).