Skip to content

Commit f1c9f6c

Browse files
committed
Merge branch 'nd/submodule-foreach-quiet'
"git submodule foreach <command> --quiet" did not pass the option down correctly, which has been corrected. * nd/submodule-foreach-quiet: submodule foreach: fix "<command> --quiet" not being respected
2 parents 5c2b4ca + a282f5a commit f1c9f6c

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

builtin/submodule--helper.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -566,12 +566,12 @@ static int module_foreach(int argc, const char **argv, const char *prefix)
566566
};
567567

568568
const char *const git_submodule_helper_usage[] = {
569-
N_("git submodule--helper foreach [--quiet] [--recursive] <command>"),
569+
N_("git submodule--helper foreach [--quiet] [--recursive] [--] <command>"),
570570
NULL
571571
};
572572

573573
argc = parse_options(argc, argv, prefix, module_foreach_options,
574-
git_submodule_helper_usage, PARSE_OPT_KEEP_UNKNOWN);
574+
git_submodule_helper_usage, 0);
575575

576576
if (module_list_compute(0, NULL, prefix, &pathspec, &list) < 0)
577577
return 1;
@@ -709,7 +709,7 @@ static int module_init(int argc, const char **argv, const char *prefix)
709709
};
710710

711711
const char *const git_submodule_helper_usage[] = {
712-
N_("git submodule--helper init [<path>]"),
712+
N_("git submodule--helper init [<options>] [<path>]"),
713713
NULL
714714
};
715715

@@ -2096,7 +2096,7 @@ static int absorb_git_dirs(int argc, const char **argv, const char *prefix)
20962096
};
20972097

20982098
const char *const git_submodule_helper_usage[] = {
2099-
N_("git submodule--helper embed-git-dir [<path>...]"),
2099+
N_("git submodule--helper absorb-git-dirs [<options>] [<path>...]"),
21002100
NULL
21012101
};
21022102

git-submodule.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ cmd_foreach()
347347
shift
348348
done
349349

350-
git ${wt_prefix:+-C "$wt_prefix"} ${prefix:+--super-prefix "$prefix"} submodule--helper foreach ${GIT_QUIET:+--quiet} ${recursive:+--recursive} "$@"
350+
git ${wt_prefix:+-C "$wt_prefix"} ${prefix:+--super-prefix "$prefix"} submodule--helper foreach ${GIT_QUIET:+--quiet} ${recursive:+--recursive} -- "$@"
351351
}
352352

353353
#
@@ -378,7 +378,7 @@ cmd_init()
378378
shift
379379
done
380380

381-
git ${wt_prefix:+-C "$wt_prefix"} ${prefix:+--super-prefix "$prefix"} submodule--helper init ${GIT_QUIET:+--quiet} "$@"
381+
git ${wt_prefix:+-C "$wt_prefix"} ${prefix:+--super-prefix "$prefix"} submodule--helper init ${GIT_QUIET:+--quiet} -- "$@"
382382
}
383383

384384
#
@@ -414,7 +414,7 @@ cmd_deinit()
414414
shift
415415
done
416416

417-
git ${wt_prefix:+-C "$wt_prefix"} submodule--helper deinit ${GIT_QUIET:+--quiet} ${prefix:+--prefix "$prefix"} ${force:+--force} ${deinit_all:+--all} "$@"
417+
git ${wt_prefix:+-C "$wt_prefix"} submodule--helper deinit ${GIT_QUIET:+--quiet} ${prefix:+--prefix "$prefix"} ${force:+--force} ${deinit_all:+--all} -- "$@"
418418
}
419419

420420
is_tip_reachable () (
@@ -543,6 +543,7 @@ cmd_update()
543543
${depth:+--depth "$depth"} \
544544
$recommend_shallow \
545545
$jobs \
546+
-- \
546547
"$@" || echo "#unmatched" $?
547548
} | {
548549
err=
@@ -1001,7 +1002,7 @@ cmd_status()
10011002
shift
10021003
done
10031004

1004-
git ${wt_prefix:+-C "$wt_prefix"} ${prefix:+--super-prefix "$prefix"} submodule--helper status ${GIT_QUIET:+--quiet} ${cached:+--cached} ${recursive:+--recursive} "$@"
1005+
git ${wt_prefix:+-C "$wt_prefix"} ${prefix:+--super-prefix "$prefix"} submodule--helper status ${GIT_QUIET:+--quiet} ${cached:+--cached} ${recursive:+--recursive} -- "$@"
10051006
}
10061007
#
10071008
# Sync remote urls for submodules
@@ -1034,7 +1035,7 @@ cmd_sync()
10341035
esac
10351036
done
10361037

1037-
git ${wt_prefix:+-C "$wt_prefix"} ${prefix:+--super-prefix "$prefix"} submodule--helper sync ${GIT_QUIET:+--quiet} ${recursive:+--recursive} "$@"
1038+
git ${wt_prefix:+-C "$wt_prefix"} ${prefix:+--super-prefix "$prefix"} submodule--helper sync ${GIT_QUIET:+--quiet} ${recursive:+--recursive} -- "$@"
10381039
}
10391040

10401041
cmd_absorbgitdirs()

t/t7407-submodule-foreach.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,4 +411,14 @@ test_expect_success 'multi-argument command passed to foreach is not shell-evalu
411411
test_cmp expected actual
412412
'
413413

414+
test_expect_success 'option-like arguments passed to foreach commands are not lost' '
415+
(
416+
cd super &&
417+
git submodule foreach "echo be --quiet" > ../expected &&
418+
git submodule foreach echo be --quiet > ../actual
419+
) &&
420+
grep -sq -e "--quiet" expected &&
421+
test_cmp expected actual
422+
'
423+
414424
test_done

0 commit comments

Comments
 (0)