From: Junio C Hamano Date: Sun, 22 Aug 2010 06:27:29 +0000 (-0700) Subject: Merge branch 'en/rebase-against-rebase-fix' X-Git-Tag: v1.7.3-rc0~53 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/d25c72f7da5116f7b7a1f88a59d2bc14415a03b2?ds=inline;hp=-c Merge branch 'en/rebase-against-rebase-fix' * en/rebase-against-rebase-fix: pull --rebase: Avoid spurious conflicts and reapplying unnecessary patches t5520-pull: Add testcases showing spurious conflicts from git pull --rebase --- d25c72f7da5116f7b7a1f88a59d2bc14415a03b2 diff --combined git-pull.sh index a09a44ec4c,5dbc4387f7..8eb74d45de --- a/git-pull.sh +++ b/git-pull.sh @@@ -38,12 -38,11 +38,12 @@@ test -z "$(git ls-files -u)" || die_con test -f "$GIT_DIR/MERGE_HEAD" && die_merge strategy_args= diffstat= no_commit= squash= no_ff= ff_only= -log_arg= verbosity= +log_arg= verbosity= progress= merge_args= curr_branch=$(git symbolic-ref -q HEAD) -curr_branch_short=$(echo "$curr_branch" | sed "s|refs/heads/||") +curr_branch_short="${curr_branch#refs/heads/}" rebase=$(git config --bool branch.$curr_branch_short.rebase) +dry_run= while : do case "$1" in @@@ -51,8 -50,6 +51,8 @@@ verbosity="$verbosity -q" ;; -v|--verbose) verbosity="$verbosity -v" ;; + --progress) + progress=--progress ;; -n|--no-stat|--no-summary) diffstat=--no-stat ;; --stat|--summary) @@@ -105,9 -102,6 +105,9 @@@ --no-r|--no-re|--no-reb|--no-reba|--no-rebas|--no-rebase) rebase=false ;; + --d|--dr|--dry|--dry-|--dry-r|--dry-ru|--dry-run) + dry_run=--dry-run + ;; -h|--h|--he|--hel|--help) usage ;; @@@ -220,8 -214,7 +220,8 @@@ test true = "$rebase" && done } orig_head=$(git rev-parse -q --verify HEAD) -git fetch $verbosity --update-head-ok "$@" || exit 1 +git fetch $verbosity $progress $dry_run --update-head-ok "$@" || exit 1 +test -z "$dry_run" || exit 0 curr_head=$(git rev-parse -q --verify HEAD) if test -n "$orig_head" && test "$curr_head" != "$orig_head" @@@ -273,6 -266,15 +273,15 @@@ the exit fi + if test true = "$rebase" + then + o=$(git show-branch --merge-base $curr_branch $merge_head $oldremoteref) + if test "$oldremoteref" = "$o" + then + unset oldremoteref + fi + fi + merge_name=$(git fmt-merge-msg $log_arg <"$GIT_DIR/FETCH_HEAD") || exit case "$rebase" in true) diff --combined t/t5520-pull.sh index 319e389ed0,eee6f6d9cc..0b489f5b12 --- a/t/t5520-pull.sh +++ b/t/t5520-pull.sh @@@ -4,6 -4,11 +4,11 @@@ test_description='pulling into void . ./test-lib.sh + modify () { + sed -e "$1" <"$2" >"$2.x" && + mv "$2.x" "$2" + } + D=`pwd` test_expect_success setup ' @@@ -26,7 -31,7 +31,7 @@@ cd "$D test_expect_success 'checking the results' ' test -f file && test -f cloned/file && - diff file cloned/file + test_cmp file cloned/file ' test_expect_success 'pulling into void using master:master' ' @@@ -160,4 -165,61 +165,61 @@@ test_expect_success 'pull --rebase work test_cmp expect actual ' + test_expect_success 'setup for detecting upstreamed changes' ' + mkdir src && + (cd src && + git init && + printf "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n" > stuff && + git add stuff && + git commit -m "Initial revision" + ) && + git clone src dst && + (cd src && + modify s/5/43/ stuff && + git commit -a -m "5->43" && + modify s/6/42/ stuff && + git commit -a -m "Make it bigger" + ) && + (cd dst && + modify s/5/43/ stuff && + git commit -a -m "Independent discovery of 5->43" + ) + ' + + test_expect_success 'git pull --rebase detects upstreamed changes' ' + (cd dst && + git pull --rebase && + test -z "$(git ls-files -u)" + ) + ' + + test_expect_success 'setup for avoiding reapplying old patches' ' + (cd dst && + test_might_fail git rebase --abort && + git reset --hard origin/master + ) && + git clone --bare src src-replace.git && + rm -rf src && + mv src-replace.git src && + (cd dst && + modify s/2/22/ stuff && + git commit -a -m "Change 2" && + modify s/3/33/ stuff && + git commit -a -m "Change 3" && + modify s/4/44/ stuff && + git commit -a -m "Change 4" && + git push && + + modify s/44/55/ stuff && + git commit --amend -a -m "Modified Change 4" + ) + ' + + test_expect_success 'git pull --rebase does not reapply old patches' ' + (cd dst && + test_must_fail git pull --rebase && + test 1 = $(find .git/rebase-apply -name "000*" | wc -l) + ) + ' + test_done