1515#include "column.h"
1616#include "strbuf.h"
1717#include "utf8.h"
18+ #include "worktree.h"
1819
1920static const char cut_line [] =
2021"------------------------ >8 ------------------------\n" ;
@@ -1262,13 +1263,13 @@ static void show_bisect_in_progress(struct wt_status *s,
12621263/*
12631264 * Extract branch information from rebase/bisect
12641265 */
1265- static char * read_and_strip_branch ( const char * path )
1266+ static char * get_branch ( const struct worktree * wt , const char * path )
12661267{
12671268 struct strbuf sb = STRBUF_INIT ;
12681269 unsigned char sha1 [20 ];
12691270 const char * branch_name ;
12701271
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 )
12721273 goto got_nothing ;
12731274
12741275 while (sb .len && sb .buf [sb .len - 1 ] == '\n' )
@@ -1295,6 +1296,11 @@ static char *read_and_strip_branch(const char *path)
12951296 return NULL ;
12961297}
12971298
1299+ static char * read_and_strip_branch (const char * path )
1300+ {
1301+ return get_branch (NULL , path );
1302+ }
1303+
12981304struct grab_1st_switch_cbdata {
12991305 struct strbuf buf ;
13001306 unsigned char nsha1 [20 ];
@@ -1360,27 +1366,28 @@ static void wt_status_get_detached_from(struct wt_status_state *state)
13601366 strbuf_release (& cb .buf );
13611367}
13621368
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 )
13641371{
13651372 struct stat st ;
13661373
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 )) {
13691376 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 )
13711378 state -> am_empty_patch = 1 ;
13721379 } else {
13731380 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" );
13761383 }
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 ))
13791386 state -> rebase_interactive_in_progress = 1 ;
13801387 else
13811388 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" );
13841391 } else
13851392 return 0 ;
13861393 return 1 ;
@@ -1394,7 +1401,7 @@ void wt_status_get_state(struct wt_status_state *state,
13941401
13951402 if (!stat (git_path_merge_head (), & st )) {
13961403 state -> merge_in_progress = 1 ;
1397- } else if (wt_status_check_rebase (state )) {
1404+ } else if (wt_status_check_rebase (NULL , state )) {
13981405 ; /* all set */
13991406 } else if (!stat (git_path_cherry_pick_head (), & st ) &&
14001407 !get_sha1 ("CHERRY_PICK_HEAD" , sha1 )) {
0 commit comments