get_fetch_map(remote_refs, &refspec, &fetch_map_tail, 0);
matches = guess_remote_head(find_ref_by_name(remote_refs, "HEAD"),
- fetch_map, 1);
+ fetch_map, REMOTE_GUESS_HEAD_ALL);
for (ref = matches; ref; ref = ref->next) {
string_list_append(&heads, strip_refshead(ref->name));
}
get_fetch_map(remote_refs, &refspec, &fetch_map_tail, 0);
matches = guess_remote_head(find_ref_by_name(remote_refs, "HEAD"),
- fetch_map, 1);
+ fetch_map, REMOTE_GUESS_HEAD_ALL);
for (ref = matches; ref; ref = ref->next)
string_list_append(&states->heads, abbrev_branch(ref->name));
struct ref *guess_remote_head(const struct ref *head,
const struct ref *refs,
- int all)
+ unsigned flags)
{
const struct ref *r;
struct ref *list = NULL;
return copy_ref(find_ref_by_name(refs, head->symref));
/* If a remote branch exists with the default branch name, let's use it. */
- if (!all) {
- char *default_branch = repo_default_branch_name(the_repository, 0);
+ if (!(flags & REMOTE_GUESS_HEAD_ALL)) {
+ char *default_branch =
+ repo_default_branch_name(the_repository,
+ flags & REMOTE_GUESS_HEAD_QUIET);
char *ref = xstrfmt("refs/heads/%s", default_branch);
r = find_ref_by_name(refs, ref);
oideq(&r->old_oid, &head->old_oid)) {
*tail = copy_ref(r);
tail = &((*tail)->next);
- if (!all)
+ if (!(flags & REMOTE_GUESS_HEAD_ALL))
break;
}
}
int show_divergence_advice);
struct ref *get_local_heads(void);
+
/*
* Find refs from a list which are likely to be pointed to by the given HEAD
- * ref. If 'all' is false, returns the most likely ref; otherwise, returns a
- * list of all candidate refs. If no match is found (or 'head' is NULL),
- * returns NULL. All returns are newly allocated and should be freed.
+ * ref. If REMOTE_GUESS_HEAD_ALL is set, return a list of all candidate refs;
+ * otherwise, return the most likely ref. If no match is found (or 'head' is
+ * NULL), returns NULL. All returns are newly allocated and should be freed.
*/
+#define REMOTE_GUESS_HEAD_ALL (1 << 0)
+#define REMOTE_GUESS_HEAD_QUIET (1 << 1)
struct ref *guess_remote_head(const struct ref *head,
const struct ref *refs,
- int all);
+ unsigned flags);
/* Return refs which no longer exist on remote */
struct ref *get_stale_heads(struct refspec *rs, struct ref *fetch_map);