@@ -351,3 +351,47 @@ void test_fetchhead_nonetwork__quote_in_branch_name(void)
351
351
cl_git_rewritefile ("./test1/.git/FETCH_HEAD" , FETCH_HEAD_QUOTE_DATA );
352
352
cl_git_pass (git_repository_fetchhead_foreach (g_repo , read_noop , NULL ));
353
353
}
354
+
355
+ static bool found_master ;
356
+ static bool find_master_called ;
357
+
358
+ int find_master (const char * ref_name , const char * remote_url , const git_oid * oid , unsigned int is_merge , void * payload )
359
+ {
360
+ GIT_UNUSED (remote_url );
361
+ GIT_UNUSED (oid );
362
+ GIT_UNUSED (payload );
363
+
364
+ find_master_called = true;
365
+
366
+ if (!strcmp ("refs/heads/master" , ref_name )) {
367
+ cl_assert (is_merge );
368
+ found_master = true;
369
+ }
370
+
371
+ return 0 ;
372
+ }
373
+
374
+ void test_fetchhead_nonetwork__create_when_refpecs_given (void )
375
+ {
376
+ git_remote * remote ;
377
+ git_buf path = GIT_BUF_INIT ;
378
+ char * refspec = "refs/heads/master" ;
379
+ git_strarray specs = {
380
+ & refspec ,
381
+ 1 ,
382
+ };
383
+
384
+ cl_set_cleanup (& cleanup_repository , "./test1" );
385
+ cl_git_pass (git_repository_init (& g_repo , "./test1" , 0 ));
386
+
387
+ cl_git_pass (git_buf_joinpath (& path , git_repository_path (g_repo ), "FETCH_HEAD" ));
388
+ cl_git_pass (git_remote_create (& remote , g_repo , "origin" , cl_fixture ("testrepo.git" )));
389
+
390
+ cl_assert (!git_path_exists (path .ptr ));
391
+ cl_git_pass (git_remote_fetch (remote , & specs , NULL , NULL ));
392
+ cl_assert (git_path_exists (path .ptr ));
393
+
394
+ cl_git_pass (git_repository_fetchhead_foreach (g_repo , find_master , NULL ));
395
+ cl_assert (find_master_called );
396
+ cl_assert (found_master );
397
+ }
0 commit comments