@@ -49,7 +49,7 @@ struct ref_cache *create_ref_cache(struct ref_store *refs,
49
49
50
50
ret -> ref_store = refs ;
51
51
ret -> fill_ref_dir = fill_ref_dir ;
52
- ret -> root = create_dir_entry (ret , "" , 0 , 1 );
52
+ ret -> root = create_dir_entry (ret , "" , 0 );
53
53
return ret ;
54
54
}
55
55
@@ -86,14 +86,13 @@ static void clear_ref_dir(struct ref_dir *dir)
86
86
}
87
87
88
88
struct ref_entry * create_dir_entry (struct ref_cache * cache ,
89
- const char * dirname , size_t len ,
90
- int incomplete )
89
+ const char * dirname , size_t len )
91
90
{
92
91
struct ref_entry * direntry ;
93
92
94
93
FLEX_ALLOC_MEM (direntry , name , dirname , len );
95
94
direntry -> u .subdir .cache = cache ;
96
- direntry -> flag = REF_DIR | ( incomplete ? REF_INCOMPLETE : 0 ) ;
95
+ direntry -> flag = REF_DIR | REF_INCOMPLETE ;
97
96
return direntry ;
98
97
}
99
98
@@ -144,30 +143,19 @@ int search_ref_dir(struct ref_dir *dir, const char *refname, size_t len)
144
143
/*
145
144
* Search for a directory entry directly within dir (without
146
145
* recursing). Sort dir if necessary. subdirname must be a directory
147
- * name (i.e., end in '/'). If mkdir is set, then create the
148
- * directory if it is missing; otherwise, return NULL if the desired
146
+ * name (i.e., end in '/'). Returns NULL if the desired
149
147
* directory cannot be found. dir must already be complete.
150
148
*/
151
149
static struct ref_dir * search_for_subdir (struct ref_dir * dir ,
152
- const char * subdirname , size_t len ,
153
- int mkdir )
150
+ const char * subdirname , size_t len )
154
151
{
155
152
int entry_index = search_ref_dir (dir , subdirname , len );
156
153
struct ref_entry * entry ;
157
- if (entry_index == -1 ) {
158
- if (!mkdir )
159
- return NULL ;
160
- /*
161
- * Since dir is complete, the absence of a subdir
162
- * means that the subdir really doesn't exist;
163
- * therefore, create an empty record for it but mark
164
- * the record complete.
165
- */
166
- entry = create_dir_entry (dir -> cache , subdirname , len , 0 );
167
- add_entry_to_dir (dir , entry );
168
- } else {
169
- entry = dir -> entries [entry_index ];
170
- }
154
+
155
+ if (entry_index == -1 )
156
+ return NULL ;
157
+
158
+ entry = dir -> entries [entry_index ];
171
159
return get_ref_dir (entry );
172
160
}
173
161
@@ -176,18 +164,17 @@ static struct ref_dir *search_for_subdir(struct ref_dir *dir,
176
164
* tree that should hold refname. If refname is a directory name
177
165
* (i.e., it ends in '/'), then return that ref_dir itself. dir must
178
166
* represent the top-level directory and must already be complete.
179
- * Sort ref_dirs and recurse into subdirectories as necessary. If
180
- * mkdir is set, then create any missing directories; otherwise,
167
+ * Sort ref_dirs and recurse into subdirectories as necessary. Will
181
168
* return NULL if the desired directory cannot be found.
182
169
*/
183
170
static struct ref_dir * find_containing_dir (struct ref_dir * dir ,
184
- const char * refname , int mkdir )
171
+ const char * refname )
185
172
{
186
173
const char * slash ;
187
174
for (slash = strchr (refname , '/' ); slash ; slash = strchr (slash + 1 , '/' )) {
188
175
size_t dirnamelen = slash - refname + 1 ;
189
176
struct ref_dir * subdir ;
190
- subdir = search_for_subdir (dir , refname , dirnamelen , mkdir );
177
+ subdir = search_for_subdir (dir , refname , dirnamelen );
191
178
if (!subdir ) {
192
179
dir = NULL ;
193
180
break ;
@@ -202,7 +189,7 @@ struct ref_entry *find_ref_entry(struct ref_dir *dir, const char *refname)
202
189
{
203
190
int entry_index ;
204
191
struct ref_entry * entry ;
205
- dir = find_containing_dir (dir , refname , 0 );
192
+ dir = find_containing_dir (dir , refname );
206
193
if (!dir )
207
194
return NULL ;
208
195
entry_index = search_ref_dir (dir , refname , strlen (refname ));
@@ -212,50 +199,6 @@ struct ref_entry *find_ref_entry(struct ref_dir *dir, const char *refname)
212
199
return (entry -> flag & REF_DIR ) ? NULL : entry ;
213
200
}
214
201
215
- int remove_entry_from_dir (struct ref_dir * dir , const char * refname )
216
- {
217
- int refname_len = strlen (refname );
218
- int entry_index ;
219
- struct ref_entry * entry ;
220
- int is_dir = refname [refname_len - 1 ] == '/' ;
221
- if (is_dir ) {
222
- /*
223
- * refname represents a reference directory. Remove
224
- * the trailing slash; otherwise we will get the
225
- * directory *representing* refname rather than the
226
- * one *containing* it.
227
- */
228
- char * dirname = xmemdupz (refname , refname_len - 1 );
229
- dir = find_containing_dir (dir , dirname , 0 );
230
- free (dirname );
231
- } else {
232
- dir = find_containing_dir (dir , refname , 0 );
233
- }
234
- if (!dir )
235
- return -1 ;
236
- entry_index = search_ref_dir (dir , refname , refname_len );
237
- if (entry_index == -1 )
238
- return -1 ;
239
- entry = dir -> entries [entry_index ];
240
-
241
- MOVE_ARRAY (& dir -> entries [entry_index ],
242
- & dir -> entries [entry_index + 1 ], dir -> nr - entry_index - 1 );
243
- dir -> nr -- ;
244
- if (dir -> sorted > entry_index )
245
- dir -> sorted -- ;
246
- free_ref_entry (entry );
247
- return dir -> nr ;
248
- }
249
-
250
- int add_ref_entry (struct ref_dir * dir , struct ref_entry * ref )
251
- {
252
- dir = find_containing_dir (dir , ref -> name , 1 );
253
- if (!dir )
254
- return -1 ;
255
- add_entry_to_dir (dir , ref );
256
- return 0 ;
257
- }
258
-
259
202
/*
260
203
* Emit a warning and return true iff ref1 and ref2 have the same name
261
204
* and the same oid. Die if they have the same name but different
@@ -522,7 +465,7 @@ struct ref_iterator *cache_ref_iterator_begin(struct ref_cache *cache,
522
465
523
466
dir = get_ref_dir (cache -> root );
524
467
if (prefix && * prefix )
525
- dir = find_containing_dir (dir , prefix , 0 );
468
+ dir = find_containing_dir (dir , prefix );
526
469
if (!dir )
527
470
/* There's nothing to iterate over. */
528
471
return empty_ref_iterator_begin ();
0 commit comments