Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH, 4th version] git-branch: register where to merge from, when branching off a remote branch

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:42:57
Subsystem: the rest · Maintainer: Linus Torvalds

Possibly related (same subject, not in this thread)

Junio C Hamano [off-list ref] writes:
I have a feeling that "git checkout -b" and "git checkout -B"
should be taught to explicitly use "git branch --no-track" and
"git branch --track" to create a new branch (currently it does
not even use "git branch" as far as I can tell).  With your
patch, I suspect that you have to say "git branch topic
origin/topic" and then "git checkout topic", which means you
made the three-step process into two steps, but you could have
made it into one step.  I'll send out an untested patch to
git-checkout so that you can try it out in a separate message.
This does not add -B because I haven't applied your patch to my
tree yet, but it should be obvious where to add --track/--no-track.

Oh, as usual, I only have tested it once, so it may or may not
work.

diff --git a/git-checkout.sh b/git-checkout.sh
index 14835a4..bdf5cdf 100755
--- a/git-checkout.sh
+++ b/git-checkout.sh
@@ -33,7 +33,7 @@ while [ "$#" != "0" ]; do
 			die "git checkout: we do not like '$newbranch' as a branch name."
 		;;
 	"-l")
-		newbranch_log=1
+		newbranch_log=-l
 		;;
 	"-f")
 		force=1
@@ -235,11 +235,7 @@ fi
 #
 if [ "$?" -eq 0 ]; then
 	if [ "$newbranch" ]; then
-		if [ "$newbranch_log" ]; then
-			mkdir -p $(dirname "$GIT_DIR/logs/refs/heads/$newbranch")
-			touch "$GIT_DIR/logs/refs/heads/$newbranch"
-		fi
-		git-update-ref -m "checkout: Created from $new_name" "refs/heads/$newbranch" $new || exit
+		git branch $newbranch_log "$newbranch" "$new_name" || exit
 		branch="$newbranch"
 	fi
 	if test -n "$branch"
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help