@@ -144,30 +144,19 @@ int search_ref_dir(struct ref_dir *dir, const char *refname, size_t len)
144
144
/*
145
145
* Search for a directory entry directly within dir (without
146
146
* 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
147
+ * name (i.e., end in '/'). Returns NULL if the desired
149
148
* directory cannot be found. dir must already be complete.
150
149
*/
151
150
static struct ref_dir * search_for_subdir (struct ref_dir * dir ,
152
- const char * subdirname , size_t len ,
153
- int mkdir )
151
+ const char * subdirname , size_t len )
154
152
{
155
153
int entry_index = search_ref_dir (dir , subdirname , len );
156
154
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
- }
155
+
156
+ if (entry_index == -1 )
157
+ return NULL ;
158
+
159
+ entry = dir -> entries [entry_index ];
171
160
return get_ref_dir (entry );
172
161
}
173
162
@@ -176,18 +165,17 @@ static struct ref_dir *search_for_subdir(struct ref_dir *dir,
176
165
* tree that should hold refname. If refname is a directory name
177
166
* (i.e., it ends in '/'), then return that ref_dir itself. dir must
178
167
* 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,
168
+ * Sort ref_dirs and recurse into subdirectories as necessary. Will
181
169
* return NULL if the desired directory cannot be found.
182
170
*/
183
171
static struct ref_dir * find_containing_dir (struct ref_dir * dir ,
184
- const char * refname , int mkdir )
172
+ const char * refname )
185
173
{
186
174
const char * slash ;
187
175
for (slash = strchr (refname , '/' ); slash ; slash = strchr (slash + 1 , '/' )) {
188
176
size_t dirnamelen = slash - refname + 1 ;
189
177
struct ref_dir * subdir ;
190
- subdir = search_for_subdir (dir , refname , dirnamelen , mkdir );
178
+ subdir = search_for_subdir (dir , refname , dirnamelen );
191
179
if (!subdir ) {
192
180
dir = NULL ;
193
181
break ;
@@ -202,7 +190,7 @@ struct ref_entry *find_ref_entry(struct ref_dir *dir, const char *refname)
202
190
{
203
191
int entry_index ;
204
192
struct ref_entry * entry ;
205
- dir = find_containing_dir (dir , refname , 0 );
193
+ dir = find_containing_dir (dir , refname );
206
194
if (!dir )
207
195
return NULL ;
208
196
entry_index = search_ref_dir (dir , refname , strlen (refname ));
@@ -478,7 +466,7 @@ struct ref_iterator *cache_ref_iterator_begin(struct ref_cache *cache,
478
466
479
467
dir = get_ref_dir (cache -> root );
480
468
if (prefix && * prefix )
481
- dir = find_containing_dir (dir , prefix , 0 );
469
+ dir = find_containing_dir (dir , prefix );
482
470
if (!dir )
483
471
/* There's nothing to iterate over. */
484
472
return empty_ref_iterator_begin ();
0 commit comments