Skip to content

Commit af8ccd8

Browse files
peffgitster
authored andcommitted
remote: drop "explicit" parameter from remote_ref_for_branch()
Commit 9700fae (for-each-ref: let upstream/push report the remote ref name, 2017-11-07) added a remote_ref_for_branch() helper, which is modeled after remote_for_branch(). This includes providing an "explicit" out-parameter that tells the caller whether the remote was configured by the user, or whether we picked a default name like "origin". But unlike remote names, there is no default name when the user didn't configure one. The only way the "explicit" parameter is used by the caller is to use the value returned from the helper when it is set, and use an empty string otherwise, ignoring the returned value from the helper. Let's drop the "explicit" out-parameter, and return NULL when the returned value from the helper should be ignored, to simplify the function interface. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Damien Robert <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2f26889 commit af8ccd8

File tree

3 files changed

+5
-15
lines changed

3 files changed

+5
-15
lines changed

ref-filter.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,12 +1459,10 @@ static void fill_remote_ref_details(struct used_atom *atom, const char *refname,
14591459
remote_for_branch(branch, &explicit);
14601460
*s = xstrdup(explicit ? remote : "");
14611461
} else if (atom->u.remote_ref.option == RR_REMOTE_REF) {
1462-
int explicit;
14631462
const char *merge;
14641463

1465-
merge = remote_ref_for_branch(branch, atom->u.remote_ref.push,
1466-
&explicit);
1467-
*s = xstrdup(explicit ? merge : "");
1464+
merge = remote_ref_for_branch(branch, atom->u.remote_ref.push);
1465+
*s = xstrdup(merge ? merge : "");
14681466
} else
14691467
BUG("unhandled RR_* enum");
14701468
}

remote.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -516,14 +516,11 @@ const char *pushremote_for_branch(struct branch *branch, int *explicit)
516516
return remote_for_branch(branch, explicit);
517517
}
518518

519-
const char *remote_ref_for_branch(struct branch *branch, int for_push,
520-
int *explicit)
519+
const char *remote_ref_for_branch(struct branch *branch, int for_push)
521520
{
522521
if (branch) {
523522
if (!for_push) {
524523
if (branch->merge_nr) {
525-
if (explicit)
526-
*explicit = 1;
527524
return branch->merge_name[0];
528525
}
529526
} else {
@@ -534,15 +531,11 @@ const char *remote_ref_for_branch(struct branch *branch, int for_push,
534531
if (remote && remote->push.nr &&
535532
(dst = apply_refspecs(&remote->push,
536533
branch->refname))) {
537-
if (explicit)
538-
*explicit = 1;
539534
return dst;
540535
}
541536
}
542537
}
543-
if (explicit)
544-
*explicit = 0;
545-
return "";
538+
return NULL;
546539
}
547540

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

remote.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,7 @@ struct branch {
261261
struct branch *branch_get(const char *name);
262262
const char *remote_for_branch(struct branch *branch, int *explicit);
263263
const char *pushremote_for_branch(struct branch *branch, int *explicit);
264-
const char *remote_ref_for_branch(struct branch *branch, int for_push,
265-
int *explicit);
264+
const char *remote_ref_for_branch(struct branch *branch, int for_push);
266265

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

0 commit comments

Comments
 (0)