* [PATCH RESEND] Git.pm: Set GIT_WORK_TREE if we set GIT_DIR
@ 2009-05-07 13:41 Frank Lichtenheld
2009-05-07 13:41 ` [PATCH RESEND] Git.pm: Always set Repository to absolute path if autodetecting Frank Lichtenheld
2009-05-07 19:40 ` [PATCH RESEND] Git.pm: Set GIT_WORK_TREE if we set GIT_DIR Petr Baudis
0 siblings, 2 replies; 7+ messages in thread
From: Frank Lichtenheld @ 2009-05-07 13:41 UTC (permalink / raw)
To: gitster; +Cc: Petr Baudis, git
From: Frank Lichtenheld <flichtenheld@astaro.com>
Otherwise git will use the current directory as work tree which will
lead to unexpected results if we operate in sub directory of the
work tree.
Signed-off-by: Frank Lichtenheld <flichtenheld@astaro.com>
---
perl/Git.pm | 2 ++
t/t9700-perl-git.sh | 4 ++++
t/t9700/test.pl | 13 +++++++++++++
3 files changed, 19 insertions(+), 0 deletions(-)
No comments and doesn't seem to have been applied, so resent unchanged.
diff --git a/perl/Git.pm b/perl/Git.pm
index 291ff5b..4313db7 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -1280,6 +1280,8 @@ sub _cmd_exec {
my ($self, @args) = @_;
if ($self) {
$self->repo_path() and $ENV{'GIT_DIR'} = $self->repo_path();
+ $self->repo_path() and $self->wc_path()
+ and $ENV{'GIT_WORK_TREE'} = $self->wc_path();
$self->wc_path() and chdir($self->wc_path());
$self->wc_subdir() and chdir($self->wc_subdir());
}
diff --git a/t/t9700-perl-git.sh b/t/t9700-perl-git.sh
index b4ca244..4eb7d3f 100755
--- a/t/t9700-perl-git.sh
+++ b/t/t9700-perl-git.sh
@@ -29,6 +29,10 @@ test_expect_success \
git add . &&
git commit -m "first commit" &&
+ echo "new file in subdir 2" > directory2/file2 &&
+ git add . &&
+ git commit -m "commit in directory2" &&
+
echo "changed file 1" > file1 &&
git commit -a -m "second commit" &&
diff --git a/t/t9700/test.pl b/t/t9700/test.pl
index 697daf3..d9b29ea 100755
--- a/t/t9700/test.pl
+++ b/t/t9700/test.pl
@@ -98,3 +98,16 @@ TODO: {
todo_skip 'config after wc_chdir', 1;
is($r->config("color.string"), "value", "config after wc_chdir");
}
+
+# Object generation in sub directory
+chdir("directory2");
+my $r2 = Git->repository();
+is($r2->repo_path, $abs_repo_dir . "/.git", "repo_path (2)");
+is($r2->wc_path, $abs_repo_dir . "/", "wc_path (2)");
+is($r2->wc_subdir, "directory2/", "wc_subdir initial (2)");
+
+# commands in sub directory
+my $last_commit = $r2->command_oneline(qw(rev-parse --verify HEAD));
+like($last_commit, qr/^[0-9a-fA-F]{40}$/, 'rev-parse returned hash');
+my $dir_commit = $r2->command_oneline('log', '-n1', '--pretty=format:%H', '.');
+isnt($last_commit, $dir_commit, 'log . does not show last commit');
--
1.6.2.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH RESEND] Git.pm: Always set Repository to absolute path if autodetecting
2009-05-07 13:41 [PATCH RESEND] Git.pm: Set GIT_WORK_TREE if we set GIT_DIR Frank Lichtenheld
@ 2009-05-07 13:41 ` Frank Lichtenheld
2009-05-25 7:33 ` Johannes Sixt
2009-05-07 19:40 ` [PATCH RESEND] Git.pm: Set GIT_WORK_TREE if we set GIT_DIR Petr Baudis
1 sibling, 1 reply; 7+ messages in thread
From: Frank Lichtenheld @ 2009-05-07 13:41 UTC (permalink / raw)
To: gitster; +Cc: Petr Baudis, git
From: Frank Lichtenheld <flichtenheld@astaro.com>
So far we only set it to absolute paths in some cases which lead
to problems like wc_chdir not working.
Signed-off-by: Frank Lichtenheld <flichtenheld@astaro.com>
---
perl/Git.pm | 2 +-
t/t9700/test.pl | 10 ++--------
2 files changed, 3 insertions(+), 9 deletions(-)
Resent unchanged. There was one comment which I've reponded too and
argued that it didn't apply and there was no further objections.
diff --git a/perl/Git.pm b/perl/Git.pm
index 4313db7..e8df55d 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -185,7 +185,7 @@ sub repository {
if ($dir) {
$dir =~ m#^/# or $dir = $opts{Directory} . '/' . $dir;
- $opts{Repository} = $dir;
+ $opts{Repository} = abs_path($dir);
# If --git-dir went ok, this shouldn't die either.
my $prefix = $search->command_oneline('rev-parse', '--show-prefix');
diff --git a/t/t9700/test.pl b/t/t9700/test.pl
index d9b29ea..6c70aec 100755
--- a/t/t9700/test.pl
+++ b/t/t9700/test.pl
@@ -86,18 +86,12 @@ close TEMPFILE;
unlink $tmpfile;
# paths
-is($r->repo_path, "./.git", "repo_path");
+is($r->repo_path, $abs_repo_dir . "/.git", "repo_path");
is($r->wc_path, $abs_repo_dir . "/", "wc_path");
is($r->wc_subdir, "", "wc_subdir initial");
$r->wc_chdir("directory1");
is($r->wc_subdir, "directory1", "wc_subdir after wc_chdir");
-TODO: {
- local $TODO = "commands do not work after wc_chdir";
- # Failure output is active even in non-verbose mode and thus
- # annoying. Hence we skip these tests as long as they fail.
- todo_skip 'config after wc_chdir', 1;
- is($r->config("color.string"), "value", "config after wc_chdir");
-}
+is($r->config("test.string"), "value", "config after wc_chdir");
# Object generation in sub directory
chdir("directory2");
--
1.6.2.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH RESEND] Git.pm: Set GIT_WORK_TREE if we set GIT_DIR
2009-05-07 13:41 [PATCH RESEND] Git.pm: Set GIT_WORK_TREE if we set GIT_DIR Frank Lichtenheld
2009-05-07 13:41 ` [PATCH RESEND] Git.pm: Always set Repository to absolute path if autodetecting Frank Lichtenheld
@ 2009-05-07 19:40 ` Petr Baudis
1 sibling, 0 replies; 7+ messages in thread
From: Petr Baudis @ 2009-05-07 19:40 UTC (permalink / raw)
To: Frank Lichtenheld; +Cc: gitster, git
On Thu, May 07, 2009 at 03:41:27PM +0200, Frank Lichtenheld wrote:
> From: Frank Lichtenheld <flichtenheld@astaro.com>
>
> Otherwise git will use the current directory as work tree which will
> lead to unexpected results if we operate in sub directory of the
> work tree.
>
> Signed-off-by: Frank Lichtenheld <flichtenheld@astaro.com>
> ---
> perl/Git.pm | 2 ++
> t/t9700-perl-git.sh | 4 ++++
> t/t9700/test.pl | 13 +++++++++++++
> 3 files changed, 19 insertions(+), 0 deletions(-)
>
> No comments and doesn't seem to have been applied, so resent unchanged.
>
> diff --git a/perl/Git.pm b/perl/Git.pm
> index 291ff5b..4313db7 100644
> --- a/perl/Git.pm
> +++ b/perl/Git.pm
> @@ -1280,6 +1280,8 @@ sub _cmd_exec {
> my ($self, @args) = @_;
> if ($self) {
> $self->repo_path() and $ENV{'GIT_DIR'} = $self->repo_path();
> + $self->repo_path() and $self->wc_path()
> + and $ENV{'GIT_WORK_TREE'} = $self->wc_path();
> $self->wc_path() and chdir($self->wc_path());
> $self->wc_subdir() and chdir($self->wc_subdir());
> }
This looks obviously correct?
You could even skip the first chdir and use $self->wc_path() .
$self->wc_subdir() in the second one to save a syscall, I guess. ;-)
I've really forgot most of the code already so it's not worth much, but
Acked-by: Petr Baudis <pasky@suse.cz>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH RESEND] Git.pm: Always set Repository to absolute path if autodetecting
2009-05-07 13:41 ` [PATCH RESEND] Git.pm: Always set Repository to absolute path if autodetecting Frank Lichtenheld
@ 2009-05-25 7:33 ` Johannes Sixt
2009-05-27 10:54 ` Frank Lichtenheld
0 siblings, 1 reply; 7+ messages in thread
From: Johannes Sixt @ 2009-05-25 7:33 UTC (permalink / raw)
To: Frank Lichtenheld; +Cc: gitster, Petr Baudis, git
Frank Lichtenheld schrieb:
> From: Frank Lichtenheld <flichtenheld@astaro.com>
>
> So far we only set it to absolute paths in some cases which lead
> to problems like wc_chdir not working.
>
> Signed-off-by: Frank Lichtenheld <flichtenheld@astaro.com>
> ---
> perl/Git.pm | 2 +-
> t/t9700/test.pl | 10 ++--------
> 2 files changed, 3 insertions(+), 9 deletions(-)
>
> Resent unchanged. There was one comment which I've reponded too and
> argued that it didn't apply and there was no further objections.
>
> diff --git a/perl/Git.pm b/perl/Git.pm
> index 4313db7..e8df55d 100644
> --- a/perl/Git.pm
> +++ b/perl/Git.pm
> @@ -185,7 +185,7 @@ sub repository {
>
> if ($dir) {
> $dir =~ m#^/# or $dir = $opts{Directory} . '/' . $dir;
> - $opts{Repository} = $dir;
> + $opts{Repository} = abs_path($dir);
Unfortunately, this change breaks MinGW git because the absolute path that
this produces is MSYS-style /c/path/to/repo, but git does not understand
this; it should be c:/path/to/repo. This value is ultimately assigned to
GIT_DIR, but the path name mangling that usually happens when an MSYS
program (like perl) spawns a non-MSYS program (like git) does not happen.
Your commit message is quite vague about the problems that you have seen.
I vote to revert this change.
-- Hannes
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH RESEND] Git.pm: Always set Repository to absolute path if autodetecting
2009-05-25 7:33 ` Johannes Sixt
@ 2009-05-27 10:54 ` Frank Lichtenheld
2009-05-27 11:16 ` Johannes Sixt
0 siblings, 1 reply; 7+ messages in thread
From: Frank Lichtenheld @ 2009-05-27 10:54 UTC (permalink / raw)
To: Johannes Sixt; +Cc: gitster, Petr Baudis, git
On Mon, May 25, 2009 at 09:33:20AM +0200, Johannes Sixt wrote:
> Frank Lichtenheld schrieb:
> > From: Frank Lichtenheld <flichtenheld@astaro.com>
> >
> > So far we only set it to absolute paths in some cases which lead
> > to problems like wc_chdir not working.
> >
> > Signed-off-by: Frank Lichtenheld <flichtenheld@astaro.com>
> > ---
> > perl/Git.pm | 2 +-
> > t/t9700/test.pl | 10 ++--------
> > 2 files changed, 3 insertions(+), 9 deletions(-)
> >
> > Resent unchanged. There was one comment which I've reponded too and
> > argued that it didn't apply and there was no further objections.
> >
> > diff --git a/perl/Git.pm b/perl/Git.pm
> > index 4313db7..e8df55d 100644
> > --- a/perl/Git.pm
> > +++ b/perl/Git.pm
> > @@ -185,7 +185,7 @@ sub repository {
> >
> > if ($dir) {
> > $dir =~ m#^/# or $dir = $opts{Directory} . '/' . $dir;
> > - $opts{Repository} = $dir;
> > + $opts{Repository} = abs_path($dir);
>
> Unfortunately, this change breaks MinGW git because the absolute path that
> this produces is MSYS-style /c/path/to/repo, but git does not understand
> this; it should be c:/path/to/repo. This value is ultimately assigned to
> GIT_DIR, but the path name mangling that usually happens when an MSYS
> program (like perl) spawns a non-MSYS program (like git) does not happen.
>
> Your commit message is quite vague about the problems that you have seen.
> I vote to revert this change.
Note that abs_path is already used twice in the same function. Why are those
usages not problematic? I would be happy to work with you on finding a patch
that doesn't break, but I have to admit that I have no idea of the
Windows<->Perl<->git interactions.
As for the problems, a part of the public API of the module simply doesn't work
(i.e. wc_chdir) which I fixed. If we can't fix it we should at least not pretend
that it works.
Gruesse,
--
Frank Lichtenheld <frank@lichtenheld.de>
www: http://www.djpig.de/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH RESEND] Git.pm: Always set Repository to absolute path if autodetecting
2009-05-27 10:54 ` Frank Lichtenheld
@ 2009-05-27 11:16 ` Johannes Sixt
2009-05-27 13:46 ` Frank Lichtenheld
0 siblings, 1 reply; 7+ messages in thread
From: Johannes Sixt @ 2009-05-27 11:16 UTC (permalink / raw)
To: Frank Lichtenheld; +Cc: gitster, Petr Baudis, git
Frank Lichtenheld schrieb:
> On Mon, May 25, 2009 at 09:33:20AM +0200, Johannes Sixt wrote:
>> Frank Lichtenheld schrieb:
>>> --- a/perl/Git.pm
>>> +++ b/perl/Git.pm
>>> @@ -185,7 +185,7 @@ sub repository {
>>>
>>> if ($dir) {
>>> $dir =~ m#^/# or $dir = $opts{Directory} . '/' . $dir;
>>> - $opts{Repository} = $dir;
>>> + $opts{Repository} = abs_path($dir);
>> Unfortunately, this change breaks MinGW git because the absolute path that
>> this produces is MSYS-style /c/path/to/repo, but git does not understand
>> this; it should be c:/path/to/repo. This value is ultimately assigned to
>> GIT_DIR, but the path name mangling that usually happens when an MSYS
>> program (like perl) spawns a non-MSYS program (like git) does not happen.
>>
>> Your commit message is quite vague about the problems that you have seen.
>> I vote to revert this change.
>
> Note that abs_path is already used twice in the same function. Why are those
> usages not problematic? I would be happy to work with you on finding a patch
> that doesn't break, but I have to admit that I have no idea of the
> Windows<->Perl<->git interactions.
The result of abs_path() three lines below the cited context is never
passed to git; only its trailing part is ever used. This does not seem to
be problematic on Windows, according to the test suite.
The other use if abs_path() is about bare repositories and that is
certainly problematic, but nobody uses the tools written in perl in a bare
repository on Windows, obviously, otherwise we would have heard complaints. ;)
> As for the problems, a part of the public API of the module simply doesn't work
> (i.e. wc_chdir) which I fixed. If we can't fix it we should at least not pretend
> that it works.
Since you keep repeating "does not work", without any specifics, I can't
help (and I'm not going to find out myself what "does not work").
-- Hannes
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH RESEND] Git.pm: Always set Repository to absolute path if autodetecting
2009-05-27 11:16 ` Johannes Sixt
@ 2009-05-27 13:46 ` Frank Lichtenheld
0 siblings, 0 replies; 7+ messages in thread
From: Frank Lichtenheld @ 2009-05-27 13:46 UTC (permalink / raw)
To: Johannes Sixt; +Cc: gitster, Petr Baudis, git
On Wed, May 27, 2009 at 01:16:16PM +0200, Johannes Sixt wrote:
> Frank Lichtenheld schrieb:
> > As for the problems, a part of the public API of the module simply doesn't work
> > (i.e. wc_chdir) which I fixed. If we can't fix it we should at least not pretend
> > that it works.
>
> Since you keep repeating "does not work", without any specifics, I can't
> help (and I'm not going to find out myself what "does not work").
Oh, sorry, I thought that the core problem would be obvious from the related test
suite changes. I can elaborate on that later this evening when I'm not at work.
Gruesse,
--
Frank Lichtenheld <frank@lichtenheld.de>
www: http://www.djpig.de/
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-05-27 13:46 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-07 13:41 [PATCH RESEND] Git.pm: Set GIT_WORK_TREE if we set GIT_DIR Frank Lichtenheld
2009-05-07 13:41 ` [PATCH RESEND] Git.pm: Always set Repository to absolute path if autodetecting Frank Lichtenheld
2009-05-25 7:33 ` Johannes Sixt
2009-05-27 10:54 ` Frank Lichtenheld
2009-05-27 11:16 ` Johannes Sixt
2009-05-27 13:46 ` Frank Lichtenheld
2009-05-07 19:40 ` [PATCH RESEND] Git.pm: Set GIT_WORK_TREE if we set GIT_DIR Petr Baudis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).