Git development
 help / color / mirror / Atom feed
* [PATCH 13/14] gitweb: CSS style and refs mark for detached HEAD
From: Giuseppe Bilotta @ 2007-08-31 11:19 UTC (permalink / raw)
  To: git; +Cc: Giuseppe Bilotta
In-Reply-To: <11885591653402-git-send-email-giuseppe.bilotta@gmail.com>

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 gitweb/gitweb.css  |    5 +++++
 gitweb/gitweb.perl |    2 +-
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/gitweb/gitweb.css b/gitweb/gitweb.css
index c36b20a..59ca071 100644
--- a/gitweb/gitweb.css
+++ b/gitweb/gitweb.css
@@ -498,6 +498,11 @@ span.refs span.head {
 	border-color: #ccffcc #00cc33 #00cc33 #ccffcc;
 }
 
+span.refs span.detached {
+	background-color: #ffaaaa;
+	border-color: #ccffcc #00cc33 #00cc33 #ccffcc;
+}
+
 span.atnight {
 	color: #cc0000;
 }
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 4f7b7da..2c8a665 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1690,7 +1690,7 @@ sub git_get_references {
 	my %refs;
 	if (git_is_head_detached()) {
 		my $hash = git_get_head_hash($project);
-		$refs{$hash} = [ 'HEAD' ];
+		$refs{$hash} = [ 'detached/HEAD' ];
 	}
 	# 5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c refs/tags/v2.6.11
 	# c39ae07f393806ccf406ef966e9a15afc43cc36a refs/tags/v2.6.11^{}
-- 
1.5.2.5

^ permalink raw reply related

* [PATCH 12/14] gitweb: add HEAD to list of shortlog refs if detached
From: Giuseppe Bilotta @ 2007-08-31 11:19 UTC (permalink / raw)
  To: git; +Cc: Giuseppe Bilotta
In-Reply-To: <11885591601143-git-send-email-giuseppe.bilotta@gmail.com>

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 gitweb/gitweb.perl |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index a745434..4f7b7da 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1688,6 +1688,10 @@ sub git_get_last_activity {
 sub git_get_references {
 	my $type = shift || "";
 	my %refs;
+	if (git_is_head_detached()) {
+		my $hash = git_get_head_hash($project);
+		$refs{$hash} = [ 'HEAD' ];
+	}
 	# 5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c refs/tags/v2.6.11
 	# c39ae07f393806ccf406ef966e9a15afc43cc36a refs/tags/v2.6.11^{}
 	open my $fd, "-|", git_cmd(), "show-ref", "--dereference",
-- 
1.5.2.5

^ permalink raw reply related

* [PATCH 11/14] gitweb: git_is_head_detached() function
From: Giuseppe Bilotta @ 2007-08-31 11:19 UTC (permalink / raw)
  To: git; +Cc: Giuseppe Bilotta
In-Reply-To: <11885591542097-git-send-email-giuseppe.bilotta@gmail.com>

The function checks if the HEAD for the current project is detached by checking if 'git branch' returns "* (no branch)"

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 gitweb/gitweb.perl |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index e743c3d..a745434 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1416,6 +1416,13 @@ sub git_get_head_hash {
 	return $retval;
 }
 
+# check if current HEAD is detached
+sub git_is_head_detached {
+	my @x = (git_cmd(), 'branch');
+	my @ret = split("\n", qx(@x));
+	return 0 + grep { /^* \(no branch\)$/ } @ret;
+}
+
 # get type of given object
 sub git_get_type {
 	my $hash = shift;
@@ -2091,11 +2098,9 @@ sub git_get_heads_list {
 	my @headslist;
 
 	if (grep { $_ eq 'heads' } @class) {
-		my @x = (git_cmd(), 'branch');
-		my @ret = split("\n", qx(@x));
-		if (grep { /^* \(no branch\)$/ } @ret) { ;
+		if (git_is_head_detached()) { ;
 			my %ref_item;
-			@x = (git_cmd(), 'log', '-1', '--pretty=format:%H%n%ct%n%s');
+			my @x = (git_cmd(), 'log', '-1', '--pretty=format:%H%n%ct%n%s');
 			my ($hash, $epoch, $title) = split("\n", qx(@x), 3);
 
 			$ref_item{'class'} = 'head';
-- 
1.5.2.5

^ permalink raw reply related

* [PATCH 10/14] gitweb: display HEAD in heads list when detached
From: Giuseppe Bilotta @ 2007-08-31 11:19 UTC (permalink / raw)
  To: git; +Cc: Giuseppe Bilotta
In-Reply-To: <cb7bb73a0708301915y47ca4a05nf511889b2bb2eaec@mail.gmail.com>

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 gitweb/gitweb.perl |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 09d9793..e743c3d 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2090,6 +2090,27 @@ sub git_get_heads_list {
 	my @refs = map { "refs/$_" } @class ;
 	my @headslist;
 
+	if (grep { $_ eq 'heads' } @class) {
+		my @x = (git_cmd(), 'branch');
+		my @ret = split("\n", qx(@x));
+		if (grep { /^* \(no branch\)$/ } @ret) { ;
+			my %ref_item;
+			@x = (git_cmd(), 'log', '-1', '--pretty=format:%H%n%ct%n%s');
+			my ($hash, $epoch, $title) = split("\n", qx(@x), 3);
+
+			$ref_item{'class'} = 'head';
+			$ref_item{'name'} = 'HEAD';
+			$ref_item{'id'} = $hash;
+			$ref_item{'title'} = $title || '(no commit message)';
+			if ($ref_item{'epoch'} = $epoch) {
+				$ref_item{'age'} = age_string(time - $ref_item{'epoch'});
+			} else {
+				$ref_item{'age'} = "unknown";
+			}
+			push @headslist, \%ref_item;
+		}
+	}
+
 	open my $fd, '-|', git_cmd(), 'for-each-ref',
 		($limit ? '--count='.($limit+1) : ()), '--sort=-committerdate',
 		'--format=%(objectname) %(refname) %(subject)%00%(committer)',
-- 
1.5.2.5

^ permalink raw reply related

* [PATCH 09/14] gitweb: split heads list in head view if appropriate
From: Giuseppe Bilotta @ 2007-08-31 11:18 UTC (permalink / raw)
  To: git; +Cc: Giuseppe Bilotta
In-Reply-To: <11885591283893-git-send-email-giuseppe.bilotta@gmail.com>

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 gitweb/gitweb.perl |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 6dfb2f4..09d9793 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -4195,6 +4195,9 @@ sub git_heads {
 
 	my @headslist = git_get_heads_list();
 	if (@headslist) {
+		my ($remote_heads) = gitweb_check_feature('remote_heads');
+		$remote_heads ? 
+		git_split_heads_body(\@headslist, $head) :
 		git_heads_body(\@headslist, $head);
 	}
 	git_footer_html();
-- 
1.5.2.5

^ permalink raw reply related

* [PATCH 08/14] gitweb: add 'remotes' action as a synonym for git_heads()
From: Giuseppe Bilotta @ 2007-08-31 11:18 UTC (permalink / raw)
  To: git; +Cc: Giuseppe Bilotta
In-Reply-To: <11885591201440-git-send-email-giuseppe.bilotta@gmail.com>

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 gitweb/gitweb.perl |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index dc9727e..6dfb2f4 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -562,6 +562,7 @@ my %actions = (
 	"commit" => \&git_commit,
 	"forks" => \&git_forks,
 	"heads" => \&git_heads,
+	"remotes" => \&git_heads,
 	"history" => \&git_history,
 	"log" => \&git_log,
 	"rss" => \&git_rss,
-- 
1.5.2.5

^ permalink raw reply related

* [PATCH 07/14] gitweb: use CSS to style split head lists.
From: Giuseppe Bilotta @ 2007-08-31 11:18 UTC (permalink / raw)
  To: git; +Cc: Giuseppe Bilotta
In-Reply-To: <cb7bb73a0708301915y47ca4a05nf511889b2bb2eaec@mail.gmail.com>

Introduce a new div class 'subsection' in the CSS and use it to style split head lists.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 gitweb/gitweb.css  |   10 ++++++++++
 gitweb/gitweb.perl |    4 +++-
 2 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/gitweb/gitweb.css b/gitweb/gitweb.css
index 1b88879..c36b20a 100644
--- a/gitweb/gitweb.css
+++ b/gitweb/gitweb.css
@@ -8,6 +8,16 @@ body {
 	color: #000000;
 }
 
+div.subsection {
+	border: solid #d9d8d1;
+	border-width: 1px;
+	margin: 10px;
+}
+
+.subsection .title {
+	font-size: smaller;
+}
+
 a {
 	color: #0000cc;
 }
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index cacb0d7..dc9727e 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -3665,9 +3665,11 @@ sub git_split_heads_body {
 	} @$headlist;
 
 	foreach $leader (sort(keys %headlists)) {
-		print "<b>$leader</b><br/>\n" unless $leader eq "\000";
+		print "<div class=\"subsection\">\n";
+		git_print_header_div(undef, $leader) unless $leader eq "\000";
 		$list = $headlists{$leader};
 		git_heads_body($list, $head, $from, $to, $extra);
+		print "</div>\n";
 	}
 }
 
-- 
1.5.2.5

^ permalink raw reply related

* [PATCH 06/14] gitweb: git_split_heads_body function.
From: Giuseppe Bilotta @ 2007-08-31 11:05 UTC (permalink / raw)
  To: git; +Cc: Giuseppe Bilotta
In-Reply-To: <cb7bb73a0708301915y47ca4a05nf511889b2bb2eaec@mail.gmail.com>

The purpose of this function is to split a headlist into groups determined by the leading part of the refname, and call git_heads_body() on each group.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 gitweb/gitweb.perl |   33 ++++++++++++++++++++++++++++++++-
 1 files changed, 32 insertions(+), 1 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index c46e982..cacb0d7 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -3640,6 +3640,37 @@ sub git_tags_body {
 	print "</table>\n";
 }
 
+sub git_split_heads_body {
+	my ($headlist, $head, $from, $to, $extra) = @_;
+	my %headlists;
+	my $leader; my $list; my @list;
+
+	# Split @$headlist into a hash of lists
+	map {
+		my %ref = %$_;
+		$ref{'hname'} = $ref{'name'};
+		if ($ref{'name'} =~ /\//) {
+			$ref{'name'} =~ s!^([^/]+)/!!;
+			$leader = $1;
+		} else {
+			$leader = "\000";
+		}
+		if (defined $headlists{$leader}) {
+			@list = @{$headlists{$leader}}
+		} else {
+			@list = ()
+		}
+		push @list, \%ref;
+		$headlists{$leader} = [@list];
+	} @$headlist;
+
+	foreach $leader (sort(keys %headlists)) {
+		print "<b>$leader</b><br/>\n" unless $leader eq "\000";
+		$list = $headlists{$leader};
+		git_heads_body($list, $head, $from, $to, $extra);
+	}
+}
+
 sub git_heads_body {
 	# uses global variable $project
 	my ($headlist, $head, $from, $to, $extra) = @_;
@@ -3880,7 +3911,7 @@ sub git_summary {
 
 	if (@remotelist) {
 		git_print_header_div('remotes');
-		git_heads_body(\@remotelist, $head, 0, 15,
+		git_split_heads_body(\@remotelist, $head, 0, 15,
 		               $#remotelist <= 15 ? undef :
 		               $cgi->a({-href => href(action=>"heads")}, "..."));
 	}
-- 
1.5.2.5

^ permalink raw reply related

* [PATCH 05/14] gitweb: allow refs passed to git_heads_body to use a name different from the hash name
From: Giuseppe Bilotta @ 2007-08-31 10:59 UTC (permalink / raw)
  To: git; +Cc: Giuseppe Bilotta
In-Reply-To: <cb7bb73a0708301915y47ca4a05nf511889b2bb2eaec@mail.gmail.com>

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 gitweb/gitweb.perl |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 6aec28e..c46e982 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -3657,16 +3657,18 @@ sub git_heads_body {
 		} else {
 			print "<tr class=\"light\">\n";
 		}
+		my $hname = $ref{'hname'} || $ref{'name'};
+		my $name = $ref{'name'};
 		$alternate ^= 1;
 		print "<td><i>$ref{'age'}</i></td>\n" .
 		      ($curr ? "<td class=\"current_head\">" : "<td>") .
-		      $cgi->a({-href => href(action=>"shortlog", hash=>$ref{'name'}),
-		               -class => "list name"},esc_html($ref{'name'})) .
+		      $cgi->a({-href => href(action=>"shortlog", hash=>$hname),
+		               -class => "list name"},esc_html($name)) .
 		      "</td>\n" .
 		      "<td class=\"link\">" .
-		      $cgi->a({-href => href(action=>"shortlog", hash=>$ref{'name'})}, "shortlog") . " | " .
-		      $cgi->a({-href => href(action=>"log", hash=>$ref{'name'})}, "log") . " | " .
-		      $cgi->a({-href => href(action=>"tree", hash=>$ref{'name'}, hash_base=>$ref{'name'})}, "tree") .
+		      $cgi->a({-href => href(action=>"shortlog", hash=>$hname)}, "shortlog") . " | " .
+		      $cgi->a({-href => href(action=>"log", hash=>$hname)}, "log") . " | " .
+		      $cgi->a({-href => href(action=>"tree", hash=>$hname, hash_base=>$hname)}, "tree") .
 		      "</td>\n" .
 		      "</tr>";
 	}
-- 
1.5.2.5

^ permalink raw reply related

* [PATCH 04/14] gitweb: separate heads and remotes list in summary view
From: Giuseppe Bilotta @ 2007-08-31 10:55 UTC (permalink / raw)
  To: git; +Cc: Giuseppe Bilotta
In-Reply-To: <cb7bb73a0708301915y47ca4a05nf511889b2bb2eaec@mail.gmail.com>

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 gitweb/gitweb.perl |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 4b27352..6aec28e 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -3804,6 +3804,7 @@ sub git_summary {
 	my %co = parse_commit("HEAD");
 	my %cd = %co ? parse_date($co{'committer_epoch'}, $co{'committer_tz'}) : ();
 	my $head = $co{'id'};
+	my ($remote_heads) = gitweb_check_feature('remote_heads');
 
 	my $owner = git_get_project_owner($project);
 
@@ -3811,7 +3812,8 @@ sub git_summary {
 	# These get_*_list functions return one more to allow us to see if
 	# there are more ...
 	my @taglist  = git_get_tags_list(16);
-	my @headlist = git_get_heads_list(16);
+	my @headlist = git_get_heads_list(16, 'heads');
+	my @remotelist = $remote_heads ? git_get_heads_list(16, 'remotes') : ();
 	my @forklist;
 	my ($check_forks) = gitweb_check_feature('forks');
 
@@ -3874,6 +3876,13 @@ sub git_summary {
 		               $cgi->a({-href => href(action=>"heads")}, "..."));
 	}
 
+	if (@remotelist) {
+		git_print_header_div('remotes');
+		git_heads_body(\@remotelist, $head, 0, 15,
+		               $#remotelist <= 15 ? undef :
+		               $cgi->a({-href => href(action=>"heads")}, "..."));
+	}
+
 	if (@forklist) {
 		git_print_header_div('forks');
 		git_project_list_body(\@forklist, undef, 0, 15,
-- 
1.5.2.5

^ permalink raw reply related

* [PATCH 03/14] gitweb: git_get_heads_list now accepts an optional list of refs.
From: Giuseppe Bilotta @ 2007-08-31 10:55 UTC (permalink / raw)
  To: git; +Cc: Giuseppe Bilotta
In-Reply-To: <cb7bb73a0708301915y47ca4a05nf511889b2bb2eaec@mail.gmail.com>

git_get_heads_list(limit, dir1, dir2, ...) can now be used to retrieve refs/dir1, refs/dir2 etc.
Defaults to ('heads') or ('heads', 'remotes') depending on the remote_heads option.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 gitweb/gitweb.perl |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 6514bef..4b27352 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2081,15 +2081,18 @@ sub parse_from_to_diffinfo {
 ## parse to array of hashes functions
 
 sub git_get_heads_list {
-	my $limit = shift;
+	my ($limit, @class) = @_;
+	unless (defined @class) {
+		my ($remote_heads) = gitweb_check_feature('remote_heads');
+		@class = ('heads', $remote_heads ? 'remotes' : undef);
+	}
+	my @refs = map { "refs/$_" } @class ;
 	my @headslist;
 
-	my ($remote_heads) = gitweb_check_feature('remote_heads');
-
 	open my $fd, '-|', git_cmd(), 'for-each-ref',
 		($limit ? '--count='.($limit+1) : ()), '--sort=-committerdate',
 		'--format=%(objectname) %(refname) %(subject)%00%(committer)',
-		'refs/heads', ( $remote_heads ? 'refs/remotes' : '')
+		@refs
 		or return;
 	while (my $line = <$fd>) {
 		my %ref_item;
-- 
1.5.2.5

^ permalink raw reply related

* [PATCH 02/14] gitweb: make remote heads in heads list optional
From: Giuseppe Bilotta @ 2007-08-31 10:55 UTC (permalink / raw)
  To: git; +Cc: Giuseppe Bilotta
In-Reply-To: <cb7bb73a0708301915y47ca4a05nf511889b2bb2eaec@mail.gmail.com>

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 gitweb/gitweb.perl |   28 +++++++++++++++++++++++++++-
 1 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 65953db..6514bef 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -271,6 +271,18 @@ our %feature = (
 	'forks' => {
 		'override' => 0,
 		'default' => [0]},
+
+	# Make gitweb show remotes too in the heads list
+
+	# To enable system wide have in $GITWEB_CONFIG
+	# $feature{'remote_heads'}{'default'} = [1];
+	# To have project specific config enable override in $GITWEB_CONFIG
+	# $feature{'remote_heads'}{'override'} = 1;
+	# and in project config gitweb.remote_heads = 0|1;
+	'remote_heads' => {
+		'sub' => \&feature_remote_heads,
+		'override' => 0,
+		'default' => [0]},
 );
 
 sub gitweb_check_feature {
@@ -336,6 +348,18 @@ sub feature_pickaxe {
 	return ($_[0]);
 }
 
+sub feature_remote_heads {
+	my ($val) = git_get_project_config('remote_heads', '--bool');
+
+	if ($val eq 'true') {
+		return (1);
+	} elsif ($val eq 'false') {
+		return (0);
+	}
+
+	return ($_[0]);
+}
+
 # checking HEAD file with -e is fragile if the repository was
 # initialized long time ago (i.e. symlink HEAD) and was pack-ref'ed
 # and then pruned.
@@ -2060,10 +2084,12 @@ sub git_get_heads_list {
 	my $limit = shift;
 	my @headslist;
 
+	my ($remote_heads) = gitweb_check_feature('remote_heads');
+
 	open my $fd, '-|', git_cmd(), 'for-each-ref',
 		($limit ? '--count='.($limit+1) : ()), '--sort=-committerdate',
 		'--format=%(objectname) %(refname) %(subject)%00%(committer)',
-		'refs/heads', 'refs/remotes'
+		'refs/heads', ( $remote_heads ? 'refs/remotes' : '')
 		or return;
 	while (my $line = <$fd>) {
 		my %ref_item;
-- 
1.5.2.5

^ permalink raw reply related

* [PATCH 01/14] gitweb: get remotes too when getting heads list
From: Giuseppe Bilotta @ 2007-08-31 10:54 UTC (permalink / raw)
  To: git; +Cc: Giuseppe Bilotta
In-Reply-To: <cb7bb73a0708301915y47ca4a05nf511889b2bb2eaec@mail.gmail.com>

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 gitweb/gitweb.perl |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index b2bae1b..65953db 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2063,7 +2063,7 @@ sub git_get_heads_list {
 	open my $fd, '-|', git_cmd(), 'for-each-ref',
 		($limit ? '--count='.($limit+1) : ()), '--sort=-committerdate',
 		'--format=%(objectname) %(refname) %(subject)%00%(committer)',
-		'refs/heads'
+		'refs/heads', 'refs/remotes'
 		or return;
 	while (my $line = <$fd>) {
 		my %ref_item;
@@ -2073,8 +2073,9 @@ sub git_get_heads_list {
 		my ($hash, $name, $title) = split(' ', $refinfo, 3);
 		my ($committer, $epoch, $tz) =
 			($committerinfo =~ /^(.*) ([0-9]+) (.*)$/);
-		$name =~ s!^refs/heads/!!;
+		$name =~ s!^refs/(head|remote)s/!!;
 
+		$ref_item{'class'} = $1;
 		$ref_item{'name'}  = $name;
 		$ref_item{'id'}    = $hash;
 		$ref_item{'title'} = $title || '(no commit message)';
-- 
1.5.2.5

^ permalink raw reply related

* Re: Buffer overflows
From: Wincent Colaiuta @ 2007-08-31 10:52 UTC (permalink / raw)
  To: Reece Dunn; +Cc: Timo Sirainen, Linus Torvalds, git
In-Reply-To: <3f4fd2640708301534k40f07a1cva90a59d12ace6138@mail.gmail.com>

El 31/8/2007, a las 0:34, Reece Dunn escribió:

> As an example, do your safe API do null pointer checks. This is
> because strcpy, strlen and the like don't, which is one of the reasons
> why they are considered unsafe. But then, if you guarantee that you
> are not passing a null pointer to one of these API, why take the hit
> of the additional checks when you know that these are safe.

Do you really think that comparing a pointer to NULL is going to be a  
speed hit? I would imagine that on most architectures it boils down  
to one or two machine code instructions.

Cheers,
Wincent

^ permalink raw reply

* Re: [BUG] (minor) Cloning an empty repository
From: Petr Baudis @ 2007-08-31 10:10 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: git
In-Reply-To: <vpqk5rc10mx.fsf@bauges.imag.fr>

  Hi,

On Fri, Aug 31, 2007 at 12:03:50PM CEST, Matthieu Moy wrote:
> That's a detail, but it would be better if either git could actually
> do the clone, or give me a clean error message like "Can not clone
> empty repository".

FWIW, I would like git to clone empty repositories too. With the current
smart remotes handling, it will pick up the first branches as they
appear in the other repository automagically. And with e.g. repo.or.cz,
if you are starting a project from scratch this would be useful. Sure,
you can instead git init && git remote add origin git+ssh://.../, but
this fact seems to be confusing not-so-git-well-versed people.

Now, I guess you'd like a patch... ;-)

-- 
				Petr "Pasky" Baudis
Early to rise and early to bed makes a male healthy and wealthy and dead.
                -- James Thurber

^ permalink raw reply

* Re: Buffer overflows
From: Johannes Schindelin @ 2007-08-31 10:06 UTC (permalink / raw)
  To: Timo Sirainen; +Cc: Linus Torvalds, git
In-Reply-To: <1188536430.29782.903.camel@hurina>

Hi,

On Fri, 31 Aug 2007, Timo Sirainen wrote:

> On Thu, 2007-08-30 at 21:09 -0700, Linus Torvalds wrote:
> 
> > So yes, I bet there are faster string libraries out there.
> 
> Oh, well that's easy to fix. But I don't think the speed matters much in 
> string manipulation, it's usually not done in performance critical 
> paths.

AFAIR one of the recent performance studies showed strlen() as one of the 
_biggest_ offenders.  So no, your point has been disproven _already_.

I have to wonder, though, why you do not just go and enhance strbuf.[ch], 
which is nice and easy, and not the least unelegant.

Ciao,
Dscho

^ permalink raw reply

* [BUG] (minor) Cloning an empty repository
From: Matthieu Moy @ 2007-08-31 10:03 UTC (permalink / raw)
  To: git

Hi,

Git fails to clone an empty repository (no commit yet), but claims it
does:

/tmp$ mkdir empty
/tmp$ cd empty
/tmp/empty$ git init
Initialized empty Git repository in .git/
/tmp/empty$ cd ../
/tmp$ git clone empty my-clone
Initialized empty Git repository in /tmp/my-clone/.git/

# All seems correct.

/tmp$ cd my-clone
cd: no such file or directory: my-clone

# Gosh, git lied when telling me it initialized
# /tmp/my-clone/.git/ ? ;-)

A quick look at the code tells me that the directory was actually
initialized, but later, at git-clone.sh:282,

			# objects directory should not be empty because
			# we are cloning!
			test -f "$repo/$sample_file" || exit

and the exit is trapped to "cleanup()" which rm -fr the directory.
Unfortunately, just commenting-out this line isn't sufficient, it
leaves me with a half-initialized repository (.git/config/ doesn't
contain the "origin" remote).

That's a detail, but it would be better if either git could actually
do the clone, or give me a clean error message like "Can not clone
empty repository".

If no one does anything better, the following patch can be a very
small step forward.


>From fdbb61bb9ac26627c4786b58f38426bde621cdcb Mon Sep 17 00:00:00 2001
From: Matthieu Moy <Matthieu.Moy@imag.fr>
Date: Fri, 31 Aug 2007 12:00:09 +0200
Subject: [PATCH] Slightly more informative error message when cloning an empty repository.

---
 git-clone.sh |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/git-clone.sh b/git-clone.sh
index 18003ab..1aad510 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -278,7 +278,11 @@ yes)
 				      find objects -type f -print | sed -e 1q)
 			# objects directory should not be empty because
 			# we are cloning!
-			test -f "$repo/$sample_file" || exit
+			if test \! -f "$repo/$sample_file"
+			then
+				echo "No objects in repository. Cleaning up ..." >&2
+				exit
+			fi
 			if ln "$repo/$sample_file" "$GIT_DIR/objects/sample" 2>/dev/null
 			then
 				rm -f "$GIT_DIR/objects/sample"
-- 
1.5.3.rc6.49.gd50b


PS: In case someone's interested, my use-case is the following:

I have ~/archives/git/ which contains git tree-less repositories
(normally bare repository, but sometimes simply normal repositories in
which I didn't checkout), and I have a working tree somewhere else in
my $HOME (or on my /local, faster but not backed-up). I set my commit
hook to "git push --all", so it's a kind of centralized system inside
my machine. Just to separate the stuff that matters (repositories),
and the others (working tree).

To start a new project, I can either create the repository with the
working tree, and clone it to ~/archives/git/some-project, but it's
more conveinient to create ~/archives/git/some-project and then clone
it somewhere else, since it sets up the "origin" remote for me, and
push/pull work out of the box.

-- 
Matthieu

^ permalink raw reply related

* Re: Buffer overflows
From: Andreas Ericsson @ 2007-08-31  9:53 UTC (permalink / raw)
  To: Timo Sirainen; +Cc: Linus Torvalds, git
In-Reply-To: <1188536430.29782.903.camel@hurina>

Timo Sirainen wrote:
> On Thu, 2007-08-30 at 21:09 -0700, Linus Torvalds wrote:
>> On Fri, 31 Aug 2007, Timo Sirainen wrote:
>>>> Perhaps because your patch was using a totally nonstandard and slow
>>>> interface, and had nasty string declaration issues, as people even pointed
>>>> out to you.
>>> Slow?
>> Having a string library, and then implementing "str_append()" with a 
>> strlen() sounds pretty disgusting to me. 
>>
>> Gcc could have optimized the strlen() away for constant string arguments, 
>> but since you made the thing out-of-line, it can't do that any more.
>>
>> So yes, I bet there are faster string libraries out there.
> 
> Oh, well that's easy to fix. But I don't think the speed matters much in
> string manipulation, it's usually not done in performance critical
> paths.
> 

In git it is, as strings are manipulated en masse in order to traverse
history, look up paths from index/filesystem etc, etc.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

^ permalink raw reply

* Re: [PATCH] Add commands that git-gc runs underneath
From: Andreas Ericsson @ 2007-08-31  9:33 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Johannes Schindelin, Jari Aalto, git
In-Reply-To: <7v7inc907e.fsf@gitster.siamese.dyndns.org>

Junio C Hamano wrote:
> Andreas Ericsson <ae@op5.se> writes:
> 
>> When gc was a shell-script, it was fairly easy to find out the command-
>> sequence...
> 
> Maybe referring more advanced/curious users to contrib/examples/
> directory is a good idea, but not necessarily from manpages of
> the commands that have been rewritten in C.
> 
> I think contrib/examples/ needs a README file that effectively
> say "these are the last versions of shell script implementation
> of the commands before they were rewritten in C.  New features
> may have been added to the built-in ones but these example
> scripts are not kept up to date.  They are here to serve as
> examples to show you how you would pipeline the plumbing level
> commands."
> 

Sensible, and also avoids the possible bitrot problem with the
man-page should there be additional actions added to standard
git-gc operations.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

^ permalink raw reply

* Re: [PATCH] Test for windows format absolute paths on cygwin too
From: Johannes Sixt @ 2007-08-31  9:31 UTC (permalink / raw)
  To: Robin Rosenberg; +Cc: git
In-Reply-To: <xMhwifY1.1188551240.4001640.roro@localhost>

Robin Rosenberg schrieb:
> ---
> 
> Requires cherry-picking 6397c3119ecaa258b5185315c64062bec29bcd86

... which you find in mingw.git.

However, that commit is not signed-off for a reason: It is going to be 
rewritten mostly because it doesn't yet use the is_absolute_path() from 
git-compat-util.h.

-- Hannes

^ permalink raw reply

* Regression in gitk from git-1.5.3-rc7
From: Adam Piątyszek @ 2007-08-31  6:26 UTC (permalink / raw)
  To: git

Hi!

First of all thanks for this great piece of software you are providing
for the community! I am a refugee from the SVN camp, BTW. ;-)

To the point...

Today I noticed a problem in gitk from git-1.5.3-rc7 package, which I
think did not exist in rc5. The problem is as follows:

I am working with two parallel branches (master and stable). And I often
use the cherry-pick option from gitk context menu to pick some patches
from the master branch to the stable one (I cannot merge, because stable
is a tracking branch of some remote SVN repository).
If the picked patch does not apply cleanly on stable, I fix the problem
in editor, then switch to git-gui to update the index and commit this
conflicted commit to the stable branch.

Now, I go back to gitk, and *without* updating the view (using <F5> for
instance), I try to cherry pick another patch from my master branch.
And in such a situation I got this error from git-gui:

===== cut here =====

can't read "arcnos(6e9a6c5fdabddeac2717d810997a1c4787ec72a2)": no such
element in array
can't read "arcnos(6e9a6c5fdabddeac2717d810997a1c4787ec72a2)": no such
element in array
    while executing
"set a $arcnos($p)"
    (procedure "splitarc" line 5)
    invoked from within
"splitarc $p"
    (procedure "addnewchild" line 20)
    invoked from within
"addnewchild $newhead $oldhead"
    (procedure "cherrypick" line 26)
    invoked from within
"cherrypick"
    invoked from within
".rowctxmenu invoke active"
    ("uplevel" body line 1)
    invoked from within
"uplevel #0 [list $w invoke active]"
    (procedure "tk::MenuInvoke" line 50)
    invoked from within
"tk::MenuInvoke .rowctxmenu 1"
    (command bound to event)

===== cut here =====

BTW, the patch which I am trying to cherry-pick to stable is correctly
committed, but gitk is not usable any more (I need to close it and start
again).

The above described problem does not occur when I refresh the gitk tree
manually before cherry-picking another commit.

Best regards,
/Adam


-- 
.:.  Adam Piatyszek - "ediap"       .:.  JID: ediap(at)jabber.org .:.
.:.  ediap(at)users.sourceforge.net .:.  PGP key ID: 0x1F115CCB   .:.

^ permalink raw reply

* [PATCH] Test for windows format absolute paths on cygwin too
From: Robin Rosenberg @ 2007-08-31  9:07 UTC (permalink / raw)
  To: git

---

Requires cherry-picking 6397c3119ecaa258b5185315c64062bec29bcd86

 sha1_file.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/sha1_file.c b/sha1_file.c
index 97ea448..fa867b8 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -84,7 +84,7 @@ int get_sha1_hex(const char *hex, unsigned char *sha1)
 /* returns the number of chars to skip to first component */
 static inline int is_path_absolute(const char *path)
 {
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(__CYGWIN__)
 	if (isalpha(path[0]) && path[1] == ':')
 		return 2 + (path[2] == '/');
 	/* TODO: C:dir/file 'relative' paths are not catered for */
--
1.5.3.rc7.25.g5389f-dirty

^ permalink raw reply related

* Re: [PATCH 01/14] gitweb: get remotes too when getting heads list
From: Giuseppe Bilotta @ 2007-08-31  9:10 UTC (permalink / raw)
  To: git
In-Reply-To: <11885491241529-git-send-email-giuseppe.bilotta@gmail.com>

On Friday 31 August 2007 10:32, Giuseppe Bilotta wrote:

> Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>

A-hem, sorry, I think I've done something seriously wrong with the
patch sending. It should have been threaded under the previous thread,
and my smtp server decided to throttle me after the second.

Let me see if I can get this right.

-- 
Giuseppe "Oblomov" Bilotta

^ permalink raw reply

* Re: [PATCH 1/2] Introduces xmkstemp()
From: Marius Storm-Olsen @ 2007-08-31  9:00 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: git
In-Reply-To: <46D7D60C.8090608@telecom.at>

[-- Attachment #1: Type: text/plain, Size: 671 bytes --]

Johannes Sixt said the following on 31.08.2007 10:49:
> Marius Storm-Olsen schrieb:
>> Just wanted to let the original author know, so he would be aware
>> of it, and we wouldn't have to go the extra round-trips with
>> patches to fix patches. (And for MinGW awareness when adding code
>> to git-compat-util.h)
> 
> You can't expect a lot of MinGW awareness from non-MinGW users when
> they make changes to git-compat-util.h since upstream does not have
> _any_ references to MinGW there, yet.

D'oh!
/me smacks self

We really need to streamline the patches needed for MinGW, and get 
those merged into upstream when 1.5.3 is released.

-- 
.marius


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 187 bytes --]

^ permalink raw reply

* Re: [PATCH 1/2] Introduces xmkstemp()
From: Johannes Sixt @ 2007-08-31  8:49 UTC (permalink / raw)
  To: Marius Storm-Olsen; +Cc: git
In-Reply-To: <46D7D48D.6000503@trolltech.com>

Marius Storm-Olsen schrieb:
> Just wanted to let the original author know, so he would be aware of it, 
> and we wouldn't have to go the extra round-trips with patches to fix 
> patches. (And for MinGW awareness when adding code to git-compat-util.h)

You can't expect a lot of MinGW awareness from non-MinGW users when they 
make changes to git-compat-util.h since upstream does not have _any_ 
references to MinGW there, yet.

-- Hannes

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox