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>
This commit is contained in:

committed by
Junio C Hamano

parent
f0fd0dc5c5
commit
b6f7ac8fd5
@ -183,11 +183,13 @@ information too.
|
|||||||
|
|
||||||
foreach [--recursive] <command>::
|
foreach [--recursive] <command>::
|
||||||
Evaluates an arbitrary shell command in each checked out submodule.
|
Evaluates an arbitrary shell command in each checked out submodule.
|
||||||
The command has access to the variables $name, $sm_path, $sha1 and
|
The command has access to the variables $name, $sm_path, $displaypath,
|
||||||
$toplevel:
|
$sha1 and $toplevel:
|
||||||
$name is the name of the relevant submodule section in `.gitmodules`,
|
$name is the name of the relevant submodule section in `.gitmodules`,
|
||||||
$sm_path is the path of the submodule as recorded in the immediate
|
$sm_path is the path of the submodule as recorded in the immediate
|
||||||
superproject, $sha1 is the commit as recorded in the immediate
|
superproject, $displaypath contains the relative path from the
|
||||||
|
current working directory to the submodules root directory,
|
||||||
|
$sha1 is the commit as recorded in the immediate
|
||||||
superproject, and $toplevel is the absolute path to the top-level
|
superproject, and $toplevel is the absolute path to the top-level
|
||||||
of the immediate superproject.
|
of the immediate superproject.
|
||||||
Note that to avoid conflicts with '$PATH' on Windows, the '$path'
|
Note that to avoid conflicts with '$PATH' on Windows, the '$path'
|
||||||
|
@ -82,16 +82,16 @@ test_expect_success 'test basic "submodule foreach" usage' '
|
|||||||
|
|
||||||
cat >expect <<EOF
|
cat >expect <<EOF
|
||||||
Entering '../sub1'
|
Entering '../sub1'
|
||||||
$pwd/clone-foo1-sub1-$sub1sha1
|
$pwd/clone-foo1-sub1-../sub1-$sub1sha1
|
||||||
Entering '../sub3'
|
Entering '../sub3'
|
||||||
$pwd/clone-foo3-sub3-$sub3sha1
|
$pwd/clone-foo3-sub3-../sub3-$sub3sha1
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
test_expect_success 'test "submodule foreach" from subdirectory' '
|
test_expect_success 'test "submodule foreach" from subdirectory' '
|
||||||
mkdir clone/sub &&
|
mkdir clone/sub &&
|
||||||
(
|
(
|
||||||
cd clone/sub &&
|
cd clone/sub &&
|
||||||
git submodule foreach "echo \$toplevel-\$name-\$sm_path-\$sha1" >../../actual
|
git submodule foreach "echo \$toplevel-\$name-\$sm_path-\$displaypath-\$sha1" >../../actual
|
||||||
) &&
|
) &&
|
||||||
test_i18ncmp expect actual
|
test_i18ncmp expect actual
|
||||||
'
|
'
|
||||||
@ -206,25 +206,25 @@ submodulesha1=$(cd clone2/nested1/nested2/nested3/submodule && git rev-parse HEA
|
|||||||
|
|
||||||
cat >expect <<EOF
|
cat >expect <<EOF
|
||||||
Entering '../nested1'
|
Entering '../nested1'
|
||||||
toplevel: $pwd/clone2 name: nested1 path: nested1 hash: $nested1sha1
|
toplevel: $pwd/clone2 name: nested1 path: nested1 displaypath: ../nested1 hash: $nested1sha1
|
||||||
Entering '../nested1/nested2'
|
Entering '../nested1/nested2'
|
||||||
toplevel: $pwd/clone2/nested1 name: nested2 path: nested2 hash: $nested2sha1
|
toplevel: $pwd/clone2/nested1 name: nested2 path: nested2 displaypath: ../nested1/nested2 hash: $nested2sha1
|
||||||
Entering '../nested1/nested2/nested3'
|
Entering '../nested1/nested2/nested3'
|
||||||
toplevel: $pwd/clone2/nested1/nested2 name: nested3 path: nested3 hash: $nested3sha1
|
toplevel: $pwd/clone2/nested1/nested2 name: nested3 path: nested3 displaypath: ../nested1/nested2/nested3 hash: $nested3sha1
|
||||||
Entering '../nested1/nested2/nested3/submodule'
|
Entering '../nested1/nested2/nested3/submodule'
|
||||||
toplevel: $pwd/clone2/nested1/nested2/nested3 name: submodule path: submodule hash: $submodulesha1
|
toplevel: $pwd/clone2/nested1/nested2/nested3 name: submodule path: submodule displaypath: ../nested1/nested2/nested3/submodule hash: $submodulesha1
|
||||||
Entering '../sub1'
|
Entering '../sub1'
|
||||||
toplevel: $pwd/clone2 name: foo1 path: sub1 hash: $sub1sha1
|
toplevel: $pwd/clone2 name: foo1 path: sub1 displaypath: ../sub1 hash: $sub1sha1
|
||||||
Entering '../sub2'
|
Entering '../sub2'
|
||||||
toplevel: $pwd/clone2 name: foo2 path: sub2 hash: $sub2sha1
|
toplevel: $pwd/clone2 name: foo2 path: sub2 displaypath: ../sub2 hash: $sub2sha1
|
||||||
Entering '../sub3'
|
Entering '../sub3'
|
||||||
toplevel: $pwd/clone2 name: foo3 path: sub3 hash: $sub3sha1
|
toplevel: $pwd/clone2 name: foo3 path: sub3 displaypath: ../sub3 hash: $sub3sha1
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
test_expect_success 'test "submodule foreach --recursive" from subdirectory' '
|
test_expect_success 'test "submodule foreach --recursive" from subdirectory' '
|
||||||
(
|
(
|
||||||
cd clone2/untracked &&
|
cd clone2/untracked &&
|
||||||
git submodule foreach --recursive "echo toplevel: \$toplevel name: \$name path: \$sm_path hash: \$sha1" >../../actual
|
git submodule foreach --recursive "echo toplevel: \$toplevel name: \$name path: \$sm_path displaypath: \$displaypath hash: \$sha1" >../../actual
|
||||||
) &&
|
) &&
|
||||||
test_i18ncmp expect actual
|
test_i18ncmp expect actual
|
||||||
'
|
'
|
||||||
|
Reference in New Issue
Block a user