git-branch -D: make it work even when on a yet-to-be-born branch
[gitweb.git] / git-checkout.sh
index eb28b291b6d1b7d77306bb3437b9955671e45d3a..737abd0c094ae6cfb201fb46c28f4962a9826a02 100755 (executable)
@@ -112,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