File tree Expand file tree Collapse file tree 3 files changed +38
-1
lines changed
Expand file tree Collapse file tree 3 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -159,7 +159,9 @@ update::
159159 This will make the submodules HEAD be detached unless `--rebase` or
160160 `--merge` is specified or the key `submodule.$name.update` is set to
161161 `rebase`, `merge` or `none`. `none` can be overridden by specifying
162- `--checkout`.
162+ `--checkout`. Setting the key `submodule.$name.update` to `!command`
163+ will cause `command` to be run. `command` can be any arbitrary shell
164+ command that takes a single argument, namely the sha1 to update to.
163165+
164166If the submodule is not yet initialized, and you just want to use the
165167setting as stored in .gitmodules, you can automatically initialize the
Original file line number Diff line number Diff line change @@ -860,6 +860,12 @@ Maybe you want to use 'update --init'?")"
860860 say_msg=" $( eval_gettext " Submodule path '\$ displaypath': merged in '\$ sha1'" ) "
861861 must_die_on_failure=yes
862862 ;;
863+ !* )
864+ command=" ${update_module#! } "
865+ die_msg=" $( eval_gettext " Execution of '\$ command \$ sha1' failed in submodule path '\$ prefix\$ sm_path'" ) "
866+ say_msg=" $( eval_gettext " Submodule path '\$ prefix\$ sm_path': '\$ command \$ sha1'" ) "
867+ must_die_on_failure=yes
868+ ;;
863869 * )
864870 command=" git checkout $subforce -q"
865871 die_msg=" $( eval_gettext " Unable to checkout '\$ sha1' in submodule path '\$ displaypath'" ) "
Original file line number Diff line number Diff line change @@ -294,6 +294,35 @@ test_expect_success 'submodule update - checkout in .git/config' '
294294 )
295295'
296296
297+ test_expect_success ' submodule update - command in .git/config' '
298+ (cd super &&
299+ git config submodule.submodule.update "!git checkout"
300+ ) &&
301+ (cd super/submodule &&
302+ git reset --hard HEAD^
303+ ) &&
304+ (cd super &&
305+ (cd submodule &&
306+ compare_head
307+ ) &&
308+ git submodule update submodule &&
309+ cd submodule &&
310+ ! compare_head
311+ )
312+ '
313+
314+ test_expect_success ' submodule update - command in .git/config catches failure' '
315+ (cd super &&
316+ git config submodule.submodule.update "!false"
317+ ) &&
318+ (cd super/submodule &&
319+ git reset --hard HEAD^
320+ ) &&
321+ (cd super &&
322+ test_must_fail git submodule update submodule
323+ )
324+ '
325+
297326test_expect_success ' submodule init picks up rebase' '
298327 (cd super &&
299328 git config -f .gitmodules submodule.rebasing.update rebase &&
You can’t perform that action at this time.
0 commit comments