git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Git.pm: Fix internal git_command_bidi_pipe() users

From
Petr Baudis <pasky@suse.cz>
Date
Aug 4, 2008, 07:56 UTC
Message-ID
<20080804075313.21325.28396.stgit@localhost>
In-Reply-To
<be6fef0d0808032149p651309a8o773dca5f16923ee1@mail.gmail.com>

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};
 }
 
Previous: Abhijit Menon-SenNext: Junio C Hamano
Message 3 of 9 in “[git/perl] unusual syntax?”
  1. Ray ChuanAug 4, 2008
  2. Fix hash slice syntax errorAbhijit Menon-Sen, Aug 4, 2008
  3. Git.pm: Fix internal git_command_bidi_pipe() usersPetr Baudis, Aug 4, 2008
  4. Junio C HamanoAug 4, 2008
  5. Petr BaudisAug 4, 2008
  6. Junio C HamanoAug 4, 2008
  7. Git.pm: localise $? in command_close_bidi_pipe()Abhijit Menon-Sen, Aug 4, 2008
  8. Junio C HamanoAug 5, 2008
  9. David ChristensenAug 4, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.