Skip to content

Commit 789c9a6

Browse files
committed
SQUASH???
1 parent 722abec commit 789c9a6

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

refs.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,25 @@ static unsigned char refname_disposition[256] = {
6363
* not legal. It is legal if it is something reasonable to have under
6464
* ".git/refs/"; We do not like it if:
6565
*
66-
* - any path component of it begins with ".", or
66+
* - it begins with ".", or
6767
* - it has double dots "..", or
6868
* - it has ASCII control characters, or
6969
* - it has ":", "?", "[", "\", "^", "~", SP, or TAB anywhere, or
7070
* - it has "*" anywhere unless REFNAME_REFSPEC_PATTERN is set, or
7171
* - it ends with a "/", or
7272
* - it ends with ".lock", or
7373
* - it contains a "@{" portion
74+
*
75+
* When sanitized is not NULL, instead of rejecting the input refname
76+
* as an error, try to come up with a usable replacement for the input
77+
* refname in it.
7478
*/
7579
static int check_refname_component(const char *refname, int *flags,
7680
struct strbuf *sanitized)
7781
{
7882
const char *cp;
7983
char last = '\0';
80-
size_t component_start;
84+
size_t component_start = 0; /* garbage - not a reasonable initial value */
8185

8286
if (sanitized)
8387
component_start = sanitized->len;
@@ -95,7 +99,8 @@ static int check_refname_component(const char *refname, int *flags,
9599
case 2:
96100
if (last == '.') { /* Refname contains "..". */
97101
if (sanitized)
98-
sanitized->len--; /* collapse ".." to single "." */
102+
/* collapse ".." to single "." */
103+
strbuf_setlen(sanitized, sanitized->len - 1);
99104
else
100105
return -1;
101106
}

0 commit comments

Comments
 (0)