Skip to content

Commit 958742b

Browse files
committed
Merge branch 'jk/maint-1.6.3-ls-files-i' into maint
* jk/maint-1.6.3-ls-files-i: ls-files: unbreak "ls-files -i"
2 parents 3e606ea + 500348a commit 958742b

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

Documentation/git-ls-files.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@ OPTIONS
4848

4949
-i::
5050
--ignored::
51-
Show ignored files in the output.
52-
Note that this also reverses any exclude list present.
51+
Show only ignored files in the output. When showing files in the
52+
index, print only those matched by an exclude pattern. When
53+
showing "other" files, show only those matched by an exclude
54+
pattern.
5355

5456
-s::
5557
--stage::

builtin-ls-files.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ static void show_files(struct dir_struct *dir, const char *prefix)
170170
if (show_cached | show_stage) {
171171
for (i = 0; i < active_nr; i++) {
172172
struct cache_entry *ce = active_cache[i];
173+
int dtype = ce_to_dtype(ce);
174+
if (dir->flags & DIR_SHOW_IGNORED &&
175+
!excluded(dir, ce->name, &dtype))
176+
continue;
173177
if (show_unmerged && !ce_stage(ce))
174178
continue;
175179
if (ce->ce_flags & CE_UPDATE)
@@ -182,6 +186,10 @@ static void show_files(struct dir_struct *dir, const char *prefix)
182186
struct cache_entry *ce = active_cache[i];
183187
struct stat st;
184188
int err;
189+
int dtype = ce_to_dtype(ce);
190+
if (dir->flags & DIR_SHOW_IGNORED &&
191+
!excluded(dir, ce->name, &dtype))
192+
continue;
185193
if (ce->ce_flags & CE_UPDATE)
186194
continue;
187195
err = lstat(ce->name, &st);

t/t3003-ls-files-exclude.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,12 @@ test_expect_success 'add file to gitignore' '
2929
'
3030
check_all_output
3131

32+
test_expect_success 'ls-files -i lists only tracked-but-ignored files' '
33+
echo content >other-file &&
34+
git add other-file &&
35+
echo file >expect &&
36+
git ls-files -i --exclude-standard >output &&
37+
test_cmp expect output
38+
'
39+
3240
test_done

0 commit comments

Comments
 (0)