* [git/perl] unusual syntax?
@ 2008-08-04 4:49 Ray Chuan
2008-08-04 5:02 ` [PATCH] Fix hash slice syntax error Abhijit Menon-Sen
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Ray Chuan @ 2008-08-04 4:49 UTC (permalink / raw)
To: git
Hi,
i noticed that this doesn't work for me (Perl 5.10):
sub _close_hash_and_insert_object {
my ($self) = @_;
return unless defined($self->{hash_object_pid});
my @vars = map { 'hash_object_' . $_ } qw(pid in out ctx);
command_close_bidi_pipe($self->{@vars});
delete $self->{@vars};
}
$self->{@vars} evaluates to undef. i can't find any mention of using
arrays to dereference objects in the manual and elsewhere; is this a
mistake?
--
Cheers,
Ray Chuan
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] Fix hash slice syntax error
2008-08-04 4:49 [git/perl] unusual syntax? Ray Chuan
@ 2008-08-04 5:02 ` Abhijit Menon-Sen
2008-08-04 7:56 ` [PATCH] Git.pm: Fix internal git_command_bidi_pipe() users Petr Baudis
2008-08-04 15:01 ` [git/perl] unusual syntax? David Christensen
2 siblings, 0 replies; 9+ messages in thread
From: Abhijit Menon-Sen @ 2008-08-04 5:02 UTC (permalink / raw)
To: Ray Chuan; +Cc: git
Signed-off-by: Abhijit Menon-Sen <ams@toroid.org>
---
At 2008-08-04 12:49:27 +0800, rctay89@gmail.com wrote:
>
> $self->{@vars} evaluates to undef. i can't find any mention of using
> arrays to dereference objects in the manual and elsewhere; is this a
> mistake?
Yes, @vars would be interpreted in scalar context, which certainly isn't
the intended effect.
-- ams
perl/Git.pm | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/perl/Git.pm b/perl/Git.pm
index 087d3d0..2ef437f 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -839,8 +839,8 @@ sub _close_hash_and_insert_object {
my @vars = map { 'hash_object_' . $_ } qw(pid in out ctx);
- command_close_bidi_pipe($self->{@vars});
- delete $self->{@vars};
+ command_close_bidi_pipe(@$self{@vars});
+ delete @$self{@vars};
}
=item cat_blob ( SHA1, FILEHANDLE )
@@ -928,8 +928,8 @@ sub _close_cat_blob {
my @vars = map { 'cat_blob_' . $_ } qw(pid in out ctx);
- command_close_bidi_pipe($self->{@vars});
- delete $self->{@vars};
+ command_close_bidi_pipe(@$self{@vars});
+ delete @$self{@vars};
}
=back
--
1.6.0.rc0.43.g2aa74
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH] Git.pm: Fix internal git_command_bidi_pipe() users
2008-08-04 4:49 [git/perl] unusual syntax? Ray Chuan
2008-08-04 5:02 ` [PATCH] Fix hash slice syntax error Abhijit Menon-Sen
@ 2008-08-04 7:56 ` Petr Baudis
2008-08-04 8:05 ` Junio C Hamano
2008-08-04 15:01 ` [git/perl] unusual syntax? David Christensen
2 siblings, 1 reply; 9+ messages in thread
From: Petr Baudis @ 2008-08-04 7:56 UTC (permalink / raw)
To: gitster; +Cc: git
The hash_and_insert_object() and cat_blob() helpers were using
an incorrect slice-from-ref Perl syntax. This patch fixes that up
in the _close_*() helpers and make the _open_*() helpers use the
same syntax for consistnecy.
Signed-off-by: Petr Baudis <pasky@suse.cz>
---
Wow, the command_bidi_pipe API really is dirty. Of course, it is
my fault as anyone's since I didn't get around to review the patches
introducing it.
perl/Git.pm | 16 ++++++----------
1 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/perl/Git.pm b/perl/Git.pm
index 087d3d0..0624428 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -827,8 +827,7 @@ sub _open_hash_and_insert_object_if_needed {
return if defined($self->{hash_object_pid});
- ($self->{hash_object_pid}, $self->{hash_object_in},
- $self->{hash_object_out}, $self->{hash_object_ctx}) =
+ @$self{map { "hash_object_$_" } qw(pid in out ctx)} =
command_bidi_pipe(qw(hash-object -w --stdin-paths));
}
@@ -837,9 +836,8 @@ sub _close_hash_and_insert_object {
return unless defined($self->{hash_object_pid});
- my @vars = map { 'hash_object_' . $_ } qw(pid in out ctx);
-
- command_close_bidi_pipe($self->{@vars});
+ my @vars = map { "hash_object_$_" } qw(pid in out ctx);
+ command_close_bidi_pipe(@$self{@vars});
delete $self->{@vars};
}
@@ -916,8 +914,7 @@ sub _open_cat_blob_if_needed {
return if defined($self->{cat_blob_pid});
- ($self->{cat_blob_pid}, $self->{cat_blob_in},
- $self->{cat_blob_out}, $self->{cat_blob_ctx}) =
+ @$self{map { "cat_blob_$_" } qw(pid in out ctx)} =
command_bidi_pipe(qw(cat-file --batch));
}
@@ -926,9 +923,8 @@ sub _close_cat_blob {
return unless defined($self->{cat_blob_pid});
- my @vars = map { 'cat_blob_' . $_ } qw(pid in out ctx);
-
- command_close_bidi_pipe($self->{@vars});
+ my @vars = map { "cat_blob_$_" } qw(pid in out ctx);
+ command_close_bidi_pipe(@$self{@vars});
delete $self->{@vars};
}
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] Git.pm: Fix internal git_command_bidi_pipe() users
2008-08-04 7:56 ` [PATCH] Git.pm: Fix internal git_command_bidi_pipe() users Petr Baudis
@ 2008-08-04 8:05 ` Junio C Hamano
2008-08-04 8:21 ` Petr Baudis
0 siblings, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2008-08-04 8:05 UTC (permalink / raw)
To: Petr Baudis; +Cc: git
Petr Baudis <pasky@suse.cz> writes:
> The hash_and_insert_object() and cat_blob() helpers were using
> an incorrect slice-from-ref Perl syntax. This patch fixes that up
> in the _close_*() helpers and make the _open_*() helpers use the
> same syntax for consistnecy.
>
> Signed-off-by: Petr Baudis <pasky@suse.cz>
> ---
>
> Wow, the command_bidi_pipe API really is dirty. Of course, it is
> my fault as anyone's since I didn't get around to review the patches
> introducing it.
Sorry, delete is still broken with your patch, isn't it?
The earlier patch from Abhijit Menon-Sen does this properly for
close_hash_and_insert and close_cat_blob, which I've queued already.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Git.pm: Fix internal git_command_bidi_pipe() users
2008-08-04 8:05 ` Junio C Hamano
@ 2008-08-04 8:21 ` Petr Baudis
2008-08-04 8:37 ` Junio C Hamano
0 siblings, 1 reply; 9+ messages in thread
From: Petr Baudis @ 2008-08-04 8:21 UTC (permalink / raw)
To: Junio C Hamano, ams; +Cc: git
On Mon, Aug 04, 2008 at 01:05:56AM -0700, Junio C Hamano wrote:
> Petr Baudis <pasky@suse.cz> writes:
>
> > The hash_and_insert_object() and cat_blob() helpers were using
> > an incorrect slice-from-ref Perl syntax. This patch fixes that up
> > in the _close_*() helpers and make the _open_*() helpers use the
> > same syntax for consistnecy.
> >
> > Signed-off-by: Petr Baudis <pasky@suse.cz>
> > ---
> >
> > Wow, the command_bidi_pipe API really is dirty. Of course, it is
> > my fault as anyone's since I didn't get around to review the patches
> > introducing it.
>
> Sorry, delete is still broken with your patch, isn't it?
Oh, right - I forgot that one and it didn't occur to me to test this
part.
> The earlier patch from Abhijit Menon-Sen does this properly for
> close_hash_and_insert and close_cat_blob, which I've queued already.
Abhijit, can you please tag your Git.pm patches so that I actually have
a chance to see and review it?
Thanks,
Petr "Pasky" Baudis
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Git.pm: Fix internal git_command_bidi_pipe() users
2008-08-04 8:21 ` Petr Baudis
@ 2008-08-04 8:37 ` Junio C Hamano
2008-08-04 11:38 ` [PATCH] Git.pm: localise $? in command_close_bidi_pipe() Abhijit Menon-Sen
0 siblings, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2008-08-04 8:37 UTC (permalink / raw)
To: Petr Baudis; +Cc: ams, git
Petr Baudis <pasky@suse.cz> writes:
> On Mon, Aug 04, 2008 at 01:05:56AM -0700, Junio C Hamano wrote:
>> Petr Baudis <pasky@suse.cz> writes:
>>
>> > The hash_and_insert_object() and cat_blob() helpers were using
>> > an incorrect slice-from-ref Perl syntax. This patch fixes that up
>> > in the _close_*() helpers and make the _open_*() helpers use the
>> > same syntax for consistnecy.
>> >
>> > Signed-off-by: Petr Baudis <pasky@suse.cz>
>> > ---
>> >
>> > Wow, the command_bidi_pipe API really is dirty. Of course, it is
>> > my fault as anyone's since I didn't get around to review the patches
>> > introducing it.
>>
>> Sorry, delete is still broken with your patch, isn't it?
>
> Oh, right - I forgot that one and it didn't occur to me to test this
> part.
>
>> The earlier patch from Abhijit Menon-Sen does this properly for
>> close_hash_and_insert and close_cat_blob, which I've queued already.
>
> Abhijit, can you please tag your Git.pm patches so that I actually have
> a chance to see and review it?
It is $gmane/91316, Message-ID: <20080804050247.GA13539@toroid.org>
After queueing it, I actually had to revert it, because it seems to break
git-svn (t9106-git-svn-commit-diff-clobber.sh, test #8), and I am about to
go to bed. If you did not see the same breakage with your patch that does
not "fix" delete, it could be that the git-svn uses some of the resources
that are released by the delete actually doing what it is asked to do.
---
At 2008-08-04 12:49:27 +0800, rctay89@gmail.com wrote:
>
> $self->{@vars} evaluates to undef. i can't find any mention of using
> arrays to dereference objects in the manual and elsewhere; is this a
> mistake?
Yes, @vars would be interpreted in scalar context, which certainly isn't
the intended effect.
-- ams
perl/Git.pm | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/perl/Git.pm b/perl/Git.pm
index 087d3d0..2ef437f 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -839,8 +839,8 @@ sub _close_hash_and_insert_object {
my @vars = map { 'hash_object_' . $_ } qw(pid in out ctx);
- command_close_bidi_pipe($self->{@vars});
- delete $self->{@vars};
+ command_close_bidi_pipe(@$self{@vars});
+ delete @$self{@vars};
}
=item cat_blob ( SHA1, FILEHANDLE )
@@ -928,8 +928,8 @@ sub _close_cat_blob {
my @vars = map { 'cat_blob_' . $_ } qw(pid in out ctx);
- command_close_bidi_pipe($self->{@vars});
- delete $self->{@vars};
+ command_close_bidi_pipe(@$self{@vars});
+ delete @$self{@vars};
}
=back
--
1.6.0.rc0.43.g2aa74
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH] Git.pm: localise $? in command_close_bidi_pipe()
2008-08-04 8:37 ` Junio C Hamano
@ 2008-08-04 11:38 ` Abhijit Menon-Sen
2008-08-05 6:12 ` Junio C Hamano
0 siblings, 1 reply; 9+ messages in thread
From: Abhijit Menon-Sen @ 2008-08-04 11:38 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Petr Baudis, git
Git::DESTROY calls _close_cat_blob and _close_hash_and_insert_object,
which in turn call command_close_bidi_pipe, which calls waitpid, which
alters $?. If this happens during global destruction, it may alter the
program's exit status unexpectedly. Making $? local to the function
solves the problem.
(The problem was discovered due to a failure of test #8 in
t9106-git-svn-commit-diff-clobber.sh.)
Signed-off-by: Abhijit Menon-Sen <ams@toroid.org>
---
At 2008-08-04 01:37:06 -0700, gitster@pobox.com wrote:
>
> After queueing it, I actually had to revert it, because it seems to
> break git-svn (t9106-git-svn-commit-diff-clobber.sh, test #8), and I
> am about to go to bed.
This patch in addition to my earlier one should solve the problem.
For test #8 to fail, the "git svn dcommit" must succeed, but in both
cases (i.e. without my patch applied, or with), the rebase fails:
rebase refs/remotes/git-svn: command returned error: 1
This results in a call to "fatal $@" on git-svn.perl:254, which calls
"exit 1", and test_must_fail is happy.
With my patch, however, Git::DESTROY calls the two _close functions
during global destruction, which in turn call command_close_bidi_pipe,
which calls waitpid with sensible arguments this time, which alters $?,
thus altering the exit status of the dcommit itself to 0. Oops.
All of "make test" passes for me after this change.
-- ams
perl/Git.pm | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/perl/Git.pm b/perl/Git.pm
index 2ef437f..3b6707b 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -417,6 +417,7 @@ have more complicated structure.
=cut
sub command_close_bidi_pipe {
+ local $?;
my ($pid, $in, $out, $ctx) = @_;
foreach my $fh ($in, $out) {
unless (close $fh) {
--
1.6.0.rc0.43.g2aa74
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [git/perl] unusual syntax?
2008-08-04 4:49 [git/perl] unusual syntax? Ray Chuan
2008-08-04 5:02 ` [PATCH] Fix hash slice syntax error Abhijit Menon-Sen
2008-08-04 7:56 ` [PATCH] Git.pm: Fix internal git_command_bidi_pipe() users Petr Baudis
@ 2008-08-04 15:01 ` David Christensen
2 siblings, 0 replies; 9+ messages in thread
From: David Christensen @ 2008-08-04 15:01 UTC (permalink / raw)
To: Ray Chuan; +Cc: git
> sub _close_hash_and_insert_object {
> my ($self) = @_;
>
> return unless defined($self->{hash_object_pid});
>
> my @vars = map { 'hash_object_' . $_ } qw(pid in out ctx);
>
> command_close_bidi_pipe($self->{@vars});
> delete $self->{@vars};
> }
> $self->{@vars} evaluates to undef. i can't find any mention of using
> arrays to dereference objects in the manual and elsewhere; is this a
> mistake?
This is a hash slice notation, returning an array of hash values
matching the corresponding keys. 5.10 removed some syntax warts in
the case of hash slices; this is more portably expressed as @{$self}
{@vars}; this should work in 5.10 and earlier versions, and so is the
preferred syntax.
Regards,
David
--
David Christensen
End Point Corporation
david@endpoint.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Git.pm: localise $? in command_close_bidi_pipe()
2008-08-04 11:38 ` [PATCH] Git.pm: localise $? in command_close_bidi_pipe() Abhijit Menon-Sen
@ 2008-08-05 6:12 ` Junio C Hamano
0 siblings, 0 replies; 9+ messages in thread
From: Junio C Hamano @ 2008-08-05 6:12 UTC (permalink / raw)
To: Abhijit Menon-Sen; +Cc: Petr Baudis, git
Abhijit Menon-Sen <ams@toroid.org> writes:
> With my patch, however, Git::DESTROY calls the two _close functions
> during global destruction, which in turn call command_close_bidi_pipe,
> which calls waitpid with sensible arguments this time, which alters $?,
> thus altering the exit status of the dcommit itself to 0. Oops.
Thanks.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2008-08-05 6:13 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-04 4:49 [git/perl] unusual syntax? Ray Chuan
2008-08-04 5:02 ` [PATCH] Fix hash slice syntax error Abhijit Menon-Sen
2008-08-04 7:56 ` [PATCH] Git.pm: Fix internal git_command_bidi_pipe() users Petr Baudis
2008-08-04 8:05 ` Junio C Hamano
2008-08-04 8:21 ` Petr Baudis
2008-08-04 8:37 ` Junio C Hamano
2008-08-04 11:38 ` [PATCH] Git.pm: localise $? in command_close_bidi_pipe() Abhijit Menon-Sen
2008-08-05 6:12 ` Junio C Hamano
2008-08-04 15:01 ` [git/perl] unusual syntax? David Christensen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.