summaryrefslogtreecommitdiff
path: root/t/t7814-grep-recurse-submodules.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-08-22 19:34:10 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-08-22 19:34:10 (GMT)
commit307179732d580735c579b9bfae2eaf7a536f4ae9 (patch)
tree83689a991d1519207c510d0ff6669ffc758b5e3b /t/t7814-grep-recurse-submodules.sh
parent5fa0f5238b0cd46cfe7f6fa76c3f526ea98148d9 (diff)
parent6a289d45c0e5d155f536d7c1f73c3b33690e92c6 (diff)
downloadgit-307179732d580735c579b9bfae2eaf7a536f4ae9.zip
git-307179732d580735c579b9bfae2eaf7a536f4ae9.tar.gz
git-307179732d580735c579b9bfae2eaf7a536f4ae9.tar.bz2
Merge branch 'mt/grep-submodules-working-tree'
"git grep --recurse-submodules" that looks at the working tree files looked at the contents in the index in submodules, instead of files in the working tree. * mt/grep-submodules-working-tree: grep: fix worktree case in submodules
Diffstat (limited to 't/t7814-grep-recurse-submodules.sh')
-rwxr-xr-xt/t7814-grep-recurse-submodules.sh21
1 files changed, 21 insertions, 0 deletions
diff --git a/t/t7814-grep-recurse-submodules.sh b/t/t7814-grep-recurse-submodules.sh
index a11366b..946f91f 100755
--- a/t/t7814-grep-recurse-submodules.sh
+++ b/t/t7814-grep-recurse-submodules.sh
@@ -408,4 +408,25 @@ test_expect_success 'grep --recurse-submodules with submodules without .gitmodul
test_cmp expect actual
'
+reset_and_clean () {
+ git reset --hard &&
+ git clean -fd &&
+ git submodule foreach --recursive 'git reset --hard' &&
+ git submodule foreach --recursive 'git clean -fd'
+}
+
+test_expect_success 'grep --recurse-submodules without --cached considers worktree modifications' '
+ reset_and_clean &&
+ echo "A modified line in submodule" >>submodule/a &&
+ echo "submodule/a:A modified line in submodule" >expect &&
+ git grep --recurse-submodules "A modified line in submodule" >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'grep --recurse-submodules with --cached ignores worktree modifications' '
+ reset_and_clean &&
+ echo "A modified line in submodule" >>submodule/a &&
+ test_must_fail git grep --recurse-submodules --cached "A modified line in submodule" >actual 2>&1 &&
+ test_must_be_empty actual
+'
test_done