Skip to content

Commit b08238a

Browse files
stefanbellergitster
authored andcommitted
submodule update: align reporting path for custom command execution
In the predefined actions (merge, rebase, none, checkout), we use the display path, which is relative to the current working directory. Also use the display path when running a custom command. Signed-off-by: Stefan Beller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 10450cf commit b08238a

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

git-submodule.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -802,8 +802,8 @@ Maybe you want to use 'update --init'?")"
802802
;;
803803
!*)
804804
command="${update_module#!}"
805-
die_msg="$(eval_gettext "Execution of '\$command \$sha1' failed in submodule path '\$prefix\$sm_path'")"
806-
say_msg="$(eval_gettext "Submodule path '\$prefix\$sm_path': '\$command \$sha1'")"
805+
die_msg="$(eval_gettext "Execution of '\$command \$sha1' failed in submodule path '\$displaypath'")"
806+
say_msg="$(eval_gettext "Submodule path '\$displaypath': '\$command \$sha1'")"
807807
must_die_on_failure=yes
808808
;;
809809
*)

t/t7406-submodule-update.sh

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,16 +344,39 @@ test_expect_success 'submodule update - command in .git/config' '
344344
)
345345
'
346346

347+
cat << EOF >expect
348+
Execution of 'false $submodulesha1' failed in submodule path 'submodule'
349+
EOF
350+
347351
test_expect_success 'submodule update - command in .git/config catches failure' '
348352
(cd super &&
349353
git config submodule.submodule.update "!false"
350354
) &&
351355
(cd super/submodule &&
352-
git reset --hard HEAD^
356+
git reset --hard $submodulesha1^
353357
) &&
354358
(cd super &&
355-
test_must_fail git submodule update submodule
356-
)
359+
test_must_fail git submodule update submodule 2>../actual
360+
) &&
361+
test_cmp actual expect
362+
'
363+
364+
cat << EOF >expect
365+
Execution of 'false $submodulesha1' failed in submodule path '../submodule'
366+
EOF
367+
368+
test_expect_success 'submodule update - command in .git/config catches failure -- subdirectory' '
369+
(cd super &&
370+
git config submodule.submodule.update "!false"
371+
) &&
372+
(cd super/submodule &&
373+
git reset --hard $submodulesha1^
374+
) &&
375+
(cd super &&
376+
mkdir tmp && cd tmp &&
377+
test_must_fail git submodule update ../submodule 2>../../actual
378+
) &&
379+
test_cmp actual expect
357380
'
358381

359382
test_expect_success 'submodule init does not copy command into .git/config' '

0 commit comments

Comments
 (0)