submodule foreach: document variable '$displaypath'
It was observed that the variable '$displaypath' was accessible but undocumented. Hence, document it. Discussed-with: Ramsay Jones <ramsay@ramsayjones.plus.com> Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Prathamesh Chavan <pc44800@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Prathamesh Chavan committed
May 8, 2018 at 17:29 UTC
b6f7ac8fd561d6df9c76009898daf96a93765ffc
2 files changed
+16
-14
Documentation/git-submodule.txt
+5
-3
@@ -183,11 +183,13 @@ information too.
183
184
foreach [--recursive] <command>::
185
Evaluates an arbitrary shell command in each checked out submodule.
186
- The command has access to the variables $name, $sm_path, $sha1 and
187
- $toplevel:
186
+ The command has access to the variables $name, $sm_path, $displaypath,
187
+ $sha1 and $toplevel:
188
$name is the name of the relevant submodule section in `.gitmodules`,
189
$sm_path is the path of the submodule as recorded in the immediate
190
- superproject, $sha1 is the commit as recorded in the immediate
190
+ superproject, $displaypath contains the relative path from the
191
+ current working directory to the submodules root directory,
192
+ $sha1 is the commit as recorded in the immediate
193
superproject, and $toplevel is the absolute path to the top-level
194
of the immediate superproject.
195
Note that to avoid conflicts with '$PATH' on Windows, the '$path'
t/t7407-submodule-foreach.sh
+11
-11
@@ -82,16 +82,16 @@ test_expect_success 'test basic "submodule foreach" usage' '
82
83
cat >expect <<EOF
84
Entering '../sub1'
85
-$pwd/clone-foo1-sub1-$sub1sha1
85
+$pwd/clone-foo1-sub1-../sub1-$sub1sha1
86
Entering '../sub3'
87
-$pwd/clone-foo3-sub3-$sub3sha1
87
+$pwd/clone-foo3-sub3-../sub3-$sub3sha1
88
EOF
89
90
test_expect_success 'test "submodule foreach" from subdirectory' '
91
mkdir clone/sub &&
92
(
93
cd clone/sub &&
94
- git submodule foreach "echo \$toplevel-\$name-\$sm_path-\$sha1" >../../actual
94
+ git submodule foreach "echo \$toplevel-\$name-\$sm_path-\$displaypath-\$sha1" >../../actual
95
) &&
96
test_i18ncmp expect actual
97
'
@@ -206,25 +206,25 @@ submodulesha1=$(cd clone2/nested1/nested2/nested3/submodule && git rev-parse HEA
206
207
cat >expect <<EOF
208
Entering '../nested1'
209
-toplevel: $pwd/clone2 name: nested1 path: nested1 hash: $nested1sha1
209
+toplevel: $pwd/clone2 name: nested1 path: nested1 displaypath: ../nested1 hash: $nested1sha1
210
Entering '../nested1/nested2'
211
-toplevel: $pwd/clone2/nested1 name: nested2 path: nested2 hash: $nested2sha1
211
+toplevel: $pwd/clone2/nested1 name: nested2 path: nested2 displaypath: ../nested1/nested2 hash: $nested2sha1
212
Entering '../nested1/nested2/nested3'
213
-toplevel: $pwd/clone2/nested1/nested2 name: nested3 path: nested3 hash: $nested3sha1
213
+toplevel: $pwd/clone2/nested1/nested2 name: nested3 path: nested3 displaypath: ../nested1/nested2/nested3 hash: $nested3sha1
214
Entering '../nested1/nested2/nested3/submodule'
215
-toplevel: $pwd/clone2/nested1/nested2/nested3 name: submodule path: submodule hash: $submodulesha1
215
+toplevel: $pwd/clone2/nested1/nested2/nested3 name: submodule path: submodule displaypath: ../nested1/nested2/nested3/submodule hash: $submodulesha1
216
Entering '../sub1'
217
-toplevel: $pwd/clone2 name: foo1 path: sub1 hash: $sub1sha1
217
+toplevel: $pwd/clone2 name: foo1 path: sub1 displaypath: ../sub1 hash: $sub1sha1
218
Entering '../sub2'
219
-toplevel: $pwd/clone2 name: foo2 path: sub2 hash: $sub2sha1
219
+toplevel: $pwd/clone2 name: foo2 path: sub2 displaypath: ../sub2 hash: $sub2sha1
220
Entering '../sub3'
221
-toplevel: $pwd/clone2 name: foo3 path: sub3 hash: $sub3sha1
221
+toplevel: $pwd/clone2 name: foo3 path: sub3 displaypath: ../sub3 hash: $sub3sha1
222
EOF
223
224
test_expect_success 'test "submodule foreach --recursive" from subdirectory' '
225
(
226
cd clone2/untracked &&
227
- git submodule foreach --recursive "echo toplevel: \$toplevel name: \$name path: \$sm_path hash: \$sha1" >../../actual
227
+ git submodule foreach --recursive "echo toplevel: \$toplevel name: \$name path: \$sm_path displaypath: \$displaypath hash: \$sha1" >../../actual
228
) &&
229
test_i18ncmp expect actual
230
'