@@ -99,7 +99,6 @@ static struct strbuf stash_index_path = STRBUF_INIT;
9999 * i_tree is set to the index tree
100100 * u_tree is set to the untracked files tree
101101 */
102-
103102struct stash_info {
104103 struct object_id w_commit ;
105104 struct object_id b_commit ;
@@ -320,11 +319,7 @@ static void add_diff_to_buf(struct diff_queue_struct *q,
320319 for (i = 0 ; i < q -> nr ; i ++ ) {
321320 strbuf_addstr (data , q -> queue [i ]-> one -> path );
322321
323- /*
324- * The reason we add "0" at the end of this strbuf
325- * is because we will pass the output further to
326- * "git update-index -z ...".
327- */
322+ /* NUL-terminate: will be fed to update-index -z */
328323 strbuf_addch (data , '\0' );
329324 }
330325}
@@ -579,9 +574,9 @@ static int do_drop_stash(const char *prefix, struct stash_info *info, int quiet)
579574static void assert_stash_ref (struct stash_info * info )
580575{
581576 if (!info -> is_stash_ref ) {
582- free_stash_info (info );
583577 error (_ ("'%s' is not a stash reference" ), info -> revision .buf );
584- exit (128 );
578+ free_stash_info (info );
579+ exit (1 );
585580 }
586581}
587582
@@ -837,7 +832,7 @@ static void add_pathspecs(struct argv_array *args,
837832 int i ;
838833
839834 for (i = 0 ; i < ps .nr ; i ++ )
840- argv_array_push (args , ps .items [i ].match );
835+ argv_array_push (args , ps .items [i ].original );
841836}
842837
843838/*
@@ -869,7 +864,7 @@ static int get_untracked_files(struct pathspec ps, int include_untracked,
869864 found ++ ;
870865 strbuf_addstr (untracked_files , ent -> name );
871866 /* NUL-terminate: will be fed to update-index -z */
872- strbuf_addch (untracked_files , 0 );
867+ strbuf_addch (untracked_files , '\0' );
873868 }
874869 free (ent );
875870 }
@@ -888,7 +883,6 @@ static int get_untracked_files(struct pathspec ps, int include_untracked,
888883 * = 0 if there are no changes.
889884 * > 0 if there are changes.
890885 */
891-
892886static int check_changes_tracked_files (struct pathspec ps )
893887{
894888 int result ;
@@ -928,7 +922,6 @@ static int check_changes_tracked_files(struct pathspec ps)
928922 * The function will fill `untracked_files` with the names of untracked files
929923 * It will return 1 if there were any changes and 0 if there were not.
930924 */
931-
932925static int check_changes (struct pathspec ps , int include_untracked ,
933926 struct strbuf * untracked_files )
934927{
@@ -1238,7 +1231,9 @@ static int create_stash(int argc, const char **argv, const char *prefix)
12381231 if (!check_changes_tracked_files (ps ))
12391232 return 0 ;
12401233
1241- if (!(ret = do_create_stash (ps , & stash_msg_buf , 0 , 0 , & info , NULL , 0 )))
1234+ ret = do_create_stash (ps , & stash_msg_buf , 0 , 0 , & info ,
1235+ NULL , 0 );
1236+ if (!ret )
12421237 printf_ln ("%s" , oid_to_hex (& info .w_commit ));
12431238
12441239 strbuf_release (& stash_msg_buf );
@@ -1429,8 +1424,6 @@ static int do_push_stash(struct pathspec ps, const char *stash_msg, int quiet,
14291424 if (keep_index < 1 ) {
14301425 struct child_process cp = CHILD_PROCESS_INIT ;
14311426
1432- discard_cache ();
1433-
14341427 cp .git_cmd = 1 ;
14351428 argv_array_pushl (& cp .args , "reset" , "-q" , "--" , NULL );
14361429 add_pathspecs (& cp .args , ps );
@@ -1475,7 +1468,8 @@ static int push_stash(int argc, const char **argv, const char *prefix)
14751468 git_stash_push_usage ,
14761469 0 );
14771470
1478- parse_pathspec (& ps , 0 , PATHSPEC_PREFER_FULL , prefix , argv );
1471+ parse_pathspec (& ps , 0 , PATHSPEC_PREFER_FULL | PATHSPEC_PREFIX_ORIGIN ,
1472+ prefix , argv );
14791473 return do_push_stash (ps , stash_msg , quiet , keep_index , patch_mode ,
14801474 include_untracked );
14811475}
0 commit comments