@matheusbsbs / matheus-bagliano / commits / 2a1ddc58e4
Fork 0

git-sh-setup: move the repository check to a core program.

Any core commands that use setup_git_directory() now check if given GIT_DIR is really a valid repository, so the same check in git-sh-setup can use it without reimplementing it in shell. This commit changes git-sh-setup to use git-var command for that, although any other commands would do. Note that we export GIT_DIR explicitly when calling git-var; without it, the caller of this script would use GIT_DIR that we return (which is to assume ./.git unless the caller has it elsewhere) while git-var would go up to find a .git directory in our parent directories, which would be checking a different directory from what our callers will be using. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Nov 25, 2005 at 15:52 UTC 2a1ddc58e4d2220feea7eba4623dac07a0f83f94
1 file changed +2 -7
git-sh-setup.sh
+2 -7
@@ -19,10 +19,5 @@ die() {
19 exit 1
20 }
21
22 -case "$(GIT_DIR="$GIT_DIR" git-symbolic-ref HEAD 2>/dev/null)" in
23 -refs/*) : ;;
24 -*) false ;;
25 -esac &&
26 -[ -d "$GIT_DIR/refs" ] &&
27 -[ -d "$GIT_OBJECT_DIRECTORY/" ] ||
28 - die "Not a git repository."
22 +# Make sure we are in a valid repository of a vintage we understand.
23 +GIT_DIR="$GIT_DIR" git-var GIT_AUTHOR_IDENT >/dev/null || exit