summaryrefslogtreecommitdiff
path: root/git-submodule.sh
diff options
context:
space:
mode:
authorStefan Beller <sbeller@google.com>2016-03-29 18:27:43 -0700
committerJunio C Hamano <gitster@pobox.com>2016-03-30 13:07:23 -0700
commit10450cf72b51baf3bac6a779fb4e47241af7ae5e (patch)
tree0f1a368e41a8663bec3d2559a77cae1324225d27 /git-submodule.sh
parentc1ab00fb267fb0166376ff2c81083ef2cada6d9d (diff)
downloadgit-10450cf72b51baf3bac6a779fb4e47241af7ae5e.tar.gz
submodule status: correct path handling in recursive submodules
The new test which is a replica of the previous test except that it executes from a sub directory. Prior to this patch the test failed by having too many '../' prefixed: --- expect 2016-03-29 19:02:33.087336115 +0000 +++ actual 2016-03-29 19:02:33.359343311 +0000 @@ -1,7 +1,7 @@ b23f134787d96fae589a6b76da41f4db112fc8db ../nested1 (heads/master) -+25d56d1ddfb35c3e91ff7d8f12331c2e53147dcc ../nested1/nested2 (file2) - 5ec83512b76a0b8170b899f8e643913c3e9b72d9 ../nested1/nested2/nested3 (heads/master) - 509f622a4f36a3e472affcf28fa959174f3dd5b5 ../nested1/nested2/nested3/submodule (heads/master) ++25d56d1ddfb35c3e91ff7d8f12331c2e53147dcc ../../nested1/nested2 (file2) + 5ec83512b76a0b8170b899f8e643913c3e9b72d9 ../../../nested1/nested2/nested3 (heads/master) + 509f622a4f36a3e472affcf28fa959174f3dd5b5 ../../../../nested1/nested2/nested3/submodule (heads/master) 0c90624ab7f1aaa301d3bb79f60dcfed1ec4897f ../sub1 (0c90624) 0c90624ab7f1aaa301d3bb79f60dcfed1ec4897f ../sub2 (0c90624) 509f622a4f36a3e472affcf28fa959174f3dd5b5 ../sub3 (heads/master) The path code in question: displaypath=$(relative_path "$prefix$sm_path") prefix=$displaypath if recursive: eval cmd_status That way we change `prefix` each iteration to contain another '../', because of the the relative_path computation is done on an already computed relative path. We must call relative_path exactly once with `wt_prefix` non empty. Further calls in recursive instances to to calculate the displaypath already incorporate the correct prefix from before. Fix the issue by clearing `wt_prefix` in recursive calls. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-submodule.sh')
-rwxr-xr-xgit-submodule.sh1
1 files changed, 1 insertions, 0 deletions
diff --git a/git-submodule.sh b/git-submodule.sh
index 9fffa5c54a..1024774f61 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -1159,6 +1159,7 @@ cmd_status()
(
prefix="$displaypath/"
clear_local_git_env
+ wt_prefix=
cd "$sm_path" &&
eval cmd_status
) ||