@matheusbsbs / matheus-bagliano / commits / 1abf095063
Fork 0

git-add: adjust to the get_pathspec() changes.

We would need to notice and fail if command line had a nonsense pathspec. Earlier get_pathspec() returned all the inputs including bad ones, but the new one issues warnings and removes offending ones from its return value, so the callers need to be adjusted to notice it. Additional test scripts were initially from Robin Rosenberg, further fixed. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Feb 1, 2008 at 03:13 UTC 1abf0950638d4f3279d059a1365da9c253d5718a
2 files changed +59
builtin-add.c
+12
@@ -228,6 +228,18 @@ int cmd_add(int argc, const char **argv, const char *prefix)
228 goto finish;
229 }
230
231 + if (*argv) {
232 + /* Was there an invalid path? */
233 + if (pathspec) {
234 + int num;
235 + for (num = 0; pathspec[num]; num++)
236 + ; /* just counting */
237 + if (argc != num)
238 + exit(1); /* error message already given */
239 + } else
240 + exit(1); /* error message already given */
241 + }
242 +
243 fill_directory(&dir, pathspec, ignored_too);
244
245 if (show_only) {
t/t7010-setup.sh
+47
@@ -114,4 +114,51 @@ test_expect_success 'git ls-files (relative #3)' '
114
115 '
116
117 +test_expect_success 'commit using absolute path names' '
118 + git commit -m "foo" &&
119 + echo aa >>a/b/c/d &&
120 + git commit -m "aa" "$(pwd)/a/b/c/d"
121 +'
122 +
123 +test_expect_success 'log using absolute path names' '
124 + echo bb >>a/b/c/d &&
125 + git commit -m "bb" $(pwd)/a/b/c/d &&
126 +
127 + git log a/b/c/d >f1.txt &&
128 + git log "$(pwd)/a/b/c/d" >f2.txt &&
129 + diff -u f1.txt f2.txt
130 +'
131 +
132 +test_expect_success 'blame using absolute path names' '
133 + git blame a/b/c/d >f1.txt &&
134 + git blame "$(pwd)/a/b/c/d" >f2.txt &&
135 + diff -u f1.txt f2.txt
136 +'
137 +
138 +test_expect_success 'setup deeper work tree' '
139 + test_create_repo tester
140 +'
141 +
142 +test_expect_success 'add a directory outside the work tree' '(
143 + cd tester &&
144 + d1="$(cd .. ; pwd)" &&
145 + git add "$d1"
146 +)'
147 +
148 +test_expect_success 'add a file outside the work tree, nasty case 1' '(
149 + cd tester &&
150 + f="$(pwd)x" &&
151 + echo "$f" &&
152 + touch "$f" &&
153 + git add "$f"
154 +)'
155 +
156 +test_expect_success 'add a file outside the work tree, nasty case 2' '(
157 + cd tester &&
158 + f="$(pwd | sed "s/.$//")x" &&
159 + echo "$f" &&
160 + touch "$f" &&
161 + git add "$f"
162 +)'
163 +
164 test_done