[RFC/PATCH] Re: git submodule -b ... of current HEAD fails

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



	git submodule add -b $branch $repository

fails when HEAD already points to $branch in $repository.

Reported-by: Klaus Ethgen <Klaus@xxxxxxxxx>
Signed-off-by: Jonathan Nieder <jrnieder@xxxxxxxxx>
---
Hi Klaus,

Klaus Ethgen wrote at <http://bugs.debian.org/605600>:

> Strange problem, if I create a submodule of an other repository giving
> the currently used HEAD branch I get the error: Âfatal: git checkout:
> branch myimbabranch already exists while when giving other branch
> work well.

Interesting.  The problem is in cmd_add of git-submodule.sh; this
patch demonstrates a quick fix.  Jens, any idea why git submodule
is not using "clone --branch" directly?

diff --git a/git-submodule.sh b/git-submodule.sh
index 33bc41f..6242d7f 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -241,7 +241,7 @@ cmd_add()
 			# ash fails to wordsplit ${branch:+-b "$branch"...}
 			case "$branch" in
 			'') git checkout -f -q ;;
-			?*) git checkout -f -q -b "$branch" "origin/$branch" ;;
+			?*) git checkout -f -q -B "$branch" "origin/$branch" ;;
 			esac
 		) || die "Unable to checkout submodule '$path'"
 	fi
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]