Skip to content

Commit 06708ce

Browse files
blanetgitster
authored andcommitted
transport: introduce parse_transport_option() method
Add the `parse_transport_option()` method to parse the `push.pushOption` configuration. This method will also be used in the next commit to handle the new `remote.<name>.serverOption` configuration for setting server options in Git protocol v2. Signed-off-by: Xing Xin <[email protected]> Reviewed-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 777489f commit 06708ce

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

builtin/push.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -519,14 +519,7 @@ static int git_push_config(const char *k, const char *v,
519519
RECURSE_SUBMODULES_ON_DEMAND : RECURSE_SUBMODULES_OFF;
520520
recurse_submodules = val;
521521
} else if (!strcmp(k, "push.pushoption")) {
522-
if (!v)
523-
return config_error_nonbool(k);
524-
else
525-
if (!*v)
526-
string_list_clear(&push_options_config, 0);
527-
else
528-
string_list_append(&push_options_config, v);
529-
return 0;
522+
return parse_transport_option(k, v, &push_options_config);
530523
} else if (!strcmp(k, "color.push")) {
531524
push_use_color = git_config_colorbool(k, v);
532525
return 0;

transport.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,18 @@ int is_transport_allowed(const char *type, int from_user)
11081108
BUG("invalid protocol_allow_config type");
11091109
}
11101110

1111+
int parse_transport_option(const char *var, const char *value,
1112+
struct string_list *transport_options)
1113+
{
1114+
if (!value)
1115+
return config_error_nonbool(var);
1116+
if (!*value)
1117+
string_list_clear(transport_options, 0);
1118+
else
1119+
string_list_append(transport_options, value);
1120+
return 0;
1121+
}
1122+
11111123
void transport_check_allowed(const char *type)
11121124
{
11131125
if (!is_transport_allowed(type, -1))

transport.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,4 +342,8 @@ void transport_print_push_status(const char *dest, struct ref *refs,
342342
/* common method used by transport-helper.c and send-pack.c */
343343
void reject_atomic_push(struct ref *refs, int mirror_mode);
344344

345+
/* common method to parse push-option or server-option from config */
346+
int parse_transport_option(const char *var, const char *value,
347+
struct string_list *transport_options);
348+
345349
#endif

0 commit comments

Comments
 (0)