ls-files: fix broken --no-empty-directory
Commit ce8e880 converted ls-files to use parseopt; the --no-empty-directory option was converted as an OPT_BIT for "empty-directory" to set the DIR_HIDE_EMPTY_DIRECTORY flag. However, that makes it do the opposite of what it should: --empty-directory would hide, but --no-empty-directory would turn off hiding. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Mar 7, 2009 at 20:27 UTC
2fb6d6d6dd1033bfe82d6d327ac270f9cf8943cd
2 files changed
+15
-3
builtin-ls-files.c
+2
-2
@@ -454,8 +454,8 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
454
OPT_BIT(0, "directory", &dir.flags,
455
"show 'other' directories' name only",
456
DIR_SHOW_OTHER_DIRECTORIES),
457
- OPT_BIT(0, "empty-directory", &dir.flags,
458
- "list empty directories",
457
+ OPT_BIT(0, "no-empty-directory", &dir.flags,
458
+ "don't show empty directories",
459
DIR_HIDE_EMPTY_DIRECTORIES),
460
OPT_BOOLEAN('u', "unmerged", &show_unmerged,
461
"show unmerged files in the output"),
t/t3000-ls-files-others.sh
+13
-1
@@ -13,12 +13,13 @@ filesystem.
13
path2/file2 - a file in a directory
14
path3-junk - a file to confuse things
15
path3/file3 - a file in a directory
16
+ path4 - an empty directory
17
'
18
. ./test-lib.sh
19
20
date >path0
21
ln -s xyzzy path1
21
-mkdir path2 path3
22
+mkdir path2 path3 path4
23
date >path2/file2
24
date >path2-junk
25
date >path3/file3
@@ -28,6 +29,7 @@ git update-index --add path3-junk path3/file3
29
cat >expected1 <<EOF
30
expected1
31
expected2
32
+expected3
33
output
34
path0
35
path1
@@ -35,6 +37,8 @@ path2-junk
37
path2/file2
38
EOF
39
sed -e 's|path2/file2|path2/|' <expected1 >expected2
40
+cat <expected2 >expected3
41
+echo path4/ >>expected2
42
43
test_expect_success \
44
'git ls-files --others to show output.' \
@@ -53,4 +57,12 @@ test_expect_success \
57
'git ls-files --others --directory should not get confused.' \
58
'test_cmp expected2 output'
59
60
+test_expect_success \
61
+ 'git ls-files --others --directory --no-empty-directory to show output.' \
62
+ 'git ls-files --others --directory --no-empty-directory >output'
63
+
64
+test_expect_success \
65
+ '--no-empty-directory hides empty directory' \
66
+ 'test_cmp expected3 output'
67
+
68
test_done