Merge branch 'maint'
[gitweb.git] / git-checkout.sh
index 119bca1ffbfb8fb0dae404a8e7389f577aebc42c..4192a99fec1e137599b250a4f65c1b1e4201c601 100755 (executable)
@@ -77,6 +77,11 @@ while [ "$#" != "0" ]; do
     esac
 done
 
+case "$force$merge" in
+11)
+       die "git checkout: -f and -m are incompatible"
+esac
+
 # The behaviour of the command with and without explicit path
 # parameters is quite different.
 #
@@ -107,7 +112,11 @@ Did you intend to checkout '$@' which can not be resolved as commit?"
                git-ls-tree --full-name -r "$new" "$@" |
                git-update-index --index-info || exit $?
        fi
-       git-checkout-index -f -u -- "$@"
+
+       # Make sure the request is about existing paths.
+       git-ls-files --error-unmatch -- "$@" >/dev/null || exit
+       git-ls-files -- "$@" |
+       git-checkout-index -f -u --stdin
        exit $?
 else
        # Make sure we did not fall back on $arg^{tree} codepath
@@ -152,7 +161,7 @@ then
     git-read-tree --reset -u $new
 else
     git-update-index --refresh >/dev/null
-    merge_error=$(git-read-tree -m -u $old $new 2>&1) || (
+    merge_error=$(git-read-tree -m -u --exclude-per-directory=.gitignore $old $new 2>&1) || (
        case "$merge" in
        '')
                echo >&2 "$merge_error"
@@ -163,7 +172,8 @@ 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 $old $new $work || exit
+       git read-tree -m -u --aggressive --exclude-per-directory=.gitignore $old $new $work ||
+       exit
 
        if result=`git write-tree 2>/dev/null`
        then