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>
This commit is contained in:
parent
daf6c2edc2
commit
cced48a808
@ -137,6 +137,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
|
|||||||
|
|
||||||
if (read_cache() < 0)
|
if (read_cache() < 0)
|
||||||
die("index file corrupt");
|
die("index file corrupt");
|
||||||
|
refresh_cache(REFRESH_QUIET);
|
||||||
|
|
||||||
pathspec = get_pathspec(prefix, argv);
|
pathspec = get_pathspec(prefix, argv);
|
||||||
seen = NULL;
|
seen = NULL;
|
||||||
|
@ -219,14 +219,23 @@ test_expect_success 'Remove nonexistent file returns nonzero exit status' '
|
|||||||
|
|
||||||
test_expect_success 'Call "rm" from outside the work tree' '
|
test_expect_success 'Call "rm" from outside the work tree' '
|
||||||
mkdir repo &&
|
mkdir repo &&
|
||||||
cd repo &&
|
(cd repo &&
|
||||||
git init &&
|
git init &&
|
||||||
echo something > somefile &&
|
echo something > somefile &&
|
||||||
git add somefile &&
|
git add somefile &&
|
||||||
git commit -m "add a file" &&
|
git commit -m "add a file" &&
|
||||||
(cd .. &&
|
(cd .. &&
|
||||||
git --git-dir=repo/.git --work-tree=repo rm somefile) &&
|
git --git-dir=repo/.git --work-tree=repo rm somefile) &&
|
||||||
test_must_fail git ls-files --error-unmatch 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
|
test_done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user