commit - fe389d9e9b32033b8ea536ca04677a62243d42a7
commit + 55ff12a650e3bd5e4a81811caf98904a627c59e3
blob - 736c8e342f847a5c286727292fe961ed4fcac388
blob + 78332997dbcd1bbcf19dda1a4540702bf27094d6
--- libexec/got-fetch-pack/got-fetch-pack.c
+++ libexec/got-fetch-pack/got-fetch-pack.c
char *id_str = NULL, *default_id_str = NULL, *refname = NULL;
char *server_capabilities = NULL, *my_capabilities = NULL;
const char *default_branch = NULL;
+ char *free_default_branch = NULL;
struct got_pathlist_head symrefs;
struct got_pathlist_entry *pe;
int sent_my_capabilites = 0, have_sidebands = 0;
continue;
default_branch = symref_target;
break;
+ }
+ if (default_branch == NULL) {
+ default_id_str = strdup(id_str);
+ if (default_id_str == NULL) {
+ err = got_error_from_errno(
+ "strdup");
+ goto done;
+ }
}
}
if (default_branch)
goto done;
}
}
+ /* If no symrefs is given, go for first matching id_str */
+ if (default_branch == NULL && default_id_str &&
+ strncmp(refname, "refs/heads/", 11) == 0 &&
+ strcmp(id_str, default_id_str) == 0) {
+ free_default_branch = strdup(refname);
+ if (free_default_branch == NULL) {
+ err = got_error_from_errno("strdup");
+ goto done;
+ }
+ default_branch = free_default_branch;
+ }
if (list_refs_only || strncmp(refname, "refs/tags/", 10) == 0) {
err = fetch_ref(ibuf, have_refs, &have[nref],
free(have);
free(want);
free(id_str);
+ free(free_default_branch);
free(default_id_str);
free(refname);
free(server_capabilities);