]> git.ipfire.org Git - thirdparty/git.git/commitdiff
sequencer: teach autostash apply to take optional conflict marker labels
authorHarald Nordgren <haraldnordgren@gmail.com>
Sun, 12 Apr 2026 11:51:44 +0000 (11:51 +0000)
committerJunio C Hamano <gitster@pobox.com>
Sun, 12 Apr 2026 22:11:39 +0000 (15:11 -0700)
Add label_ours, label_theirs, and label_base parameters to the autostash
apply machinery so callers can pass custom conflict marker labels
through to "git stash apply --label-ours/--label-theirs/--label-base".
Introduce apply_autostash_ref_with_labels() for callers that want
to pass labels.

Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sequencer.c
sequencer.h

index 1197d7d8a0801d83d1f9eacbd60cf26eb2b541de..913be115f21c38defbd02889c2515cb9db4ba7c9 100644 (file)
@@ -4729,7 +4729,9 @@ void create_autostash_ref_silent(struct repository *r, const char *refname)
        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;
@@ -4740,6 +4742,12 @@ static int apply_save_autostash_oid(const char *stash_oid, int attempt_apply)
                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);
        }
@@ -4784,7 +4792,8 @@ static int apply_save_autostash(const char *path, int attempt_apply)
        }
        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);
@@ -4803,11 +4812,13 @@ int apply_autostash(const char *path)
 
 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];
@@ -4823,7 +4834,8 @@ static int apply_save_autostash_ref(struct repository *r, const char *refname,
                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);
@@ -4833,12 +4845,20 @@ static int apply_save_autostash_ref(struct repository *r, const char *refname,
 
 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,
index 570f804457b84920af76ef7cfd2c035a4c2b74fd..2c4ff17c4e6c2f663730b21737d0a79351a6aa39 100644 (file)
@@ -236,6 +236,9 @@ int save_autostash_ref(struct repository *r, const char *refname);
 int apply_autostash(const char *path);
 int apply_autostash_oid(const char *stash_oid);
 int apply_autostash_ref(struct repository *r, const char *refname);
+int apply_autostash_ref_with_labels(struct repository *r, const char *refname,
+                                   const char *label_ours, const char *label_theirs,
+                                   const char *label_base);
 
 #define SUMMARY_INITIAL_COMMIT   (1 << 0)
 #define SUMMARY_SHOW_AUTHOR_DATE (1 << 1)