@@ -251,8 +251,10 @@ static int apply_autostash(struct rebase_options *opts)
251
251
if (!file_exists (path ))
252
252
return 0 ;
253
253
254
- if (read_one (state_dir_path ( "autostash" , opts ) , & autostash ))
254
+ if (read_one (path , & autostash ))
255
255
return error (_ ("Could not read '%s'" ), path );
256
+ /* Ensure that the hash is not mistaken for a number */
257
+ strbuf_addstr (& autostash , "^0" );
256
258
argv_array_pushl (& stash_apply .args ,
257
259
"stash" , "apply" , autostash .buf , NULL );
258
260
stash_apply .git_cmd = 1 ;
@@ -1353,7 +1355,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1353
1355
update_index_if_able (& the_index , & lock_file );
1354
1356
rollback_lock_file (& lock_file );
1355
1357
1356
- if (has_unstaged_changes (0 ) || has_uncommitted_changes (0 )) {
1358
+ if (has_unstaged_changes (1 ) || has_uncommitted_changes (1 )) {
1357
1359
const char * autostash =
1358
1360
state_dir_path ("autostash" , & options );
1359
1361
struct child_process stash = CHILD_PROCESS_INIT ;
@@ -1379,7 +1381,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1379
1381
if (safe_create_leading_directories_const (autostash ))
1380
1382
die (_ ("Could not create directory for '%s'" ),
1381
1383
options .state_dir );
1382
- write_file (autostash , "%s" , buf . buf );
1384
+ write_file (autostash , "%s" , oid_to_hex ( & oid ) );
1383
1385
printf (_ ("Created autostash: %s\n" ), buf .buf );
1384
1386
if (reset_head (& head -> object .oid , "reset --hard" ,
1385
1387
NULL , 0 , NULL , NULL ) < 0 )
0 commit comments