Re: [PATCH 4/5] branch_get: provide per-branch pushremote pointers

2014-01-08 Thread Jeff King
On Wed, Jan 08, 2014 at 04:35:31AM -0500, Jeff King wrote:

 @@ -385,8 +387,11 @@ static int handle_config(const char *key, const char 
 *value, void *cb)
   name = key + 7;
  
   /* Handle remote.* variables */
 - if (!strcmp(name, pushdefault))
 - return git_config_string(pushremote_name, key, value);
 + if (!strcmp(name, pushdefault)) {
 + if (git_config_string(pushremote_config_default, key, value)  
 0)
 + return -1;
 + pushremote_name = pushremote_config_default;
 + }

This needs return 0 squashed in at the end of the conditional, of
course, to match the old behavior.

This patch passes the test suite by itself (with or without that fixup).
But oddly, it seems to fail t5531 when merged with 'next'. I can't
figure out why, though. It shouldn't affect any code that doesn't look
at branch-pushremote.

-Peff
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/5] branch_get: provide per-branch pushremote pointers

2014-01-08 Thread Jeff King
On Wed, Jan 08, 2014 at 05:27:07AM -0500, Jeff King wrote:

 This patch passes the test suite by itself (with or without that fixup).
 But oddly, it seems to fail t5531 when merged with 'next'. I can't
 figure out why, though. It shouldn't affect any code that doesn't look
 at branch-pushremote.

OK, I figured it out. My patch calls:

  remote_get(origin)

which creates an origin remote, even if one does not exist (it assumes
it to be a URL origin). Later, when we want to decide if the push is
triangular or not, we ask for:

  remote_get(NULL);

which will internally look for a remote called origin. Before my patch
there was not such a remote, and so the push could not be triangular.
After my patch, it finds the bogus remote and says this thing exists,
and is not what we are pushing to; therefore the push is triangular.

The solution is that I should not be passing the term origin to
remote_get, but rather passing NULL and relying on it to figure out the
default remote correctly. I.e.:

diff --git a/remote.c b/remote.c
index 8724388..d214fa2 100644
--- a/remote.c
+++ b/remote.c
@@ -1574,7 +1574,7 @@ struct branch *branch_get(const char *name)
else if (ret-remote_name)
ret-pushremote = remote_get(ret-remote_name);
else
-   ret-pushremote = remote_get(origin);
+   ret-pushremote = remote_get(NULL);
 
return ret;
 }

-Peff
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html