From: Junio C Hamano Date: Fri, 02 Mar 2007 09:55:25 GMT Subject: Re: [PATCH, 4th version] git-branch: register where to merge from, when branching off a remote branch Message-ID: <7vmz2wezqq.fsf@assigned-by-dhcp.cox.net> In-Reply-To: <7vtzx4ezvm.fsf@assigned-by-dhcp.cox.net> Junio C Hamano 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"