merge-recursive: convert struct stage_data to use object_id
[gitweb.git] / worktree.c
index 5043756663eb993db5a93fe1da7149caaca8ac5c..199b1ef94ba84aad094a5a0fe95360c2df631003 100644 (file)
@@ -20,7 +20,7 @@ void free_worktrees(struct worktree **worktrees)
 
 /*
  * read 'path_to_ref' into 'ref'.  Also if is_detached is not NULL,
- * set is_detached to 1 (0) if the ref is detatched (is not detached).
+ * set is_detached to 1 (0) if the ref is detached (is not detached).
  *
  * $GIT_COMMON_DIR/$symref (e.g. HEAD) is practically outside $GIT_DIR so
  * for linked worktrees, `resolve_ref_unsafe()` won't work (it uses
@@ -216,8 +216,8 @@ const char *get_worktree_git_dir(const struct worktree *wt)
                return git_common_path("worktrees/%s", wt->id);
 }
 
-static int is_worktree_being_rebased(const struct worktree *wt,
-                                    const char *target)
+int is_worktree_being_rebased(const struct worktree *wt,
+                             const char *target)
 {
        struct wt_status_state state;
        int found_rebase;
@@ -234,6 +234,21 @@ static int is_worktree_being_rebased(const struct worktree *wt,
        return found_rebase;
 }
 
+int is_worktree_being_bisected(const struct worktree *wt,
+                              const char *target)
+{
+       struct wt_status_state state;
+       int found_rebase;
+
+       memset(&state, 0, sizeof(state));
+       found_rebase = wt_status_check_bisect(wt, &state) &&
+               state.branch &&
+               starts_with(target, "refs/heads/") &&
+               !strcmp(state.branch, target + strlen("refs/heads/"));
+       free(state.branch);
+       return found_rebase;
+}
+
 /*
  * note: this function should be able to detect shared symref even if
  * HEAD is temporarily detached (e.g. in the middle of rebase or
@@ -261,6 +276,10 @@ const struct worktree *find_shared_symref(const char *symref,
                                existing = wt;
                                break;
                        }
+                       if (is_worktree_being_bisected(wt, target)) {
+                               existing = wt;
+                               break;
+                       }
                }
 
                strbuf_reset(&path);