Code

Merge branch 'maint'
authorJunio C Hamano <gitster@pobox.com>
Fri, 8 Jun 2007 09:55:19 +0000 (02:55 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 8 Jun 2007 09:55:19 +0000 (02:55 -0700)
* maint:
  checkout: do not get confused with ambiguous tag/branch names

1  2 
git-checkout.sh

diff --combined git-checkout.sh
index d561c88dcbd3d5a67b4b6725e00683e613d80b9b,7c5ca3d62f85b78ec82f02c2045435d889c32cdd..33f1e87c0c209b89eb785381db62d826818b602d
@@@ -63,12 -63,13 +63,13 @@@ while [ "$#" != "0" ]; d
                                echo "unknown flag $arg"
                                exit 1
                        fi
-                       new="$rev"
                        new_name="$arg"
                        if git-show-ref --verify --quiet -- "refs/heads/$arg"
                        then
+                               rev=$(git-rev-parse --verify "refs/heads/$arg^0")
                                branch="$arg"
                        fi
+                       new="$rev"
                elif rev=$(git-rev-parse --verify "$arg^{tree}" 2>/dev/null)
                then
                        # checking out selected paths from a tree-ish.
@@@ -210,7 -211,7 +211,7 @@@ els
        esac
  
        # Match the index to the working tree, and do a three-way.
 -      git diff-files --name-only | git update-index --remove --stdin &&
 +      git diff-files --name-only | git update-index --remove --stdin &&
        work=`git write-tree` &&
        git read-tree $v --reset -u $new || exit
  
      (exit $saved_err)
  fi
  
 -# 
 +#
  # Switch the HEAD pointer to the new branch if we
  # checked out a branch head, and remove any potential
  # old MERGE_HEAD's (subsequent commits will clearly not
@@@ -270,7 -271,15 +271,7 @@@ if [ "$?" -eq 0 ]; the
                fi
        elif test -n "$detached"
        then
 -              # NEEDSWORK: we would want a command to detach the HEAD
 -              # atomically, instead of this handcrafted command sequence.
 -              # Perhaps:
 -              #       git update-ref --detach HEAD $new
 -              # or something like that...
 -              #
 -              git-rev-parse HEAD >"$GIT_DIR/HEAD.new" &&
 -              mv "$GIT_DIR/HEAD.new" "$GIT_DIR/HEAD" &&
 -              git-update-ref -m "checkout: moving to $arg" HEAD "$detached" ||
 +              git-update-ref --no-deref -m "checkout: moving to $arg" HEAD "$detached" ||
                        die "Cannot detach HEAD"
                if test -n "$detach_warn"
                then