Git development
 help / color / mirror / Atom feed
* [PATCH] gitweb: fix project list if PATH_INFO=="/".
From: Martin Waitz @ 2006-08-16 22:28 UTC (permalink / raw)
  To: git; +Cc: Martin Waitz
In-Reply-To: <11557673263081-git-send-email-tali@admingilde.org>

The project list now uses several common header / footer generation functions.
These functions only check for "defined $project", but when PATH_INFO just
contains a "/" (which is often generated by web servers), then this test
fails.

Now explicitly undef $project if there is none so that the tests in other
gitweb parts work again.

Signed-off-by: Martin Waitz <tali@admingilde.org>
---
 gitweb/gitweb.perl |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 0a0b37f..3b6333c 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -100,8 +100,9 @@ our $project = ($cgi->param('p') || $ENV
 if (defined $project) {
 	$project =~ s|^/||;
 	$project =~ s|/$||;
+	$project = undef unless $project;
 }
-if (defined $project && $project) {
+if (defined $project) {
 	if (!validate_input($project)) {
 		die_error(undef, "Invalid project parameter");
 	}
-- 
1.4.2.rc2.gf055

^ permalink raw reply related

* [PATCH] gitweb: use action dispatcher for non-project actions, too.
From: Martin Waitz @ 2006-08-16 22:28 UTC (permalink / raw)
  To: git; +Cc: Martin Waitz
In-Reply-To: <11557673262714-git-send-email-tali@admingilde.org>

Allow to use the global action dispatcher for all actions by introducing
"/actions".  If no project directory is given then a / is prepended to the
action and the normal dispatcher is called.
Project list and OPML generation are now hooked into the list as "/summary"
and "/opml".

As "/" is not an allowed character in actions accepted through the CGI
parameters, it is still ensured that no normal action can be called without
giving a valid project directory.

Signed-off-by: Martin Waitz <tali@admingilde.org>
---
 gitweb/gitweb.perl |   17 ++++++++---------
 1 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 3b6333c..9a7faab 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -84,11 +84,6 @@ if (defined $action) {
 	if ($action =~ m/[^0-9a-zA-Z\.\-_]/) {
 		die_error(undef, "Invalid action parameter");
 	}
-	# action which does not check rest of parameters
-	if ($action eq "opml") {
-		git_opml();
-		exit;
-	}
 }
 
 our $order = $cgi->param('o');
@@ -113,9 +108,6 @@ if (defined $project) {
 		die_error(undef, "No such project");
 	}
 	$ENV{'GIT_DIR'} = "$projectroot/$project";
-} else {
-	git_project_list();
-	exit;
 }
 
 our $file_name = $cgi->param('f');
@@ -185,12 +177,19 @@ my %actions = (
 	"search" => \&git_search,
 	"shortlog" => \&git_shortlog,
 	"summary" => \&git_summary,
+	"/summary" => \&git_project_list,
+	"/opml" => \&git_opml,
 	"tag" => \&git_tag,
 	"tags" => \&git_tags,
 	"tree" => \&git_tree,
 );
 
-$action = 'summary' if (!defined($action));
+# default action
+$action ||= 'summary';
+
+#only allow non-/ actions if we have a project directory
+$action = "/$action" if !defined($project);
+
 if (!defined($actions{$action})) {
 	die_error(undef, "Unknown action");
 }
-- 
1.4.2.rc2.gf055

^ permalink raw reply related

* [PATCH] gitweb: use common parameter parsing and generation for "o", too.
From: Martin Waitz @ 2006-08-16 22:28 UTC (permalink / raw)
  To: git; +Cc: Martin Waitz
In-Reply-To: <11557673213372-git-send-email-tali@admingilde.org>

The "o" (list order) parameter was handled special.
Now it is generated with the common href() function and parsed together with
all other parameters.

Signed-off-by: Martin Waitz <tali@admingilde.org>
---
 gitweb/gitweb.perl |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 72e687e..ed6bd0e 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -91,6 +91,11 @@ if (defined $action) {
 	}
 }
 
+our $order = $cgi->param('o');
+if (defined $order && $order !~ m/project|descr|owner|age/) {
+	die_error(undef, "Unknown order parameter");
+}
+
 our $project = ($cgi->param('p') || $ENV{'PATH_INFO'});
 if (defined $project) {
 	$project =~ s|^/||;
@@ -197,6 +202,7 @@ sub href(%) {
 		hash_base => "hb",
 		page => "pg",
 		searchtext => "s",
+		order => "o",
 	);
 
 	my %params = @_;
@@ -1577,11 +1583,6 @@ ## =====================================
 ## actions
 
 sub git_project_list {
-	my $order = $cgi->param('o');
-	if (defined $order && $order !~ m/project|descr|owner|age/) {
-		die_error(undef, "Unknown order parameter");
-	}
-
 	my @list = git_get_projects_list();
 	my @projects;
 	if (!@list) {
@@ -1624,7 +1625,7 @@ sub git_project_list {
 		print "<th>Project</th>\n";
 	} else {
 		print "<th>" .
-		      $cgi->a({-href => "$my_uri?" . esc_param("o=project"),
+		      $cgi->a({-href => href(order=>"project"),
 		               -class => "header"}, "Project") .
 		      "</th>\n";
 	}
@@ -1633,7 +1634,7 @@ sub git_project_list {
 		print "<th>Description</th>\n";
 	} else {
 		print "<th>" .
-		      $cgi->a({-href => "$my_uri?" . esc_param("o=descr"),
+		      $cgi->a({-href => href(order=>"descr"),
 		               -class => "header"}, "Description") .
 		      "</th>\n";
 	}
@@ -1642,7 +1643,7 @@ sub git_project_list {
 		print "<th>Owner</th>\n";
 	} else {
 		print "<th>" .
-		      $cgi->a({-href => "$my_uri?" . esc_param("o=owner"),
+		      $cgi->a({-href => href(order=>"owner"),
 		               -class => "header"}, "Owner") .
 		      "</th>\n";
 	}
@@ -1651,7 +1652,7 @@ sub git_project_list {
 		print "<th>Last Change</th>\n";
 	} else {
 		print "<th>" .
-		      $cgi->a({-href => "$my_uri?" . esc_param("o=age"),
+		      $cgi->a({-href => href(order=>"age"),
 		               -class => "header"}, "Last Change") .
 		      "</th>\n";
 	}
-- 
1.4.2.rc2.gf055

^ permalink raw reply related

* [PATCH] gitweb: continue consolidation of URL generation.
From: Martin Waitz @ 2006-08-16 22:28 UTC (permalink / raw)
  To: git; +Cc: Martin Waitz

Further use href() instead of URL generation by string concatenation.
Almost all functions are converted now.

Signed-off-by: Martin Waitz <tali@admingilde.org>
---
 gitweb/gitweb.perl |   68 +++++++++++++++++++++++++++-------------------------
 1 files changed, 35 insertions(+), 33 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 37a6284..72e687e 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -204,7 +204,9 @@ sub href(%) {
 
 	my $href = "$my_uri?";
 	$href .= esc_param( join(";",
-		map { "$mapping{$_}=$params{$_}" } keys %params
+		map {
+			"$mapping{$_}=$params{$_}" if $params{$_}
+		} keys %params
 	) );
 
 	return $href;
@@ -1047,7 +1049,7 @@ sub git_footer_html {
 		}
 		print $cgi->a({-href => href(action=>"rss"), -class => "rss_logo"}, "RSS") . "\n";
 	} else {
-		print $cgi->a({-href => "$my_uri?" . esc_param("a=opml"), -class => "rss_logo"}, "OPML") . "\n";
+		print $cgi->a({-href => href(action=>"opml"), -class => "rss_logo"}, "OPML") . "\n";
 	}
 	print "</div>\n" .
 	      "</body>\n" .
@@ -1252,7 +1254,7 @@ sub git_difftree_body {
 			      "<td class=\"link\">" .
 				$cgi->a({-href => href(action=>"blob", hash=>$to_id, hash_base=>$hash, file_name=>$file)}, "blob");
 			if ($to_id ne $from_id) { # modified
-				print $cgi->a({-href => href(action=>"blobdiff", hash=>$to_id, hash_parent=>$from_id, hash_base=>$hash, file_name=>$file)}, "diff");
+				print " | " . $cgi->a({-href => href(action=>"blobdiff", hash=>$to_id, hash_parent=>$from_id, hash_base=>$hash, file_name=>$file)}, "diff");
 			}
 			print " | " . $cgi->a({-href => href(action=>"history", hash_base=>$hash, file_name=>$file)}, "history") . "\n";
 			print "</td>\n";
@@ -1663,16 +1665,16 @@ sub git_project_list {
 			print "<tr class=\"light\">\n";
 		}
 		$alternate ^= 1;
-		print "<td>" . $cgi->a({-href => "$my_uri?" . esc_param("p=$pr->{'path'};a=summary"),
+		print "<td>" . $cgi->a({-href => href(project=>$pr->{'path'}, action=>"summary"),
 		                        -class => "list"}, esc_html($pr->{'path'})) . "</td>\n" .
 		      "<td>" . esc_html($pr->{'descr'}) . "</td>\n" .
 		      "<td><i>" . chop_str($pr->{'owner'}, 15) . "</i></td>\n";
 		print "<td class=\"". age_class($pr->{'commit'}{'age'}) . "\">" .
 		      $pr->{'commit'}{'age_string'} . "</td>\n" .
 		      "<td class=\"link\">" .
-		      $cgi->a({-href => "$my_uri?" . esc_param("p=$pr->{'path'};a=summary")}, "summary")   . " | " .
-		      $cgi->a({-href => "$my_uri?" . esc_param("p=$pr->{'path'};a=shortlog")}, "shortlog") . " | " .
-		      $cgi->a({-href => "$my_uri?" . esc_param("p=$pr->{'path'};a=log")}, "log") .
+		      $cgi->a({-href => href(project=>$pr->{'path'}, action=>"summary")}, "summary")   . " | " .
+		      $cgi->a({-href => href(project=>$pr->{'path'}, action=>"shortlog")}, "shortlog") . " | " .
+		      $cgi->a({-href => href(project=>$pr->{'path'}, action=>"log")}, "log") .
 		      "</td>\n" .
 		      "</tr>\n";
 	}
@@ -2036,11 +2038,11 @@ sub git_tree {
 	my $refs = git_get_references();
 	my $ref = format_ref_marker($refs, $hash_base);
 	git_header_html();
-	my $base_key = "";
+	my %base_key = ();
 	my $base = "";
 	my $have_blame = git_get_project_config_bool ('blame');
 	if (defined $hash_base && (my %co = parse_commit($hash_base))) {
-		$base_key = ";hb=$hash_base";
+		$base_key{hash_base} = $hash_base;
 		git_print_page_nav('tree','', $hash_base);
 		git_print_header_div('commit', esc_html($co{'title'}) . $ref, $hash_base);
 	} else {
@@ -2071,23 +2073,23 @@ sub git_tree {
 		print "<td class=\"mode\">" . mode_str($t_mode) . "</td>\n";
 		if ($t_type eq "blob") {
 			print "<td class=\"list\">" .
-			      $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$t_hash$base_key;f=$base$t_name"), -class => "list"}, esc_html($t_name)) .
+			      $cgi->a({-href => href(action=>"blob", hash=>$t_hash, file_name=>"$base$t_name", %base_key), -class => "list"}, esc_html($t_name)) .
 			      "</td>\n" .
 			      "<td class=\"link\">" .
-			      $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$t_hash$base_key;f=$base$t_name")}, "blob");
+			      $cgi->a({-href => href(action=>"blob", hash=>$t_hash, file_name=>"$base$t_name", %base_key)}, "blob");
 			if ($have_blame) {
-				print " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blame;h=$t_hash$base_key;f=$base$t_name")}, "blame");
+				print " | " . $cgi->a({-href => href(action=>"blame", hash=>$t_hash, file_name=>"$base$t_name", %base_key)}, "blame");
 			}
-			print " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=history;h=$t_hash;hb=$hash_base;f=$base$t_name")}, "history") .
-			      " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob_plain;h=$t_hash;f=$base$t_name")}, "raw") .
+			print " | " . $cgi->a({-href => href(action=>"history", hash=>$t_hash, hash_base=>$hash_base, file_name=>"$base$t_name")}, "history") .
+			      " | " . $cgi->a({-href => href(action=>"blob_plain", hash=>$t_hash, file_name=>"$base$t_name")}, "raw") .
 			      "</td>\n";
 		} elsif ($t_type eq "tree") {
 			print "<td class=\"list\">" .
-			      $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$t_hash$base_key;f=$base$t_name")}, esc_html($t_name)) .
+			      $cgi->a({-href => href(action=>"tree", hash=>$t_hash, file_name=>"$base$t_name", %base_key)}, esc_html($t_name)) .
 			      "</td>\n" .
 			      "<td class=\"link\">" .
-			      $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$t_hash$base_key;f=$base$t_name")}, "tree") .
-			      " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=history;hb=$hash_base;f=$base$t_name")}, "history") .
+			      $cgi->a({-href => href(action=>"tree", hash=>$t_hash, file_name=>"$base$t_name", %base_key)}, "tree") .
+			      " | " . $cgi->a({-href => href(action=>"history", hash_base=>$hash_base, file_name=>"$base$t_name")}, "history") .
 			      "</td>\n";
 		}
 		print "</tr>\n";
@@ -2276,7 +2278,7 @@ sub git_blobdiff {
 	git_header_html();
 	if (defined $hash_base && (my %co = parse_commit($hash_base))) {
 		my $formats_nav =
-			$cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blobdiff_plain;h=$hash;hp=$hash_parent")}, "plain");
+			$cgi->a({-href => href(action=>"blobdiff_plain", hash=>$hash, hash_parent=>$hash_parent)}, "plain");
 		git_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
 		git_print_header_div('commit', esc_html($co{'title'}), $hash_base);
 	} else {
@@ -2287,9 +2289,9 @@ sub git_blobdiff {
 	git_print_page_path($file_name, "blob");
 	print "<div class=\"page_body\">\n" .
 	      "<div class=\"diff_info\">blob:" .
-	      $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$hash_parent;hb=$hash_base;f=$file_name")}, $hash_parent) .
+	      $cgi->a({-href => href(action=>"blob", hash=>$hash_parent, hash_base=>$hash_base, file_name=>$file_name)}, $hash_parent) .
 	      " -> blob:" .
-	      $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name")}, $hash) .
+	      $cgi->a({-href => href(action=>"blob", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)}, $hash) .
 	      "</div>\n";
 	git_diff_print($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash);
 	print "</div>";
@@ -2324,7 +2326,7 @@ sub git_commitdiff {
 	my $refs = git_get_references();
 	my $ref = format_ref_marker($refs, $co{'id'});
 	my $formats_nav =
-		$cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff_plain;h=$hash;hp=$hash_parent")}, "plain");
+		$cgi->a({-href => href(action=>"commitdiff_plain", hash=>$hash, hash_parent=>$hash_parent)}, "plain");
 	git_header_html(undef, $expires);
 	git_print_page_nav('commitdiff','', $hash,$co{'tree'},$hash, $formats_nav);
 	git_print_header_div('commit', esc_html($co{'title'}) . $ref, $hash);
@@ -2367,22 +2369,22 @@ sub git_commitdiff {
 		my $file = validate_input(unquote($6));
 		if ($status eq "A") {
 			print "<div class=\"diff_info\">" . file_type($to_mode) . ":" .
-			      $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, $to_id) . "(new)" .
+			      $cgi->a({-href => href(action=>"blob", hash=>$to_id, hash_base=>$hash, file_name=>$file)}, $to_id) . "(new)" .
 			      "</div>\n";
 			git_diff_print(undef, "/dev/null", $to_id, "b/$file");
 		} elsif ($status eq "D") {
 			print "<div class=\"diff_info\">" . file_type($from_mode) . ":" .
-			      $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$from_id;hb=$hash_parent;f=$file")}, $from_id) . "(deleted)" .
+			      $cgi->a({-href => href(action=>"blob", hash=>$from_id, hash_base=>$hash_parent, file_name=>$file)}, $from_id) . "(deleted)" .
 			      "</div>\n";
 			git_diff_print($from_id, "a/$file", undef, "/dev/null");
 		} elsif ($status eq "M") {
 			if ($from_id ne $to_id) {
 				print "<div class=\"diff_info\">" .
 				      file_type($from_mode) . ":" .
-				      $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$from_id;hb=$hash_parent;f=$file")}, $from_id) .
+				      $cgi->a({-href => href(action=>"blob", hash=>$from_id, hash_base=>$hash_parent, file_name=>$file)}, $from_id) .
 				      " -> " .
 				      file_type($to_mode) . ":" .
-				      $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, $to_id);
+				      $cgi->a({-href => href(action=>"blob", hash=>$to_id, hash_base=>$hash, file_name=>$file)}, $to_id) .
 				print "</div>\n";
 				git_diff_print($from_id, "a/$file",  $to_id, "b/$file");
 			}
@@ -2544,7 +2546,7 @@ sub git_search {
 			print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
 			      "<td><i>" . esc_html(chop_str($co{'author_name'}, 15, 5)) . "</i></td>\n" .
 			      "<td>" .
-			      $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$co{'id'}"), -class => "list"}, "<b>" . esc_html(chop_str($co{'title'}, 50)) . "</b><br/>");
+			      $cgi->a({-href => href(action=>"commit", hash=>$co{'id'}) -class => "list"}, "<b>" . esc_html(chop_str($co{'title'}, 50)) . "</b><br/>");
 			my $comment = $co{'comment'};
 			foreach my $line (@$comment) {
 				if ($line =~ m/^(.*)($searchtext)(.*)$/i) {
@@ -2559,8 +2561,8 @@ sub git_search {
 			}
 			print "</td>\n" .
 			      "<td class=\"link\">" .
-			      $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$co{'id'}")}, "commit") .
-			      " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}")}, "tree");
+			      $cgi->a({-href => href(action=>"commit", hash=>$co{'id'})}, "commit") .
+			      " | " . $cgi->a({-href => href(action=>"tree", hash=>$co{'tree'}, hash_base=>$co{'id'})}, "tree");
 			print "</td>\n" .
 			      "</tr>\n";
 		}
@@ -2597,18 +2599,18 @@ sub git_search {
 					print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
 					      "<td><i>" . esc_html(chop_str($co{'author_name'}, 15, 5)) . "</i></td>\n" .
 					      "<td>" .
-					      $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$co{'id'}"), -class => "list"}, "<b>" .
+					      $cgi->a({-href => href(action=>"commit", hash=>$co{'id'}), -class => "list"}, "<b>" .
 					      esc_html(chop_str($co{'title'}, 50)) . "</b><br/>");
 					while (my $setref = shift @files) {
 						my %set = %$setref;
-						print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$set{'id'};hb=$co{'id'};f=$set{'file'}"), class => "list"},
+						print $cgi->a({-href => href(action=>"blob", hash=>$set{'id'}, hash_base=>$co{'id'}, file_name=>$set{'file'}), class => "list"},
 						      "<span class=\"match\">" . esc_html($set{'file'}) . "</span>") .
 						      "<br/>\n";
 					}
 					print "</td>\n" .
 					      "<td class=\"link\">" .
-					      $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$co{'id'}")}, "commit") .
-					      " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}")}, "tree");
+					      $cgi->a({-href => href(action=>"commit", hash=>$co{'id'})}, "commit") .
+					      " | " . $cgi->a({-href => href(action=>"tree", hash=>$co{'tree'}, hash_base=>$co{'id'})}, "tree");
 					print "</td>\n" .
 					      "</tr>\n";
 				}
@@ -2641,7 +2643,7 @@ sub git_shortlog {
 	my $next_link = '';
 	if ($#revlist >= (100 * ($page+1)-1)) {
 		$next_link =
-			$cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog;h=$hash;pg=" . ($page+1)),
+			$cgi->a({-href => href(action=>"shortlog", hash=>$hash, page=>$page+1),
 			         -title => "Alt-n"}, "next");
 	}
 
-- 
1.4.2.rc2.gf055

^ permalink raw reply related

* Re: [PATCH] remove inline iteration variable
From: David Rientjes @ 2006-08-16 21:41 UTC (permalink / raw)
  To: Alex Riesen; +Cc: git
In-Reply-To: <20060816201019.GA6083@steel.home>

On Wed, 16 Aug 2006, Alex Riesen wrote:

> David Rientjes, Wed, Aug 16, 2006 19:14:44 +0200:
> > > > Remove unnecessary iteration variable in inline.
> > > > -       for (i = 0; i < in; i++) putchar(' ');
> > > > +       for (; in > 0; in--)
> > > 
> > > while(in--) putchar(' ');
> > > 
> > 
> > That goes into an infinite loop if the argument is negative because
> > it emits a cmpl $0, x(%ebp).  Should never happen, but there's no
> > reason not to prevent it with a for loop.
> 
> while (in-- > 0) putchar(' ');
> 
> still shorter :)
> 

It emits a slightly rearranged assembly with the same number of instructions.

		David

^ permalink raw reply

* Re: [RFC/PATCH] Trace into a file if GIT_TRACE can interpreted as a filename.
From: Junio C Hamano @ 2006-08-16 21:18 UTC (permalink / raw)
  To: Christian Couder; +Cc: git
In-Reply-To: <20060816225846.ae424b46.chriscool@tuxfamily.org>

Christian Couder <chriscool@tuxfamily.org> writes:

> So this change is not compatible with the previous
> behavior, because stderr will not be used anymore if
> GIT_TRACE is set to something other than "1" or "true".
> No file locking is done. This maybe a problem.

I wonder if we can pass an already opened file descriptor to
GIT_TRACE.  E.g.

	GIT_TRACE=9 make test 9>/var/tmp/trace.log

and make the trace code to emit the message with one write(2) to
make sure messages from processes do not get mixed up in the
middle.

^ permalink raw reply

* Re: [RFC] Enable 'check for copy and renames' (-C) also when path filtering
From: Junio C Hamano @ 2006-08-16 21:11 UTC (permalink / raw)
  To: Marco Costalba; +Cc: Junio C Hamano, git
In-Reply-To: <e5bfff550608161349t29a678ccl4b211cb570a1217d@mail.gmail.com>

"Marco Costalba" <mcostalba@gmail.com> writes:

> On 8/16/06, Junio C Hamano <junkio@cox.net> wrote:
>> "Marco Costalba" <mcostalba@gmail.com> writes:
>>
>> > It seems that -C option of git-diff-tree it works only if the whole
>> > changeset is retrieved.
>>
>> Correct (sort of).  Pathspec works on the input side not on the
>> output side.  It's been specified and worked that way from the
>> beginning (check the list archive to see me arguing that it
>> would be easier to use on the output side, and Linus vetoing
>> because following a single file is not that interesting and the
>> cost outweighs the benefit of that uninteresting case).
>>
>> Always feeding the whole tree is wasteful, but if we are
>> interested in following a single file, we could do something
>> like:
>>
>>  - follow that file and that file only from the recent to past;
>>
>>  - notice when that file disappears -- that is the point the
>>    file was created.  it may have created from scratch, it may
>>    have been renamed or copied.
>>
>>  - on that commit that creates the file, look at the whole tree
>>    to see if we can find an origin.
>>
>>  - if we find that the file was created by renaming or copying
>>    another, keep following that other file from that point on.
>
> Yes, I was thinking about something like this, Thanks for point me out
> this, now I am quite sure it's the correct way to go ;-)

You may want to talk with Fredrik about this.  The above is not
entirely my making but was an outline brought up while we
discussed his "rename following revision walker" on the list
recently. 

^ permalink raw reply

* [RFC/PATCH] Trace into a file if GIT_TRACE can interpreted as a filename.
From: Christian Couder @ 2006-08-16 20:58 UTC (permalink / raw)
  To: Junio Hamano; +Cc: git

This RFC/patch is a first step to trace the git commands used when running
the test suite.

Thanks,
Christian.

-- 8< --
[RFC/PATCH] Trace into a file if GIT_TRACE can interpreted as a filename.

If GIT_TRACE is set to something different than "1" or
"true" then we suppose it's a filemane and try to trace
into it instead of stderr.
So this change is not compatible with the previous
behavior, because stderr will not be used anymore if
GIT_TRACE is set to something other than "1" or "true".
No file locking is done. This maybe a problem.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>

---
 Makefile      |    3 ++-
 cache.h       |    4 ++++
 exec_cmd.c    |   19 ++++++++++---------
 git.c         |   26 ++++++++++++++------------
 t/test-lib.sh |    3 +++
 trace.c       |   43 +++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 76 insertions(+), 22 deletions(-)

diff --git a/Makefile b/Makefile
index c6b62d9..8ce78b3 100644
--- a/Makefile
+++ b/Makefile
@@ -253,7 +253,8 @@ LIB_OBJS = \
 	server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \
 	tag.o tree.o usage.o config.o environment.o ctype.o copy.o \
 	fetch-clone.o revision.o pager.o tree-walk.o xdiff-interface.o \
-	alloc.o merge-file.o path-list.o unpack-trees.o help.o $(DIFF_OBJS)
+	alloc.o merge-file.o path-list.o unpack-trees.o help.o trace.o \
+	$(DIFF_OBJS)

 BUILTIN_OBJS = \
 	builtin-add.o \
diff --git a/cache.h b/cache.h
index 913be6a..0efcf50 100644
--- a/cache.h
+++ b/cache.h
@@ -409,4 +409,8 @@ extern struct commit *alloc_commit_node(
 extern struct tag *alloc_tag_node(void);
 extern void alloc_report(void);
 
+/* trace.c */
+extern FILE *start_trace(void);
+extern void stop_trace(void);
+  
 #endif /* CACHE_H */
diff --git a/exec_cmd.c b/exec_cmd.c
index 62f51fc..ddb45a3 100644
--- a/exec_cmd.c
+++ b/exec_cmd.c
@@ -43,6 +43,7 @@ int execv_git_cmd(const char **argv)
 		int rc;
 		const char *exec_dir = paths[i];
 		const char *tmp;
+		FILE *trace_file;
 
 		if (!exec_dir || !*exec_dir) continue;
 
@@ -97,25 +98,25 @@ int execv_git_cmd(const char **argv)
 		tmp = argv[0];
 		argv[0] = git_command;
 
-		if (getenv("GIT_TRACE")) {
+		if ((trace_file = start_trace())) {
 			const char **p = argv;
-			fputs("trace: exec:", stderr);
+			fputs("trace: exec:", trace_file);
 			while (*p) {
-				fputc(' ', stderr);
-				sq_quote_print(stderr, *p);
+				fputc(' ', trace_file);
+				sq_quote_print(trace_file, *p);
 				++p;
 			}
-			putc('\n', stderr);
-			fflush(stderr);
+			putc('\n', trace_file);
+			stop_trace();
 		}
 
 		/* execve() can only ever return if it fails */
 		execve(git_command, (char **)argv, environ);
 
-		if (getenv("GIT_TRACE")) {
-			fprintf(stderr, "trace: exec failed: %s\n",
+		if ((trace_file = start_trace())) {
+			fprintf(trace_file, "trace: exec failed: %s\n",
 				strerror(errno));
-			fflush(stderr);
+			stop_trace();
 		}
 
 		argv[0] = tmp;
diff --git a/git.c b/git.c
index 96e596b..39b78e2 100644
--- a/git.c
+++ b/git.c
@@ -161,6 +161,7 @@ static int handle_alias(int *argcp, cons
 	const char *subdir;
 	int count, option_count;
 	const char** new_argv;
+	FILE *trace_file;
 
 	subdir = setup_git_directory_gently(&nongit);
 
@@ -179,16 +180,16 @@ static int handle_alias(int *argcp, cons
 		if (!strcmp(alias_command, new_argv[0]))
 			die("recursive alias: %s", alias_command);
 
-		if (getenv("GIT_TRACE")) {
+		if ((trace_file = start_trace())) {
 			int i;
-			fprintf(stderr, "trace: alias expansion: %s =>",
+			fprintf(trace_file, "trace: alias expansion: %s =>",
 				alias_command);
 			for (i = 0; i < count; ++i) {
-				fputc(' ', stderr);
-				sq_quote_print(stderr, new_argv[i]);
+				fputc(' ', trace_file);
+				sq_quote_print(trace_file, new_argv[i]);
 			}
-			fputc('\n', stderr);
-			fflush(stderr);
+			fputc('\n', trace_file);
+			stop_trace();
 		}
 
 		new_argv = realloc(new_argv, sizeof(char*) *
@@ -282,6 +283,7 @@ static void handle_internal_command(int 
 	for (i = 0; i < ARRAY_SIZE(commands); i++) {
 		struct cmd_struct *p = commands+i;
 		const char *prefix;
+		FILE * trace_file;
 		if (strcmp(p->cmd, cmd))
 			continue;
 
@@ -290,15 +292,15 @@ static void handle_internal_command(int 
 			prefix = setup_git_directory();
 		if (p->option & USE_PAGER)
 			setup_pager();
-		if (getenv("GIT_TRACE")) {
+		if ((trace_file = start_trace())) {
 			int i;
-			fprintf(stderr, "trace: built-in: git");
+			fprintf(trace_file, "trace: built-in: git");
 			for (i = 0; i < argc; ++i) {
-				fputc(' ', stderr);
-				sq_quote_print(stderr, argv[i]);
+				fputc(' ', trace_file);
+				sq_quote_print(trace_file, argv[i]);
 			}
-			putc('\n', stderr);
-			fflush(stderr);
+			putc('\n', trace_file);
+			stop_trace();
 		}
 
 		exit(p->fn(argc, argv, prefix));
diff --git a/t/test-lib.sh b/t/test-lib.sh
index b6d119a..5afa5f0 100755
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -35,6 +35,9 @@ export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
 export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME
 export EDITOR VISUAL
 
+# Uncomment the following line to trace the git commands into a file.
+# export GIT_TRACE=`pwd`/git_trace.log
+
 # Each test should start with something like this, after copyright notices:
 #
 # test_description='Description of this test...
diff --git a/trace.c b/trace.c
new file mode 100644
index 0000000..b1a14e0
--- /dev/null
+++ b/trace.c
@@ -0,0 +1,43 @@
+/*
+ * GIT - The information manager from hell
+ *
+ * Copyright (C) Christian Couder, 2006
+ *
+ */
+#include "cache.h"
+
+static FILE *trace_file = NULL;
+
+FILE *start_trace()
+{
+	char * trace = getenv("GIT_TRACE");
+
+	if (trace && (!strcmp(trace,"1") || !strcasecmp(trace,"true")))
+		trace_file = stderr;
+	else if (trace && strcmp(trace, "") &&
+		 strcmp(trace, "0") && strcasecmp(trace, "false")) {
+		/* We suppose we have a filename. */
+		trace_file = fopen(trace, "a");
+		if (!trace_file) {
+			fprintf(stderr, "Error: %s\n"
+				"when opening trace file: %s\n"
+				"Tracing on stderr instead.\n",
+				strerror(errno), trace);
+			trace_file = stderr;
+		}
+	}
+
+	return trace_file;
+}
+
+void stop_trace()
+{
+	if (trace_file) {
+		if (trace_file == stderr)
+			fflush(stderr);
+		else
+			fclose(trace_file);
+		trace_file = NULL;
+	}
+}
+
-- 
1.4.2.rc3.gcc6ea

^ permalink raw reply related

* Re: [RFC] Enable 'check for copy and renames' (-C) also when path filtering
From: Marco Costalba @ 2006-08-16 20:49 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <7v8xlo4lht.fsf@assigned-by-dhcp.cox.net>

On 8/16/06, Junio C Hamano <junkio@cox.net> wrote:
> "Marco Costalba" <mcostalba@gmail.com> writes:
>
> > It seems that -C option of git-diff-tree it works only if the whole
> > changeset is retrieved.
>
> Correct (sort of).  Pathspec works on the input side not on the
> output side.  It's been specified and worked that way from the
> beginning (check the list archive to see me arguing that it
> would be easier to use on the output side, and Linus vetoing
> because following a single file is not that interesting and the
> cost outweighs the benefit of that uninteresting case).
>
> Always feeding the whole tree is wasteful, but if we are
> interested in following a single file, we could do something
> like:
>
>  - follow that file and that file only from the recent to past;
>
>  - notice when that file disappears -- that is the point the
>    file was created.  it may have created from scratch, it may
>    have been renamed or copied.
>
>  - on that commit that creates the file, look at the whole tree
>    to see if we can find an origin.
>
>  - if we find that the file was created by renaming or copying
>    another, keep following that other file from that point on.
>

Yes, I was thinking about something like this, Thanks for point me out
this, now I am quite sure it's the correct way to go ;-)

   Marco

P.S: The first thing will be to teach qgit about renames and copies,
i.e. diff-tree with -C option. I'm cooking a patch on this.

BTW, regarding copies, there are only 6 (6973dca, 8752d11, 927a503,
2276aa6, ddafa7e9 and 7ef7692) in git tree, against 181 renames.

^ permalink raw reply

* Re: [PATCH 2/2] gitweb: Add support for per project git URLs
From: Junio C Hamano @ 2006-08-16 20:40 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git
In-Reply-To: <200608161450.35118.jnareb@gmail.com>

Jakub Narebski <jnareb@gmail.com> writes:

> It is now possible for project to have individual clone/fetch URLs.
> They are provided in new file 'cloneurl' added below project's
> $GIT_DIR directory.
>
> If there is no cloneurl file, concatenation of git base URLs with
> project name is used.
>
> This is merge of Jakub Narebski and David Rientjes
>   gitweb: Show project's git URL on summary page
> with Aneesh Kumar
>   gitweb: Add support for cloneurl.
>   gitweb: Support multiple clone urls
> patches.
>
> Signed-off-by: Jakub Narebski <jnareb@gmail.com>
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>

I'll take this for now, but we might want to consider moving
'description' and 'cloneurl' information to the config file to
prevent cluttering.

        gitweb.description
        gitweb.giturl

The URL is not for cloning only, but also for fetch/pull, right?

^ permalink raw reply

* Re: [PATCH] remove inline iteration variable
From: Junio C Hamano @ 2006-08-16 20:16 UTC (permalink / raw)
  To: Alex Riesen; +Cc: git, David Rientjes
In-Reply-To: <20060816201019.GA6083@steel.home>

fork0@t-online.de (Alex Riesen) writes:

> David Rientjes, Wed, Aug 16, 2006 19:14:44 +0200:
>> > > Remove unnecessary iteration variable in inline.
>> > > -       for (i = 0; i < in; i++) putchar(' ');
>> > > +       for (; in > 0; in--)
>> > 
>> > while(in--) putchar(' ');
>> > 
>> 
>> That goes into an infinite loop if the argument is negative because
>> it emits a cmpl $0, x(%ebp).  Should never happen, but there's no
>> reason not to prevent it with a for loop.
>
> while (in-- > 0) putchar(' ');
>
> still shorter :)

Why do we keep talking about a usually ifdef'ed out debugging
section?

I'll be removing that section altogether ;-).

^ permalink raw reply

* Re: [PATCH] remove inline iteration variable
From: Alex Riesen @ 2006-08-16 20:10 UTC (permalink / raw)
  To: David Rientjes; +Cc: git
In-Reply-To: <Pine.LNX.4.63.0608161011100.20470@chino.corp.google.com>

David Rientjes, Wed, Aug 16, 2006 19:14:44 +0200:
> > > Remove unnecessary iteration variable in inline.
> > > -       for (i = 0; i < in; i++) putchar(' ');
> > > +       for (; in > 0; in--)
> > 
> > while(in--) putchar(' ');
> > 
> 
> That goes into an infinite loop if the argument is negative because
> it emits a cmpl $0, x(%ebp).  Should never happen, but there's no
> reason not to prevent it with a for loop.

while (in-- > 0) putchar(' ');

still shorter :)

^ permalink raw reply

* Re: gitweb / cg-export
From: Fredrik Kuivinen @ 2006-08-16 20:05 UTC (permalink / raw)
  To: Aneesh Kumar K.V; +Cc: git
In-Reply-To: <ebuvok$vnv$1@sea.gmane.org>

On Wed, Aug 16, 2006 at 05:02:36PM +0530, Aneesh Kumar K.V wrote:
> Aneesh Kumar K.V wrote:
> >Jakub Narebski wrote:
> >>Toby White wrote:
> >>
> >>>I was wondering if a feature like the following would be of
> >>>use to anyone except me: I'd like to be able to download
> >>>the full source of a given tree from gitweb.
> >>[...]
> >>So you want to have snapshot of a tree. Why not snapshot of a commit, 
> >>or of a tag?
> >>
> >>>I've quickly hacked gitweb to do this for me - patch below.
> >>>
> >>>It adds an extra link to the 'commit' page. Next to the link
> >>>that would lead you to 'tree', there is 'tar.gz' which simply
> >>>returns the tar.gz of the same tree.
> >>>
> >>>The patch is against the version of gitweb currently in
> >>>Debian, which is, erm, '264-1', apparently, because that's
> >>>what I had to hand.
> >>
> >>It is really better to hack git with git. And you can use current gitweb
> >>with old git (well, not always, as current gitweb requires --full-history
> >>option to git-rev-list to be available).
> >>
> >
> >How about the below on top of latest git
> 
> Add it to git_commit too. The patch contains the pervious changes also.
> 

Nice.

> +sub git_snapshot {
> +	if (!defined $hash) {
> +		$hash = git_get_head_hash($project);
> +	}
> +	print $cgi->header(-type=>'application/x-tar',
> +			  -Content-Encoding=>'x-gzip', -status=> '200 OK');
> +	open my $fd, "-|", "$GIT tar-tree $hash $project | gzip -c9" or die_error(undef, "Execute git-tar-tree failed.");

It might be better to use -6 (the default compression/speed trade-off)
instead of using -9 (best but slowest compression) here.  Or maybe
even make it configurable. On some servers it is probably preferable
to make the snapshot (slightly) larger and gain some cpu time.

To get some numbers I made a small benchmark with the current git
tree. I get the following on my machine:

Compression/speed    Size   Time
-1                   1.1M   0.16s
-6                   923K   0.36s
-9                   917K   0.50s  

- Fredrik

^ permalink raw reply

* Re: [PATCH] git-mv: succeed even if source is a prefix of destination
From: Fredrik Kuivinen @ 2006-08-16 19:22 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Fredrik Kuivinen, David Rientjes, git
In-Reply-To: <Pine.LNX.4.63.0608161041300.28360@wbgn013.biozentrum.uni-wuerzburg.de>

On Wed, Aug 16, 2006 at 10:44:02AM +0200, Johannes Schindelin wrote:
> > 
> > It looks like we need some kind of path normalization before we do
> > those tests.
> 
> I kind of hoped it was not necessary to do this, since get_pathspec() does 
> a rudimentary version of it (BTW git-mv.perl got it wrong: it substituted 
> "./" by "", which would fail for a directory name like "endsWithADot.").
> 
> It was a little more involved:
> 
> -- 8< --
> [PATCH] git-mv: add more path normalization
> 
> We already use the normalization from get_pathspec(), but now we also
> remove a trailing slash. So,
> 
> 	git mv some_path/ into_some_path/
> 
> works now.
> 
> Also, move the "can not move directory into itself" test before the
> subdirectory expansion.
> 

It works as expected now. Thanks!

- Fredrik

^ permalink raw reply

* Re: gitweb / cg-export
From: Junio C Hamano @ 2006-08-16 18:01 UTC (permalink / raw)
  To: Aneesh Kumar K.V; +Cc: git
In-Reply-To: <44E2F911.6060002@gmail.com>

"Aneesh Kumar K.V" <aneesh.kumar@gmail.com> writes:

> How about the below on top of latest git
>
> -aneesh

This looks Ok (except "$project" needs to be shell quoted on the
pipe-open line and possibly in the URL; there may be some other
minor details I missed).  It needs to be protected by elective,
opt-in configuration variable, similarly to how "blame" is done,
since I suspect this would be rather expensive.

> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index 37a6284..b9b522a 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -175,6 +175,7 @@ my %actions = (
>  	"tag" => \&git_tag,
>  	"tags" => \&git_tags,
>  	"tree" => \&git_tree,
> +	"snapshot" => \&git_snapshot,
>  );
>  
>  $action = 'summary' if (!defined($action));
> @@ -1334,6 +1335,7 @@ sub git_shortlog_body {
>  		      "<td class=\"link\">" .
>  		      $cgi->a({-href => href(action=>"commit", hash=>$commit)}, "commit") . " | " .
>  		      $cgi->a({-href => href(action=>"commitdiff", hash=>$commit)}, "commitdiff") .
> +		      " | " .$cgi->a({-href => "$my_uri/$project.tar.gz?" . esc_param("p=$project;a=snapshot;h=$commit")}, "snapshot") .
>  		      "</td>\n" .
>  		      "</tr>\n";
>  	}
> @@ -2097,6 +2099,21 @@ sub git_tree {
>  	git_footer_html();
>  }
>  
> +sub git_snapshot {
> +	if (!defined $hash) {
> +		$hash = git_get_head_hash($project);
> +	}
> +	print $cgi->header(-type=>'application/x-tar',
> +			  -Content-Encoding=>'x-gzip', -status=> '200 OK');
> +	open my $fd, "-|", "$GIT tar-tree $hash $project | gzip -c9" or die_error(undef, "Execute git-tar-tree failed.");
> +	binmode STDOUT, ':raw';
> +	print <$fd>;
> +	binmode STDOUT, ':utf8'; # as set at the beginning of gitweb.cgi
> +	close $fd;
> +
> +
> +}
> +
>  sub git_log {
>  	my $head = git_get_head_hash($project);
>  	if (!defined $hash) {

^ permalink raw reply

* Re: [RFC] Enable 'check for copy and renames' (-C) also when path filtering
From: Junio C Hamano @ 2006-08-16 17:51 UTC (permalink / raw)
  To: Marco Costalba; +Cc: git
In-Reply-To: <e5bfff550608160206w606008ddv2da42ce49e98fa2b@mail.gmail.com>

"Marco Costalba" <mcostalba@gmail.com> writes:

> It seems that -C option of git-diff-tree it works only if the whole
> changeset is retrieved.

Correct (sort of).  Pathspec works on the input side not on the
output side.  It's been specified and worked that way from the
beginning (check the list archive to see me arguing that it
would be easier to use on the output side, and Linus vetoing
because following a single file is not that interesting and the
cost outweighs the benefit of that uninteresting case).

Always feeding the whole tree is wasteful, but if we are
interested in following a single file, we could do something
like:

 - follow that file and that file only from the recent to past;

 - notice when that file disappears -- that is the point the
   file was created.  it may have created from scratch, it may
   have been renamed or copied.

 - on that commit that creates the file, look at the whole tree
   to see if we can find an origin.

 - if we find that the file was created by renaming or copying
   another, keep following that other file from that point on.

^ permalink raw reply

* Huge win, compressing a window of delta runs as a unit
From: Jon Smirl @ 2006-08-16 17:20 UTC (permalink / raw)
  To: Shawn Pearce, git

Shawn put together a new version of his import utility that packs all
of the deltas from a run into a single blob instead of one blob per
delta. The idea is to put 10 or more deltas into each delta entry
instead of one. The index format would map the 10 sha1's to a single
packed delta entry which would be expanded when needed. Note that you
probably needed multiple entries out of the delta pack to generate the
revision you were looking for so this is no real loss on extraction.

I ran it overnight on mozcvs. If his delta pack code is correct this
is a huge win.

One entry per delta -  845,42,0150
Packed deltas - 295,018,474
65% smaller

The effect of packing the deltas is to totally eliminate many of the
redundant zlib dictionaries.

This is without using a zlib dictionary which gains another 4% form a
4KB dictionary.

-- 
Jon Smirl
jonsmirl@gmail.com

^ permalink raw reply

* Re: [PATCH] remove inline iteration variable
From: David Rientjes @ 2006-08-16 17:14 UTC (permalink / raw)
  To: Alex Riesen; +Cc: git
In-Reply-To: <81b0412b0608160027l2ac53c10gd9a75525ca144f1d@mail.gmail.com>

On Wed, 16 Aug 2006, Alex Riesen wrote:

> On 8/15/06, David Rientjes <rientjes@google.com> wrote:
> > Remove unnecessary iteration variable in inline.
> > -       for (i = 0; i < in; i++) putchar(' ');
> > +       for (; in > 0; in--)
> 
> while(in--) putchar(' ');
> 

That goes into an infinite loop if the argument is negative because it emits a 
cmpl $0, x(%ebp).  Should never happen, but there's no reason not to prevent it 
with a for loop.

		David

^ permalink raw reply

* Re: Git files data formats documentation
From: Nicolas Pitre @ 2006-08-16 16:55 UTC (permalink / raw)
  To: A Large Angry SCM; +Cc: git
In-Reply-To: <44D51D47.9090700@gmail.com>

A Large Angry SCM wrote:
> This information may be useful for reading and writing the various Git
> files.

[...]

        # For version 2 pack files, the size of a copy is limited to
        # 64K bytes or less and bit 6 of the opcode byte is set if the
        # source of the copy is from the buffer of the result object
        # instead of the the base object.
        #
        # It's unknown if any version 2 pack files were created with
        # bit 6 set in the opcode byte; however, the change that added
        # support for version 3 pack files removed the code that would
        # change the copy source to the result buffer.

There were no version 2 pack files with bit 6 set in the opcode byte 
ever produced (except on my own hard disk when I was experimenting with 
that feature).  The (negative) compression gain turned up to be not 
worth the needed computational cost to make use of it, hence that bit is 
now dedicated to specifying an extra size byte.

See commit d60fc1c8649f80c006b9f493c542461e81608d4b log message for 
more.


Nicolas

^ permalink raw reply

* Re: Compression and dictionaries
From: Jon Smirl @ 2006-08-16 14:43 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Shawn Pearce, John Rigby, linux@horizon.com, git
In-Reply-To: <Pine.LNX.4.63.0608160908070.28360@wbgn013.biozentrum.uni-wuerzburg.de>

On 8/16/06, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> Hi,
>
> On Wed, 16 Aug 2006, Shawn Pearce wrote:
>
> > Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> > > Hi,
> > >
> > > On Wed, 16 Aug 2006, Jon Smirl wrote:
> > >
> > > > On 8/16/06, John Rigby <jcrigby@gmail.com> wrote:
> > > > > Sorry if this is off topic, but could the dictionary be used to make
> > > > > git-grep alot faster?
> > > >
> > > > It would be almost instant.
> > >
> > > But only if you are not using a regular expression, but a single word.
> >
> > Yes and no.  If the inverted index contains terms broken by some
> > known pattern (e.g. break on word-type boundaries) and the regex
> > in question has constant sections (it should, otherwise it might
> > as well just be '.') then you can reduce your search space to a
> > fraction of the overall data by looking at the inverted index to
> > select likely terms, select the related revisions containing those
> > possible terms, then run the regex only on those revisions.
> >
> > Sure you would be possibly pulling out a number of false positives
> > but if the constant sequence(s) in the regex reduce your search
> > space to below 1/2 of the overall data that's probably a lot less
> > I/O and CPU required to complete the query, even if you have to
> > read the entire dictionary and apply each term in the dictionary
> > to the regex to look for those possible matches.
>
> So it would speed up the search, but no, in case of regular expressions,
> particularly any interesting one, the result would not be instantaneous.

Instant is a relative term. Google is instant compared to running grep
over 10TB of data. How long would that take, a month?

Shawn is correct, the inverted indexes are used to eliminate as many
files as possible. So the response time is a more of a function of how
many hits you have instead of how big the data set is. Of course if
you give it a pattern that matches everything it will just as slow as
grep. Give it a pattern that is only in one file and detectable by the
index and it will be very fast. If you are going to give it a bunch of
patterns that aren't in the index, then we need to adjust how the
index is built.

-- 
Jon Smirl
jonsmirl@gmail.com

^ permalink raw reply

* Re: [PATCH (revised)] gitweb: Show project's git URL on summary page
From: Jakub Narebski @ 2006-08-16 12:56 UTC (permalink / raw)
  To: git
In-Reply-To: <ebuhjn$kdm$1@sea.gmane.org>

Aneesh Kumar K.V wrote:


> this can give wrong value is some case with index.aux as projects_list. 
> I have a setup where project details are displayed via gitweb but not
> reachable via http:// url and some reachable via http:// url. 
> 
> For the first one only ssh:// based clone mechanism will work and for 
> the other both will work. How do we handle that

See my "[PATCH 2/2] gitweb: Add support for per project git URLs" in this
thread.

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

^ permalink raw reply

* [PATCH 2/2] gitweb: Add support for per project git URLs
From: Jakub Narebski @ 2006-08-16 12:50 UTC (permalink / raw)
  To: git
In-Reply-To: <200608152303.17994.jnareb@gmail.com>

It is now possible for project to have individual clone/fetch URLs.
They are provided in new file 'cloneurl' added below project's
$GIT_DIR directory.

If there is no cloneurl file, concatenation of git base URLs with
project name is used.

This is merge of Jakub Narebski and David Rientjes
  gitweb: Show project's git URL on summary page
with Aneesh Kumar
  gitweb: Add support for cloneurl.
  gitweb: Support multiple clone urls
patches.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>
---
Based on previous patch.

 gitweb/gitweb.perl |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 37a6284..7c92ac3 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -533,6 +533,16 @@ sub git_get_project_description {
 	return $descr;
 }
 
+sub git_get_project_url_list {
+	my $path = shift;
+
+	open my $fd, "$projectroot/$path/cloneurl" or return undef;
+	my @git_project_url_list = map { chomp; $_ } <$fd>;
+	close $fd;
+
+	return wantarray ? @git_project_url_list : \@git_project_url_list;
+}
+
 sub git_get_projects_list {
 	my @list;
 
@@ -1697,10 +1707,14 @@ sub git_summary {
 	      "<tr><td>description</td><td>" . esc_html($descr) . "</td></tr>\n" .
 	      "<tr><td>owner</td><td>$owner</td></tr>\n" .
 	      "<tr><td>last change</td><td>$cd{'rfc2822'}</td></tr>\n";
+	# use per project git URL list in $projectroot/$project/cloneurl
+	# or make project git URL from git base URL and project name
 	my $url_tag = "URL";
-	foreach my $git_base_url (@git_base_url_list) {
-		next unless $git_base_url;
-		print "<tr><td>$url_tag</td><td>$git_base_url/$project</td></tr>\n";
+	my @url_list = git_get_project_url_list($project);
+	@url_list = map { "$_/$project" } @git_base_url_list unless @url_list;
+	foreach my $git_url (@url_list) {
+		next unless $git_url;
+		print "<tr><td>$url_tag</td><td>$git_url</td></tr>\n";
 		$url_tag = "";
 	}
 	print "</table>\n";
-- 
1.4.1.1

^ permalink raw reply related

* Re: gitweb / cg-export
From: Aneesh Kumar K.V @ 2006-08-16 11:32 UTC (permalink / raw)
  To: git
In-Reply-To: <44E2F911.6060002@gmail.com>

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

Aneesh Kumar K.V wrote:
> Jakub Narebski wrote:
>> Toby White wrote:
>>
>>> I was wondering if a feature like the following would be of
>>> use to anyone except me: I'd like to be able to download
>>> the full source of a given tree from gitweb.
>> [...]
>> So you want to have snapshot of a tree. Why not snapshot of a commit, 
>> or of a tag?
>>
>>> I've quickly hacked gitweb to do this for me - patch below.
>>>
>>> It adds an extra link to the 'commit' page. Next to the link
>>> that would lead you to 'tree', there is 'tar.gz' which simply
>>> returns the tar.gz of the same tree.
>>>
>>> The patch is against the version of gitweb currently in
>>> Debian, which is, erm, '264-1', apparently, because that's
>>> what I had to hand.
>>
>> It is really better to hack git with git. And you can use current gitweb
>> with old git (well, not always, as current gitweb requires --full-history
>> option to git-rev-list to be available).
>>
> 
> How about the below on top of latest git

Add it to git_commit too. The patch contains the pervious changes also.

-aneesh


[-- Attachment #2: gitweb.snapshot.diff --]
[-- Type: text/x-patch, Size: 1966 bytes --]

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 37a6284..b2e375e 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -175,6 +175,7 @@ my %actions = (
 	"tag" => \&git_tag,
 	"tags" => \&git_tags,
 	"tree" => \&git_tree,
+	"snapshot" => \&git_snapshot,
 );
 
 $action = 'summary' if (!defined($action));
@@ -1334,6 +1335,7 @@ sub git_shortlog_body {
 		      "<td class=\"link\">" .
 		      $cgi->a({-href => href(action=>"commit", hash=>$commit)}, "commit") . " | " .
 		      $cgi->a({-href => href(action=>"commitdiff", hash=>$commit)}, "commitdiff") .
+		      " | " .$cgi->a({-href => "$my_uri/$project.tar.gz?" . esc_param("p=$project;a=snapshot;h=$commit")}, "snapshot") .
 		      "</td>\n" .
 		      "</tr>\n";
 	}
@@ -2097,6 +2099,21 @@ sub git_tree {
 	git_footer_html();
 }
 
+sub git_snapshot {
+	if (!defined $hash) {
+		$hash = git_get_head_hash($project);
+	}
+	print $cgi->header(-type=>'application/x-tar',
+			  -Content-Encoding=>'x-gzip', -status=> '200 OK');
+	open my $fd, "-|", "$GIT tar-tree $hash $project | gzip -c9" or die_error(undef, "Execute git-tar-tree failed.");
+	binmode STDOUT, ':raw';
+	print <$fd>;
+	binmode STDOUT, ':utf8'; # as set at the beginning of gitweb.cgi
+	close $fd;
+
+
+}
+
 sub git_log {
 	my $head = git_get_head_hash($project);
 	if (!defined $hash) {
@@ -2226,7 +2243,8 @@ sub git_commit {
 	      "<td class=\"sha1\">" .
 	      $cgi->a({-href => href(action=>"tree", hash=>$co{'tree'}, hash_base=>$hash), class => "list"}, $co{'tree'}) .
 	      "</td>" .
-	      "<td class=\"link\">" . $cgi->a({-href => href(action=>"tree", hash=>$co{'tree'}, hash_base=>$hash)}, "tree") .
+	      "<td class=\"link\">" . $cgi->a({-href => href(action=>"tree", hash=>$co{'tree'}, hash_base=>$hash)}, "tree") . " | " .
+	      $cgi->a({-href => "$my_uri/$project.tar.gz?" . esc_param("p=$project;a=snapshot;h=$hash")}, "snapshot") .
 	      "</td>" .
 	      "</tr>\n";
 	my $parents = $co{'parents'};

^ permalink raw reply related

* Re: gitweb / cg-export
From: Aneesh Kumar K.V @ 2006-08-16 10:53 UTC (permalink / raw)
  To: git
In-Reply-To: <ebupuk$dgl$1@sea.gmane.org>

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

Jakub Narebski wrote:
> Toby White wrote:
> 
>> I was wondering if a feature like the following would be of
>> use to anyone except me: I'd like to be able to download
>> the full source of a given tree from gitweb.
> [...]
> So you want to have snapshot of a tree. Why not snapshot of a commit, 
> or of a tag?
> 
>> I've quickly hacked gitweb to do this for me - patch below.
>>
>> It adds an extra link to the 'commit' page. Next to the link
>> that would lead you to 'tree', there is 'tar.gz' which simply
>> returns the tar.gz of the same tree.
>>
>> The patch is against the version of gitweb currently in
>> Debian, which is, erm, '264-1', apparently, because that's
>> what I had to hand.
> 
> It is really better to hack git with git. And you can use current gitweb
> with old git (well, not always, as current gitweb requires --full-history
> option to git-rev-list to be available).
> 

How about the below on top of latest git 

-aneesh


[-- Attachment #2: gitweb.snapshot.diff --]
[-- Type: text/x-patch, Size: 1328 bytes --]

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 37a6284..b9b522a 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -175,6 +175,7 @@ my %actions = (
 	"tag" => \&git_tag,
 	"tags" => \&git_tags,
 	"tree" => \&git_tree,
+	"snapshot" => \&git_snapshot,
 );
 
 $action = 'summary' if (!defined($action));
@@ -1334,6 +1335,7 @@ sub git_shortlog_body {
 		      "<td class=\"link\">" .
 		      $cgi->a({-href => href(action=>"commit", hash=>$commit)}, "commit") . " | " .
 		      $cgi->a({-href => href(action=>"commitdiff", hash=>$commit)}, "commitdiff") .
+		      " | " .$cgi->a({-href => "$my_uri/$project.tar.gz?" . esc_param("p=$project;a=snapshot;h=$commit")}, "snapshot") .
 		      "</td>\n" .
 		      "</tr>\n";
 	}
@@ -2097,6 +2099,21 @@ sub git_tree {
 	git_footer_html();
 }
 
+sub git_snapshot {
+	if (!defined $hash) {
+		$hash = git_get_head_hash($project);
+	}
+	print $cgi->header(-type=>'application/x-tar',
+			  -Content-Encoding=>'x-gzip', -status=> '200 OK');
+	open my $fd, "-|", "$GIT tar-tree $hash $project | gzip -c9" or die_error(undef, "Execute git-tar-tree failed.");
+	binmode STDOUT, ':raw';
+	print <$fd>;
+	binmode STDOUT, ':utf8'; # as set at the beginning of gitweb.cgi
+	close $fd;
+
+
+}
+
 sub git_log {
 	my $head = git_get_head_hash($project);
 	if (!defined $hash) {

^ permalink raw reply related

* git-rebase strange message
From: Jakub Narebski @ 2006-08-16 10:26 UTC (permalink / raw)
  To: git

Why git-am says
  No changes - did you forget update-index?
when I changed file to <upstream> version? Shouldn't it suggest that either
patch is applied, or to 'git am --skip' the patch?

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

^ 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