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