Re: [PATCH] git-checkout: allow pathspec to recover lost working tree directory

Previous thread: [PATCH] git-checkout: do not allow -f and -m at the same time. by Junio C Hamano on Wednesday, November 15, 2006 - 3:06 pm. (1 message)

Next thread: [PATCH] Run "git repack -a -d" once more at end, if there's 1MB or more of not-packed data. by Jim Meyering on Wednesday, November 15, 2006 - 4:15 pm. (1 message)
To: <git@...>
Date: Wednesday, November 15, 2006 - 3:07 pm

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>
---
* Back to fixing usability issues one at a time instead of
throwing everything away with bathwater.

git-checkout.sh | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/git-checkout.sh b/git-checkout.sh
index eb28b29..737abd0 100755
--- a/git-checkout.sh
+++ b/git-checkout.sh
@@ -112,7 +112,11 @@ Did you intend to checkout '$@' which ca
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
--
1.4.4

-

To: Junio C Hamano <junkio@...>
Cc: <git@...>
Date: Friday, November 17, 2006 - 11:44 am

Wouldn't it be better to fix git-checkout-index to checkout a whole
directory if specified?

--
Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
#!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
$/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=pack('H*',/((..)*)$/)
-

Previous thread: [PATCH] git-checkout: do not allow -f and -m at the same time. by Junio C Hamano on Wednesday, November 15, 2006 - 3:06 pm. (1 message)

Next thread: [PATCH] Run "git repack -a -d" once more at end, if there's 1MB or more of not-packed data. by Jim Meyering on Wednesday, November 15, 2006 - 4:15 pm. (1 message)