Git development
 help / color / mirror / Atom feed
* Re: [PATCH/RFC 1/x] gitweb: Use git-diff-tree patch output for commitdiff
From: Marco Costalba @ 2006-08-25 17:32 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git, Junio C Hamano
In-Reply-To: <eck1em$p8b$1@sea.gmane.org>

> >>    Empty patches (mode changes and pure renames and copying)
> >>    are not written currently.
> >
> > That's quite bad.
>
> This can be easily changed. Question: what format? Current "gitweb diff

I don't know if has always been like this, but I don't see on gitweb
(http://www.kernel.org/git/?p=qgit/qgit.git;a=shortlog) the diff of
the patch I've just pushed.

The patch is "Fix correct permissions on this excutable script",
currently the HEAD of qgit repo. The content it's only a file mode
change in helpgen.sh, so it' an 'empty' patch.

I've done something wrong or it's gitweb that does not show this info?

Thanks
Marco

^ permalink raw reply

* Re: [PATCH/RFC 1/x] gitweb: Use git-diff-tree patch output for commitdiff
From: Jakub Narebski @ 2006-08-25 18:18 UTC (permalink / raw)
  To: git
In-Reply-To: <e5bfff550608251032p53ba203fl27af782c765f929f@mail.gmail.com>

Marco Costalba wrote:

>> >>    Empty patches (mode changes and pure renames and copying)
>> >>    are not written currently.
>> >
>> > That's quite bad.
>>
>> This can be easily changed. Question: what format? Current "gitweb diff
> 
> I don't know if has always been like this, but I don't see on gitweb
> (http://www.kernel.org/git/?p=qgit/qgit.git;a=shortlog) the diff of
> the patch I've just pushed.
> 
> The patch is "Fix correct permissions on this excutable script",
> currently the HEAD of qgit repo. The content it's only a file mode
> change in helpgen.sh, so it' an 'empty' patch.
> 
> I've done something wrong or it's gitweb that does not show this info?

It is visible in "commit" view, but is not visible in either "commitdiff",
or "blobdiff".

Support for showing this kind of changes is planned... but of course
you would have to wait for kernel.org to update their gitweb.
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

^ permalink raw reply

* [PATCH 12/19] gitweb: Parse two-line from-file/to-file diff header in git_patchset_body
From: Jakub Narebski @ 2006-08-25 19:04 UTC (permalink / raw)
  To: git
In-Reply-To: <200608240015.15071.jnareb@gmail.com>

Parse two-line from-file/to-file unified diff header in
git_patchset_body directly, instead of leaving pretty-printing to
format_diff_line function.  Hashes as from-file/to-file are replaced
by proper from-file and to-file names (from $diffinfo); in the future
we can put hyperlinks there.  This makes possible to do blobdiff with
only blobs hashes.

The lines in two-line unified diff header have now class "from_file"
and "to_file"; the style is chosen to match previous output (classes
"rem" and "add" because of '-' and '+' as first character of patch
line).

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
 gitweb/gitweb.css  |    2 ++
 gitweb/gitweb.perl |   18 +++++++++++++++++-
 2 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/gitweb/gitweb.css b/gitweb/gitweb.css
index 5eaa24f..0912361 100644
--- a/gitweb/gitweb.css
+++ b/gitweb/gitweb.css
@@ -273,10 +273,12 @@ td.mode {
 	font-family: monospace;
 }
 
+div.diff.to_file,
 div.diff.add {
 	color: #008800;
 }
 
+div.diff.from_file,
 div.diff.rem {
 	color: #cc0000;
 }
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 461ebcd..9222e30 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1706,8 +1706,24 @@ sub git_patchset_body {
 
 
 		if ($in_header && $patch_line =~ m/^---/) {
-			#print "</div>\n"
+			#print "</div>\n"; # class="diff extended_header"
 			$in_header = 0;
+
+			my $file = $diffinfo->{'from_file'};
+			$file  ||= $diffinfo->{'file'};
+			$patch_line =~ s|a/[0-9a-fA-F]{40}|a/$file|g;
+			print "<div class=\"diff from_file\">" . esc_html($patch_line) . "</div>\n";
+
+			$patch_line = <$fd>;
+			chomp $patch_line;
+
+			#$patch_line =~ m/^+++/;
+			$file    = $diffinfo->{'to_file'};
+			$file  ||= $diffinfo->{'file'};
+			$patch_line =~ s|b/[0-9a-fA-F]{40}|b/$file|g;
+			print "<div class=\"diff to_file\">" . esc_html($patch_line) . "</div>\n";
+
+			next LINE;
 		}
 		next LINE if $in_header;
 
-- 
1.4.1.1

^ permalink raw reply related

* [PATCH 11/19] gitweb: Allow for pre-parsed difftree info in git_patchset_body
From: Jakub Narebski @ 2006-08-25 18:59 UTC (permalink / raw)
  To: git
In-Reply-To: <200608240015.15071.jnareb@gmail.com>

Preparation for converting git_blobdiff and git_blobdiff_plain
to use git-diff-tree patch format to generate patches.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
 gitweb/gitweb.perl |   55 ++++++++++++++++++++++++++++------------------------
 1 files changed, 30 insertions(+), 25 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index a3553ad..461ebcd 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1624,7 +1624,7 @@ sub git_patchset_body {
 	my $patch_idx = 0;
 	my $in_header = 0;
 	my $patch_found = 0;
-	my %diffinfo;
+	my $diffinfo;
 
 	print "<div class=\"patchset\">\n";
 
@@ -1643,54 +1643,59 @@ sub git_patchset_body {
 			}
 			print "<div class=\"patch\">\n";
 
-			%diffinfo = parse_difftree_raw_line($difftree->[$patch_idx++]);
+			if (ref($difftree->[$patch_idx]) eq "HASH") {
+				$diffinfo = $difftree->[$patch_idx];
+			} else {
+				$diffinfo = parse_difftree_raw_line($difftree->[$patch_idx]);
+			}
+			$patch_idx++;
 
 			# for now, no extended header, hence we skip empty patches
 			# companion to	next LINE if $in_header;
-			if ($diffinfo{'from_id'} eq $diffinfo{'to_id'}) { # no change
+			if ($diffinfo->{'from_id'} eq $diffinfo->{'to_id'}) { # no change
 				$in_header = 1;
 				next LINE;
 			}
 
-			if ($diffinfo{'status'} eq "A") { # added
-				print "<div class=\"diff_info\">" . file_type($diffinfo{'to_mode'}) . ":" .
+			if ($diffinfo->{'status'} eq "A") { # added
+				print "<div class=\"diff_info\">" . file_type($diffinfo->{'to_mode'}) . ":" .
 				      $cgi->a({-href => href(action=>"blob", hash_base=>$hash,
-				                             hash=>$diffinfo{'to_id'}, file_name=>$diffinfo{'file'})},
-				              $diffinfo{'to_id'}) . "(new)" .
+				                             hash=>$diffinfo->{'to_id'}, file_name=>$diffinfo->{'file'})},
+				              $diffinfo->{'to_id'}) . "(new)" .
 				      "</div>\n"; # class="diff_info"
 
-			} elsif ($diffinfo{'status'} eq "D") { # deleted
-				print "<div class=\"diff_info\">" . file_type($diffinfo{'from_mode'}) . ":" .
+			} elsif ($diffinfo->{'status'} eq "D") { # deleted
+				print "<div class=\"diff_info\">" . file_type($diffinfo->{'from_mode'}) . ":" .
 				      $cgi->a({-href => href(action=>"blob", hash_base=>$hash_parent,
-				                             hash=>$diffinfo{'from_id'}, file_name=>$diffinfo{'file'})},
-				              $diffinfo{'from_id'}) . "(deleted)" .
+				                             hash=>$diffinfo->{'from_id'}, file_name=>$diffinfo->{'file'})},
+				              $diffinfo->{'from_id'}) . "(deleted)" .
 				      "</div>\n"; # class="diff_info"
 
-			} elsif ($diffinfo{'status'} eq "R" || # renamed
-			         $diffinfo{'status'} eq "C") { # copied
+			} elsif ($diffinfo->{'status'} eq "R" || # renamed
+			         $diffinfo->{'status'} eq "C") { # copied
 				print "<div class=\"diff_info\">" .
-				      file_type($diffinfo{'from_mode'}) . ":" .
+				      file_type($diffinfo->{'from_mode'}) . ":" .
 				      $cgi->a({-href => href(action=>"blob", hash_base=>$hash_parent,
-				                             hash=>$diffinfo{'from_id'}, file_name=>$diffinfo{'from_file'})},
-				              $diffinfo{'from_id'}) .
+				                             hash=>$diffinfo->{'from_id'}, file_name=>$diffinfo->{'from_file'})},
+				              $diffinfo->{'from_id'}) .
 				      " -> " .
