@@ -27,6 +27,8 @@ static const char * const git_stash_helper_usage[] = {
27
27
N_ ("git stash--helper [push [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet]\n"
28
28
" [-u|--include-untracked] [-a|--all] [-m|--message <message>]\n"
29
29
" [--] [<pathspec>...]]" ),
30
+ N_ ("git stash--helper save [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet]\n"
31
+ " [-u|--include-untracked] [-a|--all] [<message>]" ),
30
32
NULL
31
33
};
32
34
@@ -82,6 +84,12 @@ static const char * const git_stash_helper_push_usage[] = {
82
84
NULL
83
85
};
84
86
87
+ static const char * const git_stash_helper_save_usage [] = {
88
+ N_ ("git stash--helper save [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet]\n"
89
+ " [-u|--include-untracked] [-a|--all] [<message>]" ),
90
+ NULL
91
+ };
92
+
85
93
static const char * ref_stash = "refs/stash" ;
86
94
static struct strbuf stash_index_path = STRBUF_INIT ;
87
95
@@ -1492,6 +1500,46 @@ static int push_stash(int argc, const char **argv, const char *prefix)
1492
1500
include_untracked );
1493
1501
}
1494
1502
1503
+ static int save_stash (int argc , const char * * argv , const char * prefix )
1504
+ {
1505
+ int keep_index = -1 ;
1506
+ int patch_mode = 0 ;
1507
+ int include_untracked = 0 ;
1508
+ int quiet = 0 ;
1509
+ int ret = 0 ;
1510
+ const char * stash_msg = NULL ;
1511
+ struct pathspec ps ;
1512
+ struct strbuf stash_msg_buf = STRBUF_INIT ;
1513
+ struct option options [] = {
1514
+ OPT_BOOL ('k' , "keep-index" , & keep_index ,
1515
+ N_ ("keep index" )),
1516
+ OPT_BOOL ('p' , "patch" , & patch_mode ,
1517
+ N_ ("stash in patch mode" )),
1518
+ OPT__QUIET (& quiet , N_ ("quiet mode" )),
1519
+ OPT_BOOL ('u' , "include-untracked" , & include_untracked ,
1520
+ N_ ("include untracked files in stash" )),
1521
+ OPT_SET_INT ('a' , "all" , & include_untracked ,
1522
+ N_ ("include ignore files" ), 2 ),
1523
+ OPT_STRING ('m' , "message" , & stash_msg , "message" ,
1524
+ N_ ("stash message" )),
1525
+ OPT_END ()
1526
+ };
1527
+
1528
+ argc = parse_options (argc , argv , prefix , options ,
1529
+ git_stash_helper_save_usage ,
1530
+ PARSE_OPT_KEEP_DASHDASH );
1531
+
1532
+ if (argc )
1533
+ stash_msg = strbuf_join_argv (& stash_msg_buf , argc , argv , ' ' );
1534
+
1535
+ memset (& ps , 0 , sizeof (ps ));
1536
+ ret = do_push_stash (ps , stash_msg , quiet , keep_index ,
1537
+ patch_mode , include_untracked );
1538
+
1539
+ strbuf_release (& stash_msg_buf );
1540
+ return ret ;
1541
+ }
1542
+
1495
1543
int cmd_stash__helper (int argc , const char * * argv , const char * prefix )
1496
1544
{
1497
1545
pid_t pid = getpid ();
@@ -1532,6 +1580,8 @@ int cmd_stash__helper(int argc, const char **argv, const char *prefix)
1532
1580
return !!create_stash (argc , argv , prefix );
1533
1581
else if (!strcmp (argv [0 ], "push" ))
1534
1582
return !!push_stash (argc , argv , prefix );
1583
+ else if (!strcmp (argv [0 ], "save" ))
1584
+ return !!save_stash (argc , argv , prefix );
1535
1585
1536
1586
usage_msg_opt (xstrfmt (_ ("unknown subcommand: %s" ), argv [0 ]),
1537
1587
git_stash_helper_usage , options );
0 commit comments