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

Re: git push usage

From
Jay Soffian <jaysoffian@gmail.com>
Date
Feb 21, 2009, 09:32 UTC
Message-ID
<76718490902210132w2577c093tf8c2a5e7da8bc0e8@mail.gmail.com>
In-Reply-To
<76718490902200116n73e00b62sbe7bb774bcc058c5@mail.gmail.com>
Tap...tap...tap... is this thing on? :-)
On Fri, Feb 20, 2009 at 4:16 AM, Jay Soffian <jaysoffian@gmail.com> wrote:
Show 58 quoted lines
> The man page for git push claims:
>
>  --repo=<repository>
>     This option is only relevant if no <repository> argument is passed
>     in the invocation. In this case, git-push derives the remote name
>     from the current branch: If it tracks a remote branch, then that
>     remote repository is pushed to. Otherwise, the name "origin" is
>     used. For this latter case, this option can be used to override the
>     name "origin". In other words, the difference between these two
>     commands
>
>         git push public         #1
>         git push --repo=public  #2
>
>     is that #1 always pushes to "public" whereas #2 pushes to "public"
>     only if the current branch does not track a remote branch. This is
>     useful if you write an alias or script around git-push.
>
> However, I'm sitting here looking at the code and I don't see how this
> is possible. I've also done some testing. So I think the man page lies
> and that forms (1) and (2) are equivalent as shown.
>
> cmd_push() is:
>
>  const char *repo = NULL; /* default repository */
>  struct option options[] = {
>    ...
>    OPT_STRING( 0 , "repo", &repo, "repository", "repository"),
>    ...
>  }
>
>  argc = parse_options(argc, argv, options, push_usage, 0);
>
>  if (argc > 0) {
>    repo = argv[0];
>    set_refspecs(argv + 1, argc - 1);
>  }
>
>  rc = do_push(repo, flags);
>
> So if the user specifies --repo, then its value is assigned to *repo by
> parse_options. If the user otherwise specifies a repository w/o --repo, that
> will be argv[0] after parse_options, so it will get assigned to *repo. Assuming
> no other arguments, set_refspecs gets called with argc = 0 and returns w/o doing
> anything.
>
> So the only difference I can see is that form #1 allows the user to specify a
> refspec on the command line. Form #2 does not since the first
> non-dashed argument gets assigned to *repo, so:
>
> $ git push --repo src:dst
>
> would assign src:dst to *repo, which would choke.
>
> So, what's the point of the --repo dashed-option then?
>
> j.
>
Previous: Jay SoffianNext: Michael J Gruber
Message 2 of 13 in “git push usage”
  1. Jay SoffianFeb 20, 2009
  2. Jay SoffianFeb 21, 2009
  3. [RFC] add test cases for the --repo option to git pushMichael J Gruber, Feb 24, 2009
  4. Junio C HamanoFeb 25, 2009
  5. Michael J GruberFeb 26, 2009
  6. Junio C HamanoFeb 26, 2009
  7. Michael J GruberFeb 26, 2009
  8. Jay SoffianFeb 26, 2009
  9. Michael J GruberFeb 27, 2009
  10. Junio C HamanoFeb 27, 2009
  11. Jay SoffianFeb 27, 2009
  12. Linus TorvaldsFeb 27, 2009
  13. Jay SoffianFeb 27, 2009

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.