-				      file_type($diffinfo{'to_mode'}) . ":" .
+				      file_type($diffinfo->{'to_mode'}) . ":" .
 				      $cgi->a({-href => href(action=>"blob", hash_base=>$hash,
-				                             hash=>$diffinfo{'to_id'}, file_name=>$diffinfo{'to_file'})},
-				              $diffinfo{'to_id'});
+				                             hash=>$diffinfo->{'to_id'}, file_name=>$diffinfo->{'to_file'})},
+				              $diffinfo->{'to_id'});
 				print "</div>\n"; # class="diff_info"
 
 			} else { # modified, mode changed, ...
 				print "<div class=\"diff_info\">" .
-				      file_type($diffinfo{'from_mode'}) . ":" .
+				      file_type($diffinfo->{'from_mode'}) . ":" .
 				      $cgi->a({-href => href(action=>"blob", hash_base=>$hash_parent,
-				                             hash=>$diffinfo{'from_id'}, file_name=>$diffinfo{'file'})},
-				              $diffinfo{'from_id'}) .
+				                             hash=>$diffinfo->{'from_id'}, file_name=>$diffinfo->{'file'})},
+				              $diffinfo->{'from_id'}) .
 				      " -> " .
-				      file_type($diffinfo{'to_mode'}) . ":" .
+				      file_type($diffinfo->{'to_mode'}) . ":" .
 				      $cgi->a({-href => href(action=>"blob", hash_base=>$hash,
-				                             hash=>$diffinfo{'to_id'}, file_name=>$diffinfo{'file'})},
-				              $diffinfo{'to_id'});
+				                             hash=>$diffinfo->{'to_id'}, file_name=>$diffinfo->{'file'})},
+				              $diffinfo->{'to_id'});
 				print "</div>\n"; # class="diff_info"
 			}
 
-- 
1.4.1.1

^ permalink raw reply related

* [PATCH 14/19] gitweb: Always display link to blobdiff_plain in git_blobdiff
From: Jakub Narebski @ 2006-08-25 19:05 UTC (permalink / raw)
  To: git
