9
9
10
10
static int get_sha1_oneline (const char * , unsigned char * , struct commit_list * );
11
11
12
- static int find_short_object_filename (int len , const char * name , unsigned char * sha1 )
12
+ static int find_short_object_filename (int len , const char * hex_pfx , unsigned char * sha1 )
13
13
{
14
14
struct alternate_object_database * alt ;
15
15
char hex [40 ];
@@ -34,18 +34,18 @@ static int find_short_object_filename(int len, const char *name, unsigned char *
34
34
}
35
35
fakeent -> next = alt_odb_list ;
36
36
37
- sprintf (hex , "%.2s" , name );
37
+ sprintf (hex , "%.2s" , hex_pfx );
38
38
for (alt = fakeent ; alt && found < 2 ; alt = alt -> next ) {
39
39
struct dirent * de ;
40
40
DIR * dir ;
41
- sprintf (alt -> name , "%.2s/" , name );
41
+ sprintf (alt -> name , "%.2s/" , hex_pfx );
42
42
dir = opendir (alt -> base );
43
43
if (!dir )
44
44
continue ;
45
45
while ((de = readdir (dir )) != NULL ) {
46
46
if (strlen (de -> d_name ) != 38 )
47
47
continue ;
48
- if (memcmp (de -> d_name , name + 2 , len - 2 ))
48
+ if (memcmp (de -> d_name , hex_pfx + 2 , len - 2 ))
49
49
continue ;
50
50
if (!found ) {
51
51
memcpy (hex + 2 , de -> d_name , 38 );
@@ -79,7 +79,7 @@ static int match_sha(unsigned len, const unsigned char *a, const unsigned char *
79
79
}
80
80
81
81
static int unique_in_pack (int len ,
82
- const unsigned char * match ,
82
+ const unsigned char * bin_pfx ,
83
83
struct packed_git * p ,
84
84
const unsigned char * * found_sha1 ,
85
85
int seen_so_far )
@@ -96,7 +96,7 @@ static int unique_in_pack(int len,
96
96
int cmp ;
97
97
98
98
current = nth_packed_object_sha1 (p , mid );
99
- cmp = hashcmp (match , current );
99
+ cmp = hashcmp (bin_pfx , current );
100
100
if (!cmp ) {
101
101
first = mid ;
102
102
break ;
@@ -110,12 +110,12 @@ static int unique_in_pack(int len,
110
110
111
111
/*
112
112
* At this point, "first" is the location of the lowest object
113
- * with an object name that could match "match ". See if we have
113
+ * with an object name that could match "bin_pfx ". See if we have
114
114
* 0, 1 or more objects that actually match(es).
115
115
*/
116
116
for (i = first ; i < num ; i ++ ) {
117
117
current = nth_packed_object_sha1 (p , first );
118
- if (!match_sha (len , match , current ))
118
+ if (!match_sha (len , bin_pfx , current ))
119
119
break ;
120
120
121
121
/* current matches */
@@ -131,15 +131,15 @@ static int unique_in_pack(int len,
131
131
return seen_so_far ;
132
132
}
133
133
134
- static int find_short_packed_object (int len , const unsigned char * match , unsigned char * sha1 )
134
+ static int find_short_packed_object (int len , const unsigned char * bin_pfx , unsigned char * sha1 )
135
135
{
136
136
struct packed_git * p ;
137
137
const unsigned char * found_sha1 = NULL ;
138
138
int found = 0 ;
139
139
140
140
prepare_packed_git ();
141
141
for (p = packed_git ; p && found < 2 ; p = p -> next )
142
- found = unique_in_pack (len , match , p , & found_sha1 , found );
142
+ found = unique_in_pack (len , bin_pfx , p , & found_sha1 , found );
143
143
144
144
if (found == 1 )
145
145
hashcpy (sha1 , found_sha1 );
@@ -149,15 +149,15 @@ static int find_short_packed_object(int len, const unsigned char *match, unsigne
149
149
#define SHORT_NAME_NOT_FOUND (-1)
150
150
#define SHORT_NAME_AMBIGUOUS (-2)
151
151
152
- static int find_unique_short_object (int len , char * canonical ,
153
- unsigned char * res , unsigned char * sha1 )
152
+ static int find_unique_short_object (int len , char * hex_pfx ,
153
+ unsigned char * bin_pfx , unsigned char * sha1 )
154
154
{
155
155
int has_unpacked , has_packed ;
156
156
unsigned char unpacked_sha1 [20 ], packed_sha1 [20 ];
157
157
158
158
prepare_alt_odb ();
159
- has_unpacked = find_short_object_filename (len , canonical , unpacked_sha1 );
160
- has_packed = find_short_packed_object (len , res , packed_sha1 );
159
+ has_unpacked = find_short_object_filename (len , hex_pfx , unpacked_sha1 );
160
+ has_packed = find_short_packed_object (len , bin_pfx , packed_sha1 );
161
161
if (!has_unpacked && !has_packed )
162
162
return SHORT_NAME_NOT_FOUND ;
163
163
if (1 < has_unpacked || 1 < has_packed )
@@ -177,13 +177,13 @@ static int get_short_sha1(const char *name, int len, unsigned char *sha1,
177
177
int quietly )
178
178
{
179
179
int i , status ;
180
- char canonical [40 ];
181
- unsigned char res [20 ];
180
+ char hex_pfx [40 ];
181
+ unsigned char bin_pfx [20 ];
182
182
183
183
if (len < MINIMUM_ABBREV || len > 40 )
184
184
return -1 ;
185
- hashclr (res );
186
- memset (canonical , 'x' , 40 );
185
+ hashclr (bin_pfx );
186
+ memset (hex_pfx , 'x' , 40 );
187
187
for (i = 0 ; i < len ;i ++ ) {
188
188
unsigned char c = name [i ];
189
189
unsigned char val ;
@@ -197,15 +197,15 @@ static int get_short_sha1(const char *name, int len, unsigned char *sha1,
197
197
}
198
198
else
199
199
return -1 ;
200
- canonical [i ] = c ;
200
+ hex_pfx [i ] = c ;
201
201
if (!(i & 1 ))
202
202
val <<= 4 ;
203
- res [i >> 1 ] |= val ;
203
+ bin_pfx [i >> 1 ] |= val ;
204
204
}
205
205
206
- status = find_unique_short_object (i , canonical , res , sha1 );
206
+ status = find_unique_short_object (i , hex_pfx , bin_pfx , sha1 );
207
207
if (!quietly && (status == SHORT_NAME_AMBIGUOUS ))
208
- return error ("short SHA1 %.*s is ambiguous." , len , canonical );
208
+ return error ("short SHA1 %.*s is ambiguous." , len , hex_pfx );
209
209
return status ;
210
210
}
211
211
0 commit comments