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

Re: What's cooking in git.git (Dec 2017, #03; Wed, 13)

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 14, 2017, 21:08 UTC
Message-ID
<xmqq1sjxt3tz.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<xmqqk1xpusyh.fsf@gitster.mtv.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
> I think you only sent 3/3 in newer rounds, which made it not to
> apply to my tree.  If you meant to drop changes in 1/3 and 2/3,
> perhaps because they were needless churn, then 3/3 needs to be
> updated not to depend on the changes these two made.
Here is what I reconstructed to suit my taste better ;-)
-- >8 --
From: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Date: Mon, 27 Nov 2017 22:51:02 +0530
Subject: [PATCH v4 1/3] rebase: consistently use branch_name variable

The variable "branch_name" holds the <branch> parameter in "git rebase <upstream> <branch>", but one codepath did not use it after assigning $1 to it (instead it kept using $1). Make it use the variable consistently.

Also, update an error message to say there is no such branch or commit, as we are expecting either of them, and not limiting ourselves to a branch name.

Signed-off-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
---
 git-rebase.sh | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/git-rebase.sh b/git-rebase.sh
index 60b70f3def..5526b17a36 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -528,15 +528,18 @@ case "$#" in
 	branch_name="$1"
 	switch_to="$1"
 
-	if git show-ref --verify --quiet -- "refs/heads/$1" &&
-	   orig_head=$(git rev-parse -q --verify "refs/heads/$1")
+	# Is it a local branch?
+	if git show-ref --verify --quiet -- "refs/heads/$branch_name" &&
+	   orig_head=$(git rev-parse -q --verify "refs/heads/$branch_name")
 	then
-		head_name="refs/heads/$1"
-	elif orig_head=$(git rev-parse -q --verify "$1")
+		head_name="refs/heads/$branch_name"
+	# If not is it a valid ref (branch or commit)?
+	elif orig_head=$(git rev-parse -q --verify "$branch_name")
 	then
 		head_name="detached HEAD"
+
 	else
-		die "$(eval_gettext "fatal: no such branch: \$branch_name")"
+		die "$(eval_gettext "fatal: no such branch/commit: \$branch_name")"
 	fi
 	;;
 0)
@@ -547,7 +550,7 @@ case "$#" in
 		branch_name=$(expr "z$branch_name" : 'zrefs/heads/\(.*\)')
 	else
 		head_name="detached HEAD"
-		branch_name=HEAD ;# detached
+		branch_name=HEAD
 	fi
 	orig_head=$(git rev-parse --verify HEAD) || exit
 	;;
-- 
2.15.1-554-g7ec1e7e2b9
Previous: Junio C HamanoNext: Kaartic Sivaraam
Message 4 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.