@matheusbsbs / matheus-bagliano / commits / bf7e1472df
Fork 0

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 <junkio@cox.net>

Junio C Hamano committed Nov 15, 2006 at 10:54 UTC bf7e1472df65c948581e2fecd494eccfaa40b9d9
1 file changed +5 -1
git-checkout.sh
+5 -1
@@ -112,7 +112,11 @@ Did you intend to checkout '$@' which can not be resolved as commit?"
112 git-ls-tree --full-name -r "$new" "$@" |
113 git-update-index --index-info || exit $?
114 fi
115 - git-checkout-index -f -u -- "$@"
115 +
116 + # Make sure the request is about existing paths.
117 + git-ls-files --error-unmatch -- "$@" >/dev/null || exit
118 + git-ls-files -- "$@" |
119 + git-checkout-index -f -u --stdin
120 exit $?
121 else
122 # Make sure we did not fall back on $arg^{tree} codepath