Skip to content

Commit

Permalink
git rm: refresh index before up-to-date check
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Johannes Schindelin authored and Shawn O. Pearce committed Oct 8, 2008
1 parent daf6c2e commit cced48a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
1 change: 1 addition & 0 deletions builtin-rm.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)

if (read_cache() < 0)
die("index file corrupt");
refresh_cache(REFRESH_QUIET);

pathspec = get_pathspec(prefix, argv);
seen = NULL;
Expand Down
25 changes: 17 additions & 8 deletions t/t3600-rm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,23 @@ test_expect_success 'Remove nonexistent file returns nonzero exit status' '

test_expect_success 'Call "rm" from outside the work tree' '
mkdir repo &&
cd repo &&
git init &&
echo something > somefile &&
git add somefile &&
git commit -m "add a file" &&
(cd .. &&
git --git-dir=repo/.git --work-tree=repo rm somefile) &&
test_must_fail git ls-files --error-unmatch somefile
(cd repo &&
git init &&
echo something > somefile &&
git add somefile &&
git commit -m "add a file" &&
(cd .. &&
git --git-dir=repo/.git --work-tree=repo rm somefile) &&
test_must_fail git ls-files --error-unmatch somefile)
'

test_expect_success 'refresh index before checking if it is up-to-date' '
git reset --hard &&
test-chmtime -86400 frotz/nitfol &&
git rm frotz/nitfol &&
test ! -f frotz/nitfol
'

test_done

0 comments on commit cced48a

Please sign in to comment.