@@ -144,30 +144,19 @@ int search_ref_dir(struct ref_dir *dir, const char *refname, size_t len)
144144/*
145145 * Search for a directory entry directly within dir (without
146146 * 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
149148 * directory cannot be found. dir must already be complete.
150149 */
151150static 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 )
154152{
155153 int entry_index = search_ref_dir (dir , subdirname , len );
156154 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 ];
171160 return get_ref_dir (entry );
172161}
173162
@@ -176,18 +165,17 @@ static struct ref_dir *search_for_subdir(struct ref_dir *dir,
176165 * tree that should hold refname. If refname is a directory name
177166 * (i.e., it ends in '/'), then return that ref_dir itself. dir must
178167 * 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
181169 * return NULL if the desired directory cannot be found.
182170 */
183171static struct ref_dir * find_containing_dir (struct ref_dir * dir ,
184- const char * refname , int mkdir )
172+ const char * refname )
185173{
186174 const char * slash ;
187175 for (slash = strchr (refname , '/' ); slash ; slash = strchr (slash + 1 , '/' )) {
188176 size_t dirnamelen = slash - refname + 1 ;
189177 struct ref_dir * subdir ;
190- subdir = search_for_subdir (dir , refname , dirnamelen , mkdir );
178+ subdir = search_for_subdir (dir , refname , dirnamelen );
191179 if (!subdir ) {
192180 dir = NULL ;
193181 break ;
@@ -202,7 +190,7 @@ struct ref_entry *find_ref_entry(struct ref_dir *dir, const char *refname)
202190{
203191 int entry_index ;
204192 struct ref_entry * entry ;
205- dir = find_containing_dir (dir , refname , 0 );
193+ dir = find_containing_dir (dir , refname );
206194 if (!dir )
207195 return NULL ;
208196 entry_index = search_ref_dir (dir , refname , strlen (refname ));
@@ -478,7 +466,7 @@ struct ref_iterator *cache_ref_iterator_begin(struct ref_cache *cache,
478466
479467 dir = get_ref_dir (cache -> root );
480468 if (prefix && * prefix )
481- dir = find_containing_dir (dir , prefix , 0 );
469+ dir = find_containing_dir (dir , prefix );
482470 if (!dir )
483471 /* There's nothing to iterate over. */
484472 return empty_ref_iterator_begin ();
0 commit comments