| 1121 | } |
| 1122 | |
| 1123 | static int push_submodule(const char *path, |
| 1124 | const struct remote *remote, |
| 1125 | const struct refspec *rs, |
| 1126 | const struct string_list *push_options, |
| 1127 | int dry_run) |
| 1128 | { |
| 1129 | if (validate_submodule_path(path) < 0) |
| 1130 | exit(128); |
| 1131 | |
| 1132 | if (for_each_remote_ref_submodule(path, has_remote, NULL) > 0) { |
| 1133 | struct child_process cp = CHILD_PROCESS_INIT; |
| 1134 | strvec_push(&cp.args, "push"); |
| 1135 | /* |
| 1136 | * When recursing into a submodule, treat any "only" configurations as "on- |
| 1137 | * demand", since "only" would not work (we need all submodules to be pushed |
| 1138 | * in order to be able to push the superproject). |
| 1139 | */ |
| 1140 | strvec_push(&cp.args, "--recurse-submodules=only-is-on-demand"); |
| 1141 | if (dry_run) |
| 1142 | strvec_push(&cp.args, "--dry-run"); |
| 1143 | |
| 1144 | if (push_options && push_options->nr) { |
| 1145 | const struct string_list_item *item; |
| 1146 | for_each_string_list_item(item, push_options) |
| 1147 | strvec_pushf(&cp.args, "--push-option=%s", |
| 1148 | item->string); |
| 1149 | } |
| 1150 | |
| 1151 | if (remote->origin != REMOTE_UNCONFIGURED) { |
| 1152 | int i; |
| 1153 | strvec_push(&cp.args, remote->name); |
| 1154 | for (i = 0; i < rs->nr; i++) |
| 1155 | strvec_push(&cp.args, rs->items[i].raw); |
| 1156 | } |
| 1157 | |
| 1158 | prepare_submodule_repo_env(&cp.env); |
| 1159 | cp.git_cmd = 1; |
| 1160 | cp.no_stdin = 1; |
| 1161 | cp.dir = path; |
| 1162 | if (run_command(&cp)) |
| 1163 | return 0; |
| 1164 | close(cp.out); |
| 1165 | } |
| 1166 | |
| 1167 | return 1; |
| 1168 | } |
| 1169 | |
| 1170 | /* |
| 1171 | * Perform a check in the submodule to see if the remote and refspec work. |
no test coverage detected