From 2c63d6eb46da4ef0abc9c040c927818e437d2fcc Mon Sep 17 00:00:00 2001 From: John Keeping Date: Thu, 12 Sep 2013 20:25:01 +0100 Subject: reset: handle submodule with trailing slash When using tab-completion, a directory path will often end with a trailing slash which currently confuses "git reset" when dealing with submodules. Now that we have parse_pathspec we can easily handle this by simply adding the PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP flag. To do this, we need to move the read_cache() call before the parse_pathspec() call. All of the existing paths through cmd_reset() that do not die early already call read_cache() at some point, so there is no performance impact to doing this in the common case. Signed-off-by: John Keeping Signed-off-by: Junio C Hamano --- t/t7400-submodule-basic.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 't/t7400-submodule-basic.sh') diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh index 4192fe0ec6..c268d3c9a2 100755 --- a/t/t7400-submodule-basic.sh +++ b/t/t7400-submodule-basic.sh @@ -481,7 +481,7 @@ test_expect_success 'do not add files from a submodule' ' ' -test_expect_success 'gracefully add submodule with a trailing slash' ' +test_expect_success 'gracefully add/reset submodule with a trailing slash' ' git reset --hard && git commit -m "commit subproject" init && @@ -495,7 +495,9 @@ test_expect_success 'gracefully add submodule with a trailing slash' ' git add init/ && test_must_fail git diff --exit-code --cached init && test $commit = $(git ls-files --stage | - sed -n "s/^160000 \([^ ]*\).*/\1/p") + sed -n "s/^160000 \([^ ]*\).*/\1/p") && + git reset init/ && + git diff --exit-code --cached init ' -- cgit v1.2.3