Skip to content

Commit 4f2e842

Browse files
bjornggitster
authored andcommitted
Fix "git remote update" with remotes.defalt set
Starting from commit 8db3559, "git remote update" (with no group name given) will fail with the following message if remotes.default has been set in the config file: fatal: 'default' does not appear to be a git repository fatal: The remote end hung up unexpectedly The problem is that the --multiple option is not passed to "git fetch" if no remote or group name is given on the command line. Fix the problem by always passing the --multiple option to "git fetch" (which actually simplifies the code). Reported-by: YONETANI Tomokazu Signed-off-by: Björn Gustavsson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8db3559 commit 4f2e842

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

builtin-remote.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,13 +1206,11 @@ static int update(int argc, const char **argv)
12061206
fetch_argv[fetch_argc++] = "--prune";
12071207
if (verbose)
12081208
fetch_argv[fetch_argc++] = "-v";
1209-
if (argc < 2) {
1209+
fetch_argv[fetch_argc++] = "--multiple";
1210+
if (argc < 2)
12101211
fetch_argv[fetch_argc++] = "default";
1211-
} else {
1212-
fetch_argv[fetch_argc++] = "--multiple";
1213-
for (i = 1; i < argc; i++)
1214-
fetch_argv[fetch_argc++] = argv[i];
1215-
}
1212+
for (i = 1; i < argc; i++)
1213+
fetch_argv[fetch_argc++] = argv[i];
12161214

12171215
if (strcmp(fetch_argv[fetch_argc-1], "default") == 0) {
12181216
git_config(get_remote_default, &default_defined);

t/t5505-remote.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,20 @@ test_expect_success 'update default (overridden, with funny whitespace)' '
419419
420420
'
421421

422+
test_expect_success 'update (with remotes.default defined)' '
423+
424+
(cd one &&
425+
for b in $(git branch -r)
426+
do
427+
git branch -r -d $b || break
428+
done &&
429+
git config remotes.default "drosophila" &&
430+
git remote update &&
431+
git branch -r > output &&
432+
test_cmp expect output)
433+
434+
'
435+
422436
test_expect_success '"remote show" does not show symbolic refs' '
423437
424438
git clone one three &&

0 commit comments

Comments
 (0)