MCPcopy Create free account
hub / github.com/git/git / run_update_command

Function run_update_command

builtin/submodule--helper.c:2548–2638  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2546}
2547
2548static int run_update_command(const struct update_data *ud, int subforce)
2549{
2550 struct child_process cp = CHILD_PROCESS_INIT;
2551 char *oid = oid_to_hex(&ud->oid);
2552 int ret;
2553
2554 switch (ud->update_strategy.type) {
2555 case SM_UPDATE_CHECKOUT:
2556 cp.git_cmd = 1;
2557 strvec_pushl(&cp.args, "checkout", "-q", NULL);
2558 if (subforce)
2559 strvec_push(&cp.args, "-f");
2560 break;
2561 case SM_UPDATE_REBASE:
2562 cp.git_cmd = 1;
2563 strvec_push(&cp.args, "rebase");
2564 if (ud->quiet)
2565 strvec_push(&cp.args, "--quiet");
2566 break;
2567 case SM_UPDATE_MERGE:
2568 cp.git_cmd = 1;
2569 strvec_push(&cp.args, "merge");
2570 if (ud->quiet)
2571 strvec_push(&cp.args, "--quiet");
2572 break;
2573 case SM_UPDATE_COMMAND:
2574 cp.use_shell = 1;
2575 strvec_push(&cp.args, ud->update_strategy.command);
2576 break;
2577 default:
2578 BUG("unexpected update strategy type: %d",
2579 ud->update_strategy.type);
2580 }
2581 strvec_push(&cp.args, oid);
2582
2583 cp.dir = ud->sm_path;
2584 prepare_submodule_repo_env(&cp.env);
2585 if ((ret = run_command(&cp))) {
2586 switch (ud->update_strategy.type) {
2587 case SM_UPDATE_CHECKOUT:
2588 die_message(_("Unable to checkout '%s' in submodule path '%s'"),
2589 oid, ud->displaypath);
2590 /* No "ret" assignment, use "git checkout"'s */
2591 break;
2592 case SM_UPDATE_REBASE:
2593 ret = die_message(_("Unable to rebase '%s' in submodule path '%s'"),
2594 oid, ud->displaypath);
2595 break;
2596 case SM_UPDATE_MERGE:
2597 ret = die_message(_("Unable to merge '%s' in submodule path '%s'"),
2598 oid, ud->displaypath);
2599 break;
2600 case SM_UPDATE_COMMAND:
2601 ret = die_message(_("Execution of '%s %s' failed in submodule path '%s'"),
2602 ud->update_strategy.command, oid, ud->displaypath);
2603 break;
2604 default:
2605 BUG("unexpected update strategy type: %d",

Callers 1

run_update_procedureFunction · 0.85

Calls 6

oid_to_hexFunction · 0.85
strvec_pushlFunction · 0.85
strvec_pushFunction · 0.85
run_commandFunction · 0.85
die_messageFunction · 0.85

Tested by

no test coverage detected