13
13
14
14
static const char * const git_stash_helper_usage [] = {
15
15
N_ ("git stash--helper drop [-q|--quiet] [<stash>]" ),
16
- N_ ("git stash--helper apply [--index] [-q|--quiet] [<stash>]" ),
16
+ N_ ("git stash--helper ( pop | apply ) [--index] [-q|--quiet] [<stash>]" ),
17
17
N_ ("git stash--helper branch <branchname> [<stash>]" ),
18
18
N_ ("git stash--helper clear" ),
19
19
NULL
@@ -24,6 +24,11 @@ static const char * const git_stash_helper_drop_usage[] = {
24
24
NULL
25
25
};
26
26
27
+ static const char * const git_stash_helper_pop_usage [] = {
28
+ N_ ("git stash--helper pop [--index] [-q|--quiet] [<stash>]" ),
29
+ NULL
30
+ };
31
+
27
32
static const char * const git_stash_helper_apply_usage [] = {
28
33
N_ ("git stash--helper apply [--index] [-q|--quiet] [<stash>]" ),
29
34
NULL
@@ -543,6 +548,36 @@ static int drop_stash(int argc, const char **argv, const char *prefix)
543
548
return ret ;
544
549
}
545
550
551
+ static int pop_stash (int argc , const char * * argv , const char * prefix )
552
+ {
553
+ int ret ;
554
+ int index = 0 ;
555
+ int quiet = 0 ;
556
+ struct stash_info info ;
557
+ struct option options [] = {
558
+ OPT__QUIET (& quiet , N_ ("be quiet, only report errors" )),
559
+ OPT_BOOL (0 , "index" , & index ,
560
+ N_ ("attempt to recreate the index" )),
561
+ OPT_END ()
562
+ };
563
+
564
+ argc = parse_options (argc , argv , prefix , options ,
565
+ git_stash_helper_pop_usage , 0 );
566
+
567
+ if (get_stash_info (& info , argc , argv ))
568
+ return -1 ;
569
+
570
+ assert_stash_ref (& info );
571
+ if ((ret = do_apply_stash (prefix , & info , index , quiet )))
572
+ printf_ln (_ ("The stash entry is kept in case "
573
+ "you need it again." ));
574
+ else
575
+ ret = do_drop_stash (prefix , & info , quiet );
576
+
577
+ free_stash_info (& info );
578
+ return ret ;
579
+ }
580
+
546
581
static int branch_stash (int argc , const char * * argv , const char * prefix )
547
582
{
548
583
int ret ;
@@ -607,6 +642,8 @@ int cmd_stash__helper(int argc, const char **argv, const char *prefix)
607
642
return !!clear_stash (argc , argv , prefix );
608
643
else if (!strcmp (argv [0 ], "drop" ))
609
644
return !!drop_stash (argc , argv , prefix );
645
+ else if (!strcmp (argv [0 ], "pop" ))
646
+ return !!pop_stash (argc , argv , prefix );
610
647
else if (!strcmp (argv [0 ], "branch" ))
611
648
return !!branch_stash (argc , argv , prefix );
612
649
0 commit comments