Adjust to ls-tree --full-name when run from a subdirectory.
authorJunio C Hamano <junkio@cox.net>
Fri, 23 Dec 2005 22:10:16 +0000 (14:10 -0800)
committerJunio C Hamano <junkio@cox.net>
Fri, 23 Dec 2005 22:10:16 +0000 (14:10 -0800)
A proposed change to show cwd relative paths by default from
ls-tree when run from a subdirectory means we would need to
give --full-name option to it.

Signed-off-by: Junio C Hamano <junkio@cox.net>
git-checkout.sh
index 36308d22c6a72b9ad53ced60bd3c70a2e17520b6..3bbd1117739b02572aece86030bb9f02f3110d34 100755 (executable)
@@ -1,6 +1,7 @@
 #!/bin/sh
 
 USAGE='[-f] [-b <new_branch>] [<branch>] [<paths>...]'
+SUBDIRECTORY_OK=Sometimes
 . git-sh-setup
 
 old=$(git-rev-parse HEAD)
@@ -79,7 +80,7 @@ then
                # from a specific tree-ish; note that this is for
                # rescuing paths and is never meant to remove what
                # is not in the named tree-ish.
-               git-ls-tree -r "$new" "$@" |
+               git-ls-tree --full-name -r "$new" "$@" |
                git-update-index --index-info || exit $?
        fi
        git-checkout-index -f -u -- "$@"
@@ -95,6 +96,14 @@ else
        fi
 fi
 
+# We are switching branches and checking out trees, so
+# we *NEED* to be at the toplevel.
+cdup=$(git-rev-parse --show-cdup)
+if test ! -z "$cdup"
+then
+       cd "$cdup"
+fi
+
 [ -z "$new" ] && new=$old
 
 # If we don't have an old branch that we're switching to,