Skip to content

Commit e38d1c5

Browse files
committed
Merge branch 'jk/maint-1.6.3-ls-files-no-ignore-cached'
* jk/maint-1.6.3-ls-files-no-ignore-cached: ls-files: excludes should not impact tracked files
2 parents 03fee47 + b5227d8 commit e38d1c5

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-8
lines changed

builtin-ls-files.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,6 @@ 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 (excluded(dir, ce->name, &dtype) !=
175-
!!(dir->flags & DIR_SHOW_IGNORED))
176-
continue;
177173
if (show_unmerged && !ce_stage(ce))
178174
continue;
179175
if (ce->ce_flags & CE_UPDATE)
@@ -186,10 +182,6 @@ static void show_files(struct dir_struct *dir, const char *prefix)
186182
struct cache_entry *ce = active_cache[i];
187183
struct stat st;
188184
int err;
189-
int dtype = ce_to_dtype(ce);
190-
if (excluded(dir, ce->name, &dtype) !=
191-
!!(dir->flags & DIR_SHOW_IGNORED))
192-
continue;
193185
if (ce->ce_flags & CE_UPDATE)
194186
continue;
195187
err = lstat(ce->name, &st);

t/t3003-ls-files-exclude.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/sh
2+
3+
test_description='ls-files --exclude does not affect index files'
4+
. ./test-lib.sh
5+
6+
test_expect_success 'create repo with file' '
7+
echo content >file &&
8+
git add file &&
9+
git commit -m file &&
10+
echo modification >file
11+
'
12+
13+
check_output() {
14+
test_expect_success "ls-files output contains file ($1)" "
15+
echo '$2' >expect &&
16+
git ls-files --exclude-standard --$1 >output &&
17+
test_cmp expect output
18+
"
19+
}
20+
21+
check_all_output() {
22+
check_output 'cached' 'file'
23+
check_output 'modified' 'file'
24+
}
25+
26+
check_all_output
27+
test_expect_success 'add file to gitignore' '
28+
echo file >.gitignore
29+
'
30+
check_all_output
31+
32+
test_done

0 commit comments

Comments
 (0)