public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Ramsay Jones <ramsay@ramsay1•demon.co.uk>
To: Junio C Hamano <gitster@pobox•com>
Cc: git@vger•kernel.org, Johannes Sixt <j.sixt@viscovery•net>,
	Steven Penny <svnpenn@gmail•com>
Subject: Re: [PATCH 1/2] git-sh-setup: define workaround wrappers before they are used
Date: Thu, 17 May 2012 23:36:01 +0100	[thread overview]
Message-ID: <4FB57D51.7050402@ramsay1.demon.co.uk> (raw)
In-Reply-To: <1337191208-21110-2-git-send-email-gitster@pobox.com>

Junio C Hamano wrote:
> 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>
> ---
>  git-sh-setup.sh | 41 +++++++++++++++++++++--------------------
>  1 file changed, 21 insertions(+), 20 deletions(-)
> 
> diff --git a/git-sh-setup.sh b/git-sh-setup.sh
> index 7b3ae75..770a86e 100644
> --- a/git-sh-setup.sh
> +++ b/git-sh-setup.sh
> @@ -218,27 +218,8 @@ clear_local_git_env() {
>  	unset $(git rev-parse --local-env-vars)
>  }
>  
> -# Make sure we are in a valid repository of a vintage we understand,
> -# if we require to be in a git repository.
> -if test -z "$NONGIT_OK"
> -then
> -	GIT_DIR=$(git rev-parse --git-dir) || exit
> -	if [ -z "$SUBDIRECTORY_OK" ]
> -	then
> -		test -z "$(git rev-parse --show-cdup)" || {
> -			exit=$?
> -			echo >&2 "You need to run this command from the toplevel of the working tree."
> -			exit $exit
> -		}
> -	fi
> -	test -n "$GIT_DIR" && GIT_DIR=$(cd "$GIT_DIR" && pwd) || {
> -		echo >&2 "Unable to determine absolute path of git directory"
> -		exit 1
> -	}
> -	: ${GIT_OBJECT_DIRECTORY="$GIT_DIR/objects"}
> -fi
>  
> -# Fix some commands on Windows
> +# Platform specific tweaks to work around some commands
>  case $(uname -s) in
>  *MINGW*)
>  	# Windows has its own (incompatible) sort and find
> @@ -269,3 +250,23 @@ case $(uname -s) in
>  		return 1
>  	}
>  esac
> +
> +# Make sure we are in a valid repository of a vintage we understand,
> +# if we require to be in a git repository.
> +if test -z "$NONGIT_OK"
> +then
> +	GIT_DIR=$(git rev-parse --git-dir) || exit
> +	if [ -z "$SUBDIRECTORY_OK" ]
> +	then
> +		test -z "$(git rev-parse --show-cdup)" || {
> +			exit=$?
> +			echo >&2 "You need to run this command from the toplevel of the working tree."
> +			exit $exit
> +		}
> +	fi
> +	test -n "$GIT_DIR" && GIT_DIR=$(cd "$GIT_DIR" && pwd) || {
> +		echo >&2 "Unable to determine absolute path of git directory"
> +		exit 1
> +	}
> +	: ${GIT_OBJECT_DIRECTORY="$GIT_DIR/objects"}
> +fi

Thanks for doing this. (I would have got around to it, honest! However, it does
solve a minor problem for me, since I kinda promised not to post anymore MinGW
specific patches. :-D ).

I have not done a full test on this patch; I have only run the following tests
on MinGW and cygwin:

    $ git grep -l -e 'git *submodule' -- t
    t/t5526-fetch-submodules.sh
    t/t6008-rev-list-submodule.sh
    t/t7003-filter-branch.sh
    t/t7400-submodule-basic.sh
    t/t7401-submodule-summary.sh
    t/t7403-submodule-sync.sh
    t/t7405-submodule-merge.sh
    t/t7406-submodule-update.sh
    t/t7407-submodule-foreach.sh
    t/t7408-submodule-reference.sh
    t/t7506-status-submodule.sh
    t/t7610-mergetool.sh
    t/t9300-fast-import.sh
    t/t9350-fast-export.sh

(On MinGW i have to use a "GIT_TEST_CMP='diff -ub'" prefix, otherwise there are
some failures caused by "lf/crlf line ending" problems).

All of these tests pass. I don't anticipate any problems (especially on cygwin,
since it is essentially a noop there), but I have not done a complete test.

I probably won't get to it soon, so I'm hoping somebody can beat me to it!

ATB,
Ramsay Jones

  reply	other threads:[~2012-05-17 23:16 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-06  4:24 Git commit path vs rebase path Steven Penny
2012-05-07 17:27 ` Junio C Hamano
2012-05-08  6:22   ` Johannes Sixt
2012-05-08  6:44     ` Steven Penny
2012-05-08  7:06       ` Johannes Sixt
2012-05-08  7:11         ` Steven Penny
2012-05-08 17:02           ` Junio C Hamano
2012-05-08 17:25             ` Junio C Hamano
2012-05-08 22:47               ` Steven Penny
2012-05-09 21:54                 ` Junio C Hamano
2012-05-09 23:14                   ` Steven Penny
2012-05-10 18:10                 ` Ramsay Jones
2012-05-11  4:35                   ` Steven Penny
2012-05-13 22:58                     ` Ramsay Jones
2012-05-13 23:42                       ` Steven Penny
2012-05-14  6:02                       ` Johannes Sixt
2012-05-15 17:32                         ` Ramsay Jones
2012-05-16  5:52                           ` Johannes Sixt
2012-05-17 18:30                             ` Ramsay Jones
2012-05-17 19:19                               ` Junio C Hamano
2012-05-16 18:00                         ` [PATCH 0/2] " Junio C Hamano
2012-05-16 18:00                           ` [PATCH 1/2] git-sh-setup: define workaround wrappers before they are used Junio C Hamano
2012-05-17 22:36                             ` Ramsay Jones [this message]
2012-05-16 18:00                           ` [PATCH 2/2] git-sh-setup: work around Cygwin path handling gotchas Junio C Hamano
2012-05-16 18:51                             ` Steven Penny
2012-05-16 19:02                               ` Junio C Hamano
2012-05-17 23:15                                 ` Ramsay Jones
2012-05-18  2:34                                   ` Junio C Hamano
2012-05-19  0:43                                     ` Steven Penny
2012-05-21 18:43                                     ` Ramsay Jones
2012-05-21 22:24                                       ` Junio C Hamano
2012-05-24 18:27                                         ` Ramsay Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4FB57D51.7050402@ramsay1.demon.co.uk \
    --to=ramsay@ramsay1$(echo .)demon.co.uk \
    --cc=git@vger$(echo .)kernel.org \
    --cc=gitster@pobox$(echo .)com \
    --cc=j.sixt@viscovery$(echo .)net \
    --cc=svnpenn@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox