362
worktrees = get_worktrees();
363
364
while (worktrees[i]) {
365
+ struct wt_status_state state = { 0 };
366
struct worktree *wt = worktrees[i++];
367
368
if (wt->is_bare)
372
strmap_put(¤t_checked_out_branches,
373
wt->head_ref,
374
xstrdup(wt->path));
375
+
376
+ if (wt_status_check_rebase(wt, &state) &&
377
+ (state.rebase_in_progress || state.rebase_interactive_in_progress) &&
378
+ state.branch) {
379
+ struct strbuf ref = STRBUF_INIT;
380
+ strbuf_addf(&ref, "refs/heads/%s", state.branch);
381
+ strmap_put(¤t_checked_out_branches,
382
+ ref.buf,
383
+ xstrdup(wt->path));
384
+ strbuf_release(&ref);
385
+ }
386
+ wt_status_state_free_buffers(&state);
387
+
388
+ if (wt_status_check_bisect(wt, &state) &&
389
+ state.branch) {
390
+ struct strbuf ref = STRBUF_INIT;
391
+ strbuf_addf(&ref, "refs/heads/%s", state.branch);
392
+ strmap_put(¤t_checked_out_branches,
393
+ ref.buf,
394
+ xstrdup(wt->path));
395
+ strbuf_release(&ref);
396
+ }
397
+ wt_status_state_free_buffers(&state);
398
}
399
400
free_worktrees(worktrees);
414
*/
415
int validate_new_branchname(const char *name, struct strbuf *ref, int force)
416
{
393
- struct worktree **worktrees;
394
- const struct worktree *wt;
395
-
417
+ const char *path;
418
if (!validate_branchname(name, ref))
419
return 0;
420
422
die(_("a branch named '%s' already exists"),
423
ref->buf + strlen("refs/heads/"));
424
403
- worktrees = get_worktrees();
404
- wt = find_shared_symref(worktrees, "HEAD", ref->buf);
405
- if (wt && !wt->is_bare)
425
+ if ((path = branch_checked_out(ref->buf)))
426
die(_("cannot force update the branch '%s' "
427
"checked out at '%s'"),
408
- ref->buf + strlen("refs/heads/"), wt->path);
409
- free_worktrees(worktrees);
428
+ ref->buf + strlen("refs/heads/"), path);
429
430
return 1;
431
}