git-ls-files: add --exclude-standard
This provides a way for scripts to get at the new standard exclude function. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Nov 15, 2007 at 02:04 UTC
8e7b07c8a776c401ff5c4adb593f423a754d198c
3 files changed
+13
-6
Documentation/git-ls-files.txt
+5
@@ -15,6 +15,7 @@ SYNOPSIS
15
[-x <pattern>|--exclude=<pattern>]
16
[-X <file>|--exclude-from=<file>]
17
[--exclude-per-directory=<file>]
18
+ [--exclude-standard]
19
[--error-unmatch] [--with-tree=<tree-ish>]
20
[--full-name] [--abbrev] [--] [<file>]\*
21
@@ -77,6 +78,10 @@ OPTIONS
78
read additional exclude patterns that apply only to the
79
directory and its subdirectories in <file>.
80
81
+--exclude-standard::
82
+ Add the standard git exclusions: .git/info/exclude, .gitignore
83
+ in each directory, and the user's global exclusion file.
84
+
85
--error-unmatch::
86
If any <file> does not appear in the index, treat this as an
87
error (return 1).
builtin-ls-files.c
+7
-2
@@ -387,8 +387,8 @@ static void overlay_tree(const char *tree_name, const char *prefix)
387
static const char ls_files_usage[] =
388
"git-ls-files [-z] [-t] [-v] (--[cached|deleted|others|stage|unmerged|killed|modified])* "
389
"[ --ignored ] [--exclude=<pattern>] [--exclude-from=<file>] "
390
- "[ --exclude-per-directory=<filename> ] [--full-name] [--abbrev] "
391
- "[--] [<file>]*";
390
+ "[ --exclude-per-directory=<filename> ] [--exclude-standard] "
391
+ "[--full-name] [--abbrev] [--] [<file>]*";
392
393
int cmd_ls_files(int argc, const char **argv, const char *prefix)
394
{
@@ -496,6 +496,11 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
496
dir.exclude_per_dir = arg + 24;
497
continue;
498
}
499
+ if (!strcmp(arg, "--exclude-standard")) {
500
+ exc_given = 1;
501
+ setup_standard_excludes(&dir);
502
+ continue;
503
+ }
504
if (!strcmp(arg, "--full-name")) {
505
prefix_offset = 0;
506
continue;
git-add--interactive.perl
+1
-4
@@ -37,10 +37,7 @@ sub list_untracked {
37
chomp $_;
38
$_;
39
}
40
- run_cmd_pipe(qw(git ls-files --others
41
- --exclude-per-directory=.gitignore),
42
- "--exclude-from=$GIT_DIR/info/exclude",
43
- '--', @_);
40
+ run_cmd_pipe(qw(git ls-files --others --exclude-standard --), @_);
41
}
42
43
my $status_fmt = '%12s %12s %s';