Re: [PATCH 2/2] refs_resolve_ref_unsafe: handle d/f conflicts for writes
- From
Jeff King <peff@peff.net>
- Date
- Oct 6, 2017, 17:16 UTC
- Message-ID
- <20171006171623.kjzeavnzopowvqzv@sigill.intra.peff.net>
- In-Reply-To
- <38c17fdc-7a3b-d166-1abe-afe64fc823c5@alum.mit.edu>
On Fri, Oct 06, 2017 at 07:09:10PM +0200, Michael Haggerty wrote:
Show 9 quoted lines
> I do have one twinge of uneasiness at a deeper level, that I haven't had > time to check... > > Does this patch make it easier to *set* HEAD to an unborn branch that > d/f conflicts with an existing reference? If so, that might be a > slightly worse UI for users. I'd rather learn about such a problem when > setting HEAD (when I am thinking about the new branch name and am in the > frame of mind to solve the problem) rather than later, when I try to > commit to the new branch.
Good question. The answer is no, it's allowed both before and after my patch. At least via git-symbolic-ref.
I agree it would be nice to know earlier for such a case. For symbolic-ref, we probably should allow it, because it's plumbing that may be used for tricky things. For things like "checkout -b", you'd generally get a timely warning as we try to create the ref.
The odd man out is "checkout --orphan", which leaves the branch unborn. It might be nice if it did a manual check that the ref is available (and also that it's syntactically acceptable, though I think we may do that already).
But all of that is orthogonal to this fix, I think.
-Peff