File tree Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -232,16 +232,26 @@ static void strip_trailing_slashes(char *dir)
232
232
static int add_one_reference (struct string_list_item * item , void * cb_data )
233
233
{
234
234
char * ref_git ;
235
+ const char * repo ;
235
236
struct strbuf alternate = STRBUF_INIT ;
236
237
237
- /* Beware: real_path() and mkpath() return static buffer */
238
+ /* Beware: read_gitfile(), real_path() and mkpath() return static buffer */
238
239
ref_git = xstrdup (real_path (item -> string ));
239
- if (is_directory (mkpath ("%s/.git/objects" , ref_git ))) {
240
+
241
+ repo = read_gitfile (ref_git );
242
+ if (!repo )
243
+ repo = read_gitfile (mkpath ("%s/.git" , ref_git ));
244
+ if (repo ) {
245
+ free (ref_git );
246
+ ref_git = xstrdup (repo );
247
+ }
248
+
249
+ if (!repo && is_directory (mkpath ("%s/.git/objects" , ref_git ))) {
240
250
char * ref_git_git = mkpathdup ("%s/.git" , ref_git );
241
251
free (ref_git );
242
252
ref_git = ref_git_git ;
243
253
} else if (!is_directory (mkpath ("%s/objects" , ref_git )))
244
- die (_ ("reference repository '%s' is not a local directory ." ),
254
+ die (_ ("reference repository '%s' is not a local repository ." ),
245
255
item -> string );
246
256
247
257
strbuf_addf (& alternate , "%s/objects" , ref_git );
Original file line number Diff line number Diff line change @@ -185,4 +185,17 @@ test_expect_success 'fetch with incomplete alternates' '
185
185
! grep " want $tag_object" "$U.K"
186
186
'
187
187
188
+ test_expect_success ' clone using repo with gitfile as a reference' '
189
+ git clone --separate-git-dir=L A M &&
190
+ git clone --reference=M A N &&
191
+ echo "$base_dir/L/objects" >expected &&
192
+ test_cmp expected "$base_dir/N/.git/objects/info/alternates"
193
+ '
194
+
195
+ test_expect_success ' clone using repo pointed at by gitfile as reference' '
196
+ git clone --reference=M/.git A O &&
197
+ echo "$base_dir/L/objects" >expected &&
198
+ test_cmp expected "$base_dir/O/.git/objects/info/alternates"
199
+ '
200
+
188
201
test_done
You can’t perform that action at this time.
0 commit comments