Skip to content

Commit 10587ce

Browse files
committed
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 <[email protected]>
1 parent be39048 commit 10587ce

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

git-sh-setup.sh

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -218,27 +218,8 @@ clear_local_git_env() {
218218
unset $(git rev-parse --local-env-vars)
219219
}
220220
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
240221
241-
# Fix some commands on Windows
222+
# Platform specific tweaks to work around some commands
242223
case $(uname -s) in
243224
*MINGW*)
244225
# Windows has its own (incompatible) sort and find
@@ -269,3 +250,23 @@ case $(uname -s) in
269250
return 1
270251
}
271252
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

0 commit comments

Comments
 (0)