summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6217367)
raw | patch | inline | side by side (parent: 6217367)
author | Johannes Schindelin <Johannes.Schindelin@gmx.de> | |
Tue, 4 Mar 2008 11:23:53 +0000 (11:23 +0000) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 5 Mar 2008 20:17:39 +0000 (12:17 -0800) |
The rewrite in C inadvertently broke updating with remote groups: when you
pass parameters to "git remote update", it used to look up "remotes.<group>"
for every parameter, and interpret the value as a list of remotes to update.
Also, no parameter, or a single parameter "default" should update all
remotes that have not been marked with "skipDefaultUpdate".
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pass parameters to "git remote update", it used to look up "remotes.<group>"
for every parameter, and interpret the value as a list of remotes to update.
Also, no parameter, or a single parameter "default" should update all
remotes that have not been marked with "skipDefaultUpdate".
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-remote.c | patch | blob | history | |
t/t5505-remote.sh | patch | blob | history |
diff --git a/builtin-remote.c b/builtin-remote.c
index 98ff1b727e97e0b1bc6b7db4a6cdcdfc27adb84d..ca3bf265a93ee457d0069f1379ead105a470745a 100644 (file)
--- a/builtin-remote.c
+++ b/builtin-remote.c
return result;
}
-static int update_one(struct remote *remote, void *priv)
+static int get_one_remote_for_update(struct remote *remote, void *priv)
{
+ struct path_list *list = priv;
if (!remote->skip_default_update)
- return fetch_remote(remote->name);
+ path_list_append(xstrdup(remote->name), list);
+ return 0;
+}
+
+struct remote_group {
+ const char *name;
+ struct path_list *list;
+} remote_group;
+
+static int get_remote_group(const char *key, const char *value)
+{
+ if (!prefixcmp(key, "remotes.") &&
+ !strcmp(key + 8, remote_group.name)) {
+ /* split list by white space */
+ int space = strcspn(value, " \t\n");
+ while (*value) {
+ if (space > 1)
+ path_list_append(xstrndup(value, space),
+ remote_group.list);
+ value += space + (value[space] != '\0');
+ space = strcspn(value, " \t\n");
+ }
+ }
+
return 0;
}
static int update(int argc, const char **argv)
{
- int i;
+ int i, result = 0;
+ struct path_list list = { NULL, 0, 0, 0 };
+ static const char *default_argv[] = { NULL, "default", NULL };
- if (argc < 2)
- return for_each_remote(update_one, NULL);
+ if (argc < 2) {
+ argc = 2;
+ argv = default_argv;
+ }
- for (i = 1; i < argc; i++)
- if (fetch_remote(argv[i]))
- return 1;
- return 0;
+ remote_group.list = &list;
+ for (i = 1; i < argc; i++) {
+ remote_group.name = argv[i];
+ result = git_config(get_remote_group);
+ }
+
+ if (!result && !list.nr && argc == 2 && !strcmp(argv[1], "default"))
+ result = for_each_remote(get_one_remote_for_update, &list);
+
+ for (i = 0; i < list.nr; i++)
+ result |= fetch_remote(list.items[i].path);
+
+ /* all names were strdup()ed or strndup()ed */
+ list.strdup_paths = 1;
+ path_list_clear(&list, 0);
+
+ return result;
}
static int get_one_entry(struct remote *remote, void *priv)
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index 0a25c8b71c63802602abab689a0bcbb6ff9c0f05..f45ea68f63e66ae43f7d8beee0cb96a98e46bc15 100755 (executable)
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
git init &&
>file &&
git add file &&
+ test_tick &&
git commit -m "Initial" &&
git checkout -b side &&
>elif &&
git add elif &&
+ test_tick &&
git commit -m "Second" &&
git checkout master
)
git branch -d -r origin/master &&
(cd ../one &&
echo 1 > file &&
+ test_tick &&
git commit -m update file) &&
git remote show origin > output &&
git diff expect output)
git rev-parse --verify refs/heads/side)
'
+cat > one/expect << EOF
+ apis/master
+ apis/side
+ drosophila/another
+ drosophila/master
+ drosophila/side
+EOF
+
+test_expect_success 'update' '
+
+ (cd one &&
+ git remote add drosophila ../two &&
+ git remote add apis ../mirror &&
+ git remote update &&
+ git branch -r > output &&
+ git diff expect output)
+
+'
+
+cat > one/expect << EOF
+ drosophila/another
+ drosophila/master
+ drosophila/side
+ manduca/master
+ manduca/side
+ megaloprepus/master
+ megaloprepus/side
+EOF
+
+test_expect_success 'update with arguments' '
+
+ (cd one &&
+ for b in $(git branch -r)
+ do
+ git branch -r -d $b || break
+ done &&
+ git remote add manduca ../mirror &&
+ git remote add megaloprepus ../mirror &&
+ git config remotes.phobaeticus "drosophila megaloprepus" &&
+ git config remotes.titanus manduca &&
+ git remote update phobaeticus titanus &&
+ git branch -r > output &&
+ git diff expect output)
+
+'
+
+cat > one/expect << EOF
+ apis/master
+ apis/side
+ manduca/master
+ manduca/side
+ megaloprepus/master
+ megaloprepus/side
+EOF
+
+test_expect_success 'update default' '
+
+ (cd one &&
+ for b in $(git branch -r)
+ do
+ git branch -r -d $b || break
+ done &&
+ git config remote.drosophila.skipDefaultUpdate true &&
+ git remote update default &&
+ git branch -r > output &&
+ git diff expect output)
+
+'
+
+cat > one/expect << EOF
+ drosophila/another
+ drosophila/master
+ drosophila/side
+EOF
+
+test_expect_success 'update default (overridden, with funny whitespace)' '
+
+ (cd one &&
+ for b in $(git branch -r)
+ do
+ git branch -r -d $b || break
+ done &&
+ git config remotes.default "$(printf "\t drosophila \n")" &&
+ git remote update default &&
+ git branch -r > output &&
+ git diff expect output)
+
+'
+
test_done