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

Re: Bug in git rev-parse @{push}?

From
Jeff King <peff@peff.net>
Date
Nov 3, 2016, 15:14 UTC
Message-ID
<20161103151422.nhrgzivapy5tisr4@sigill.intra.peff.net>
In-Reply-To
<CAJUoZVYF=ZCBUX6jztwhJX3BZdq4JEfrSRbi4cFPwn+7yA=VjA@mail.gmail.com>
On Thu, Nov 03, 2016 at 02:53:44PM +0000, Chris Purcell wrote:
Show 11 quoted lines
> I think I have discovered a bug in rev-parse's handling of @{push}:
> 
> $ git push
> Everything up-to-date
> $ git rev-parse @{push}
> fatal: cannot resolve 'simple' push to a single destination
> 
> The documentation for rev-parse says that "the suffix @{push} reports
> the branch 'where we would push to' if git push were run while
> branchname was checked out", so I would not expect this to error
> unless git push does.

I'm not too surprised if there's a bug there. IIRC, the way the code is structured, some of the logic had to be reimplemented for @{push} rather than re-used, so there may be corner cases where they do not agree.

Show 14 quoted lines
> The relevant parts of my configuration are:
> 
> [push]
>     default = simple
> [remote]
>     pushdefault = origin
> [branch "foo"]
>     remote = origin
>     merge = refs/heads/develop
> 
> The code in branch_get_push_1 (remote.c) in the PUSH_DEFAULT_SIMPLE
> case is calling both branch_get_upstream and tracking_for_push_dest
> and erroring if they don't return the same result, which I assume is
> incorrect for a triangular workflow?
I assume you have branch "foo" checked out?

With this config I don't see how "git push" would work. Because you're using "simple", it should complain that "develop" and "foo" are not the same name.

Can you give a more full reproduction recipe? If I try:
  git init tmp && cd tmp
  git config push.default simple
  git commit -m foo --allow-empty ;# just to have some commit to push
  git init --bare dst.git
  git remote add origin dst.git
  git push origin master:refs/heads/develop
  git checkout -b foo origin/develop
  # pushdefault of "origin" is already the default. checkout will have
  # set up branch.foo.* as you specified. So let's try our push.
  git push
Then I get:
  fatal: The upstream branch of your current branch does not match
  the name of your current branch.  To push to the upstream branch
  on the remote, use
      git push origin HEAD:develop
  To push to the branch of the same name on the remote, use
      git push origin foo
which makes sense.

If you _don't_ get that same message with "git push", then my next question is: might you have any aliases or other systems like "hub" that are munging the arguments to "git push"? Running with "GIT_TRACE=1" in the environment might be enlightening there.

> Please let me know if I've missed out important information by
> mistake. I'm happy to work on a patch if given guidance, but this is
> definitely outside my comfort zone for an unfamiliar codebase
> otherwise! e.g. I can't find the test suite.

The tests are in the "t" directory; see t/README for details. You can run them all with "make test" from the top-level directory.

-Peff
Previous: Chris PurcellNext: Chris Purcell
Message 2 of 7 in “Bug in git rev-parse @{push}?”
  1. Chris PurcellNov 3, 2016
  2. Jeff KingNov 3, 2016
  3. Chris PurcellNov 3, 2016
  4. Jeff KingNov 3, 2016
  5. Chris PurcellNov 3, 2016
  6. Jeff KingNov 3, 2016
  7. Chris PurcellNov 3, 2016

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.