15
15
#include "column.h"
16
16
#include "strbuf.h"
17
17
#include "utf8.h"
18
+ #include "worktree.h"
18
19
19
20
static const char cut_line [] =
20
21
"------------------------ >8 ------------------------\n" ;
@@ -1262,13 +1263,13 @@ static void show_bisect_in_progress(struct wt_status *s,
1262
1263
/*
1263
1264
* Extract branch information from rebase/bisect
1264
1265
*/
1265
- static char * read_and_strip_branch ( const char * path )
1266
+ static char * get_branch ( const struct worktree * wt , const char * path )
1266
1267
{
1267
1268
struct strbuf sb = STRBUF_INIT ;
1268
1269
unsigned char sha1 [20 ];
1269
1270
const char * branch_name ;
1270
1271
1271
- if (strbuf_read_file (& sb , git_path ( "%s" , path ), 0 ) <= 0 )
1272
+ if (strbuf_read_file (& sb , worktree_git_path ( wt , "%s" , path ), 0 ) <= 0 )
1272
1273
goto got_nothing ;
1273
1274
1274
1275
while (sb .len && sb .buf [sb .len - 1 ] == '\n' )
@@ -1295,6 +1296,11 @@ static char *read_and_strip_branch(const char *path)
1295
1296
return NULL ;
1296
1297
}
1297
1298
1299
+ static char * read_and_strip_branch (const char * path )
1300
+ {
1301
+ return get_branch (NULL , path );
1302
+ }
1303
+
1298
1304
struct grab_1st_switch_cbdata {
1299
1305
struct strbuf buf ;
1300
1306
unsigned char nsha1 [20 ];
@@ -1360,27 +1366,28 @@ static void wt_status_get_detached_from(struct wt_status_state *state)
1360
1366
strbuf_release (& cb .buf );
1361
1367
}
1362
1368
1363
- int wt_status_check_rebase (struct wt_status_state * state )
1369
+ int wt_status_check_rebase (const struct worktree * wt ,
1370
+ struct wt_status_state * state )
1364
1371
{
1365
1372
struct stat st ;
1366
1373
1367
- if (!stat (git_path ( "rebase-apply" ), & st )) {
1368
- if (!stat (git_path ( "rebase-apply/applying" ), & st )) {
1374
+ if (!stat (worktree_git_path ( wt , "rebase-apply" ), & st )) {
1375
+ if (!stat (worktree_git_path ( wt , "rebase-apply/applying" ), & st )) {
1369
1376
state -> am_in_progress = 1 ;
1370
- if (!stat (git_path ( "rebase-apply/patch" ), & st ) && !st .st_size )
1377
+ if (!stat (worktree_git_path ( wt , "rebase-apply/patch" ), & st ) && !st .st_size )
1371
1378
state -> am_empty_patch = 1 ;
1372
1379
} else {
1373
1380
state -> rebase_in_progress = 1 ;
1374
- state -> branch = read_and_strip_branch ( "rebase-apply/head-name" );
1375
- state -> onto = read_and_strip_branch ( "rebase-apply/onto" );
1381
+ state -> branch = get_branch ( wt , "rebase-apply/head-name" );
1382
+ state -> onto = get_branch ( wt , "rebase-apply/onto" );
1376
1383
}
1377
- } else if (!stat (git_path ( "rebase-merge" ), & st )) {
1378
- if (!stat (git_path ( "rebase-merge/interactive" ), & st ))
1384
+ } else if (!stat (worktree_git_path ( wt , "rebase-merge" ), & st )) {
1385
+ if (!stat (worktree_git_path ( wt , "rebase-merge/interactive" ), & st ))
1379
1386
state -> rebase_interactive_in_progress = 1 ;
1380
1387
else
1381
1388
state -> rebase_in_progress = 1 ;
1382
- state -> branch = read_and_strip_branch ( "rebase-merge/head-name" );
1383
- state -> onto = read_and_strip_branch ( "rebase-merge/onto" );
1389
+ state -> branch = get_branch ( wt , "rebase-merge/head-name" );
1390
+ state -> onto = get_branch ( wt , "rebase-merge/onto" );
1384
1391
} else
1385
1392
return 0 ;
1386
1393
return 1 ;
@@ -1394,7 +1401,7 @@ void wt_status_get_state(struct wt_status_state *state,
1394
1401
1395
1402
if (!stat (git_path_merge_head (), & st )) {
1396
1403
state -> merge_in_progress = 1 ;
1397
- } else if (wt_status_check_rebase (state )) {
1404
+ } else if (wt_status_check_rebase (NULL , state )) {
1398
1405
; /* all set */
1399
1406
} else if (!stat (git_path_cherry_pick_head (), & st ) &&
1400
1407
!get_sha1 ("CHERRY_PICK_HEAD" , sha1 )) {
0 commit comments