On Tue, Nov 12, 2013 at 08:53:45AM -0800, Junio C Hamano wrote:

> Even though we already added has_suffix() for tail matches, it is
> not too late to rethink, as it is not in 'master' yet.
> One thing I noticed is that it is probably misnamed, or at least in
> a way that invites confusion.  Can people tell which one of these is
> correct without looking at existing callsites?
>       has_suffix(filename, "txt");
>       has_suffix(filename, ".txt");

To me, it is obviously the latter. My name for "thing at the end of a
file after the dot" is "extension", not "suffix".

I thought that was universal, but if there are people who find it
confusing, it is worth changing. After all, the point is to make the
code more readable.

> The semantics of the function we have is the latter and is better
> called endswith(), I suspect.  And the corresponding function to
> check for head matches should probably be called beginswith().

Those are OK to me. "has_suffix" would be my first choice, but if it is
confusing to others, your suggestions are fine.

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to