Skip to contentSkip to conversation

gitweb: Move git_get_last_activity subroutine earlier

PATCH In review Jakub Narebski 2 participants 5 messages Aug 11, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gitweb: Move git_get_last_activity subroutine earlier

---
Good test for git-pickaxe (git-blame2).

 gitweb/gitweb.perl |   36 ++++++++++++++++++------------------
 1 files changed, 18 insertions(+), 18 deletions(-)
gitweb/gitweb.perl +18 -18
index 5f6a562..cbab3c9 100755
@@ -976,6 +976,24 @@ sub git_get_project_owner {
 	return $owner;
 }
 
+sub git_get_last_activity {
+	my ($path) = @_;
+	my $fd;
+
+	$git_dir = "$projectroot/$path";
+	open($fd, "-|", git_cmd(), 'for-each-ref',
+	     '--format=%(refname) %(committer)',
+	     '--sort=-committerdate',
+	     'refs/heads') or return;
+	my $most_recent = <$fd>;
+	close $fd or return;
+	if ($most_recent =~ / (\d+) [-+][01]\d\d\d$/) {
+		my $timestamp = $1;
+		my $age = time - $timestamp;
+		return ($age, age_string($age));
+	}
+}
+
 sub git_get_references {
 	my $type = shift || "";
 	my %refs;
@@ -1082,24 +1100,6 @@ sub parse_tag {
 	return %tag
 }
 
-sub git_get_last_activity {
-	my ($path) = @_;
-	my $fd;
-
-	$git_dir = "$projectroot/$path";
-	open($fd, "-|", git_cmd(), 'for-each-ref',
-	     '--format=%(refname) %(committer)',
-	     '--sort=-committerdate',
-	     'refs/heads') or return;
-	my $most_recent = <$fd>;
-	close $fd or return;
-	if ($most_recent =~ / (\d+) [-+][01]\d\d\d$/) {
-		my $timestamp = $1;
-		my $age = time - $timestamp;
-		return ($age, age_string($age));
-	}
-}
-
 sub parse_commit {
 	my $commit_id = shift;
 	my $commit_text = shift;
Signature · 1 line
1.4.3.3
#4 lore raw
In reply to Jakub Narebski
Quoted 10 lines · Jakub Narebski
Quoted 1 line · Junio C Hamano

Why is this needed?

This is purely cosmetic, and originally was to be first patch in series converting git_summary, git_heads and git_tags to use of git-for-each-ref... but unfortunately git-for-each-ref lacks sorting on taggerdate OR committerdate (i.e. use taggerdate if applicable, committerdate otherwise).

I'd rather not have git_get_last_activity between two parse_* subroutines...

Ok, will apply but the last line of your response _should_ have been in the proposed commit log message without being asked.

#3 lore raw
In reply to Junio C Hamano
Quoted 1 line · Junio C Hamano

Why is this needed?

This is purely cosmetic, and originally was to be first patch in series converting git_summary, git_heads and git_tags to use of git-for-each-ref... but unfortunately git-for-each-ref lacks sorting on taggerdate OR committerdate (i.e. use taggerdate if applicable, committerdate otherwise).

I'd rather not have git_get_last_activity between two parse_* subroutines...

Signature · 3 lines
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git