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

git rm: refresh index before up-to-date check

Since "git rm" is supposed to be porcelain, we should convince it to be user friendly by refreshing the index itself. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Johannes Schindelin committed Oct 7, 2008 at 18:08 UTC cced48a808620d60e95a1e51254b135a46ddf719
2 files changed +18 -8
builtin-rm.c
+1
@@ -137,6 +137,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
137
138 if (read_cache() < 0)
139 die("index file corrupt");
140 + refresh_cache(REFRESH_QUIET);
141
142 pathspec = get_pathspec(prefix, argv);
143 seen = NULL;
t/t3600-rm.sh
+17 -8
@@ -219,14 +219,23 @@ test_expect_success 'Remove nonexistent file returns nonzero exit status' '
219
220 test_expect_success 'Call "rm" from outside the work tree' '
221 mkdir repo &&
222 - cd repo &&
223 - git init &&
224 - echo something > somefile &&
225 - git add somefile &&
226 - git commit -m "add a file" &&
227 - (cd .. &&
228 - git --git-dir=repo/.git --work-tree=repo rm somefile) &&
229 - test_must_fail git ls-files --error-unmatch somefile
222 + (cd repo &&
223 + git init &&
224 + echo something > somefile &&
225 + git add somefile &&
226 + git commit -m "add a file" &&
227 + (cd .. &&
228 + git --git-dir=repo/.git --work-tree=repo rm somefile) &&
229 + test_must_fail git ls-files --error-unmatch somefile)
230 +'
231 +
232 +test_expect_success 'refresh index before checking if it is up-to-date' '
233 +
234 + git reset --hard &&
235 + test-chmtime -86400 frotz/nitfol &&
236 + git rm frotz/nitfol &&
237 + test ! -f frotz/nitfol
238 +
239 '
240
241 test_done