Re: [PATCH] worktree add: improve message for ambiguous remote branch name
Junio C Hamano <[email protected]>
| Newsgroups | org.kernel.vger.git |
|---|---|
| Message-ID | <[email protected]> |
Yoichi Nakayama <[email protected]> writes: > Before the change, it calles lookup_commit_reference_by_name() again > in the if condition and die() at: > > if (!opts.orphan && !lookup_commit_reference_by_name(branch)) { > /* snip */ > die(_("invalid reference: %s"), branch); > } > > The motivation for the fix was that this error message did not > accurately reflect the situation. The location of this die() is a tad away from the places that the patch touched. The proposed log message could be made a bit more helpful by mentioning it. What was posted reads: Display a descriptive message when DWIM fails. Add advice on how to work around this by specifying the fully qualified name or by setting checkout.defaultRemote. but telling the readers what they will see instead of a descriptive message and how that happens would be very helpful to understand why it is a good idea to die early. Perhaps When the user runs 'git worktree add x y z' command that does not exactly say which remote they want to work with, we try to guess which remote by passing y. If there are multiple remotes that have branch named y, we silently gave up, leaving remote still NULL. This later causes A and B not happen, and we end up with passing an non-existing branch to lookup_commit_reference_by_name(), triggering "invalid reference" error and die. or something like that that describes the issue to a similar degree as above mock-up message. Thanks.