git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Cc: git@vger.kernel.org
Subject: [PATCH v4 3/3] rebase: rebasing can also be done when HEAD is detached
Date: Thu, 14 Dec 2017 13:09:32 -0800	[thread overview]
Message-ID: <xmqqshcdrp83.fsf_-_@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <xmqqk1xpusyh.fsf@gitster.mtv.corp.google.com> (Junio C. Hamano's message of "Thu, 14 Dec 2017 09:20:38 -0800")

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


  parent reply	other threads:[~2017-12-14 21:09 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-13 23:00 What's cooking in git.git (Dec 2017, #03; Wed, 13) Junio C Hamano
2017-12-14 12:37 ` Kaartic Sivaraam
2017-12-14 17:20   ` Junio C Hamano
2017-12-14 21:08     ` Junio C Hamano
2017-12-16  6:06       ` Kaartic Sivaraam
2017-12-14 21:09     ` [PATCH v4 2/3] rebase: distinguish user input by quoting it Junio C Hamano
2017-12-14 21:09     ` Junio C Hamano [this message]
2017-12-15 15:29     ` What's cooking in git.git (Dec 2017, #03; Wed, 13) Kaartic Sivaraam
2017-12-14 17:41 ` Ævar Arnfjörð Bjarmason
2017-12-14 21:04 ` Jonathan Nieder
2017-12-14 21:06   ` Junio C Hamano
2017-12-14 21:26     ` Jonathan Nieder
2017-12-15 12:39 ` Johannes Schindelin
2018-01-09 12:59 ` Lars Schneider
2018-01-09 18:59   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqshcdrp83.fsf_-_@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=kaartic.sivaraam@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this 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).