summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9c4a036)
raw | patch | inline | side by side (parent: 9c4a036)
author | Björn Gustavsson <bgustavsson@gmail.com> | |
Mon, 9 Nov 2009 20:10:32 +0000 (21:10 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 10 Nov 2009 09:01:07 +0000 (01:01 -0800) |
Add the --multiple option to specify that all arguments are either
groups or remotes. The primary reason for adding this option is
to allow us to re-implement 'git remote update' using fetch.
It would have been nice if this option was not needed, but since
the colon in a refspec is optional, it is in general not possible
to know whether a single, colon-less argument is a remote or a
refspec.
Signed-off-by: Björn Gustavsson <bgustavsson@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
groups or remotes. The primary reason for adding this option is
to allow us to re-implement 'git remote update' using fetch.
It would have been nice if this option was not needed, but since
the colon in a refspec is optional, it is in general not possible
to know whether a single, colon-less argument is a remote or a
refspec.
Signed-off-by: Björn Gustavsson <bgustavsson@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/fetch-options.txt | patch | blob | history | |
Documentation/git-fetch.txt | patch | blob | history | |
builtin-fetch.c | patch | blob | history | |
t/t5514-fetch-multiple.sh | patch | blob | history |
index 93d73c3eeac1ba4938fed5f2fc7d9cc228a75e91..8b0cf581962e48f85ff35cbe3c9eeec1109a9971 100644 (file)
--keep::
Keep downloaded pack.
+ifndef::git-pull[]
+--multiple::
+ Allow several <repository> and <group> arguments to be
+ specified. No <refspec>s may be specified.
+endif::git-pull[]
+
ifdef::git-pull[]
--no-tags::
endif::git-pull[]
index 334744c2eb2e7cfc992d3e5ceb6b1a5d807e4969..edb77dc54ef8789fc210731ec3c4e32b5d9d57b6 100644 (file)
'git fetch' <options> <group>
+'git fetch' --multiple <options> [<repository> | <group>]...
+
'git fetch' --all <options>
diff --git a/builtin-fetch.c b/builtin-fetch.c
index e6bbdc7a171dd050dd8fc94def946931244e87b6..c903c66d47c52d7e585866ab3182ec1eb69408b0 100644 (file)
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
static const char * const builtin_fetch_usage[] = {
"git fetch [options] [<repository> <refspec>...]",
"git fetch [options] <group>",
+ "git fetch --multiple [options] [<repository> | <group>]...",
"git fetch --all [options]",
NULL
};
TAGS_SET = 2
};
-static int all, append, force, keep, update_head_ok, verbosity;
+static int all, append, force, keep, multiple, update_head_ok, verbosity;
static int tags = TAGS_DEFAULT;
static const char *depth;
static const char *upload_pack;
"path to upload pack on remote end"),
OPT_BOOLEAN('f', "force", &force,
"force overwrite of local branch"),
+ OPT_BOOLEAN('m', "multiple", &multiple,
+ "fetch from multiple remotes"),
OPT_SET_INT('t', "tags", &tags,
"fetch all tags and associated objects", TAGS_SET),
OPT_SET_INT('n', NULL, &tags,
/* No arguments -- use default remote */
remote = remote_get(NULL);
result = fetch_one(remote, argc, argv);
+ } else if (multiple) {
+ /* All arguments are assumed to be remotes or groups */
+ for (i = 0; i < argc; i++)
+ if (!add_remote_or_group(argv[i], &list))
+ die("No such remote or remote group: %s", argv[i]);
+ result = fetch_multiple(&list);
} else {
/* Single remote or group */
(void) add_remote_or_group(argv[0], &list);
index 25244bf8e8fb760a1b51dcbc862d7789079e282b..69c64ab1e4029ce00c4b965cbb30227e269058f1 100755 (executable)
test_must_fail git fetch --all origin master)
'
+cat > expect << EOF
+ origin/HEAD -> origin/master
+ origin/master
+ origin/side
+ three/another
+ three/master
+ three/side
+EOF
+
+test_expect_success 'git fetch --multiple (but only one remote)' '
+ (git clone one test3 &&
+ cd test3 &&
+ git remote add three ../three &&
+ git fetch --multiple three &&
+ git branch -r > output &&
+ test_cmp ../expect output)
+'
+
+cat > expect << EOF
+ one/master
+ one/side
+ origin/HEAD -> origin/master
+ origin/master
+ origin/side
+ two/another
+ two/master
+ two/side
+EOF
+
+test_expect_success 'git fetch --multiple (two remotes)' '
+ (git clone one test4 &&
+ cd test4 &&
+ git remote add one ../one &&
+ git remote add two ../two &&
+ git fetch --multiple one two &&
+ git branch -r > output &&
+ test_cmp ../expect output)
+'
+
+test_expect_success 'git fetch --multiple (bad remote names)' '
+ (cd test4 &&
+ test_must_fail git fetch --multiple four)
+'
+
test_done