* Re: [PATCH 2/3] gitweb: Filter out commit ID from @difftree in git_commit and git_commitdiff
2006-10-24 11:54 ` [PATCH 2/3] gitweb: Filter out commit ID from @difftree in git_commit and git_commitdiff Jakub Narebski
@ 2006-10-25 4:36 ` Junio C Hamano
2006-10-25 8:03 ` Jakub Narebski
2006-10-25 12:17 ` [PATCH 4/3] gitweb: Use --no-commit-id " Jakub Narebski
2006-10-25 12:23 ` [PATCH 2/3 (amend)] " Jakub Narebski
2 siblings, 1 reply; 8+ messages in thread
From: Junio C Hamano @ 2006-10-25 4:36 UTC (permalink / raw)
To: Jakub Narebski; +Cc: git
Jakub Narebski <jnareb@gmail.com> writes:
> Filter out commit ID output that git-diff-tree adds when called with
> only one <tree-ish> (not only for --stdin) in git_commit and
> git_commitdiff.
I initially wondered why this, or other existing such sripping,
is necessary in the first place.
The collected result is given to git_difftree_body() and it
feeds parse_difftree_raw_line() with it. Interestingly enough,
it _is_ prepared to handle the line with the commit object
name.
However, the very initial part of git_difftree_body assumes that
the array it gets does not have the commit object name (i.e. it
counts the array members and says "N files changed").
So I think your change is probably a good one, but I suspect you
probably are better off to make parse_difftree_raw_line() to
barf when it gets the commit object name to make sure that all
callers strip it at the same time; better yet, perhaps you can
have a single function that invokes git-diff-tree -r (with
different parameters) and returns the result that is already
only the difftree body lines?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/3] gitweb: Filter out commit ID from @difftree in git_commit and git_commitdiff
2006-10-25 4:36 ` Junio C Hamano
@ 2006-10-25 8:03 ` Jakub Narebski
0 siblings, 0 replies; 8+ messages in thread
From: Jakub Narebski @ 2006-10-25 8:03 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
Junio C Hamano wrote:
> Jakub Narebski <jnareb@gmail.com> writes:
>
>> Filter out commit ID output that git-diff-tree adds when called with
>> only one <tree-ish> (not only for --stdin) in git_commit and
>> git_commitdiff.
>
> I initially wondered why this, or other existing such sripping,
> is necessary in the first place.
>
> The collected result is given to git_difftree_body() and it
> feeds parse_difftree_raw_line() with it. Interestingly enough,
> it _is_ prepared to handle the line with the commit object
> name.
Perhaps I was overeager in adding that. The only place it was used
was git_tree_blame in the proof-of-concept/RFC patch which added
"tree_blame" view, and even there it was discarded solution: using
git-diff-tree can give only commit which changed the file to current
version; it cannot find commit which changed tree/directory (latest
commit which changed any of its files).
This can be useful if at any time we need to parse git-diff-tree --stdin
output.
> However, the very initial part of git_difftree_body assumes that
> the array it gets does not have the commit object name (i.e. it
> counts the array members and says "N files changed").
The same is true for git_patchset_body. Moreover if I remember correctly
they count elements of @difftree array (or do equivalent of counting)
_before_ parsing.
> So I think your change is probably a good one, but I suspect you
> probably are better off to make parse_difftree_raw_line() to
> barf when it gets the commit object name to make sure that all
> callers strip it at the same time;
I'd rather not do that, and leave parse_difftree_raw_line generic.
> better yet, perhaps you can
> have a single function that invokes git-diff-tree -r (with
> different parameters) and returns the result that is already
> only the difftree body lines?
That would be good idea... if not for the fact that git_commitdiff
uses --patch-with-raw format... but that would make it only slightly
more complicated (strip commit-id, or rather tree-ish from output,
and stop on end of raw part i.e. on first empty line).
I'll do that (unless someone else would do this first).
--
Jakub Narebski
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 4/3] gitweb: Use --no-commit-id in git_commit and git_commitdiff
2006-10-24 11:54 ` [PATCH 2/3] gitweb: Filter out commit ID from @difftree in git_commit and git_commitdiff Jakub Narebski
2006-10-25 4:36 ` Junio C Hamano
@ 2006-10-25 12:17 ` Jakub Narebski
2006-10-25 12:23 ` [PATCH 2/3 (amend)] " Jakub Narebski
2 siblings, 0 replies; 8+ messages in thread
From: Jakub Narebski @ 2006-10-25 12:17 UTC (permalink / raw)
To: git
Use --no-commit-id option to git diff-tree command in git_commit and
git_commitdiff to filter out commit ID output that git-diff-tree adds
when called with only one <tree-ish> (not only for --stdin).
This option is in git since at least v1.0.0, so make use of it.
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
Gaaah, --no-commit-id is at least since v1.0.0, and we do require
--full-history and --git-dir options which are much later additions.
This is "correction" patch.
gitweb/gitweb.perl | 11 ++++-------
1 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index e35ecb4..345e336 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -3004,14 +3004,12 @@ sub git_commit {
if (!defined $parent) {
$parent = "--root";
}
- open my $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts, $parent, $hash
+ open my $fd, "-|", git_cmd(), "diff-tree", '-r', "--no-commit-id",
+ @diff_opts, $parent, $hash
or die_error(undef, "Open git-diff-tree failed");
my @difftree = map { chomp; $_ } <$fd>;
close $fd or die_error(undef, "Reading git-diff-tree failed");
- # filter out commit ID output
- @difftree = grep(!/^[0-9a-fA-F]{40}$/, @difftree);
-
# non-textual hash id's can be cached
my $expires;
if ($hash =~ m/^[0-9a-fA-F]{40}$/) {
@@ -3324,15 +3322,14 @@ sub git_commitdiff {
my @difftree;
if ($format eq 'html') {
open $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts,
+ "--no-commit-id",
"--patch-with-raw", "--full-index", $hash_parent, $hash
or die_error(undef, "Open git-diff-tree failed");
while (chomp(my $line = <$fd>)) {
# empty line ends raw part of diff-tree output
last unless $line;
- # filter out commit ID output
- push @difftree, $line
- unless $line =~ m/^[0-9a-fA-F]{40}$/;
+ push @difftree, $line;
}
} elsif ($format eq 'plain') {
--
1.4.2.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/3 (amend)] gitweb: Use --no-commit-id in git_commit and git_commitdiff
2006-10-24 11:54 ` [PATCH 2/3] gitweb: Filter out commit ID from @difftree in git_commit and git_commitdiff Jakub Narebski
2006-10-25 4:36 ` Junio C Hamano
2006-10-25 12:17 ` [PATCH 4/3] gitweb: Use --no-commit-id " Jakub Narebski
@ 2006-10-25 12:23 ` Jakub Narebski
2 siblings, 0 replies; 8+ messages in thread
From: Jakub Narebski @ 2006-10-25 12:23 UTC (permalink / raw)
To: git
Use --no-commit-id option to git diff-tree command in git_commit and
git_commitdiff to filter out commit ID output that git-diff-tree adds
when called with only one <tree-ish> (not only for --stdin).
This option is in git since at least v1.0.0, so make use of it.
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
This is "amend" patch. It adds --no-commit-id option to git-diff-tree
invocation instead of removing commit IDs (tree-ish IDs to be more exact)
from git-diff-tree output.
Still, I'm not sure why git-diff-tree outputs tree-ish before diff
when called with only one tree-ish. Bugwards compatibility?
gitweb/gitweb.perl | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 8ac60be..345e336 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -3004,7 +3004,8 @@ sub git_commit {
if (!defined $parent) {
$parent = "--root";
}
- open my $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts, $parent, $hash
+ open my $fd, "-|", git_cmd(), "diff-tree", '-r', "--no-commit-id",
+ @diff_opts, $parent, $hash
or die_error(undef, "Open git-diff-tree failed");
my @difftree = map { chomp; $_ } <$fd>;
close $fd or die_error(undef, "Reading git-diff-tree failed");
@@ -3321,6 +3322,7 @@ sub git_commitdiff {
my @difftree;
if ($format eq 'html') {
open $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts,
+ "--no-commit-id",
"--patch-with-raw", "--full-index", $hash_parent, $hash
or die_error(undef, "Open git-diff-tree failed");
--
1.4.2.1
^ permalink raw reply related [flat|nested] 8+ messages in thread