git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] rebase: rebasing can also be done when HEAD is detached
@ 2017-11-21 15:25 Kaartic Sivaraam
  2017-11-22  2:13 ` Junio C Hamano
  0 siblings, 1 reply; 18+ messages in thread
From: Kaartic Sivaraam @ 2017-11-21 15:25 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git mailing list

In a repository when attempting to rebase when the HEAD is detached
and it 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>
---
 In this patch, I basically assumed that there would be no
 branch named "HEAD". To the cotrary if it did, it would make
 'git' throw spurious ambiguity messages, in general. So, I
 guess it's not worth trying to check if HEAD is a branch or
 not and handle that specially.

 git-rebase.sh | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/git-rebase.sh b/git-rebase.sh
index 6344e8d5e..933df832a 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -598,11 +598,21 @@ 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"
+		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"
+		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.0.345.gf926f18f3


^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2017-12-16  9:04 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-21 15:25 [PATCH] rebase: rebasing can also be done when HEAD is detached Kaartic Sivaraam
2017-11-22  2:13 ` Junio C Hamano
2017-11-27 17:21   ` [PATCH v2 0/3] rebase: give precise error message Kaartic Sivaraam
2017-11-27 17:21     ` [PATCH v2 1/3] rebase: use a more appropriate variable name Kaartic Sivaraam
2017-11-27 17:21     ` [PATCH v2 2/3] rebase: distinguish user input by quoting it Kaartic Sivaraam
2017-11-27 17:21     ` [PATCH v2 3/3] rebase: rebasing can also be done when HEAD is detached Kaartic Sivaraam
2017-11-28  2:31       ` Junio C Hamano
2017-11-28 16:15         ` Kaartic Sivaraam
2017-12-01  6:09         ` [PATCH v3 " Kaartic Sivaraam
2017-11-28  2:25     ` [PATCH v2 0/3] rebase: give precise error message Junio C Hamano
2017-11-28 14:04       ` Kaartic Sivaraam
2017-11-29  0:10         ` Junio C Hamano
2017-11-29  3:11           ` Kaartic Sivaraam
2017-11-29  6:47             ` Junio C Hamano
2017-12-16  9:03     ` [PATCH v5 0/3] rebase: give precise error messages Kaartic Sivaraam
2017-12-16  9:03       ` [PATCH v5 1/3] rebase: consistently use branch_name variable Kaartic Sivaraam
2017-12-16  9:03       ` [PATCH v5 2/3] rebase: distinguish user input by quoting it Kaartic Sivaraam
2017-12-16  9:03       ` [PATCH v5 3/3] rebase: rebasing can also be done when HEAD is detached Kaartic Sivaraam

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).