aboutsummaryrefslogtreecommitdiff
path: root/t/t3007-ls-files-recurse-submodules.sh
diff options
context:
space:
mode:
authorJacob Keller <jacob.keller@gmail.com>2017-04-13 10:12:24 -0700
committerJunio C Hamano <gitster@pobox.com>2017-04-18 18:01:41 -0700
commit2cfe66a8ee57fb3da18c262db8e6df95e263510b (patch)
tree0012929e62af8eee6a24e0795f46333d38a6d72f /t/t3007-ls-files-recurse-submodules.sh
parent2e5d6503bdc92260eae9c58b9fd1add7014bb853 (diff)
downloadgit-2cfe66a8ee57fb3da18c262db8e6df95e263510b.tar.gz
git-2cfe66a8ee57fb3da18c262db8e6df95e263510b.tar.xz
ls-files: fix path used when recursing into submodules
Don't assume that the current working directory is the root of the repository. Correctly generate the path for the recursing child processes by building it from the work_tree() root instead. Otherwise if we run ls-files using --git-dir or --work-tree it will not work correctly as it attempts to change directory into a potentially invalid location. Best case, it doesn't exist and we produce an error. Worst case we cd into the wrong location and unknown behavior occurs. Add a new test which highlights this possibility. Signed-off-by: Jacob Keller <jacob.keller@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t3007-ls-files-recurse-submodules.sh')
-rwxr-xr-xt/t3007-ls-files-recurse-submodules.sh11
1 files changed, 11 insertions, 0 deletions
diff --git a/t/t3007-ls-files-recurse-submodules.sh b/t/t3007-ls-files-recurse-submodules.sh
index c8030dd32..ebb956fd1 100755
--- a/t/t3007-ls-files-recurse-submodules.sh
+++ b/t/t3007-ls-files-recurse-submodules.sh
@@ -82,6 +82,17 @@ test_expect_success 'ls-files recurses more than 1 level' '
test_cmp expect actual
'
+test_expect_success 'ls-files works with GIT_DIR' '
+ cat >expect <<-\EOF &&
+ .gitmodules
+ c
+ subsub/d
+ EOF
+
+ git --git-dir=submodule/.git ls-files --recurse-submodules >actual &&
+ test_cmp expect actual
+'
+
test_expect_success '--recurse-submodules and pathspecs setup' '
echo e >submodule/subsub/e.txt &&
git -C submodule/subsub add e.txt &&