]> git.ipfire.org Git - thirdparty/git.git/commitdiff
remote: drop "explicit" parameter from remote_ref_for_branch()
authorJeff King <peff@peff.net>
Tue, 3 Mar 2020 16:12:22 +0000 (17:12 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 3 Mar 2020 22:56:05 +0000 (14:56 -0800)
Commit 9700fae5ee (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 <peff@peff.net>
Signed-off-by: Damien Robert <damien.olivier.robert+git@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
ref-filter.c
remote.c
remote.h

index 6867e33648cb58d6836594a5cf145a58f81a884e..9837700732f72ba9bc7811eca1fbea4dc2af5299 100644 (file)
@@ -1459,12 +1459,10 @@ static void fill_remote_ref_details(struct used_atom *atom, const char *refname,
                        remote_for_branch(branch, &explicit);
                *s = xstrdup(explicit ? remote : "");
        } else if (atom->u.remote_ref.option == RR_REMOTE_REF) {
-               int explicit;
                const char *merge;
 
-               merge = remote_ref_for_branch(branch, atom->u.remote_ref.push,
-                                             &explicit);
-               *s = xstrdup(explicit ? merge : "");
+               merge = remote_ref_for_branch(branch, atom->u.remote_ref.push);
+               *s = xstrdup(merge ? merge : "");
        } else
                BUG("unhandled RR_* enum");
 }
index 593ce297ed2ad41e150a077b67623e12ceaa3d25..c43196ec06c50beb1b7c93e180a62c031d67c10e 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -516,14 +516,11 @@ const char *pushremote_for_branch(struct branch *branch, int *explicit)
        return remote_for_branch(branch, explicit);
 }
 
-const char *remote_ref_for_branch(struct branch *branch, int for_push,
-                                 int *explicit)
+const char *remote_ref_for_branch(struct branch *branch, int for_push)
 {
        if (branch) {
                if (!for_push) {
                        if (branch->merge_nr) {
-                               if (explicit)
-                                       *explicit = 1;
                                return branch->merge_name[0];
                        }
                } else {
@@ -534,15 +531,11 @@ const char *remote_ref_for_branch(struct branch *branch, int for_push,
                        if (remote && remote->push.nr &&
                            (dst = apply_refspecs(&remote->push,
                                                  branch->refname))) {
-                               if (explicit)
-                                       *explicit = 1;
                                return dst;
                        }
                }
        }
-       if (explicit)
-               *explicit = 0;
-       return "";
+       return NULL;
 }
 
 static struct remote *remote_get_1(const char *name,
index b134cc21be1aebbad9f00ae182d481eb6694dd01..11d8719b587767bf4cdf0b5b1eccb9572da2658e 100644 (file)
--- a/remote.h
+++ b/remote.h
@@ -261,8 +261,7 @@ struct branch {
 struct branch *branch_get(const char *name);
 const char *remote_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,
-                                 int *explicit);
+const char *remote_ref_for_branch(struct branch *branch, int for_push);
 
 /* returns true if the given branch has merge configuration given. */
 int branch_has_merge_config(struct branch *branch);