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

[PATCH] checkout: allow full refnames for local branches

From
LHLars Hjemli <hjemli@gmail.com>
Date
May 9, 2007, 08:40 UTC
Message-ID
<11787000032830-git-send-email-hjemli@gmail.com>

This teaches git-checkout to strip the prefix 'refs/heads/' from the supplied <branch> argument, to make

	git-checkout refs/heads/master
behave like
	git-checkout master
The former command would detach HEAD.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
---

I'm undecided on wheter this is a bugfix or a new feature. It certainly introduces new behaviour, but it passes all the tests.

 git-checkout.sh |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/git-checkout.sh b/git-checkout.sh
index ed7c2c5..6ff7b6e 100755
--- a/git-checkout.sh
+++ b/git-checkout.sh
@@ -63,6 +63,7 @@ while [ "$#" != "0" ]; do
 				echo "unknown flag $arg"
 				exit 1
 			fi
+			arg=$(echo "$arg" | sed -e "s|^refs/heads/||")
 			new="$rev"
 			new_name="$arg"
 			if git-show-ref --verify --quiet -- "refs/heads/$arg"
-- 
1.5.2.rc2.21.g3082a
Next: Junio C Hamano
Message 1 of 9 in “checkout: allow full refnames for local branches”
  1. checkout: allow full refnames for local branchesLars Hjemli, May 9, 2007
  2. Junio C HamanoMay 9, 2007
  3. Lars HjemliMay 9, 2007
  4. Shawn O. PearceMay 9, 2007
  5. Lars HjemliMay 9, 2007
  6. Shawn O. PearceMay 9, 2007
  7. Lars HjemliMay 9, 2007
  8. Junio C HamanoMay 9, 2007
  9. Lars HjemliMay 9, 2007

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.