Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH 6/6] push: honor branch.*.push

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:57:53

Johan Herland [off-list ref] writes:
quoted
+static void setup_per_branch_push(struct branch *branch)
+{
+       struct strbuf refspec = STRBUF_INIT;
+
+       strbuf_addf(&refspec, "%s:%s",
+                   branch->name, branch->push_name);
+       add_refspec(refspec.buf);
This goes back to the question I raised in 3/6: If this code path adds
refspec "foo:bar", and - say - setup_push_current() has already added
refspec "foo:foo" (or simply "foo"), then do we end up pushing into
"foo" or "bar"?
I think you answered your own question below with the "return".
quoted
@@ -194,7 +203,14 @@ static int is_workflow_triagular(struct remote *remote)
 static void setup_default_push_refspecs(struct remote *remote)
 {
        struct branch *branch = branch_get(NULL);
-       int triangular = is_workflow_triagular(remote);
+       int triangular;
+
+       if (branch->push_name) {
+               setup_per_branch_push(branch);
+               return;
I guess this return ensures that branch.*.push overrides push.default,
but might there be other sources of add_refspec() that would
complicate things?
The default-push-refspecs is meant to be used only when there is no
other stronger clue given by the user (e.g. refspec on the command
line, e.g. "git push there master", pushing with configured refspecs
on remote.$name.push), so I think it is a bug if somebody calls this
function when there is other source.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help