test_cmp expected actual
'
+test_expect_success 'rebase in a linked worktree' '
+ test_might_fail git rebase --abort &&
+ git worktree add wt &&
+ test_when_finished "test_might_fail git -C wt rebase --abort;
+ git worktree remove wt" &&
+ GIT_SEQUENCE_EDITOR="echo break >" git -C wt rebase -i HEAD &&
+ git -C wt status >actual &&
+ test_grep "interactive rebase in progress" actual
+'
test_expect_success 'prepare am_session' '
git reset --hard main &&
return is_current;
}
+struct worktree *get_worktree_from_repository(struct repository *repo)
+{
+ struct worktree *wt = xcalloc(1, sizeof(*wt));
+ char *gitdir = absolute_pathdup(repo->gitdir);
+ char *commondir = absolute_pathdup(repo->commondir);
+
+ wt->repo = repo;
+ wt->path = absolute_pathdup(repo->worktree ? repo->worktree
+ : repo->gitdir);
+ wt->is_bare = !repo->worktree;
+ if (fspathcmp(gitdir, commondir))
+ wt->id = xstrdup(find_last_dir_sep(gitdir) + 1);
+ wt->is_current = is_current_worktree(wt);
+ add_head_info(wt);
+
+ free(gitdir);
+ free(commondir);
+ return wt;
+}
+
/*
* When in a secondary worktree, and when extensions.worktreeConfig
* is true, only $commondir/config and $commondir/worktrees/<id>/
{
struct stat st;
+ if (!wt)
+ BUG("wt_status_check_rebase() called with NULL worktree");
+
if (!stat(worktree_git_path(the_repository, wt, "rebase-apply"), &st)) {
if (!stat(worktree_git_path(the_repository, wt, "rebase-apply/applying"), &st)) {
state->am_in_progress = 1;
{
struct stat st;
+ if (!wt)
+ BUG("wt_status_check_bisect() called with NULL worktree");
+
if (!stat(worktree_git_path(the_repository, wt, "BISECT_LOG"), &st)) {
state->bisect_in_progress = 1;
state->bisecting_from = get_branch(wt, "BISECT_START");
struct stat st;
struct object_id oid;
enum replay_action action;
+ struct worktree *wt = get_worktree_from_repository(r);
if (!stat(git_path_merge_head(r), &st)) {
- wt_status_check_rebase(NULL, state);
+ wt_status_check_rebase(wt, state);
state->merge_in_progress = 1;
- } else if (wt_status_check_rebase(NULL, state)) {
+ } else if (wt_status_check_rebase(wt, state)) {
; /* all set */
} else if (refs_ref_exists(get_main_ref_store(r), "CHERRY_PICK_HEAD") &&
!repo_get_oid(r, "CHERRY_PICK_HEAD", &oid)) {
state->cherry_pick_in_progress = 1;
oidcpy(&state->cherry_pick_head_oid, &oid);
}
- wt_status_check_bisect(NULL, state);
+ wt_status_check_bisect(wt, state);
if (refs_ref_exists(get_main_ref_store(r), "REVERT_HEAD") &&
!repo_get_oid(r, "REVERT_HEAD", &oid)) {
state->revert_in_progress = 1;
if (get_detached_from)
wt_status_get_detached_from(r, state);
wt_status_check_sparse_checkout(r, state);
+
+ free_worktree(wt);
}
static void wt_longstatus_print_state(struct wt_status *s)