Re: [RFC PATCH 3/5] branch: cleanup branch name validation
flat view
From: Kaartic Sivaraam <hidden>
Date: 2017-09-20 12:04:50
On Wednesday 20 September 2017 09:50 AM, Junio C Hamano wrote:
Kaartic Sivaraam [off-list ref] writes:quoted
-int validate_new_branchname(const char *name, struct strbuf *ref, - int force, int attr_only) +int validate_branch_update(const char *name, struct strbuf *ref, + int could_exist, int clobber_head)"update" to me means something already exists and the caller is asking this function if it is OK to update it, but is that what this function is used for?
Of course not. I couldn't come up with better names.
I do not find the original name too bad, but if I were renaming it, I'd call it ok_to_create_branch(), with the understanding that forcing a recreation of an existing branch falls into the wider definition of "create".
Thanks for giving a better alternative. Sounds catchy. How about `validate_branch_creation`? For some unknown reason, I seem to like to have the word "validate" in the name. If that's not ok, I'll use the suggested name.
Also I'd avoid "could", which can be taken as an optimization hint (i.e. "you usually do not have to worry about this thing to already exist, but I am telling you that for this one call that is not the case and you need to be a bit more careful by spending extra cycles to see if it is and deal with the situation accordingly if it indeed is"), and use "ok" as part of the name for the parameter (or flip the meaning of it and say "create_only" or something).
Will fix that. --- Kaartic