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 \
@@ -591,7 +591,9 @@ static void unstage_changes_unless_new(struct object_id *orig_tree)
591591}
592592
593593static int do_apply_stash (const char * prefix , struct stash_info * info ,
594- int index , int quiet )
594+ int index , int quiet ,
595+ const char * label_ours , const char * label_theirs ,
596+ const char * label_base )
595597{
596598 int clean , ret ;
597599 int has_index = index ;
@@ -643,9 +645,9 @@ static int do_apply_stash(const char *prefix, struct stash_info *info,
643645
644646 init_ui_merge_options (& o , the_repository );
645647
646- o .branch1 = "Updated upstream" ;
647- o .branch2 = "Stashed changes" ;
648- o .ancestor = "Stash base" ;
648+ o .branch1 = label_ours ? label_ours : "Updated upstream" ;
649+ o .branch2 = label_theirs ? label_theirs : "Stashed changes" ;
650+ o .ancestor = label_base ? label_base : "Stash base" ;
649651
650652 if (oideq (& info -> b_tree , & c_tree ))
651653 o .branch1 = "Version stash was based on" ;
@@ -723,11 +725,18 @@ static int apply_stash(int argc, const char **argv, const char *prefix,
723725 int ret = -1 ;
724726 int quiet = 0 ;
725727 int index = use_index ;
728+ const char * label_ours = NULL , * label_theirs = NULL , * label_base = NULL ;
726729 struct stash_info info = STASH_INFO_INIT ;
727730 struct option options [] = {
728731 OPT__QUIET (& quiet , N_ ("be quiet, only report errors" )),
729732 OPT_BOOL (0 , "index" , & index ,
730733 N_ ("attempt to recreate the index" )),
734+ OPT_STRING (0 , "label-ours" , & label_ours , N_ ("label" ),
735+ N_ ("label for the upstream side in conflict markers" )),
736+ OPT_STRING (0 , "label-theirs" , & label_theirs , N_ ("label" ),
737+ N_ ("label for the stashed side in conflict markers" )),
738+ OPT_STRING (0 , "label-base" , & label_base , N_ ("label" ),
739+ N_ ("label for the base in diff3 conflict markers" )),
731740 OPT_END ()
732741 };
733742
@@ -737,7 +746,8 @@ static int apply_stash(int argc, const char **argv, const char *prefix,
737746 if (get_stash_info (& info , argc , argv ))
738747 goto cleanup ;
739748
740- ret = do_apply_stash (prefix , & info , index , quiet );
749+ ret = do_apply_stash (prefix , & info , index , quiet ,
750+ label_ours , label_theirs , label_base );
741751cleanup :
742752 free_stash_info (& info );
743753 return ret ;
@@ -836,7 +846,8 @@ static int pop_stash(int argc, const char **argv, const char *prefix,
836846 if (get_stash_info_assert (& info , argc , argv ))
837847 goto cleanup ;
838848
839- if ((ret = do_apply_stash (prefix , & info , index , quiet )))
849+ if ((ret = do_apply_stash (prefix , & info , index , quiet ,
850+ NULL , NULL , NULL )))
840851 printf_ln (_ ("The stash entry is kept in case "
841852 "you need it again." ));
842853 else
@@ -877,7 +888,8 @@ static int branch_stash(int argc, const char **argv, const char *prefix,
877888 strvec_push (& cp .args , oid_to_hex (& info .b_commit ));
878889 ret = run_command (& cp );
879890 if (!ret )
880- ret = do_apply_stash (prefix , & info , 1 , 0 );
891+ ret = do_apply_stash (prefix , & info , 1 , 0 ,
892+ NULL , NULL , NULL );
881893 if (!ret && info .is_stash_ref )
882894 ret = do_drop_stash (& info , 0 );
883895
0 commit comments