remote: drop auto-strlen behavior of make_branch() and make_rewrite()
commit021ba32a7bca954235e31338c4f27b221a1807de
authorJeff King <peff@peff.net>
Fri, 10 Apr 2020 19:43:41 +0000 (10 15:43 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 10 Apr 2020 21:43:36 +0000 (10 14:43 -0700)
tree780c03c2fc873df2a519023a38a3dccd4df81061
parent9fadedd637b312089337d73c3ed8447e9f0aa775
remote: drop auto-strlen behavior of make_branch() and make_rewrite()

The make_branch() and make_rewrite() functions can take a NUL-terminated
string or a ptr/len pair. They use a sentinel value of "0" for the len
to tell the difference between the two. However, when parsing config
like:

  [branch ""]
  merge = whatever

whose key flattens to:

  branch..merge

we might actually have a zero-length branch name. This is obviously
nonsense, but the current code would consider it as a NUL-terminated
string and use the branch name ".merge".

We could use a better sentinel value here (like "-1"), but that gets in
the way of moving to size_t, which is a more appropriate type for a
ptr/len combo.

Let's instead just drop this feature and have the callers (of which
there are only two total) use strlen() themselves. This simplifies the
code, and lets us move to using size_t.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
remote.c