Skip to content

Commit 4e53d6a

Browse files
stefanbellergitster
authored andcommitted
builtin/push.c: respect 'submodule.recurse' option
The closest mapping from the boolean 'submodule.recurse' set to "yes" to the variety of submodule push modes is "on-demand", so implement that. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 9071c07 commit 4e53d6a

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

builtin/push.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,10 @@ static int git_push_config(const char *k, const char *v, void *cb)
498498
const char *value;
499499
if (!git_config_get_value("push.recursesubmodules", &value))
500500
recurse_submodules = parse_push_recurse_submodules_arg(k, value);
501+
} else if (!strcmp(k, "submodule.recurse")) {
502+
int val = git_config_bool(k, v) ?
503+
RECURSE_SUBMODULES_ON_DEMAND : RECURSE_SUBMODULES_OFF;
504+
recurse_submodules = val;
501505
}
502506

503507
return git_default_config(k, v, NULL);

t/t5531-deep-submodule-push.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,27 @@ test_expect_success 'push succeeds if submodule commit not on remote but using o
126126
)
127127
'
128128

129+
test_expect_success 'push succeeds if submodule commit not on remote but using auto-on-demand via submodule.recurse config' '
130+
(
131+
cd work/gar/bage &&
132+
>recurse-on-demand-from-submodule-recurse-config &&
133+
git add recurse-on-demand-from-submodule-recurse-config &&
134+
git commit -m "Recurse submodule.recurse from config junk"
135+
) &&
136+
(
137+
cd work &&
138+
git add gar/bage &&
139+
git commit -m "Recurse submodule.recurse from config for gar/bage" &&
140+
git -c submodule.recurse push ../pub.git master &&
141+
# Check that the supermodule commit got there
142+
git fetch ../pub.git &&
143+
git diff --quiet FETCH_HEAD master &&
144+
# Check that the submodule commit got there too
145+
cd gar/bage &&
146+
git diff --quiet origin/master master
147+
)
148+
'
149+
129150
test_expect_success 'push recurse-submodules on command line overrides config' '
130151
(
131152
cd work/gar/bage &&

0 commit comments

Comments
 (0)