git-sh-setup: define workaround wrappers before they are used
Recently we tweaked this scriptlet to let mingw port redefine "pwd" to always return Windows-style path, but the code to do so came after the first use of "pwd" to set up $GIT_DIR shell variable. Move the block to define these workaround wrappers, so that everything everything that executes when the scriptlet is dot-sourced uses the replacements. Noticed-by: Ramsay Jones Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
May 16, 2012 at 10:36 UTC
10587ce6dfb479cf4930657e173b673031deaa06
1 file changed
+21
-20
git-sh-setup.sh
+21
-20
@@ -218,27 +218,8 @@ clear_local_git_env() {
218
unset $(git rev-parse --local-env-vars)
219
}
220
221
-# Make sure we are in a valid repository of a vintage we understand,
222
-# if we require to be in a git repository.
223
-if test -z "$NONGIT_OK"
224
-then
225
- GIT_DIR=$(git rev-parse --git-dir) || exit
226
- if [ -z "$SUBDIRECTORY_OK" ]
227
- then
228
- test -z "$(git rev-parse --show-cdup)" || {
229
- exit=$?
230
- echo >&2 "You need to run this command from the toplevel of the working tree."
231
- exit $exit
232
- }
233
- fi
234
- test -n "$GIT_DIR" && GIT_DIR=$(cd "$GIT_DIR" && pwd) || {
235
- echo >&2 "Unable to determine absolute path of git directory"
236
- exit 1
237
- }
238
- : ${GIT_OBJECT_DIRECTORY="$GIT_DIR/objects"}
239
-fi
221
241
-# Fix some commands on Windows
222
+# Platform specific tweaks to work around some commands
223
case $(uname -s) in
224
*MINGW*)
225
# Windows has its own (incompatible) sort and find
@@ -269,3 +250,23 @@ case $(uname -s) in
250
return 1
251
}
252
esac
253
+
254
+# Make sure we are in a valid repository of a vintage we understand,
255
+# if we require to be in a git repository.
256
+if test -z "$NONGIT_OK"
257
+then
258
+ GIT_DIR=$(git rev-parse --git-dir) || exit
259
+ if [ -z "$SUBDIRECTORY_OK" ]
260
+ then
261
+ test -z "$(git rev-parse --show-cdup)" || {
262
+ exit=$?
263
+ echo >&2 "You need to run this command from the toplevel of the working tree."
264
+ exit $exit
265
+ }
266
+ fi
267
+ test -n "$GIT_DIR" && GIT_DIR=$(cd "$GIT_DIR" && pwd) || {
268
+ echo >&2 "Unable to determine absolute path of git directory"
269
+ exit 1
270
+ }
271
+ : ${GIT_OBJECT_DIRECTORY="$GIT_DIR/objects"}
272
+fi