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

[PATCH v4 3/3] rebase: rebasing can also be done when HEAD is detached

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 14, 2017, 21:09 UTC
Message-ID
<xmqqshcdrp83.fsf_-_@gitster.mtv.corp.google.com>
In-Reply-To
<xmqqk1xpusyh.fsf@gitster.mtv.corp.google.com>
From: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Date: Mon, 27 Nov 2017 22:51:04 +0530

Attempting to rebase when the HEAD is detached and is already up to date with upstream (so there's nothing to do), the following message is shown

        Current branch HEAD is up to date.
which is clearly wrong as HEAD is not a branch.

Handle the special case of HEAD correctly to give a more precise error message.

Signed-off-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 git-rebase.sh | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/git-rebase.sh b/git-rebase.sh
index e5adb596a0..f3dd864437 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -601,11 +601,23 @@ then
 		test -z "$switch_to" ||
 		GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $switch_to" \
 			git checkout -q "$switch_to" --
-		say "$(eval_gettext "Current branch \$branch_name is up to date.")"
+		if test "$branch_name" = "HEAD" &&
+			 !(git symbolic-ref -q HEAD)
+		then
+			say "$(eval_gettext "HEAD is up to date.")"
+		else
+			say "$(eval_gettext "Current branch \$branch_name is up to date.")"
+		fi
 		finish_rebase
 		exit 0
 	else
-		say "$(eval_gettext "Current branch \$branch_name is up to date, rebase forced.")"
+		if test "$branch_name" = "HEAD" &&
+			 !(git symbolic-ref -q HEAD)
+		then
+			say "$(eval_gettext "HEAD is up to date, rebase forced.")"
+		else
+			say "$(eval_gettext "Current branch \$branch_name is up to date, rebase forced.")"
+		fi
 	fi
 fi
 
-- 
2.15.1-554-g7ec1e7e2b9
Previous: Junio C HamanoNext: Kaartic Sivaraam
Message 7 of 15 in “What's cooking in git.git (Dec 2017, #03; Wed, 13)”
  1. Junio C HamanoDec 13, 2017
  2. Kaartic SivaraamDec 14, 2017
  3. Junio C HamanoDec 14, 2017
  4. Junio C HamanoDec 14, 2017
  5. Kaartic SivaraamDec 16, 2017
  6. 2/3 rebase: distinguish user input by quoting itJunio C Hamano, Dec 14, 2017
  7. 3/3 rebase: rebasing can also be done when HEAD is detachedJunio C Hamano, Dec 14, 2017
  8. Kaartic SivaraamDec 15, 2017
  9. Ævar Arnfjörð BjarmasonDec 14, 2017
  10. Jonathan NiederDec 14, 2017
  11. Junio C HamanoDec 14, 2017
  12. Jonathan NiederDec 14, 2017
  13. Johannes SchindelinDec 15, 2017
  14. Lars SchneiderJan 9, 2018
  15. Junio C HamanoJan 9, 2018

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.