From: Michael Lukashov <michael.lukashov@gmail.com>
To: git@vger.kernel.org
Cc: Michael Lukashov <michael.lukashov@gmail.com>
Subject: [PATCH] pull: fix 'git pull --all' when current branch is tracking remote that is not last in the list of remotes
Date: Tue, 23 Feb 2010 22:55:31 +0000 [thread overview]
Message-ID: <1266965731-4208-1-git-send-email-michael.lukashov@gmail.com> (raw)
Steps to reproduce the bug:
1. Create repository and add more than one remote
2. Make sure current branch is tracking branch from the remote AND this remote
is not last in the list of remotes
3. 'git pull --all' exits with error message:
You asked to pull from the remote '--all', but did not specify
a branch. Because this is not the default configured remote
for your current branch, you must specify a branch on the command line.
A minimal test case is added that reproduces the problem.
Tested under Windows and Debian GNU/Linux.
Signed-off-by: Michael Lukashov <michael.lukashov@gmail.com>
---
builtin-fetch.c | 6 +++++-
git-pull.sh | 6 +++++-
t/t5521-pull-options.sh | 39 +++++++++++++++++++++++++++++++++++++++
3 files changed, 49 insertions(+), 2 deletions(-)
diff --git a/builtin-fetch.c b/builtin-fetch.c
index d3b9d8a..8e54c5a 100644
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
@@ -784,13 +784,17 @@ static int add_remote_or_group(const char *name, struct string_list *list)
static int fetch_multiple(struct string_list *list)
{
int i, result = 0;
- const char *argv[] = { "fetch", NULL, NULL, NULL, NULL, NULL, NULL };
+ const char *argv[] = { "fetch", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
int argc = 1;
if (dry_run)
argv[argc++] = "--dry-run";
if (prune)
argv[argc++] = "--prune";
+ if (append)
+ argv[argc++] = "--append";
+ if (update_head_ok)
+ argv[argc++] = "--update-head-ok";
if (verbosity >= 2)
argv[argc++] = "-v";
if (verbosity >= 1)
diff --git a/git-pull.sh b/git-pull.sh
index 38331a8..fcde096 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -214,7 +214,11 @@ test true = "$rebase" && {
done
}
orig_head=$(git rev-parse -q --verify HEAD)
-git fetch $verbosity --update-head-ok "$@" || exit 1
+if test -e "$GIT_DIR"/FETCH_HEAD
+then
+ rm "$GIT_DIR"/FETCH_HEAD 2>/dev/null
+fi
+git fetch $verbosity --update-head-ok --append "$@" || exit 1
curr_head=$(git rev-parse -q --verify HEAD)
if test -n "$orig_head" && test "$curr_head" != "$orig_head"
diff --git a/t/t5521-pull-options.sh b/t/t5521-pull-options.sh
index 83e2e8a..2665caa 100755
--- a/t/t5521-pull-options.sh
+++ b/t/t5521-pull-options.sh
@@ -4,6 +4,17 @@ test_description='pull options'
. ./test-lib.sh
+setup_repository () {
+ mkdir "$1" && (
+ cd "$1" &&
+ git init &&
+ >file &&
+ git add file &&
+ test_tick &&
+ git commit -m "Initial"
+ )
+}
+
D=`pwd`
test_expect_success 'setup' '
@@ -57,4 +68,32 @@ test_expect_success 'git pull -q -v' '
test -s out
'
+cd "$D"
+
+test_expect_success 'git pull --all' '
+ mkdir pullall &&
+ cd pullall &&
+ setup_repository remote1 &&
+ setup_repository remote2 &&
+ mkdir test &&
+ cd test &&
+ git init &&
+ git remote add remote1 "$D/pullall/remote1" &&
+ git remote add remote2 "$D/pullall/remote2" &&
+ (
+ # "git pull remote1" should print error message
+ # because there is no local branch that is tracking remote repo
+ git pull remote1
+ test $? = 1
+ ) &&
+ (
+ # "git pull --all" should not print error message
+ # when current branch is tracking remote repo and that remote
+ # is not last in the list of remotes
+ git checkout -b remote1master remote1/master
+ git pull --all
+ test $? = 0
+ )
+'
+
test_done
--
1.7.0.1706.g00cdbe
next reply other threads:[~2010-02-23 22:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-23 22:55 Michael Lukashov [this message]
2010-02-23 23:02 ` [PATCH] pull: fix 'git pull --all' when current branch is tracking remote that is not last in the list of remotes Junio C Hamano
2010-02-23 23:44 ` Michael Lukashov
2010-02-24 0:22 ` Junio C Hamano
2010-02-24 13:07 ` [PATCH v2] " Michael Lukashov
2010-02-24 13:33 ` Paolo Bonzini
2010-02-24 17:05 ` Junio C Hamano
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=1266965731-4208-1-git-send-email-michael.lukashov@gmail.com \
--to=michael.lukashov@gmail.com \
--cc=git@vger.kernel.org \
/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).