diff options
| author | Junio C Hamano <gitster@pobox.com> | 2026-04-03 13:01:09 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2026-04-03 13:01:09 -0700 |
| commit | 05ddb9ee8a4c619fbb0e7309fe291bff5cd7c987 (patch) | |
| tree | 6c4a0689880561d4c409a0765c7cd1c4657cf382 /builtin/worktree.c | |
| parent | 0cd4fb9f46eb0ebd0d243a886ce9a52210e0723e (diff) | |
| parent | 758086869940c96585f05a0eefe6d2f24fd70630 (diff) | |
| download | git-05ddb9ee8a4c619fbb0e7309fe291bff5cd7c987.tar.xz | |
Merge branch 'pw/worktree-reduce-the-repository'
Reduce the reference to the_repository in the worktree subsystem.
* pw/worktree-reduce-the-repository:
worktree: reject NULL worktree in get_worktree_git_dir()
worktree add: stop reading ".git/HEAD"
worktree: remove "the_repository" from is_current_worktree()
Diffstat (limited to 'builtin/worktree.c')
| -rw-r--r-- | builtin/worktree.c | 21 |
1 files changed, 2 insertions, 19 deletions
diff --git a/builtin/worktree.c b/builtin/worktree.c index 4035b1cb06..4fd6f7575f 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -692,25 +692,8 @@ static int can_use_local_refs(const struct add_opts *opts) if (refs_head_ref(get_main_ref_store(the_repository), first_valid_ref, NULL)) { return 1; } else if (refs_for_each_branch_ref(get_main_ref_store(the_repository), first_valid_ref, NULL)) { - if (!opts->quiet) { - struct strbuf path = STRBUF_INIT; - struct strbuf contents = STRBUF_INIT; - char *wt_gitdir = get_worktree_git_dir(NULL); - - strbuf_add_real_path(&path, wt_gitdir); - strbuf_addstr(&path, "/HEAD"); - strbuf_read_file(&contents, path.buf, 64); - strbuf_stripspace(&contents, NULL); - strbuf_strip_suffix(&contents, "\n"); - - warning(_("HEAD points to an invalid (or orphaned) reference.\n" - "HEAD path: '%s'\n" - "HEAD contents: '%s'"), - path.buf, contents.buf); - strbuf_release(&path); - strbuf_release(&contents); - free(wt_gitdir); - } + if (!opts->quiet) + warning(_("HEAD points to an invalid (or orphaned) reference.\n")); return 1; } return 0; |
