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

Function apply_save_autostash_oid

sequencer.c:4730–4784  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4728}
4729
4730static int apply_save_autostash_oid(const char *stash_oid, int attempt_apply,
4731 const char *label_ours, const char *label_theirs,
4732 const char *label_base,
4733 const char *stash_msg)
4734{
4735 struct child_process child = CHILD_PROCESS_INIT;
4736 int ret = 0;
4737
4738 if (attempt_apply) {
4739 child.git_cmd = 1;
4740 child.no_stdout = 1;
4741 child.no_stderr = 1;
4742 strvec_push(&child.args, "stash");
4743 strvec_push(&child.args, "apply");
4744 if (label_ours)
4745 strvec_pushf(&child.args, "--label-ours=%s", label_ours);
4746 if (label_theirs)
4747 strvec_pushf(&child.args, "--label-theirs=%s", label_theirs);
4748 if (label_base)
4749 strvec_pushf(&child.args, "--label-base=%s", label_base);
4750 strvec_push(&child.args, stash_oid);
4751 ret = run_command(&child);
4752 }
4753
4754 if (attempt_apply && !ret)
4755 fprintf(stderr, _("Applied autostash.\n"));
4756 else {
4757 struct child_process store = CHILD_PROCESS_INIT;
4758
4759 store.git_cmd = 1;
4760 strvec_push(&store.args, "stash");
4761 strvec_push(&store.args, "store");
4762 strvec_push(&store.args, "-m");
4763 strvec_push(&store.args, stash_msg ? stash_msg : "autostash");
4764 strvec_push(&store.args, "-q");
4765 strvec_push(&store.args, stash_oid);
4766 if (run_command(&store))
4767 ret = error(_("cannot store %s"), stash_oid);
4768 else if (attempt_apply)
4769 fprintf(stderr,
4770 _("Your local changes are stashed, however applying them\n"
4771 "resulted in conflicts. You can either resolve the conflicts\n"
4772 "and then discard the stash with \"git stash drop\", or, if you\n"
4773 "do not want to resolve them now, run \"git reset --hard\" and\n"
4774 "apply the local changes later by running \"git stash pop\".\n"));
4775 else
4776 fprintf(stderr,
4777 _("Autostash exists; creating a new stash entry.\n"
4778 "Your changes are safe in the stash.\n"
4779 "You can run \"git stash pop\" or"
4780 " \"git stash drop\" at any time.\n"));
4781 }
4782
4783 return ret;
4784}
4785
4786static int apply_save_autostash(const char *path, int attempt_apply)
4787{

Callers 3

apply_save_autostashFunction · 0.85
apply_autostash_oidFunction · 0.85
apply_save_autostash_refFunction · 0.85

Calls 4

strvec_pushFunction · 0.85
strvec_pushfFunction · 0.85
run_commandFunction · 0.85
errorFunction · 0.85

Tested by

no test coverage detected