Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 8e7b07c

Browse files
peffgitster
authored andcommitted
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>
1 parent a777e9c commit 8e7b07c

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

Documentation/git-ls-files.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ SYNOPSIS
1515
[-x <pattern>|--exclude=<pattern>]
1616
[-X <file>|--exclude-from=<file>]
1717
[--exclude-per-directory=<file>]
18+
[--exclude-standard]
1819
[--error-unmatch] [--with-tree=<tree-ish>]
1920
[--full-name] [--abbrev] [--] [<file>]\*
2021

@@ -77,6 +78,10 @@ OPTIONS
7778
read additional exclude patterns that apply only to the
7879
directory and its subdirectories in <file>.
7980

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+
8085
--error-unmatch::
8186
If any <file> does not appear in the index, treat this as an
8287
error (return 1).

builtin-ls-files.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,8 @@ static void overlay_tree(const char *tree_name, const char *prefix)
387387
static const char ls_files_usage[] =
388388
"git-ls-files [-z] [-t] [-v] (--[cached|deleted|others|stage|unmerged|killed|modified])* "
389389
"[ --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>]*";
392392

393393
int cmd_ls_files(int argc, const char **argv, const char *prefix)
394394
{
@@ -496,6 +496,11 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
496496
dir.exclude_per_dir = arg + 24;
497497
continue;
498498
}
499+
if (!strcmp(arg, "--exclude-standard")) {
500+
exc_given = 1;
501+
setup_standard_excludes(&dir);
502+
continue;
503+
}
499504
if (!strcmp(arg, "--full-name")) {
500505
prefix_offset = 0;
501506
continue;

git-add--interactive.perl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ sub list_untracked {
3737
chomp $_;
3838
$_;
3939
}
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 --), @_);
4441
}
4542

4643
my $status_fmt = '%12s %12s %s';

0 commit comments

Comments
 (0)