Re: [PATCH v3 21/23] try_remove_empty_parents(): don't accommodate consecutive slashes
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 1, 2017, 02:30 UTC
- Message-ID
- <xmqqvatz4imu.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <c7a89febcbf7bdffb44f8fdf63a43f11339a0289.1483153436.git.mhagger@alum.mit.edu>
Michael Haggerty <mhagger@alum.mit.edu> writes:
> "refname" has already been checked by check_refname_format(), so it > cannot have consecutive slashes.
In the endgame state, this has two callers. Both use what came in the transaction->updates[] array. Presumably "has already been checked by check_refname_format()" says that whoever created entries in that array must have called the function, but it would be helpful to be more explicit here.
Show 27 quoted lines
> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
> ---
> refs/files-backend.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/refs/files-backend.c b/refs/files-backend.c
> index af5a0e2..397488e 100644
> --- a/refs/files-backend.c
> +++ b/refs/files-backend.c
> @@ -2294,15 +2294,14 @@ static void try_remove_empty_parents(const char *refname)
> for (i = 0; i < 2; i++) { /* refs/{heads,tags,...}/ */
> while (*p && *p != '/')
> p++;
> - /* tolerate duplicate slashes; see check_refname_format() */
> - while (*p == '/')
> + if (*p == '/')
> p++;
> }
> q = buf.buf + buf.len;
> while (1) {
> while (q > p && *q != '/')
> q--;
> - while (q > p && *(q-1) == '/')
> + if (q > p && *(q-1) == '/')
> q--;
> if (q == p)
> break;