git-sh-setup: move GIT_DIR initialization into a function
Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
David Aguilar committed
Oct 11, 2014 at 01:39 UTC
1c7e2d23e4f22f1599570d9c5d0cc2f4156b5b74
1 file changed
+6
-2
git-sh-setup.sh
+6
-2
@@ -330,8 +330,7 @@ esac
330
331
# Make sure we are in a valid repository of a vintage we understand,
332
# if we require to be in a git repository.
333
-if test -z "$NONGIT_OK"
334
-then
333
+git_dir_init () {
334
GIT_DIR=$(git rev-parse --git-dir) || exit
335
if [ -z "$SUBDIRECTORY_OK" ]
336
then
@@ -346,6 +345,11 @@ then
345
exit 1
346
}
347
: ${GIT_OBJECT_DIRECTORY="$GIT_DIR/objects"}
348
+}
349
+
350
+if test -z "$NONGIT_OK"
351
+then
352
+ git_dir_init
353
fi
354
355
peel_committish () {