Code

Teach the revision walker to walk by reflogs with --walk-reflogs
[git.git] / git-checkout.sh
index 8f4356d49a4935ff4a238cad3d0f90760d3e1afd..e02d4d87f622bf73ad04c356ff15ac6e0a626aa6 100755 (executable)
@@ -3,6 +3,7 @@
 USAGE='[-f] [-b <new_branch>] [-m] [<branch>] [<paths>...]'
 SUBDIRECTORY_OK=Sometimes
 . git-sh-setup
+require_work_tree
 
 old_name=HEAD
 old=$(git-rev-parse --verify $old_name 2>/dev/null)
@@ -134,11 +135,7 @@ fi
 
 # We are switching branches and checking out trees, so
 # we *NEED* to be at the toplevel.
-cdup=$(git-rev-parse --show-cdup)
-if test ! -z "$cdup"
-then
-       cd "$cdup"
-fi
+cd_to_toplevel
 
 [ -z "$new" ] && new=$old && new_name="$old_name"
 
@@ -204,8 +201,9 @@ else
        git diff-files --name-only | git update-index --remove --stdin &&
        work=`git write-tree` &&
        git read-tree --reset -u $new &&
-       git read-tree -m -u --aggressive --exclude-per-directory=.gitignore $old $new $work ||
-       exit
+       eval GITHEAD_$new=${new_name:-${branch:-$new}} GITHEAD_$work=local &&
+       export GITHEAD_$new GITHEAD_$work &&
+       git merge-recursive $old -- $new $work || exit
 
        if result=`git write-tree 2>/dev/null`
        then