Re: [PATCH v5 4/4] branch: Protect branches checked out in all worktrees
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Nov 10, 2021, 04:03 UTC
- Message-ID
- <211110.86pmr8ira2.gmgdl@evledraar.gmail.com>
- In-Reply-To
- <20211109230941.2518143-4-andersk@mit.edu>
On Tue, Nov 09 2021, Anders Kaseorg wrote:
Show 13 quoted lines
> [...]
> if (!validate_branchname(name, ref))
> return 0;
> @@ -208,9 +208,11 @@ int validate_new_branchname(const char *name, struct strbuf *ref, int force)
> die(_("A branch named '%s' already exists."),
> ref->buf + strlen("refs/heads/"));
>
> - head = resolve_ref_unsafe("HEAD", 0, NULL, NULL);
> - if (!is_bare_repository() && head && !strcmp(head, ref->buf))
> - die(_("Cannot force update the current branch."));
> + wt = find_shared_symref("HEAD", ref->buf);
> + if (wt && !wt->is_bare)
> + die(_("Cannot force update the branch '%s'"die() etc. messages should start with lower-case. See CodingGuidelines.
Here you're changing an existing die() message, but since it's something translators will need to re-do let's fix it while we're at it.