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

[PATCH 2/4] Git.pm: Add $path and $enable_filters arguments to hash_and_insert_object.

From
Matteo Bertini <naufraghi@develer.com>
Date
May 31, 2016, 15:07 UTC
Message-ID
<20160531150749.24840-3-naufraghi@develer.com>
In-Reply-To
<20160531150749.24840-1-naufraghi@develer.com>
From: Matteo Bertini <matteo@naufraghi.net>

The option $enable_filters skips the --no-filters option, the $path argument provide a path to be used alike the --path argument to hash-object in the non streaming invocation.

Signed-off-by: Matteo Bertini <naufraghi@develer.com>
---
 perl/Git.pm | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/perl/Git.pm b/perl/Git.pm
index ce7e4e8..6c2e3fc 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -963,11 +963,13 @@ The function returns the SHA1 hash.
 
 # TODO: Support for passing FILEHANDLE instead of FILENAME
 sub hash_and_insert_object {
-	my ($self, $filename) = @_;
-
-	carp "Bad filename \"$filename\"" if $filename =~ /[\r\n]/;
+	my ($self, $filename, $path, $enable_filters) = @_;
+	carp "Bad filename \"$filename\"" if $filename =~ /[\r\n\t]/;
+	if (defined($path)) {
+		$filename = join("\t", $filename, $path);
+	}
 
-	$self->_open_hash_and_insert_object_if_needed();
+	$self->_open_hash_and_insert_object_if_needed($enable_filters);
 	my ($in, $out) = ($self->{hash_object_in}, $self->{hash_object_out});
 
 	unless (print $out $filename, "\n") {
@@ -985,13 +987,18 @@ sub hash_and_insert_object {
 }
 
 sub _open_hash_and_insert_object_if_needed {
-	my ($self) = @_;
+	my ($self, $enable_filters) = @_;
 
 	return if defined($self->{hash_object_pid});
 
+	my @command = qw(hash-object -w --stdin-paths);
+	if (!$enable_filters) {
+		push(@command, "--no-filters");
+	}
+
 	($self->{hash_object_pid}, $self->{hash_object_in},
 	 $self->{hash_object_out}, $self->{hash_object_ctx}) =
-		$self->command_bidi_pipe(qw(hash-object -w --stdin-paths --no-filters));
+		$self->command_bidi_pipe(@command);
 }
 
 sub _close_hash_and_insert_object {
-- 
2.9.0.rc0.39.gb9f310b.dirty
Previous: Matteo BertiniNext: Matteo Bertini
Message 3 of 9 in “Add option to enable filters in git-svn”
  1. 0/4 Add option to enable filters in git-svnMatteo Bertini, May 31, 2016
  2. 1/4 hash-object.c: Allow distinct file/path in stdin mode too.Matteo Bertini, May 31, 2016
  3. 2/4 Git.pm: Add $path and $enable_filters arguments to hash_and_insert_object.Matteo Bertini, May 31, 2016
  4. 3/4 SVN/Fetcher.pm: Add svn-remote.<id>.enable-filters to enable the filters.Matteo Bertini, May 31, 2016
  5. 4/4 git-svn.perl: Add git svn init --enable-filters option.Matteo Bertini, May 31, 2016
  6. Matteo BertiniMay 31, 2016
  7. Eric WongMay 31, 2016
  8. Matteo BertiniMay 31, 2016
  9. Eric WongJun 2, 2016

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.