@matheusbsbs / matheus-bagliano / commits / c8af25ca01
Fork 0

git-ls-files: Fix, document, and add test for --error-unmatch option.

Signed-off-by: Junio C Hamano <junkio@cox.net>

Carl Worth committed Feb 21, 2006 at 12:48 UTC c8af25ca0157146de59b992c1f961f1af8465995
3 files changed +33
Documentation/git-ls-files.txt
+5
@@ -14,6 +14,7 @@ SYNOPSIS
14 [-x <pattern>|--exclude=<pattern>]
15 [-X <file>|--exclude-from=<file>]
16 [--exclude-per-directory=<file>]
17 + [--error-unmatch]
18 [--full-name] [--] [<file>]\*
19
20 DESCRIPTION
@@ -72,6 +73,10 @@ OPTIONS
73 read additional exclude patterns that apply only to the
74 directory and its subdirectories in <file>.
75
76 +--error-unmatch::
77 + If any <file> does not appear in the index, treat this as an
78 + error (return 1).
79 +
80 -t::
81 Identify the file status with the following tags (followed by
82 a space) at the start of each line:
ls-files.c
+1
@@ -758,6 +758,7 @@ int main(int argc, const char **argv)
758 continue;
759 error("pathspec '%s' did not match any.",
760 pathspec[num] + prefix_offset);
761 + errors++;
762 }
763 return errors ? 1 : 0;
764 }
t/t3020-ls-files-error-unmatch.sh new
+27
@@ -0,0 +1,27 @@
1 +#!/bin/sh
2 +#
3 +# Copyright (c) 2006 Carl D. Worth
4 +#
5 +
6 +test_description='git-ls-files test for --error-unmatch option
7 +
8 +This test runs git-ls-files --error-unmatch to ensure it correctly
9 +returns an error when a non-existent path is provided on the command
10 +line.
11 +'
12 +. ./test-lib.sh
13 +
14 +touch foo bar
15 +git-update-index --add foo bar
16 +git-commit -m "add foo bar"
17 +
18 +test_expect_failure \
19 + 'git-ls-files --error-unmatch should fail with unmatched path.' \
20 + 'git-ls-files --error-unmatch foo bar-does-not-match'
21 +
22 +test_expect_success \
23 + 'git-ls-files --error-unmatch should succeed eith matched paths.' \
24 + 'git-ls-files --error-unmatch foo bar'
25 +
26 +test_done
27 +1