Merge branch 'dr/push-remote-ref-update'

Code clean-up.

* dr/push-remote-ref-update:
  remote: drop "explicit" parameter from remote_ref_for_branch()
maint
Junio C Hamano 2020-03-11 10:58:16 -07:00
commit 5fa9169ced
3 changed files with 5 additions and 15 deletions

View File

@ -1459,12 +1459,10 @@ static void fill_remote_ref_details(struct used_atom *atom, const char *refname,
remote_for_branch(branch, &explicit); remote_for_branch(branch, &explicit);
*s = xstrdup(explicit ? remote : ""); *s = xstrdup(explicit ? remote : "");
} else if (atom->u.remote_ref.option == RR_REMOTE_REF) { } else if (atom->u.remote_ref.option == RR_REMOTE_REF) {
int explicit;
const char *merge; const char *merge;


merge = remote_ref_for_branch(branch, atom->u.remote_ref.push, merge = remote_ref_for_branch(branch, atom->u.remote_ref.push);
&explicit); *s = xstrdup(merge ? merge : "");
*s = xstrdup(explicit ? merge : "");
} else } else
BUG("unhandled RR_* enum"); BUG("unhandled RR_* enum");
} }

View File

@ -516,14 +516,11 @@ const char *pushremote_for_branch(struct branch *branch, int *explicit)
return remote_for_branch(branch, explicit); return remote_for_branch(branch, explicit);
} }


const char *remote_ref_for_branch(struct branch *branch, int for_push, const char *remote_ref_for_branch(struct branch *branch, int for_push)
int *explicit)
{ {
if (branch) { if (branch) {
if (!for_push) { if (!for_push) {
if (branch->merge_nr) { if (branch->merge_nr) {
if (explicit)
*explicit = 1;
return branch->merge_name[0]; return branch->merge_name[0];
} }
} else { } else {
@ -534,15 +531,11 @@ const char *remote_ref_for_branch(struct branch *branch, int for_push,
if (remote && remote->push.nr && if (remote && remote->push.nr &&
(dst = apply_refspecs(&remote->push, (dst = apply_refspecs(&remote->push,
branch->refname))) { branch->refname))) {
if (explicit)
*explicit = 1;
return dst; return dst;
} }
} }
} }
if (explicit) return NULL;
*explicit = 0;
return "";
} }


static struct remote *remote_get_1(const char *name, static struct remote *remote_get_1(const char *name,

View File

@ -261,8 +261,7 @@ struct branch {
struct branch *branch_get(const char *name); struct branch *branch_get(const char *name);
const char *remote_for_branch(struct branch *branch, int *explicit); const char *remote_for_branch(struct branch *branch, int *explicit);
const char *pushremote_for_branch(struct branch *branch, int *explicit); const char *pushremote_for_branch(struct branch *branch, int *explicit);
const char *remote_ref_for_branch(struct branch *branch, int for_push, const char *remote_ref_for_branch(struct branch *branch, int for_push);
int *explicit);


/* returns true if the given branch has merge configuration given. */ /* returns true if the given branch has merge configuration given. */
int branch_has_merge_config(struct branch *branch); int branch_has_merge_config(struct branch *branch);