Merge branch 'bw/ls-files-recurse-submodules'
"git ls-files" learned "--recurse-submodules" option that can be used to get a listing of tracked files across submodules (i.e. this only works with "--cached" option, not for listing untracked or ignored files). This would be a useful tool to sit on the upstream side of a pipe that is read with xargs to work on all working tree files from the top-level superproject. * bw/ls-files-recurse-submodules: ls-files: add pathspec matching for submodules ls-files: pass through safe options for --recurse-submodules ls-files: optionally recurse into submodules git: make super-prefix option
This commit is contained in:
27
git.c
27
git.c
@ -164,6 +164,20 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
|
||||
setenv(GIT_WORK_TREE_ENVIRONMENT, cmd, 1);
|
||||
if (envchanged)
|
||||
*envchanged = 1;
|
||||
} else if (!strcmp(cmd, "--super-prefix")) {
|
||||
if (*argc < 2) {
|
||||
fprintf(stderr, "No prefix given for --super-prefix.\n" );
|
||||
usage(git_usage_string);
|
||||
}
|
||||
setenv(GIT_SUPER_PREFIX_ENVIRONMENT, (*argv)[1], 1);
|
||||
if (envchanged)
|
||||
*envchanged = 1;
|
||||
(*argv)++;
|
||||
(*argc)--;
|
||||
} else if (skip_prefix(cmd, "--super-prefix=", &cmd)) {
|
||||
setenv(GIT_SUPER_PREFIX_ENVIRONMENT, cmd, 1);
|
||||
if (envchanged)
|
||||
*envchanged = 1;
|
||||
} else if (!strcmp(cmd, "--bare")) {
|
||||
char *cwd = xgetcwd();
|
||||
is_bare_repository_cfg = 1;
|
||||
@ -310,6 +324,7 @@ static int handle_alias(int *argcp, const char ***argv)
|
||||
* RUN_SETUP for reading from the configuration file.
|
||||
*/
|
||||
#define NEED_WORK_TREE (1<<3)
|
||||
#define SUPPORT_SUPER_PREFIX (1<<4)
|
||||
|
||||
struct cmd_struct {
|
||||
const char *cmd;
|
||||
@ -344,6 +359,13 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
|
||||
}
|
||||
commit_pager_choice();
|
||||
|
||||
if (!help && get_super_prefix()) {
|
||||
if (!(p->option & SUPPORT_SUPER_PREFIX))
|
||||
die("%s doesn't support --super-prefix", p->cmd);
|
||||
if (prefix)
|
||||
die("can't use --super-prefix from a subdirectory");
|
||||
}
|
||||
|
||||
if (!help && p->option & NEED_WORK_TREE)
|
||||
setup_work_tree();
|
||||
|
||||
@ -421,7 +443,7 @@ static struct cmd_struct commands[] = {
|
||||
{ "init-db", cmd_init_db },
|
||||
{ "interpret-trailers", cmd_interpret_trailers, RUN_SETUP_GENTLY },
|
||||
{ "log", cmd_log, RUN_SETUP },
|
||||
{ "ls-files", cmd_ls_files, RUN_SETUP },
|
||||
{ "ls-files", cmd_ls_files, RUN_SETUP | SUPPORT_SUPER_PREFIX },
|
||||
{ "ls-remote", cmd_ls_remote, RUN_SETUP_GENTLY },
|
||||
{ "ls-tree", cmd_ls_tree, RUN_SETUP },
|
||||
{ "mailinfo", cmd_mailinfo },
|
||||
@ -558,6 +580,9 @@ static void execv_dashed_external(const char **argv)
|
||||
const char *tmp;
|
||||
int status;
|
||||
|
||||
if (get_super_prefix())
|
||||
die("%s doesn't support --super-prefix", argv[0]);
|
||||
|
||||
if (use_pager == -1)
|
||||
use_pager = check_pager_config(argv[0]);
|
||||
commit_pager_choice();
|
||||
|
||||
Reference in New Issue
Block a user