#783654 'git clone -b' should accept bare SHA-1

Package:
git
Source:
git
Description:
fast, scalable, distributed revision control system
Submitter:
Jonathan Nieder
Date:
2015-04-28 19:09:06 UTC
Severity:
wishlist
#783654#5
Date:
2015-04-28 19:05:41 UTC
From:
To:
A little known feature of 'git clone -b' is that its argument doesn't
need to be a branch name:

	$ git clone -b v2.1.3 --depth=1 https://kernel.googlesource.com/pub/scm/git/git
	Cloning into 'git'...
	remote: Sending approximately 57.46 MiB ...
	remote: Counting objects: 2797, done
	remote: Finding sources: 100% (2797/2797)
	remote: Total 2797 (delta 241), reused 1264 (delta 241)
	Receiving objects: 100% (2797/2797), 5.43 MiB | 4.31 MiB/s, done.
	Resolving deltas: 100% (241/241), done.
	Checking connectivity... done.
	Note: checking out '49c3e926349e964b311b46251bb2b97d3d669855'.

	You are in 'detached HEAD' state. [...]

Alas, the syntax after "-b" is not as permissive as what "git fetch"
accepts:

	$ git clone -b refs/tags/v2.1.3 --depth=1 https://kernel.googlesource.com/pub/scm/git/git
	Cloning into 'git'...
	warning: Could not find remote branch refs/tags/v2.1.3 to clone.
	fatal: Remote branch refs/tags/v2.1.3 not found in upstream origin

In particular, while 'git fetch' has accepted a SHA-1 to mean "fetch this commit,
and I don't care what branch it's on" ever since v1.8.3-rc0~206^2 (2013-01-29),
'git clone -b' does not.  It would be helpful to.

	$ git clone -b 49c3e926349e964b311b46251bb2b97d3d669855 --depth=1 https://kernel.googlesource.com/pub/scm/git/git
	Cloning into 'git'...
	warning: Could not find remote branch 49c3e926349e964b311b46251bb2b97d3d669855 to clone.
	fatal: Remote branch 49c3e926349e964b311b46251bb2b97d3d669855 not found in upstream origin