Code

git-reset: make it work from within a subdirectory.
authorJunio C Hamano <junkio@cox.net>
Thu, 14 Dec 2006 08:40:15 +0000 (00:40 -0800)
committerJunio C Hamano <junkio@cox.net>
Thu, 14 Dec 2006 10:45:51 +0000 (02:45 -0800)
If you typically sit in, say "src/", it's annoying to have to
change directory to do a reset.

This may need to be reworked when we add "git reset -- paths..."
to encapsulate the "ls-tree $tree | update-index --index-info"
pattern.

Signed-off-by: Junio C Hamano <junkio@cox.net>
git-reset.sh

index c0feb4435d15da9cc9928800cbe270018f044152..03d2c3b9378b4a4b39c4dc5a5ec3eb4b19c2f008 100755 (executable)
@@ -1,8 +1,15 @@
 #!/bin/sh
 
 USAGE='[--mixed | --soft | --hard]  [<commit-ish>]'
+SUBDIRECTORY_OK=Yes
 . git-sh-setup
 
+TOP=$(git-rev-parse --show-cdup)
+if test ! -z "$TOP"
+then
+       cd "$TOP"
+fi
+
 update=
 reset_type=--mixed
 case "$1" in