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