create_autostash_internal(r, NULL, refname, true);
}
-static int apply_save_autostash_oid(const char *stash_oid, int attempt_apply)
+static int apply_save_autostash_oid(const char *stash_oid, int attempt_apply,
+ const char *label_ours, const char *label_theirs,
+ const char *label_base)
{
struct child_process child = CHILD_PROCESS_INIT;
int ret = 0;
child.no_stderr = 1;
strvec_push(&child.args, "stash");
strvec_push(&child.args, "apply");
+ if (label_ours)
+ strvec_pushf(&child.args, "--label-ours=%s", label_ours);
+ if (label_theirs)
+ strvec_pushf(&child.args, "--label-theirs=%s", label_theirs);
+ if (label_base)
+ strvec_pushf(&child.args, "--label-base=%s", label_base);
strvec_push(&child.args, stash_oid);
ret = run_command(&child);
}
}
strbuf_trim(&stash_oid);
- ret = apply_save_autostash_oid(stash_oid.buf, attempt_apply);
+ ret = apply_save_autostash_oid(stash_oid.buf, attempt_apply,
+ NULL, NULL, NULL);
unlink(path);
strbuf_release(&stash_oid);
int apply_autostash_oid(const char *stash_oid)
{
- return apply_save_autostash_oid(stash_oid, 1);
+ return apply_save_autostash_oid(stash_oid, 1, NULL, NULL, NULL);
}
static int apply_save_autostash_ref(struct repository *r, const char *refname,
- int attempt_apply)
+ int attempt_apply,
+ const char *label_ours, const char *label_theirs,
+ const char *label_base)
{
struct object_id stash_oid;
char stash_oid_hex[GIT_MAX_HEXSZ + 1];
return error(_("autostash reference is a symref"));
oid_to_hex_r(stash_oid_hex, &stash_oid);
- ret = apply_save_autostash_oid(stash_oid_hex, attempt_apply);
+ ret = apply_save_autostash_oid(stash_oid_hex, attempt_apply,
+ label_ours, label_theirs, label_base);
refs_delete_ref(get_main_ref_store(r), "", refname,
&stash_oid, REF_NO_DEREF);
int save_autostash_ref(struct repository *r, const char *refname)
{
- return apply_save_autostash_ref(r, refname, 0);
+ return apply_save_autostash_ref(r, refname, 0, NULL, NULL, NULL);
}
int apply_autostash_ref(struct repository *r, const char *refname)
{
- return apply_save_autostash_ref(r, refname, 1);
+ return apply_save_autostash_ref(r, refname, 1, NULL, NULL, NULL);
+}
+
+int apply_autostash_ref_with_labels(struct repository *r, const char *refname,
+ const char *label_ours, const char *label_theirs,
+ const char *label_base)
+{
+ return apply_save_autostash_ref(r, refname, 1,
+ label_ours, label_theirs, label_base);
}
static int checkout_onto(struct repository *r, struct replay_opts *opts,