From: Paul Tan <pyokagan@gmail.com>
To: git@vger.kernel.org
Cc: Stefan Beller <sbeller@google.com>,
Johannes Schindelin <johannes.schindelin@gmx.de>,
Paul Tan <pyokagan@gmail.com>
Subject: [PATCH 1/2] pull: handle git-fetch's options as well
Date: Mon, 18 May 2015 21:30:45 +0800 [thread overview]
Message-ID: <1431955855-16228-1-git-send-email-pyokagan@gmail.com> (raw)
t5520: failing test for pull --all with no configured upstream
t5521: test pull --all --dry-run does not make any changes
error_on_no_merge_candidates() does not consider the case where "$#"
includes command-line flags that are passed to git-fetch.
As such, when the current branch has no configured upstream, and there
are no merge candidates because of that, git-pull --all erroneously reports
that we are pulling from "--all", as it believes that the first argument
is the remote name.
Add a failing test that shows this case.
Signed-off-by: Paul Tan <pyokagan@gmail.com>
---
git-pull.sh | 34 ++++++++++++++++++++++++++++++++--
t/t5520-pull.sh | 20 ++++++++++++++++++++
t/t5521-pull-options.sh | 14 ++++++++++++++
3 files changed, 66 insertions(+), 2 deletions(-)
diff --git a/git-pull.sh b/git-pull.sh
index 9ed01fd..28d49ab 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -163,11 +163,39 @@ do
--d|--dr|--dry|--dry-|--dry-r|--dry-ru|--dry-run)
dry_run=--dry-run
;;
+ --all|--no-all)
+ all=$1 ;;
+ -a|--append|--no-append)
+ append=$1 ;;
+ --upload-pack=*|--no-upload-pack)
+ upload_pack="$1" ;;
+ -f|--force|--no-force)
+ force="$force $1" ;;
+ -t|--tags|--no-tags)
+ tags=$1 ;;
+ -p|--prune|--no-prune)
+ prune=$1 ;;
+ -k|--keep|--no-keep)
+ keep=$1 ;;
+ --depth=*|--no-depth)
+ depth="$1" ;;
+ --unshallow|--no-unshallow)
+ unshallow=$1 ;;
+ --update-shallow|--no-update-shallow)
+ update_shallow=$1 ;;
+ --refmap=*|--no-refmap)
+ refmap="$1" ;;
-h|--help-all)
usage
;;
+ --)
+ shift
+ break
+ ;;
+ -*)
+ usage
+ ;;
*)
- # Pass thru anything that may be meant for fetch.
break
;;
esac
@@ -254,7 +282,9 @@ test true = "$rebase" && {
oldremoteref=$(git merge-base --fork-point "$remoteref" $curr_branch 2>/dev/null)
}
orig_head=$(git rev-parse -q --verify HEAD)
-git fetch $verbosity $progress $dry_run $recurse_submodules --update-head-ok "$@" || exit 1
+git fetch $verbosity $progress $dry_run $recurse_submodules $all $append \
+$upload_pack $force $tags $prune $keep $depth $unshallow $update_shallow \
+$refmap --update-head-ok "$@" || exit 1
test -z "$dry_run" || exit 0
curr_head=$(git rev-parse -q --verify HEAD)
diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
index 62dbfb5..ea73f2f 100755
--- a/t/t5520-pull.sh
+++ b/t/t5520-pull.sh
@@ -160,6 +160,18 @@ test_expect_success 'fail if no configuration for current branch' '
test "$(cat file)" = file
'
+test_expect_success 'pull --all: fail if no configuration for current branch' '
+ git remote add test_remote . &&
+ test_when_finished "git remote remove test_remote" &&
+ git checkout -b test copy^ &&
+ test_when_finished "git checkout -f copy && git branch -D test" &&
+ test_config branch.test.remote test_remote &&
+ test "$(cat file)" = file &&
+ test_must_fail git pull --all 2>err &&
+ test_i18ngrep "There is no tracking information" err &&
+ test "$(cat file)" = file
+'
+
test_expect_success 'fail if upstream branch does not exist' '
git checkout -b test copy^ &&
test_when_finished "git checkout -f copy && git branch -D test" &&
@@ -366,6 +378,14 @@ test_expect_success '--rebase with rebased upstream' '
'
+test_expect_success '--rebase -f with rebased upstream' '
+ test_when_finished "test_might_fail git rebase --abort" &&
+ git reset --hard to-rebase-orig &&
+ git pull --rebase -f me copy &&
+ test "conflicting modification" = "$(cat file)" &&
+ test file = "$(cat file2)"
+'
+
test_expect_success '--rebase with rebased default upstream' '
git update-ref refs/remotes/me/copy copy-orig &&
diff --git a/t/t5521-pull-options.sh b/t/t5521-pull-options.sh
index 56e7377..9d5e41f 100755
--- a/t/t5521-pull-options.sh
+++ b/t/t5521-pull-options.sh
@@ -130,4 +130,18 @@ test_expect_success 'git pull --dry-run' '
)
'
+test_expect_failure 'git pull --all --dry-run' '
+ test_when_finished "rm -rf clonedmulti" &&
+ git init clonedry &&
+ (
+ cd clonedry &&
+ git remote add origin ../parent &&
+ git pull --all --dry-run &&
+ test_path_is_missing .git/FETCH_HEAD &&
+ test_path_is_missing .git/refs/remotes/origin/master &&
+ test_path_is_missing .git/index &&
+ test_path_is_missing file
+ )
+'
+
test_done
--
2.1.4
next reply other threads:[~2015-05-18 13:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-18 13:30 Paul Tan [this message]
2015-05-18 13:30 ` [PATCH 2/2] work in progress Paul Tan
2015-05-18 14:05 ` [PATCH 1/2] pull: handle git-fetch's options as well Paul Tan
2015-05-18 14:37 ` Johannes Schindelin
2015-05-21 8:29 ` Paul Tan
2015-05-21 8:29 ` Paul Tan
-- strict thread matches above, loose matches on Subject: below --
2015-05-18 13:54 [PATCH 0/2] Improve git-pull's option parsing Paul Tan
2015-05-18 13:54 ` [PATCH 1/2] pull: handle git-fetch's options as well Paul Tan
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1431955855-16228-1-git-send-email-pyokagan@gmail.com \
--to=pyokagan@gmail.com \
--cc=git@vger.kernel.org \
--cc=johannes.schindelin@gmx.de \
--cc=sbeller@google.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.
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 NNTP newsgroup(s).