Skip to content

Commit

Permalink
builtin-fetch --all/--multi: propagate options correctly
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
gitster committed Feb 24, 2010
1 parent 13e65fe commit bba5322
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
9 changes: 8 additions & 1 deletion builtin-fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -784,13 +784,19 @@ 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[10] = { "fetch" };
int argc = 1;

if (dry_run)
argv[argc++] = "--dry-run";
if (prune)
argv[argc++] = "--prune";
if (update_head_ok)
argv[argc++] = "--update-head-ok";
if (force)
argv[argc++] = "--force";
if (keep)
argv[argc++] = "--keep";
if (verbosity >= 2)
argv[argc++] = "-v";
if (verbosity >= 1)
Expand All @@ -801,6 +807,7 @@ static int fetch_multiple(struct string_list *list)
for (i = 0; i < list->nr; i++) {
const char *name = list->items[i].string;
argv[argc] = name;
argv[argc + 1] = NULL;
if (verbosity >= 0)
printf("Fetching %s\n", name);
if (run_command_v_opt(argv, RUN_GIT_CMD)) {
Expand Down
21 changes: 21 additions & 0 deletions t/t5521-pull-options.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,25 @@ test_expect_success 'git pull -q -v' '
test -s err)
'

test_expect_success 'git pull --force' '
mkdir clonedoldstyle &&
(cd clonedoldstyle && git init &&
cat >>.git/config <<-\EOF &&
[remote "one"]
url = ../parent
fetch = refs/heads/master:refs/heads/mirror
[remote "two"]
url = ../parent
fetch = refs/heads/master:refs/heads/origin
[branch "master"]
remote = two
merge = refs/heads/master
EOF
git pull two &&
test_commit A &&
git branch -f origin &&
git pull --all --force
)
'

test_done

0 comments on commit bba5322

Please sign in to comment.