Skip to content

Commit bba5322

Browse files
committed
builtin-fetch --all/--multi: propagate options correctly
When running a subfetch, the code propagated some options but not others. Propagate --force, --update-head-ok and --keep options as well. Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 13e65fe commit bba5322

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

builtin-fetch.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,13 +784,19 @@ static int add_remote_or_group(const char *name, struct string_list *list)
784784
static int fetch_multiple(struct string_list *list)
785785
{
786786
int i, result = 0;
787-
const char *argv[] = { "fetch", NULL, NULL, NULL, NULL, NULL, NULL };
787+
const char *argv[10] = { "fetch" };
788788
int argc = 1;
789789

790790
if (dry_run)
791791
argv[argc++] = "--dry-run";
792792
if (prune)
793793
argv[argc++] = "--prune";
794+
if (update_head_ok)
795+
argv[argc++] = "--update-head-ok";
796+
if (force)
797+
argv[argc++] = "--force";
798+
if (keep)
799+
argv[argc++] = "--keep";
794800
if (verbosity >= 2)
795801
argv[argc++] = "-v";
796802
if (verbosity >= 1)
@@ -801,6 +807,7 @@ static int fetch_multiple(struct string_list *list)
801807
for (i = 0; i < list->nr; i++) {
802808
const char *name = list->items[i].string;
803809
argv[argc] = name;
810+
argv[argc + 1] = NULL;
804811
if (verbosity >= 0)
805812
printf("Fetching %s\n", name);
806813
if (run_command_v_opt(argv, RUN_GIT_CMD)) {

t/t5521-pull-options.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,25 @@ test_expect_success 'git pull -q -v' '
5151
test -s err)
5252
'
5353

54+
test_expect_success 'git pull --force' '
55+
mkdir clonedoldstyle &&
56+
(cd clonedoldstyle && git init &&
57+
cat >>.git/config <<-\EOF &&
58+
[remote "one"]
59+
url = ../parent
60+
fetch = refs/heads/master:refs/heads/mirror
61+
[remote "two"]
62+
url = ../parent
63+
fetch = refs/heads/master:refs/heads/origin
64+
[branch "master"]
65+
remote = two
66+
merge = refs/heads/master
67+
EOF
68+
git pull two &&
69+
test_commit A &&
70+
git branch -f origin &&
71+
git pull --all --force
72+
)
73+
'
74+
5475
test_done

0 commit comments

Comments
 (0)