@@ -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
@@ -1488,6 +1496,46 @@ static int push_stash(int argc, const char **argv, const char *prefix)
1488
1496
include_untracked );
1489
1497
}
1490
1498
1499
+ static int save_stash (int argc , const char * * argv , const char * prefix )
1500
+ {
1501
+ int keep_index = -1 ;
1502
+ int patch_mode = 0 ;
1503
+ int include_untracked = 0 ;
1504
+ int quiet = 0 ;
1505
+ int ret = 0 ;
1506
+ const char * stash_msg = NULL ;
1507
+ struct pathspec ps ;
1508
+ struct strbuf stash_msg_buf = STRBUF_INIT ;
1509
+ struct option options [] = {
1510
+ OPT_BOOL ('k' , "keep-index" , & keep_index ,
1511
+ N_ ("keep index" )),
1512
+ OPT_BOOL ('p' , "patch" , & patch_mode ,
1513
+ N_ ("stash in patch mode" )),
1514
+ OPT__QUIET (& quiet , N_ ("quiet mode" )),
1515
+ OPT_BOOL ('u' , "include-untracked" , & include_untracked ,
1516
+ N_ ("include untracked files in stash" )),
1517
+ OPT_SET_INT ('a' , "all" , & include_untracked ,
1518
+ N_ ("include ignore files" ), 2 ),
1519
+ OPT_STRING ('m' , "message" , & stash_msg , "message" ,
1520
+ N_ ("stash message" )),
1521
+ OPT_END ()
1522
+ };
1523
+
1524
+ argc = parse_options (argc , argv , prefix , options ,
1525
+ git_stash_helper_save_usage ,
1526
+ PARSE_OPT_KEEP_DASHDASH );
1527
+
1528
+ if (argc )
1529
+ stash_msg = strbuf_join_argv (& stash_msg_buf , argc , argv , ' ' );
1530
+
1531
+ memset (& ps , 0 , sizeof (ps ));
1532
+ ret = do_push_stash (ps , stash_msg , quiet , keep_index ,
1533
+ patch_mode , include_untracked );
1534
+
1535
+ strbuf_release (& stash_msg_buf );
1536
+ return ret ;
1537
+ }
1538
+
1491
1539
int cmd_stash__helper (int argc , const char * * argv , const char * prefix )
1492
1540
{
1493
1541
pid_t pid = getpid ();
@@ -1528,6 +1576,8 @@ int cmd_stash__helper(int argc, const char **argv, const char *prefix)
1528
1576
return !!create_stash (argc , argv , prefix );
1529
1577
else if (!strcmp (argv [0 ], "push" ))
1530
1578
return !!push_stash (argc , argv , prefix );
1579
+ else if (!strcmp (argv [0 ], "save" ))
1580
+ return !!save_stash (argc , argv , prefix );
1531
1581
1532
1582
usage_msg_opt (xstrfmt (_ ("unknown subcommand: %s" ), argv [0 ]),
1533
1583
git_stash_helper_usage , options );
0 commit comments