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

Re: [PATCH v3] remote: add --fetch and --both options to set-url

From
Jeff King <peff@peff.net>
Date
Dec 4, 2014, 09:37 UTC
Message-ID
<20141204093750.GD27455@peff.net>
In-Reply-To
<1416916106-19892-1-git-send-email-peter@lekensteyn.nl>
On Tue, Nov 25, 2014 at 12:48:26PM +0100, Peter Wu wrote:
Show 23 quoted lines
> git remote set-url knew about the '--push' option to update just the
> pushurl, but it does not have a similar option for "update fetch URL and
> leave whatever was in place for the push URL".
> 
> This patch adds support for a '--fetch' option which implements that use
> case in a backwards compatible way: if no --both, --push or --fetch
> options are given, then the push URL is modified too if it was not set
> before. This is the case since the push URL is implicitly based on the
> fetch URL.
> 
> A '--both' option is added to make the command independent of previous
> pushurl settings. For the --add and --delete set operations, it will
> always set the push and/ or the fetch URLs. For the primary mode of
> operation (without --add or --delete), it will drop pushurl as the
> implicit push URL is the (fetch) URL.
> 
> The documentation has also been updated and a missing '--push' option
> is added to the 'git remote -h' command.
> 
> Tests are also added to verify the documented behavior.
> 
> Signed-off-by: Peter Wu <peter@lekensteyn.nl>
> ---

Sorry for the slowness in reviewing. The design of this version makes sense to me (not surprising, I guess, since it was in direct response to my comments).

I didn't see anything glaringly wrong in the implementation, though I did find it a little hard to follow, because of this:

> +#define MODIFY_TYPE_FETCH       (1 << 0)
> +#define MODIFY_TYPE_PUSH        (1 << 1)
> +#define MODIFY_TYPE_BOTH        (MODIFY_TYPE_FETCH | MODIFY_TYPE_PUSH)
> +#define MODIFY_TYPE_HISTORIC    (MODIFY_TYPE_FETCH | (1 << 2))
When reading through the code, the distinction between
  modify_type & MODIFY_TYPE_FETCH
and
  modify_type == MODIFY_TYPE_FETCH

is significant, because the former matches HISTORIC, while the latter does not. I imagine that a distinct bit value for HISTORIC would make things a bit more verbose (you would have to add an extra OR in many places), but I wonder if it would make the code easier to follow (one of the things I wanted to check was that HISTORIC does the same thing that it always did, and it is very hard to follow the HISTORIC behavior reading the code linearly).

I dunno. I don't insist; just noting a difficulty I had while reading it. Maybe you went down that route already during development and found it more painful.

-Peff
Previous: Peter WuNext: Torsten Bögershausen
Message 4 of 7 in “remote: add --fetch and --both options to set-url”
  1. remote: add --fetch and --both options to set-urlPeter Wu, Nov 25, 2014
  2. Eric SunshineNov 25, 2014
  3. Peter WuNov 25, 2014
  4. Jeff KingDec 4, 2014
  5. Torsten BögershausenDec 17, 2014
  6. Peter WuDec 17, 2014
  7. Jeff KingDec 17, 2014

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.