git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 5/6] remote.c: introduce remote.pushdefault

From
Jeff King <peff@peff.net>
Date
Mar 22, 2013, 14:56 UTC
Message-ID
<20130322145640.GB3083@sigill.intra.peff.net>
In-Reply-To
<1363938756-13722-6-git-send-email-artagnon@gmail.com>
On Fri, Mar 22, 2013 at 01:22:35PM +0530, Ramkumar Ramachandra wrote:
Show 16 quoted lines
> diff --git a/remote.c b/remote.c
> index 185ac11..bdb542c 100644
> --- a/remote.c
> +++ b/remote.c
> @@ -350,6 +350,11 @@ static int handle_config(const char *key, const char *value, void *cb)
>  	const char *subkey;
>  	struct remote *remote;
>  	struct branch *branch;
> +	if (!prefixcmp(key, "remote.")) {
> +		if (!strcmp(key + 7, "pushdefault"))
> +			if (git_config_string(&pushremote_name, key, value))
> +				return -1;
> +	}
>  	if (!prefixcmp(key, "branch.")) {
>  		name = key + 7;
>  		subkey = strrchr(name, '.');

I was going to say "shouldn't we return 0" here, both on successful read of pushdefault, but also just when we have remote.*. But the answer is "yes" to the first one (we know we have handled the key), but "no" to the second, because we end up parsing remote.*.* later.

So I think this should at least be:
  if (!prefixcmp(key, "remote.")) {
          if (!strcmp(key + 7, "pushdefault"))
                  return git_config_string(&pushremote_name, key, value));
          /* do not return; we handle other remote.* below */
  }
but also possibly just move it with the other remote parsing, like:
diff --git a/remote.c b/remote.c
index 02e6c4c..d3d740a 100644
--- a/remote.c
+++ b/remote.c
@@ -388,9 +388,16 @@ static int handle_config(const char *key, const char *value, void *cb)
 			add_instead_of(rewrite, xstrdup(value));
 		}
 	}
+
 	if (prefixcmp(key,  "remote."))
 		return 0;
 	name = key + 7;
+
+	/* Handle any global remote.* variables */
+	if (!strcmp(name, "pushdefault"))
+		return git_config_string(&pushremote_name, key, value);
+
+	/* Now handle any remote.NAME.* variables */
 	if (*name == '/') {
 		warning("Config remote shorthand cannot begin with '/': %s",
 			name);

-Peff
Previous: Ramkumar RamachandraNext: Ramkumar Ramachandra
Message 21 of 24 in “Support triangular workflows”
  1. 0/6 Support triangular workflowsRamkumar Ramachandra, Mar 22, 2013
  2. 1/6 remote.c: simplify a bit of code using git_config_string()Ramkumar Ramachandra, Mar 22, 2013
  3. Jonathan NiederMar 22, 2013
  4. 2/6 t5516 (fetch-push): update test descriptionRamkumar Ramachandra, Mar 22, 2013
  5. Jonathan NiederMar 22, 2013
  6. 3/6 t5516 (fetch-push): introduce mk_test_with_name()Ramkumar Ramachandra, Mar 22, 2013
  7. Jeff KingMar 22, 2013
  8. Junio C HamanoMar 22, 2013
  9. Jeff KingMar 22, 2013
  10. Jonathan NiederMar 22, 2013
  11. Ramkumar RamachandraMar 28, 2013
  12. Junio C HamanoMar 22, 2013
  13. Jeff KingMar 22, 2013
  14. 4/6 remote.c: introduce a way to have different remotes for fetch/pushRamkumar Ramachandra, Mar 22, 2013
  15. Jonathan NiederMar 22, 2013
  16. Junio C HamanoMar 22, 2013
  17. Jonathan NiederMar 22, 2013
  18. Ramkumar RamachandraMar 23, 2013
  19. Ramkumar RamachandraMar 23, 2013
  20. 5/6 remote.c: introduce remote.pushdefaultRamkumar Ramachandra, Mar 22, 2013
  21. Jeff KingMar 22, 2013
  22. Ramkumar RamachandraMar 27, 2013
  23. 6/6 remote.c: introduce branch.<name>.pushremoteRamkumar Ramachandra, Mar 22, 2013
  24. Junio C HamanoMar 22, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.