3 test_description='Test grep recurse-submodules feature
5 This test verifies the recurse-submodules feature correctly greps across
11 test_expect_success 'setup directory structure and submodule' '
16 git commit -m "add a and b" &&
18 echo "foobar" >submodule/a &&
19 git -C submodule add a &&
20 git -C submodule commit -m "add a" &&
21 git submodule add ./submodule &&
22 git commit -m "added submodule"
25 test_expect_success 'grep correctly finds patterns in a submodule' '
26 cat >expect <<-\EOF &&
32 git grep -e "bar" --recurse-submodules >actual &&
33 test_cmp expect actual
36 test_expect_success 'grep and basic pathspecs' '
37 cat >expect <<-\EOF &&
41 git grep -e. --recurse-submodules -- submodule >actual &&
42 test_cmp expect actual
45 test_expect_success 'grep and nested submodules' '
46 git init submodule/sub &&
47 echo "foobar" >submodule/sub/a &&
48 git -C submodule/sub add a &&
49 git -C submodule/sub commit -m "add a" &&
50 git -C submodule submodule add ./sub &&
51 git -C submodule add sub &&
52 git -C submodule commit -m "added sub" &&
54 git commit -m "updated submodule" &&
56 cat >expect <<-\EOF &&
60 submodule/sub/a:foobar
63 git grep -e "bar" --recurse-submodules >actual &&
64 test_cmp expect actual
67 test_expect_success 'grep and multiple patterns' '
68 cat >expect <<-\EOF &&
71 submodule/sub/a:foobar
74 git grep -e "bar" --and -e "foo" --recurse-submodules >actual &&
75 test_cmp expect actual
78 test_expect_success 'grep and multiple patterns' '
79 cat >expect <<-\EOF &&
83 git grep -e "bar" --and --not -e "foo" --recurse-submodules >actual &&
84 test_cmp expect actual
87 test_incompatible_with_recurse_submodules ()
89 test_expect_success "--recurse-submodules and $1 are incompatible" "
90 test_must_fail git grep -e. --recurse-submodules $1 2>actual &&
91 test_i18ngrep 'not supported with --recurse-submodules' actual
95 test_incompatible_with_recurse_submodules --untracked
96 test_incompatible_with_recurse_submodules --no-index
97 test_incompatible_with_recurse_submodules HEAD