4444#define BUILTIN_STASH_POP_USAGE \
4545 N_("git stash pop [--index] [-q | --quiet] [<stash>]")
4646#define BUILTIN_STASH_APPLY_USAGE \
47- N_("git stash apply [--index] [-q | --quiet] [<stash>]")
47+ N_("git stash apply [--index] [-q | --quiet] [--label-ours=<label>] [--label-theirs=<label>] [--label-base=<label>] [ <stash>]")
4848#define BUILTIN_STASH_BRANCH_USAGE \
4949 N_("git stash branch <branchname> [<stash>]")
5050#define BUILTIN_STASH_STORE_USAGE \
@@ -590,8 +590,11 @@ static void unstage_changes_unless_new(struct object_id *orig_tree)
590590 die (_ ("could not write index" ));
591591}
592592
593- static int do_apply_stash (const char * prefix , struct stash_info * info ,
594- int index , int quiet )
593+ static int do_apply_stash_with_labels (const char * prefix ,
594+ struct stash_info * info ,
595+ int index , int quiet ,
596+ const char * label_ours , const char * label_theirs ,
597+ const char * label_base )
595598{
596599 int clean , ret ;
597600 int has_index = index ;
@@ -643,9 +646,9 @@ static int do_apply_stash(const char *prefix, struct stash_info *info,
643646
644647 init_ui_merge_options (& o , the_repository );
645648
646- o .branch1 = "Updated upstream" ;
647- o .branch2 = "Stashed changes" ;
648- o .ancestor = "Stash base" ;
649+ o .branch1 = label_ours ? label_ours : "Updated upstream" ;
650+ o .branch2 = label_theirs ? label_theirs : "Stashed changes" ;
651+ o .ancestor = label_base ? label_base : "Stash base" ;
649652
650653 if (oideq (& info -> b_tree , & c_tree ))
651654 o .branch1 = "Version stash was based on" ;
@@ -717,17 +720,31 @@ static int do_apply_stash(const char *prefix, struct stash_info *info,
717720 return ret ;
718721}
719722
723+ static int do_apply_stash (const char * prefix , struct stash_info * info ,
724+ int index , int quiet )
725+ {
726+ return do_apply_stash_with_labels (prefix , info , index , quiet ,
727+ NULL , NULL , NULL );
728+ }
729+
720730static int apply_stash (int argc , const char * * argv , const char * prefix ,
721731 struct repository * repo UNUSED )
722732{
723733 int ret = -1 ;
724734 int quiet = 0 ;
725735 int index = use_index ;
736+ const char * label_ours = NULL , * label_theirs = NULL , * label_base = NULL ;
726737 struct stash_info info = STASH_INFO_INIT ;
727738 struct option options [] = {
728739 OPT__QUIET (& quiet , N_ ("be quiet, only report errors" )),
729740 OPT_BOOL (0 , "index" , & index ,
730741 N_ ("attempt to recreate the index" )),
742+ OPT_STRING (0 , "label-ours" , & label_ours , N_ ("label" ),
743+ N_ ("label for the upstream side in conflict markers" )),
744+ OPT_STRING (0 , "label-theirs" , & label_theirs , N_ ("label" ),
745+ N_ ("label for the stashed side in conflict markers" )),
746+ OPT_STRING (0 , "label-base" , & label_base , N_ ("label" ),
747+ N_ ("label for the base in diff3 conflict markers" )),
731748 OPT_END ()
732749 };
733750
@@ -737,7 +754,8 @@ static int apply_stash(int argc, const char **argv, const char *prefix,
737754 if (get_stash_info (& info , argc , argv ))
738755 goto cleanup ;
739756
740- ret = do_apply_stash (prefix , & info , index , quiet );
757+ ret = do_apply_stash_with_labels (prefix , & info , index , quiet ,
758+ label_ours , label_theirs , label_base );
741759cleanup :
742760 free_stash_info (& info );
743761 return ret ;
0 commit comments