threads / patch / 5411

patch, 2 partsgitweb: Remove git_to_hash function

Subject: [PATCH 2/2] gitweb: Remove git_to_hash function

## tl;dr

5 messages between Aug 27, 2006 and Aug 31, 2006. Diffs are folded; open one to read it.

replies: 4people: 3as markdown or json

Jakub Narebski· Aug 27, 2006, 21:43 UTC · lore

[PATCH 0/2] gitweb: Get rid of failed experiments ;-)

Remove unused subroutines or subroutines which don't work correctly from gitweb.

-- 
Jakub Narebski
Poland
Jakub Narebski· Aug 27, 2006, 21:44 UTC · re: Jakub Narebski · lore

[PATCH 1/2] gitweb: Remove unused git_get_{preceding,following}_references

Remove unused (and with errors in implementation) git_get_{preceding,following}_references subroutines.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
 gitweb/gitweb.perl |   51 ---------------------------------------------------
 1 files changed, 0 insertions(+), 51 deletions(-)
Show changes to gitweb/gitweb.perl +0 −51
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index ba5024a..6918947 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -784,57 +784,6 @@ sub git_get_references {
 	return \%refs;
 }
 
-sub git_get_following_references {
-	my $hash = shift || return undef;
-	my $type = shift;
-	my $base = shift || $hash_base || "HEAD";
-
-	my $refs = git_get_references($type);
-	open my $fd, "-|", $GIT, "rev-list", $base
-		or return undef;
-	my @commits = map { chomp; $_ } <$fd>;
-	close $fd
-		or return undef;
-
-	my @reflist;
-	my $lastref;
-
-	foreach my $commit (@commits) {
-		foreach my $ref (@{$refs->{$commit}}) {
-			$lastref = $ref;
-			push @reflist, $lastref;
-		}
-		if ($commit eq $hash) {
-			last;
-		}
-	}
-
-	return wantarray ? @reflist : $lastref;
-}
-
-sub git_get_preceding_references {
-	my $hash = shift || return undef;
-	my $type = shift;
-
-	my $refs = git_get_references($type);
-	open my $fd, "-|", $GIT, "rev-list", $hash
-		or return undef;
-	my @commits = map { chomp; $_ } <$fd>;
-	close $fd
-		or return undef;
-
-	my @reflist;
-
-	foreach my $commit (@commits) {
-		foreach my $ref (@{$refs->{$commit}}) {
-			return $ref unless wantarray;
-			push @reflist, $ref;
-		}
-	}
-
-	return @reflist;
-}
-
 sub git_get_rev_name_tags {
 	my $hash = shift || return undef;
 
-- 
1.4.1.1
Jakub Narebski· Aug 27, 2006, 21:45 UTC · re: Jakub Narebski · lore

Remove git_to_hash function, which was to translate symbolic reference to hash, and it's use in git_blobdiff. We don't try so hard to guess filename if it was not provided.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
 gitweb/gitweb.perl |   27 +++------------------------
 1 files changed, 3 insertions(+), 24 deletions(-)
Show changes to gitweb/gitweb.perl +3 −24
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 99c74f1..ae18c27 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -635,26 +635,6 @@ sub git_get_hash_by_path {
 	return $3;
 }
 
-# converts symbolic name to hash
-sub git_to_hash {
-	my @params = @_;
-	return undef unless @params;
-
-	open my $fd, "-|", $GIT, "rev-parse", @params
-		or return undef;
-	my @hashes = map { chomp; $_ } <$fd>;
-	close $fd;
-
-	if (wantarray) {
-		return @hashes;
-	} elsif (scalar(@hashes) == 1) {
-		# single hash
-		return $hashes[0];
-	} else {
-		return \@hashes;
-	}
-}
-
 ## ......................................................................
 ## git utility functions, directly accessing git repository
 
@@ -2739,10 +2719,9 @@ sub git_blobdiff {
 			@difftree
 				or die_error('404 Not Found', "Blob diff not found");
 
-		} elsif (defined $hash) { # try to find filename from $hash
-			if ($hash !~ /[0-9a-fA-F]{40}/) {
-				$hash = git_to_hash($hash);
-			}
+		} elsif (defined $hash &&
+		         $hash =~ /[0-9a-fA-F]{40}/) {
+			# try to find filename from $hash
 
 			# read filtered raw output
 			open $fd, "-|", $GIT, "diff-tree", '-r', @diff_opts, $hash_parent_base, $hash_base
-- 
1.4.1.1
Junio C Hamano· Aug 27, 2006, 22:22 UTC · re: Jakub Narebski · lore

Re: [PATCH 0/2] gitweb: Get rid of failed experiments ;-)

Jakub Narebski <jnareb@gmail.com> writes:
> Remove unused subroutines or subroutines which don't work correctly from 
> gitweb.

I'll apply both, thanks. [2/2] had a fuzz at the very end of the second hunk (your base version do not have -M to diff-tree parameter anymore) but that was easy to deal with.

Also thanks for the reminder about "typo in git_patchset_body".
Dennis Stosberg· Aug 31, 2006, 19:32 UTC · re: Junio C Hamano · lore

[PATCH] gitweb: Remove forgotten call to git_to_hash

On Aug 27th, Jakub Narebski sent a patch which removed the git_to_hash() function and this call to it. The patch did not apply cleanly and had to be applied manually. Removing the last chunk has obviously been forgotten.

See: commit  0aea33762b1262d11fb43eda9f3fc152b5622cca and
     message <200608272345.26722.jnareb@gmail.com>
Signed-off-by: Dennis Stosberg <dennis@stosberg.net>
---
 gitweb/gitweb.perl |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)
Show changes to gitweb/gitweb.perl +0 −4
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 9324d71..68f40bd 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2778,10 +2778,6 @@ sub git_blobdiff {
 			@difftree
 				or die_error('404 Not Found', "Blob diff not found");
 
-		} elsif (defined $hash) { # try to find filename from $hash
-			if ($hash !~ /[0-9a-fA-F]{40}/) {
-				$hash = git_to_hash($hash);
-			}
 		} elsif (defined $hash &&
 		         $hash =~ /[0-9a-fA-F]{40}/) {
 			# try to find filename from $hash
-- 
1.4.2

← back to recent threads