@@ -63,21 +63,25 @@ static unsigned char refname_disposition[256] = {
63
63
* not legal. It is legal if it is something reasonable to have under
64
64
* ".git/refs/"; We do not like it if:
65
65
*
66
- * - any path component of it begins with ".", or
66
+ * - it begins with ".", or
67
67
* - it has double dots "..", or
68
68
* - it has ASCII control characters, or
69
69
* - it has ":", "?", "[", "\", "^", "~", SP, or TAB anywhere, or
70
70
* - it has "*" anywhere unless REFNAME_REFSPEC_PATTERN is set, or
71
71
* - it ends with a "/", or
72
72
* - it ends with ".lock", or
73
73
* - 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.
74
78
*/
75
79
static int check_refname_component (const char * refname , int * flags ,
76
80
struct strbuf * sanitized )
77
81
{
78
82
const char * cp ;
79
83
char last = '\0' ;
80
- size_t component_start ;
84
+ size_t component_start = 0 ; /* garbage - not a reasonable initial value */
81
85
82
86
if (sanitized )
83
87
component_start = sanitized -> len ;
@@ -95,7 +99,8 @@ static int check_refname_component(const char *refname, int *flags,
95
99
case 2 :
96
100
if (last == '.' ) { /* Refname contains "..". */
97
101
if (sanitized )
98
- sanitized -> len -- ; /* collapse ".." to single "." */
102
+ /* collapse ".." to single "." */
103
+ strbuf_setlen (sanitized , sanitized -> len - 1 );
99
104
else
100
105
return -1 ;
101
106
}
0 commit comments