In-Reply-To: <200608240015.15071.jnareb@gmail.com>

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
 gitweb/gitweb.perl |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 7e68292..ade5d42 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2790,18 +2790,18 @@ sub git_commit {
 sub git_blobdiff {
 	mkdir($git_temp, 0700);
 	git_header_html();
+	my $formats_nav =
+		$cgi->a({-href => href(action=>"blobdiff_plain",
+		                       hash=>$hash, hash_parent=>$hash_parent,
+		                       hash_base=>$hash_base, hash_parent_base=>$hash_parent_base,
+		                       file_name=>$file_name, file_parent=>$file_parent)},
+		        "plain");
 	if (defined $hash_base && (my %co = parse_commit($hash_base))) {
-		my $formats_nav =
-			$cgi->a({-href => href(action=>"blobdiff_plain",
-			                       hash=>$hash, hash_parent=>$hash_parent,
-			                       hash_base=>$hash_base, hash_parent_base=>$hash_parent_base,
-			                       file_name=>$file_name, file_parent=>$file_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 {
 		print <<HTML;
-<div class="page_nav"><br/><br/></div>
+<div class="page_nav"><br/>$formats_nav<br/></div>
 <div class="title">$hash vs $hash_parent</div>
 HTML
 	}
-- 
1.4.1.1

^ permalink raw reply related

* [PATCH 13/19] gitweb: Add invisible hyperlink to from-file/to-file diff header
From: Jakub Narebski @ 2006-08-25 19:05 UTC (permalink / raw)
  To: git
In-Reply-To: <200608240015.15071.jnareb@gmail.com>

Change replacing hashes as from-file/to-file with filenames from
difftree to adding invisible (except underlining on hover/mouseover)
hyperlink to from-file/to-file blob.  /dev/null as from-file or
to-file is not changed (is not hyperlinked).

This makes two-file from-file/to-file unified diff header parsing in
git_patchset_body more generic, and not only for legacy blobdiffs.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
 gitweb/gitweb.css  |   10 ++++++++++
 gitweb/gitweb.perl |   14 ++++++++++----
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/gitweb/gitweb.css b/gitweb/gitweb.css
index 0912361..afd9e8a 100644
--- a/gitweb/gitweb.css
+++ b/gitweb/gitweb.css
@@ -273,11 +273,21 @@ td.mode {
 	font-family: monospace;
 }
 
+div.diff a.list {
+	text-decoration: none;
+}
+
+div.diff a.list:hover {
+	text-decoration: underline;
+}
+
+div.diff.to_file a.list,
 div.diff.to_file,
 div.diff.add {
 	color: #008800;
 }
 
+div.diff.from_file a.list,
 div.diff.from_file,
 div.diff.rem {
 	color: #cc0000;
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 9222e30..7e68292 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1711,8 +1711,11 @@ sub git_patchset_body {
 
 			my $file = $diffinfo->{'from_file'};
 			$file  ||= $diffinfo->{'file'};
-			$patch_line =~ s|a/[0-9a-fA-F]{40}|a/$file|g;
-			print "<div class=\"diff from_file\">" . esc_html($patch_line) . "</div>\n";
+			$file = $cgi->a({-href => href(action=>"blob", hash_base=>$hash_parent,
+			                               hash=>$diffinfo->{'from_id'}, file_name=>$file),
+			                -class => "list"}, esc_html($file));
+			$patch_line =~ s|a/.*$|a/$file|g;
+			print "<div class=\"diff from_file\">$patch_line</div>\n";
 
 			$patch_line = <$fd>;
 			chomp $patch_line;
@@ -1720,8 +1723,11 @@ sub git_patchset_body {
 			#$patch_line =~ m/^+++/;
 			$file    = $diffinfo->{'to_file'};
 			$file  ||= $diffinfo->{'file'};
-			$patch_line =~ s|b/[0-9a-fA-F]{40}|b/$file|g;
-			print "<div class=\"diff to_file\">" . esc_html($patch_line) . "</div>\n";
+			$file = $cgi->a({-href => href(action=>"blob", hash_base=>$hash,
+			                               hash=>$diffinfo->{'to_id'}, file_name=>$file),
+			                -class => "list"}, esc_html($file));
+			$patch_line =~ s|b/.*|b/$file|g;
+			print "<div class=\"diff to_file\">$patch_line</div>\n";
 
 			next LINE;
 		}
-- 
1.4.1.1

^ permalink raw reply related

* [PATCH 15/19] gitweb: Change here-doc back for style consistency in git_blobdiff
From: Jakub Narebski @ 2006-08-25 19:06 UTC (permalink / raw)
  To: git
In-Reply-To: <200608240015.15071.jnareb@gmail.com>

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
Next will be patches which get rid of external diff dependency.

 gitweb/gitweb.perl |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index ade5d42..a866922 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2800,10 +2800,8 @@ sub git_blobdiff {
 		git_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
 		git_print_header_div('commit', esc_html($co{'title'}), $hash_base);
 	} else {
-		print <<HTML;
-<div class="page_nav"><br/>$formats_nav<br/></div>
-<div class="title">$hash vs $hash_parent</div>
-HTML
+		print "<div class=\"page_nav\"><br/>$formats_nav<br/></div>\n";
+		print "<div class=\"title\">$hash vs $hash_parent</div>\n";
 	}
 	git_print_page_path($file_name, "blob", $hash_base);
 	print "<div class=\"page_body\">\n" .
-- 
1.4.1.1

^ permalink raw reply related

* Re: git-svn problem: unexpected files/diffs in commit
From: Eric Wong @ 2006-08-25 19:15 UTC (permalink / raw)
  To: Seth Falcon; +Cc: git
In-Reply-To: <m2u040n5e2.fsf@ziti.local>

Seth Falcon <sethfalcon@gmail.com> wrote:
> Hi,
> 
> I just made an svn commit using 'git-svn commit' and ended up with a
> quite unexpected result.  
> 
> I'm using svn, version 1.3.2 (r19776) _with_ the SVN:: lib and 
> git is git version 1.4.2.g7099c (actually, I just updated and so I was
> a few commits back, but git-svn.perl didn't change, so I'm pretty
> confident that I'm current w.r.t. git-svn).

Cool that it works for you, I've yet to get SVN:: libs working with a
repository I didn't have full read access to.  I assume you have full
read access?

> Here is a copy/paste of my session (some edits since some history was lost):
> 
> ## Check for changes in svn repos and merge them in.
> 
>     ziti:~/proj/graph-git seth$ git-svn fetch
>     ziti:~/proj/graph-git seth$ git pull . remotes/git-svn
>     Trying really trivial in-index merge...
>     Wonderful.
>     In-index merge
>      DESCRIPTION            |    2 +-
>      R/AllGenerics.R        |    2 +-
>      R/clustergraph.R       |    4 ++--
>      man/distGraph-class.Rd |    6 ++++--
>      4 files changed, 8 insertions(+), 6 deletions(-)
> 
> ## I'm really where I think I am:
> 
>    ziti:~/proj/graph-git seth$ git branch
>    * master
> 
> ## Let's see what I _would_ commit if I did the normal git-svn commit
> ## thing
> 
>    ziti:~/proj/graph-git seth$ git diff --stat remotes/git-svn..master
>     inst/unitTests/graphNEL_test.R |    2 +-
>     inst/unitTests/runalltests.R   |    6 +++---
>     2 files changed, 4 insertions(+), 4 deletions(-)
> 
> ## Yeah, that looks right.

I usually check with git log remotes/git-svn..HEAD instead of git diff.
Perhaps adding --no-merges would be more correct?

> ## ok, go for the commit
> 
>     ziti:~/proj/graph-git seth$ git-svn commit remotes/git-svn..master
>     diff-tree f5ebf17f7e460d3bc3de72ab381c72dc76d26936 0681f7614c342b85b91d909ff02a9a966a44c3f4
>             M       DESCRIPTION
>             M       R/AllGenerics.R
>             M       R/clustergraph.R
>             M       inst/unitTests/graphNEL_test.R
>             M       inst/unitTests/runalltests.R
>             M       man/distGraph-class.Rd
>     r19467 = 1b75d81a95da328f0b0d06b7562fdb48970b4c98
>     RA layer request failed: OPTIONS request failed on '/bioconductor': OPTIONS of '/bioconductor': Could not read status line: SSL error: decryption failed or bad record mac (https://hedgehog.fhcrc.org) at /Users/seth/scm/bin/git-svn line 526
>     65280 at /Users/seth/scm/bin/git-svn line 547
>             main::commit_lib('0681f7614c342b85b91d909ff02a9a966a44c3f4', '0cccf3753b472b52a93154ed8021499055bb3923') called at /Users/seth/scm/bin/git-svn line 457
>             main::commit('remotes/git-svn..master') called at /Users/seth/scm/bin/git-svn line 149
> 
> 
> ## GAAAHH! That isn't what I wanted at all.  It looks as if I didn't
> ## really do the pull.  What is going on?
> 
> Despite the SSL error, the commit to svn actually went through and I
> had to back it out.  Did I do something wrong?  I did the git-svn
> fetch and pull to sync up, then reapplied my patch and git-svn commit
> "worked" although I got the same SSL error.
 
I haven't been able to reproduce the SSL error message consistently,
but I have seen it[1].  It could be SSL having state information that gets
screwed up with the forking git-svn does to avoid memory leaks in SVN::

Outside of the SSL problems, the mis-commit isn't strictly user-error,
but git-svn is confusing in this case, as the documentation is unclear
about what git-svn should do in this case :x

Simple answer: instead of pull, you should've used git rebase.  But I
don't think the documentation makes it clear at all.

I've been really slacking on the git-svn documentation the past few
months, help would be much appreciated.

Here's an in-depth explanation:

This is what git-svn does when issued "commit remotes/git-svn..master":
1. git-rev-list remotes/git-svn..master | tac =>
	0681f7614c342b85b91d909ff02a9a966a44c3f4
	0cccf3753b472b52a93154ed8021499055bb3923

0cccf3753b472b52a93154ed8021499055bb3923 is the result of your
'git pull . remotes/git-svn', correct?
And 0681f7614c342b85b91d909ff02a9a966a44c3f4 was made to git before
the pull.

So this is what git-svn does, it commits the output of:
diff-tree f5ebf17f7e460d3bc3de72ab381c72dc76d26936 0681f7614c342b85b91d909ff02a9a966a44c3f4
(f5eb... is remotes/git-svn at that point).

If the SVN/SSL connection had not died, it would've then proceeded to
commit the output of:

diff-tree 1b75d81a95da328f0b0d06b7562fdb48970b4c98 0cccf3753b472b52a93154ed8021499055bb3923
Where 1b75d81a95da328f0b0d06b7562fdb48970b4c98 is the output of your
previous commit (r19467)

Personally, I've been starting to favor 'git-svn commit-diff' myself
over 'git-svn commit', as it leaves cleaner history and makes git-svn
fetch results reproducable on different machines.

[1] - unfortunately, I seem to have forgotten about it since I use
commit-diff more often these days :x

-- 
Eric Wong

^ permalink raw reply

* [PATCH] git-svn: establish new connections on commit after fork
From: Eric Wong @ 2006-08-25 19:28 UTC (permalink / raw)
  To: Seth Falcon; +Cc: git
In-Reply-To: <20060825191516.GA8957@localdomain>

SVN seems to have a problem with https:// repositories from
time-to-time when doing multiple, sequential commits.  This
problem is not consistently reproducible without the patch,
but it should go away entirely with this patch...

Signed-off-by: Eric Wong <normalperson@yhbt.net>
---

 git-svn.perl |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index 0d58bb9..b311c3d 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -500,6 +500,8 @@ sub commit_lib {
 	my @lock = $SVN::Core::VERSION ge '1.2.0' ? (undef, 0) : ();
 	my $commit_msg = "$GIT_SVN_DIR/.svn-commit.tmp.$$";
 
+	my $repo;
+	($repo, $SVN_PATH) = repo_path_split($SVN_URL);
 	set_svn_commit_env();
 	foreach my $c (@revs) {
 		my $log_msg = get_commit_message($c, $commit_msg);
@@ -508,6 +510,8 @@ sub commit_lib {
 		# can't track down... (it's probably in the SVN code)
 		defined(my $pid = open my $fh, '-|') or croak $!;
 		if (!$pid) {
+			$SVN_LOG = libsvn_connect($repo);
+			$SVN = libsvn_connect($repo);
 			my $ed = SVN::Git::Editor->new(
 					{	r => $r_last,
 						ra => $SVN,
-- 
1.4.2.g7c9b

^ permalink raw reply related

* [PATCH 18/19] gitweb: Remove git_diff_print subroutine
From: Jakub Narebski @ 2006-08-25 19:15 UTC (permalink / raw)
  To: git
In-Reply-To: <200608240015.15071.jnareb@gmail.com>

Remove git_diff_print subroutine, used to print diff in previous
versions of "diff" actions, namely git_commitdiff,
git_commitdiff_plain, git_blobdiff, git_blobdiff_plain.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
 gitweb/gitweb.perl |   71 ----------------------------------------------------
 1 files changed, 0 insertions(+), 71 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index b20640e..2f932f0 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1975,77 +1975,6 @@ sub git_heads_body {
 	print "</table>\n";
 }
 
-## ----------------------------------------------------------------------
-## functions printing large fragments, format as one of arguments
-
-sub git_diff_print {
-	my $from = shift;
-	my $from_name = shift;
-	my $to = shift;
-	my $to_name = shift;
-	my $format = shift || "html";
-
-	my $from_tmp = "/dev/null";
-	my $to_tmp = "/dev/null";
-	my $pid = $$;
-
-	# create tmp from-file
-	if (defined $from) {
-		$from_tmp = "$git_temp/gitweb_" . $$ . "_from";
-		open my $fd2, "> $from_tmp";
-		open my $fd, "-|", $GIT, "cat-file", "blob", $from;
-		my @file = <$fd>;
-		print $fd2 @file;
-		close $fd2;
-		close $fd;
-	}
-
-	# create tmp to-file
-	if (defined $to) {
-		$to_tmp = "$git_temp/gitweb_" . $$ . "_to";
-		open my $fd2, "> $to_tmp";
-		open my $fd, "-|", $GIT, "cat-file", "blob", $to;
-		my @file = <$fd>;
-		print $fd2 @file;
-		close $fd2;
-		close $fd;
-	}
-
-	open my $fd, "-|", "/usr/bin/diff -u -p -L \'$from_name\' -L \'$to_name\' $from_tmp $to_tmp";
-	if ($format eq "plain") {
-		undef $/;
-		print <$fd>;
-		$/ = "\n";
-	} else {
-		while (my $line = <$fd>) {
-			chomp $line;
-			my $char = substr($line, 0, 1);
-			my $diff_class = "";
-			if ($char eq '+') {
-				$diff_class = " add";
-			} elsif ($char eq "-") {
-				$diff_class = " rem";
-			} elsif ($char eq "@") {
-				$diff_class = " chunk_header";
-			} elsif ($char eq "\\") {
-				# skip errors
-				next;
-			}
-			$line = untabify($line);
-			print "<div class=\"diff$diff_class\">" . esc_html($line) . "</div>\n";
-		}
-	}
-	close $fd;
-
-	if (defined $from) {
-		unlink($from_tmp);
-	}
-	if (defined $to) {
-		unlink($to_tmp);
-	}
-}
-
-
 ## ======================================================================
 ## ======================================================================
 ## actions
-- 
1.4.1.1

^ permalink raw reply related

* [PATCH 17/19] gitweb: git_blobdiff_plain is git_blobdiff('plain')
From: Jakub Narebski @ 2006-08-25 19:14 UTC (permalink / raw)
  To: git
In-Reply-To: <200608240015.15071.jnareb@gmail.com>

git_blobdiff and git_blobdiff_plain are now collapsed into one
subroutine git_blobdiff, with format (currently 'html' which is
default format corresponding to git_blobdiff, and 'plain'
corresponding to git_blobdiff_plain) specified in argument.

blobdiff_plain format is now generated either by git-diff-tree
or by git-diff.  Added X-Git-Url: header.  From-file and to-file name
in header are corrected.

Note that for now commitdiff_plain does not detect renames 
and copying, while blobdiff_plain does.

While at it, set expires to "+1d" for non-textual hash ids.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---

 gitweb/gitweb.perl |   95 ++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 69 insertions(+), 26 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 9be2b2c..b20640e 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2815,9 +2815,12 @@ sub git_commit {
 }
 
 sub git_blobdiff {
+	my $format = shift || 'html';
+
 	my $fd;
 	my @difftree;
 	my %diffinfo;
+	my $expires;
 
 	# preparing $fd and %diffinfo for git_patchset_body
 	# new style URI
@@ -2866,6 +2869,12 @@ sub git_blobdiff {
 		$hash_parent ||= $diffinfo{'from_id'};
 		$hash        ||= $diffinfo{'to_id'};
 
+		# non-textual hash id's can be cached
+		if ($hash_base =~ m/^[0-9a-fA-F]{40}$/ &&
+		    $hash_parent_base =~ m/^[0-9a-fA-F]{40}$/) {
+			$expires = '+1d';
+		}
+
 		# open patch output
 		open $fd, "-|", $GIT, "diff-tree", '-r', '-p', '-M', '-C', $hash_parent_base, $hash_base,
 			"--", $file_name
@@ -2894,7 +2903,14 @@ sub git_blobdiff {
 			$diffinfo{'from_file'} = $hash_parent;
 			$diffinfo{'to_file'}   = $hash;
 		}
 
+		# non-textual hash id's can be cached
+		if ($hash =~ m/^[0-9a-fA-F]{40}$/ &&
+		    $hash_parent =~ m/^[0-9a-fA-F]{40}$/) {
+			$expires = '+1d';
+		}
+
+		# open patch output
 		#open $fd, "-|", $GIT, "diff", '-p', $hash_parent, $hash
 		open $fd, "-|", $GIT, "diff", '-p', $hash, $hash_parent
 			or die_error(undef, "Open git-diff failed");
@@ -2904,40 +2920,67 @@ sub git_blobdiff {
 	}
 
 	# header
-	my $formats_nav =
-		$cgi->a({-href => href(action=>"blobdiff_plain",
-		                       hash=>$hash, hash_parent=>$hash_parent,
-		                       hash_base=>$hash_base, hash_parent_base=>$hash_parent_base,
-		                       file_name=>$file_name, file_parent=>$file_parent)},
-		        "plain");
-	git_header_html();
-	if (defined $hash_base && (my %co = parse_commit($hash_base))) {
-		git_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
-		git_print_header_div('commit', esc_html($co{'title'}), $hash_base);
-	} else {
-		print "<div class=\"page_nav\"><br/>$formats_nav<br/></div>\n";
-		print "<div class=\"title\">$hash vs $hash_parent</div>\n";
-	}
-	if (defined $file_name) {
-		git_print_page_path($file_name, "blob", $hash_base);
+	if ($format eq 'html') {
+		my $formats_nav =
+			$cgi->a({-href => href(action=>"blobdiff_plain",
+			                       hash=>$hash, hash_parent=>$hash_parent,
+			                       hash_base=>$hash_base, hash_parent_base=>$hash_parent_base,
+			                       file_name=>$file_name, file_parent=>$file_parent)},
+			        "plain");
+		git_header_html(undef, $expires);
+		if (defined $hash_base && (my %co = parse_commit($hash_base))) {
+			git_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
+			git_print_header_div('commit', esc_html($co{'title'}), $hash_base);
+		} else {
+			print "<div class=\"page_nav\"><br/>$formats_nav<br/></div>\n";
+			print "<div class=\"title\">$hash vs $hash_parent</div>\n";
+		}
+		if (defined $file_name) {
+			git_print_page_path($file_name, "blob", $hash_base);
+		} else {
+			print "<div class=\"page_path\"></div>\n";
+		}
+
+	} elsif ($format eq 'plain') {
+		print $cgi->header(
+			-type => 'text/plain',
+			-charset => 'utf-8',
+			-expires => $expires,
+			-content_disposition => qq(inline; filename="${file_name}.patch"));
+
+		print "X-Git-Url: " . $cgi->self_url() . "\n\n";
+
 	} else {
-		print "<div class=\"page_path\"></div>\n";
+		die_error(undef, "Unknown blobdiff format");
 	}
 
 	# patch
-	print "<div class=\"page_body\">\n";
+	if ($format eq 'html') {
+		print "<div class=\"page_body\">\n";
 
-	git_patchset_body($fd, [ \%diffinfo ], $hash_base, $hash_parent_base);
-	close $fd;
+		git_patchset_body($fd, [ \%diffinfo ], $hash_base, $hash_parent_base);
+		close $fd;
 
-	print "</div>\n"; # class="page_body"
-	git_footer_html();
+		print "</div>\n"; # class="page_body"
+		git_footer_html();
+
+	} else {
+		while (my $line = <$fd>) {
+			$line =~ s!a/($hash|$hash_parent)!a/$diffinfo{'from_file'}!g;
+			$line =~ s!b/($hash|$hash_parent)!b/$diffinfo{'to_file'}!g;
+
+			print $line;
+
+			last if $line =~ m!^\+\+\+!;
+		}
+		local $/ = undef;
+		print <$fd>;
+		close $fd;
+	}
 }
 
 sub git_blobdiff_plain {
-	mkdir($git_temp, 0700);
-	print $cgi->header(-type => "text/plain", -charset => 'utf-8');
-	git_diff_print($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash, "plain");
+	git_blobdiff('plain');
 }
 
 sub git_commitdiff {
-- 
1.4.1.1

^ permalink raw reply related

* [PATCH 16/19] gitweb: Use git-diff-tree or git-diff patch output for blobdiff
From: Jakub Narebski @ 2006-08-25 19:13 UTC (permalink / raw)
  To: git
In-Reply-To: <200608240015.15071.jnareb@gmail.com>

This is second part of removing gitweb dependency on external
diff (used in git_diff_print).

Get rid of git_diff_print invocation in git_blobdiff, and use either
git-diff-tree (when both hash_base and hash_parent_base are provided)
patch format or git-diff patch format (when only hash and hash_parent
are provided) for output.

Supported URI schemes, and output formats:
* New URI scheme: both hash_base and hash_parent_base (trees-ish
  containing blobs versions we want to compare) are provided.
  Also either filename is provided, or hash (of blob) is provided
  (we try to find filename then).

  For this scheme we have copying and renames detection, mode changes,
  file types etc., and information extended diff header is correct.

* Old URI scheme: hash_parent_base is not provided, we use hash and
  hash_parent to directly compare blobs using git-diff. If no filename
  is given, blobs hashes are used in place of filenames.

  This scheme has always "blob" as file type, it cannot detect mode
  changes, and we rely on CGI parameters to provide name of the file.

Added git_to_hash subroutine, which transforms symbolic name or list
of symbolic name to hash or list of hashes using git-rev-parse.

To have "blob" instead of "unknown" (or "file" regardless of the type)
in "gitweb diff header" for legacy scheme, file_type function now
returns its argument if it is not octal string.

Added support for fake "2" status code in git_patchset_body. Such code
is generated by git_blobdiff in legacy scheme case.

ATTENTION: The order of arguments (operands) to git-diff is reversed
(sic!) to have correct diff in the legacy (no hash_parent_base) case.
$hash_parent, $hash ordering is commented out, as it gives reversed
patch (at least for git version 1.4.1.1) as compared to output in new
scheme and output of older gitweb version.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
P.S. This is the place to mention that it would be nice to have in 
gitweb/README specification what minimal version of git is needed
for some gitweb features; e.g. "history" relies on having --full-history
option to git-rev-list, "blobdiff" (and later "blobdiff_plain") relies
on git-diff which accepts blob hashes, and relies on bug in git-diff...

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

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index a866922..9be2b2c 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -454,7 +454,13 @@ sub mode_str {
 
 # convert file mode in octal to file type string
 sub file_type {
-	my $mode = oct shift;
+	my $mode = shift;
+
+	if ($mode !~ m/^[0-7]+$/) {
+		return $mode;
+	} else {
+		$mode = oct $mode;
+	}
 
 	if (S_ISDIR($mode & S_IFMT)) {
 		return "directory";
@@ -618,6 +624,26 @@ 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
 
@@ -1672,7 +1698,8 @@ sub git_patchset_body {
 				      "</div>\n"; # class="diff_info"
 
 			} elsif ($diffinfo->{'status'} eq "R" || # renamed
-			         $diffinfo->{'status'} eq "C") { # copied
+			         $diffinfo->{'status'} eq "C" || # copied
+			         $diffinfo->{'status'} eq "2") { # with two filenames (from git_blobdiff)
 				print "<div class=\"diff_info\">" .
 				      file_type($diffinfo->{'from_mode'}) . ":" .
 				      $cgi->a({-href => href(action=>"blob", hash_base=>$hash_parent,
@@ -2788,14 +2815,102 @@ sub git_commit {
 }
 
 sub git_blobdiff {
-	mkdir($git_temp, 0700);
-	git_header_html();
+	my $fd;
+	my @difftree;
+	my %diffinfo;
+
+	# preparing $fd and %diffinfo for git_patchset_body
+	# new style URI
+	if (defined $hash_base && defined $hash_parent_base) {
+		if (defined $file_name) {
+			# read raw output
+			open $fd, "-|", $GIT, "diff-tree", '-r', '-M', '-C', $hash_parent_base, $hash_base,
+				"--", $file_name
+				or die_error(undef, "Open git-diff-tree failed");
+			@difftree = map { chomp; $_ } <$fd>;
+			close $fd
+				or die_error(undef, "Reading git-diff-tree failed");
+			@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);
+			}
+
+			# read filtered raw output
+			open $fd, "-|", $GIT, "diff-tree", '-r', '-M', '-C', $hash_parent_base, $hash_base
+				or die_error(undef, "Open git-diff-tree failed");
+			@difftree =
+				# ':100644 100644 03b21826... 3b93d5e7... M	ls-files.c'
+				# $hash == to_id
+				grep { /^:[0-7]{6} [0-7]{6} [0-9a-fA-F]{40} $hash/ }
+				map { chomp; $_ } <$fd>;
+			close $fd
+				or die_error(undef, "Reading git-diff-tree failed");
+			@difftree
+				or die_error('404 Not Found', "Blob diff not found");
+
+		} else {
+			die_error('404 Not Found', "Missing one of the blob diff parameters");
+		}
+
+		if (@difftree > 1) {
+			die_error('404 Not Found', "Ambiguous blob diff specification");
+		}
+
+		%diffinfo = parse_difftree_raw_line($difftree[0]);
+		$file_parent ||= $diffinfo{'from_file'} || $file_name || $diffinfo{'file'};
+		$file_name   ||= $diffinfo{'to_file'}   || $diffinfo{'file'};
+
+		$hash_parent ||= $diffinfo{'from_id'};
+		$hash        ||= $diffinfo{'to_id'};
+
+		# open patch output
+		open $fd, "-|", $GIT, "diff-tree", '-r', '-p', '-M', '-C', $hash_parent_base, $hash_base,
+			"--", $file_name
+			or die_error(undef, "Open git-diff-tree failed");
+	}
+
+	# old/legacy style URI
+	if (!%diffinfo && # if new style URI failed
+	    defined $hash && defined $hash_parent) {
+		# fake git-diff-tree raw output
+		$diffinfo{'from_mode'} = $diffinfo{'to_mode'} = "blob";
+		$diffinfo{'from_id'} = $hash_parent;
+		$diffinfo{'to_id'}   = $hash;
+		if (defined $file_name) {
+			if (defined $file_parent) {
+				$diffinfo{'status'} = '2';
+				$diffinfo{'from_file'} = $file_parent;
+				$diffinfo{'to_file'}   = $file_name;
+			} else { # assume not renamed
+				$diffinfo{'status'} = '1';
+				$diffinfo{'from_file'} = $file_name;
+				$diffinfo{'to_file'}   = $file_name;
+			}
+		} else { # no filename given
+			$diffinfo{'status'} = '2';
+			$diffinfo{'from_file'} = $hash_parent;
+			$diffinfo{'to_file'}   = $hash;
+		}
+
+		#open $fd, "-|", $GIT, "diff", '-p', $hash_parent, $hash
+		open $fd, "-|", $GIT, "diff", '-p', $hash, $hash_parent
+			or die_error(undef, "Open git-diff failed");
+	} else  {
+		die_error('404 Not Found', "Missing one of the blob diff parameters")
+			unless %diffinfo;
+	}
+
+	# header
 	my $formats_nav =
 		$cgi->a({-href => href(action=>"blobdiff_plain",
 		                       hash=>$hash, hash_parent=>$hash_parent,
 		                       hash_base=>$hash_base, hash_parent_base=>$hash_parent_base,
 		                       file_name=>$file_name, file_parent=>$file_parent)},
 		        "plain");
+	git_header_html();
 	if (defined $hash_base && (my %co = parse_commit($hash_base))) {
 		git_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
 		git_print_header_div('commit', esc_html($co{'title'}), $hash_base);
@@ -2803,19 +2918,19 @@ sub git_blobdiff {
 		print "<div class=\"page_nav\"><br/>$formats_nav<br/></div>\n";
 		print "<div class=\"title\">$hash vs $hash_parent</div>\n";
 	}
-	git_print_page_path($file_name, "blob", $hash_base);
-	print "<div class=\"page_body\">\n" .
-	      "<div class=\"diff_info\">blob:" .
-	      $cgi->a({-href => href(action=>"blob", hash=>$hash_parent,
-	                             hash_base=>$hash_parent_base, file_name=>($file_parent || $file_name))},
-	              $hash_parent) .
-	      " -> blob:" .
-	      $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>"; # page_body
+	if (defined $file_name) {
+		git_print_page_path($file_name, "blob", $hash_base);
+	} else {
+		print "<div class=\"page_path\"></div>\n";
+	}
+
+	# patch
+	print "<div class=\"page_body\">\n";
+
+	git_patchset_body($fd, [ \%diffinfo ], $hash_base, $hash_parent_base);
+	close $fd;
+
+	print "</div>\n"; # class="page_body"
 	git_footer_html();
 }
 
-- 
1.4.1.1

^ permalink raw reply related

* [PATCH 19/19] gitweb: Remove creating directory for temporary files
From: Jakub Narebski @ 2006-08-25 19:35 UTC (permalink / raw)
  To: git
In-Reply-To: <200608240015.15071.jnareb@gmail.com>

Remove $git_temp variable which held location for temporary files
needed by git_diff_print, and removed creating $git_temp directory.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
This is last patch in this (admittedly quite large) series, removing
dependency on external diff, and the need for temporary files, from
gitweb.

You can view new gitweb in work at
  http://front.fuw.edu.pl/cgi-bin/jnareb/gitweb.cgi

Changes are in branch "gitweb/web" in repository available at
  http://front.fuw.edu.pl/jnareb/scm/git.git/

Comments appreciated.


 gitweb/gitweb.perl |    6 ------
 1 files changed, 0 insertions(+), 6 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 2f932f0..a6d6637 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -31,9 +31,6 @@ # absolute fs-path which will be prepend
 #our $projectroot = "/pub/scm";
 our $projectroot = "++GITWEB_PROJECTROOT++";
 
-# location for temporary files needed for diffs
-our $git_temp = "/tmp/gitweb";
-
 # target of the home link on top of all pages
 our $home_link = $my_uri || "/";
 
@@ -144,9 +141,6 @@ # version of the core git binary
 our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : "unknown";
 
 $projects_list ||= $projectroot;
-if (! -d $git_temp) {
-	mkdir($git_temp, 0700) || die_error(undef, "Couldn't mkdir $git_temp");
-}
 
 # ======================================================================
 # input validation and dispatch
-- 
1.4.1.1

^ permalink raw reply related

* [PATCH] git-svn: recommend rebase for syncing against an SVN repo
From: Eric Wong @ 2006-08-25 19:48 UTC (permalink / raw)
  To: Seth Falcon; +Cc: git
In-Reply-To: <20060825191516.GA8957@localdomain>

Does this make sense to other git-svn users out there?

pull can give funky history unless you understand how git-svn works
internally, which users should not be expected to do.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
 Documentation/git-svn.txt |   22 ++++++++++++++++++++--
 1 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt
index 7d86809..9fce4d3 100644
--- a/Documentation/git-svn.txt
+++ b/Documentation/git-svn.txt
@@ -212,12 +212,26 @@ # Commit only the git commits you want t
 	git-svn commit <tree-ish> [<tree-ish_2> ...]
 # Commit all the git commits from my-branch that don't exist in SVN:
 	git-svn commit remotes/git-svn..my-branch
-# Something is committed to SVN, pull the latest into your branch:
-	git-svn fetch && git pull . remotes/git-svn
+# Something is committed to SVN, rebase the latest into your branch:
+	git-svn fetch && git rebase remotes/git-svn
 # Append svn:ignore settings to the default git exclude file:
 	git-svn show-ignore >> .git/info/exclude
 ------------------------------------------------------------------------
 
+REBASE VS. PULL
+---------------
+
+Originally, git-svn recommended that the remotes/git-svn branch be
+pulled from.  This is because the author favored 'git-svn commit B'
+to commit a single head rather than the 'git-svn commit A..B' notation
+to commit multiple commits.
+
+If you use 'git-svn commit A..B' to commit several diffs and you do not
+have the latest remotes/git-svn merged into my-branch, you should use
+'git rebase' to update your work branch instead of 'git pull'.  'pull'
+can cause non-linear history to be flattened when committing into SVN,
+which can lead to merge commits reversing previous commits in SVN.
+
 DESIGN PHILOSOPHY
 -----------------
 Merge tracking in Subversion is lacking and doing branched development
@@ -310,6 +324,10 @@ the possible corner cases (git doesn't d
 copied files are fully supported if they're similar enough for git to
 detect them.
 
+SEE ALSO
+--------
+gitlink:git-rebase[1]
+
 Author
 ------
 Written by Eric Wong <normalperson@yhbt.net>.
-- 
1.4.2.g7c9b

^ permalink raw reply related

* [PATCH 00/19] gitweb: Remove dependency on external diff and need for temporary files
From: Jakub Narebski @ 2006-08-25 21:15 UTC (permalink / raw)
  To: git
In-Reply-To: <200608240015.15071.jnareb@gmail.com>

This series of patches (now finished) removes dependency on
external diff (/usr/bin/diff) to produce commitdiff and blobdiff
views, and the need for temporary files.

Comments appreciated.

You can view new gitweb in work at
  http://front.fuw.edu.pl/cgi-bin/jnareb/gitweb.cgi
---
 gitweb/gitweb.css  |   16 +
 gitweb/gitweb.perl |  734 +++++++++++++++++++++++++++++++++++-----------------
 2 files changed, 515 insertions(+), 235 deletions(-)


Shortlog:

01/19 gitweb: Use git-diff-tree patch output for commitdiff
02/19 gitweb: Replace git_commitdiff_plain by anonymous subroutine
03/19 gitweb: Show information about incomplete lines in commitdiff
      Revert "gitweb: Replace git_commitdiff_plain by anonymous
              subroutine"
04/19 gitweb: Remove invalid comment in format_diff_line
05/19 gitweb: Streamify patch output in git_commitdiff
06/19 gitweb: Add git_get_{following,preceding}_references functions
07/19 gitweb: Return on first ref found when
      git_get_preceding_references is called in scalar context
08/19 gitweb: Add git_get_rev_name_tags function
09/19 gitweb: Use git_get_name_rev_tags for commitdiff_plain 
      X-Git-Tag: header
10/19 gitweb: Add support for hash_parent_base parameter for blobdiffs
11/19 gitweb: Allow for pre-parsed difftree info in git_patchset_body
12/19 gitweb: Parse two-line from-file/to-file diff header
      in git_patchset_body
13/19 gitweb: Add invisible hyperlink to from-file/to-file diff header
14/19 gitweb: Always display link to blobdiff_plain in git_blobdiff
15/19 gitweb: Change here-doc back for consistency in git_blobdiff
16/19 gitweb: Use git-diff-tree or git-diff patch output for blobdiff
17/19 gitweb: git_blobdiff_plain is git_blobdiff('plain')
18/19 gitweb: Remove git_diff_print subroutine
19/19 gitweb: Remove creating directory for temporary files

-- 
Jakub Narebski
ShadeHawk on #git
Poland

^ permalink raw reply

* Re: Unresolved issues #3
From: Jakub Narebski @ 2006-08-25 21:22 UTC (permalink / raw)
  To: git
In-Reply-To: <7vpseyelcw.fsf@assigned-by-dhcp.cox.net>

There was a thread about system-wide and per-user git configuration. Some
patches were accepted... but it is nowhere documented. Not all ideas are
incorporated in git.

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

^ permalink raw reply

* Re: [PATCH 19/19] gitweb: Remove creating directory for temporary files
From: Marco Costalba @ 2006-08-25 21:33 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git
In-Reply-To: <200608252135.27894.jnareb@gmail.com>

>
> You can view new gitweb in work at
>   http://front.fuw.edu.pl/cgi-bin/jnareb/gitweb.cgi
>

Very nice job!

Just a couple of suggestion regarding blame.

- Instead of commit sha perhaps is more useful to show author name
(linked to commit) and progressive number of revision.

- Original code lines, ie. imported at the beginning and never
modified, perhaps it is better to view without commit number, this
could obfuscate the view and in any case is not an accurate info
because the line was not modified during initial patch.
[Note] Also in qgit there was the annotation of the first initial
commit in case of unmodified code lines, then Ingo Molnar suggest me
to remove that line and leave it blank for the reasons I reported
above. I think he was right.

Marco

^ permalink raw reply

* Re: [PATCH 19/19] gitweb: Remove creating directory for temporary files
From: Jakub Narebski @ 2006-08-25 21:48 UTC (permalink / raw)
  To: git
In-Reply-To: <e5bfff550608251433o36713ee1na5544992320b5845@mail.gmail.com>

Marco Costalba wrote:

>> You can view new gitweb in work at
>>   http://front.fuw.edu.pl/cgi-bin/jnareb/gitweb.cgi
>>
> 
> Very nice job!
> 
> Just a couple of suggestion regarding blame.

Well, blame code is not mine. 

Luben Tuikov did some work on git_blame2 (using git-blame), original work
was by Florian Forster (using git-annotate). At least it is what I found.

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

^ permalink raw reply

* [PATCH/RFC] gitweb: Restore old git_blame using git-annotate under "annotate"
From: Jakub Narebski @ 2006-08-25 23:47 UTC (permalink / raw)
  To: git

Rename git_blame to git_annotate, and git_blame2 to git_blame.
Link git_annotate under "annotate" action.  Add link to "blame
in git_annotate, and to "annotate" in git_blame.

git_annotate doesn't work correctly yet - error during parsing
some lines.  Needs investigation.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
Not for work, just for testing and comparing the two implementations.
Applies cleanly to 'next' (v1.4.2-g6580c6b).

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

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index a6d6637..6344263 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -229,7 +229,8 @@ if (defined $searchtext) {
 
 # dispatch
 my %actions = (
-	"blame" => \&git_blame2,
+	"blame" => \&git_blame,
+	"annotate" => \&git_annotate,
 	"blobdiff" => \&git_blobdiff,
 	"blobdiff_plain" => \&git_blobdiff_plain,
 	"blob" => \&git_blob,
@@ -2166,7 +2167,7 @@ sub git_tag {
 	git_footer_html();
 }
 
-sub git_blame2 {
+sub git_blame {
 	my $fd;
 	my $ftype;
 
@@ -2193,6 +2194,9 @@ sub git_blame2 {
 		$cgi->a({-href => href(action=>"blob", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)},
 		        "blob") .
 		" | " .
+		$cgi->a({-href => href(action=>"annotate", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)},
+		        "annotate") .
+		" | " .
 		$cgi->a({-href => href(action=>"blame", file_name=>$file_name)},
 		        "head");
 	git_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
@@ -2236,7 +2240,7 @@ HTML
 	git_footer_html();
 }
 
-sub git_blame {
+sub git_annotate {
 	my $fd;
 
 	if (!gitweb_check_feature('blame')) {
@@ -2258,6 +2262,9 @@ sub git_blame {
 		$cgi->a({-href => href(action=>"blob", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)},
 		        "blob") .
 		" | " .
+		$cgi->a({-href => href(action=>"blame", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)},
+		        "blame") .
+		" | " .
 		$cgi->a({-href => href(action=>"blame", file_name=>$file_name)},
 		        "head");
 	git_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
-- 
1.4.1.1

^ permalink raw reply related

* [PATCH] gitweb: git_annotate didn't expect negative numeric timezone
From: Jakub Narebski @ 2006-08-26  0:13 UTC (permalink / raw)
  To: git
In-Reply-To: <200608260147.10880.jnareb@gmail.com>

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
This fixes error in git_annotate mentioned in parent post.

 gitweb/gitweb.perl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 6344263..e5a0db5 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2298,7 +2298,7 @@ HTML
 		chomp $line;
 		$line_class_num = ($line_class_num + 1) % $line_class_len;
 
-		if ($line =~ m/^([0-9a-fA-F]{40})\t\(\s*([^\t]+)\t(\d+) \+\d\d\d\d\t(\d+)\)(.*)$/) {
+		if ($line =~ m/^([0-9a-fA-F]{40})\t\(\s*([^\t]+)\t(\d+) [+-]\d\d\d\d\t(\d+)\)(.*)$/) {
 			$long_rev = $1;
 			$author   = $2;
 			$time     = $3;
-- 
1.4.1.1

^ permalink raw reply related

* Re: [PATCH 19/19] gitweb: Remove creating directory for temporary files
From: Josef Weidendorfer @ 2006-08-26  0:26 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git
In-Reply-To: <200608252135.27894.jnareb@gmail.com>

On Friday 25 August 2006 21:35, you wrote:
> You can view new gitweb in work at
>   http://front.fuw.edu.pl/cgi-bin/jnareb/gitweb.cgi

Hmm... history pages seem not to work.
Otherwise, looks fine.

Josef

^ permalink raw reply

* Re: git-svn problem: unexpected files/diffs in commit
From: Seth Falcon @ 2006-08-26  0:46 UTC (permalink / raw)
  To: git
In-Reply-To: <20060825191516.GA8957@localdomain>

Eric Wong <normalperson@yhbt.net> writes:
> Cool that it works for you, I've yet to get SVN:: libs working with a
> repository I didn't have full read access to.  I assume you have full
> read access?

Yes, I have full rw access on that part of the svn repos.  The 
SVN:: libs are noticeably faster.

Aside:
   For others tracking this: the "SVN::" libs in question are the Perl
   bindings that come with Subversion and are optionally built when
   you build from source.  I wasted some google time searching CPAN
   for SVN:: so this might help someone. :-)

> Outside of the SSL problems, the mis-commit isn't strictly user-error,
> but git-svn is confusing in this case, as the documentation is unclear
> about what git-svn should do in this case :x

> I usually check with git log remotes/git-svn..HEAD instead of git
> diff.  Perhaps adding --no-merges would be more correct?

I'm not sure how to reproduce the situation I was in, but what would
git log have shown me that git diff didn't -- IOW, would it have been
obvious that the commit op was going to add extra stuff and
effectively undo a rev in svn?

> Simple answer: instead of pull, you should've used git rebase.  But I
> don't think the documentation makes it clear at all.

... reads git-rebase man page...
Ah, git-rebase does sound like what I want.

> I've been really slacking on the git-svn documentation the past few
> months, help would be much appreciated.

I will try to send some doc patches.  But I may have a few questions ;-)

> Here's an in-depth explanation:
>
> This is what git-svn does when issued "commit remotes/git-svn..master":
> 1. git-rev-list remotes/git-svn..master | tac =>
> 	0681f7614c342b85b91d909ff02a9a966a44c3f4
> 	0cccf3753b472b52a93154ed8021499055bb3923
>
> 0cccf3753b472b52a93154ed8021499055bb3923 is the result of your
> 'git pull . remotes/git-svn', correct?
> And 0681f7614c342b85b91d909ff02a9a966a44c3f4 was made to git before
> the pull.
>
> So this is what git-svn does, it commits the output of:
> diff-tree f5ebf17f7e460d3bc3de72ab381c72dc76d26936 0681f7614c342b85b91d909ff02a9a966a44c3f4
> (f5eb... is remotes/git-svn at that point).
>
> If the SVN/SSL connection had not died, it would've then proceeded to
> commit the output of:
>
> diff-tree 1b75d81a95da328f0b0d06b7562fdb48970b4c98 0cccf3753b472b52a93154ed8021499055bb3923
> Where 1b75d81a95da328f0b0d06b7562fdb48970b4c98 is the output of your
> previous commit (r19467)

I think I'm getting it.  Thank you very much for providing these details.

> Personally, I've been starting to favor 'git-svn commit-diff' myself
> over 'git-svn commit', as it leaves cleaner history and makes git-svn
> fetch results reproducable on different machines.
>
> [1] - unfortunately, I seem to have forgotten about it since I use
> commit-diff more often these days :x

I think commit-diff might be what I want to be using too, but I need
to contribute some documentation for it before I can read the man page
and start using it ;-)

An example call to git-svn commit-diff would be very helpful, I
suspect.

I will have a look...

While I'm thinking of it, it would be really nice for git-svn's commit and
commit-diff to have a dry-run type of flag.  Commits to your own git
repos are easy to correct, but those made on some other public scm are
less pretty.

Cheers,

+ seth

^ permalink raw reply

* Re: [PATCH 19/19] gitweb: Remove creating directory for temporary files
From: Jakub Narebski @ 2006-08-26  0:46 UTC (permalink / raw)
  To: git
In-Reply-To: <200608260226.25966.Josef.Weidendorfer@gmx.de>

Josef Weidendorfer wrote:

> On Friday 25 August 2006 21:35, you wrote:
>> You can view new gitweb in work at
>>   http://front.fuw.edu.pl/cgi-bin/jnareb/gitweb.cgi
> 
> Hmm... history pages seem not to work.
> Otherwise, looks fine.

Probably git core on this machine (version 1.3.0) is too old and doesn't
support --full-history option to git-rev-list, needed by git_history.

Relevant changes were made to commitdiff, comitdiff_plain, blobdiff and
blobdiff_plain views.
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

^ permalink raw reply

* reversible binary diff
From: Nicolas Pitre @ 2006-08-26  1:04 UTC (permalink / raw)
  To: git


I just noticed that the binary diff format was augmented in order to 
carry the reverse diff information.

Why was this needed?

I mean, if you want to reverse a binary diff you only need to retrieve 
the original blob the forward diff was meant to apply against, and it is 
certainly already available in the object store if the forward diff has 
been previously applied.  Or has this assumption been wrong for some 
work flow?


Nicolas

^ permalink raw reply

* Re: [PATCH 19/19] gitweb: Remove creating directory for temporary files
From: Junio C Hamano @ 2006-08-26  2:05 UTC (permalink / raw)
  To: Marco Costalba; +Cc: git, Jakub Narebski
In-Reply-To: <e5bfff550608251433o36713ee1na5544992320b5845@mail.gmail.com>

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

>> You can view new gitweb in work at
>>   http://front.fuw.edu.pl/cgi-bin/jnareb/gitweb.cgi
>
> Very nice job!
>
> Just a couple of suggestion regarding blame.
>
> - Instead of commit sha perhaps is more useful to show author name
> (linked to commit) and progressive number of revision.

Remember git history is not linear so progressive number does
not make much sense here.  I agree author and commit date would
be nice if they were readily available without cluttering.
A pop-up when hovered, perhaps?

> - Original code lines, ie. imported at the beginning and never
> modified, perhaps it is better to view without commit number, this
> could obfuscate the view and in any case is not an accurate info
> because the line was not modified during initial patch.

That holds only true for very young projects, or ones that were
perfect from the beginning and did not see much action ;-).

^ 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