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

[PATCH v2 0/3] rebase: give precise error message

From
Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Date
Nov 27, 2017, 17:21 UTC
Message-ID
<20171127172104.5796-1-kaartic.sivaraam@gmail.com>
In-Reply-To
<xmqq60a3xdpw.fsf@gitster.mtv.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
> Perhaps time to learn "git symbolic-ref HEAD" and use it instead of
> depending on the name?

Good point. Helped remove the assumption that there's no branch named HEAD. (and indirectly led to 2 additional patches and the 3 questions found below ;-)

This started as a small fix to make 'git rebase' give a precise error message when a rebase was done with a detached HEAD. Now it includes a few cleanups that I caught while analysing the code.

There were a few weird observations when I was anlaysing the code. They are listed below. Please give your thoughts about them.

The commands I use below were run on my local clone of 'git' and 'origin' in this context refers to the git mirror at GitHub.

1. "git rebase <upstream> <remote_branch>" does nothing

I tried to play around with rebase by trying out various combinations while analysing and found the following to have not effect even though the output doesn't say anything about that,

$ git rebase origin/next origin/maint First, rewinding head to replay your work on top of it... Fast-forwarded origin/maint to origin/next.

IOW, updating a remote branch with a remote upstream had no effect. Though trying to update a remote branch with a remote upstream doesn't seem to be very meaningful, the output says it HAS updated the remote which seems to be misleading. What should be done about this?

2. It's possible to do "git rebase <upstream> <commit>"
$ git origin/next f926f18f3dda0c52e794b2de0911f1b046c7dadf"

This checks out the commit(detaches HEAD) tries to rebase origin/next from there.

This behaviour doesn't seems to be documented. It says that only a 'branch' can be specified. (The error message updated in 1/3 previously reported that the 'branch' name is invalid rather than stating the 'ref (branch/commit) is invlid')

 git rebase [...] [<upstream> [<branch>]]
 git rebase [...] --root [<branch>]
 ...

Shouldn't it have said that we can give any <ref> apart from <branch> instead of saying we could give only a <branch>. If intentional, why?

3. "git rebase <upstream> <commit>" shows misleading message

$ git origin/next f926f18f3dda0c52e794b2de0911f1b046c7dadf" Current branch f926f18f3dda0c52e794b2de0911f1b046c7dadf is up to date.

As it's clear the commit is not a branch. What should be done to fix this?
Kaartic Sivaraam (3):
  rebase: use a more appropriate variable name
  rebase: distinguish user input by quoting it
  rebase: rebasing can also be done when HEAD is detached
 git-rebase.sh | 46 +++++++++++++++++++++++++++++++---------------
 1 file changed, 31 insertions(+), 15 deletions(-)
-- 
2.15.0.345.gf926f18f3
Previous: Junio C HamanoNext: Kaartic Sivaraam
Message 3 of 18 in “rebase: rebasing can also be done when HEAD is detached”
  1. rebase: rebasing can also be done when HEAD is detachedKaartic Sivaraam, Nov 21, 2017
  2. Junio C HamanoNov 22, 2017
  3. 0/3 rebase: give precise error messageKaartic Sivaraam, Nov 27, 2017
  4. 1/3 rebase: use a more appropriate variable nameKaartic Sivaraam, Nov 27, 2017
  5. 2/3 rebase: distinguish user input by quoting itKaartic Sivaraam, Nov 27, 2017
  6. 3/3 rebase: rebasing can also be done when HEAD is detachedKaartic Sivaraam, Nov 27, 2017
  7. Junio C HamanoNov 28, 2017
  8. Kaartic SivaraamNov 28, 2017
  9. 3/3 rebase: rebasing can also be done when HEAD is detachedKaartic Sivaraam, Dec 1, 2017
  10. Junio C HamanoNov 28, 2017
  11. Kaartic SivaraamNov 28, 2017
  12. Junio C HamanoNov 29, 2017
  13. Kaartic SivaraamNov 29, 2017
  14. Junio C HamanoNov 29, 2017
  15. 0/3 rebase: give precise error messagesKaartic Sivaraam, Dec 16, 2017
  16. 1/3 rebase: consistently use branch_name variableKaartic Sivaraam, Dec 16, 2017
  17. 2/3 rebase: distinguish user input by quoting itKaartic Sivaraam, Dec 16, 2017
  18. 3/3 rebase: rebasing can also be done when HEAD is detachedKaartic Sivaraam, Dec 16, 2017

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.