From: Junio C Hamano Date: Wed, 15 Nov 2006 18:54:10 +0000 (-0800) Subject: git-checkout: allow pathspec to recover lost working tree directory X-Git-Tag: v1.4.4.1~21 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=bf7e1472df65c948581e2fecd494eccfaa40b9d9;p=git.git git-checkout: allow pathspec to recover lost working tree directory It is often wanted on the #git channel that this were to work to recover removed directory: rm -fr Documentation git checkout -- Documentation git checkout HEAD -- Documentation ;# alternatively Now it does. Signed-off-by: Junio C Hamano --- diff --git a/git-checkout.sh b/git-checkout.sh index eb28b291b..737abd0c0 100755 --- a/git-checkout.sh +++ b/git-checkout.sh @@ -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