Skip to content

Commit b6f7ac8

Browse files
pratham-pcgitster
authored andcommitted
submodule foreach: document variable '$displaypath'
It was observed that the variable '$displaypath' was accessible but undocumented. Hence, document it. Discussed-with: Ramsay Jones <[email protected]> Signed-off-by: Stefan Beller <[email protected]> Signed-off-by: Prathamesh Chavan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f0fd0dc commit b6f7ac8

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

Documentation/git-submodule.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,13 @@ information too.
183183

184184
foreach [--recursive] <command>::
185185
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:
188188
$name is the name of the relevant submodule section in `.gitmodules`,
189189
$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
191193
superproject, and $toplevel is the absolute path to the top-level
192194
of the immediate superproject.
193195
Note that to avoid conflicts with '$PATH' on Windows, the '$path'

t/t7407-submodule-foreach.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,16 @@ test_expect_success 'test basic "submodule foreach" usage' '
8282

8383
cat >expect <<EOF
8484
Entering '../sub1'
85-
$pwd/clone-foo1-sub1-$sub1sha1
85+
$pwd/clone-foo1-sub1-../sub1-$sub1sha1
8686
Entering '../sub3'
87-
$pwd/clone-foo3-sub3-$sub3sha1
87+
$pwd/clone-foo3-sub3-../sub3-$sub3sha1
8888
EOF
8989

9090
test_expect_success 'test "submodule foreach" from subdirectory' '
9191
mkdir clone/sub &&
9292
(
9393
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
9595
) &&
9696
test_i18ncmp expect actual
9797
'
@@ -206,25 +206,25 @@ submodulesha1=$(cd clone2/nested1/nested2/nested3/submodule && git rev-parse HEA
206206

207207
cat >expect <<EOF
208208
Entering '../nested1'
209-
toplevel: $pwd/clone2 name: nested1 path: nested1 hash: $nested1sha1
209+
toplevel: $pwd/clone2 name: nested1 path: nested1 displaypath: ../nested1 hash: $nested1sha1
210210
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
212212
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
214214
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
216216
Entering '../sub1'
217-
toplevel: $pwd/clone2 name: foo1 path: sub1 hash: $sub1sha1
217+
toplevel: $pwd/clone2 name: foo1 path: sub1 displaypath: ../sub1 hash: $sub1sha1
218218
Entering '../sub2'
219-
toplevel: $pwd/clone2 name: foo2 path: sub2 hash: $sub2sha1
219+
toplevel: $pwd/clone2 name: foo2 path: sub2 displaypath: ../sub2 hash: $sub2sha1
220220
Entering '../sub3'
221-
toplevel: $pwd/clone2 name: foo3 path: sub3 hash: $sub3sha1
221+
toplevel: $pwd/clone2 name: foo3 path: sub3 displaypath: ../sub3 hash: $sub3sha1
222222
EOF
223223

224224
test_expect_success 'test "submodule foreach --recursive" from subdirectory' '
225225
(
226226
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
228228
) &&
229229
test_i18ncmp expect actual
230230
'

0 commit comments

Comments
 (0)