commit - ec9e97005c78048a84eebd1889f6d149c337ac8e
commit + cd154312d1af8f1612bb73c728a1394608539da3
blob - a5bdba20fbfdf3cd131ffb9a646559556bc5f2fd
blob + e93728385f32d4085286df2430149d36ac1a6af1
--- got/got.c
+++ got/got.c
break;
}
+ /*
+ * If we have no HEAD ref yet, set it to the first branch
+ * which was fetched.
+ */
+ if (pe == NULL) {
+ RB_FOREACH(pe, got_pathlist_head, &refs) {
+ const char *refname = pe->path;
+ struct got_reference *target_ref;
+
+ if (strncmp("refs/heads/", refname, 11) != 0)
+ continue;
+
+ error = got_ref_open(&target_ref, repo,
+ refname, 0);
+ if (error) {
+ if (error->code == GOT_ERR_NOT_REF) {
+ error = NULL;
+ continue;
+ }
+ goto done;
+ }
+
+ error = create_symref(GOT_REF_HEAD, target_ref,
+ verbosity, repo);
+ got_ref_close(target_ref);
+ if (error)
+ goto done;
+ break;
+ }
+ }
+
if (!fpa.configs_created && pe != NULL) {
error = create_config_files(fpa.config_info.proto,
fpa.config_info.host, fpa.config_info.port,