Skip to content

Commit

Permalink
Merge branch 'nd/submodule-foreach-quiet'
Browse files Browse the repository at this point in the history
"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
  • Loading branch information
gitster committed Apr 25, 2019
2 parents 5c2b4ca + a282f5a commit f1c9f6c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
8 changes: 4 additions & 4 deletions builtin/submodule--helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -566,12 +566,12 @@ static int module_foreach(int argc, const char **argv, const char *prefix)
};

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

argc = parse_options(argc, argv, prefix, module_foreach_options,
git_submodule_helper_usage, PARSE_OPT_KEEP_UNKNOWN);
git_submodule_helper_usage, 0);

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

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

Expand Down Expand Up @@ -2096,7 +2096,7 @@ static int absorb_git_dirs(int argc, const char **argv, const char *prefix)
};

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

Expand Down
11 changes: 6 additions & 5 deletions git-submodule.sh
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ cmd_foreach()
shift
done

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

#
Expand Down Expand Up @@ -378,7 +378,7 @@ cmd_init()
shift
done

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

#
Expand Down Expand Up @@ -414,7 +414,7 @@ cmd_deinit()
shift
done

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

is_tip_reachable () (
Expand Down Expand Up @@ -543,6 +543,7 @@ cmd_update()
${depth:+--depth "$depth"} \
$recommend_shallow \
$jobs \
-- \
"$@" || echo "#unmatched" $?
} | {
err=
Expand Down Expand Up @@ -1001,7 +1002,7 @@ cmd_status()
shift
done

git ${wt_prefix:+-C "$wt_prefix"} ${prefix:+--super-prefix "$prefix"} submodule--helper status ${GIT_QUIET:+--quiet} ${cached:+--cached} ${recursive:+--recursive} "$@"
git ${wt_prefix:+-C "$wt_prefix"} ${prefix:+--super-prefix "$prefix"} submodule--helper status ${GIT_QUIET:+--quiet} ${cached:+--cached} ${recursive:+--recursive} -- "$@"
}
#
# Sync remote urls for submodules
Expand Down Expand Up @@ -1034,7 +1035,7 @@ cmd_sync()
esac
done

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

cmd_absorbgitdirs()
Expand Down
10 changes: 10 additions & 0 deletions t/t7407-submodule-foreach.sh
Original file line number Diff line number Diff line change
Expand Up @@ -411,4 +411,14 @@ test_expect_success 'multi-argument command passed to foreach is not shell-evalu
test_cmp expected actual
'

test_expect_success 'option-like arguments passed to foreach commands are not lost' '
(
cd super &&
git submodule foreach "echo be --quiet" > ../expected &&
git submodule foreach echo be --quiet > ../actual
) &&
grep -sq -e "--quiet" expected &&
test_cmp expected actual
'

test_done

0 comments on commit f1c9f6c

Please sign in to comment.