* [PATCH] gitweb: Strip trailing slashes from $path in git_get_hash_by_path
@ 2006-09-21 12:23 Jakub Narebski
2006-09-21 16:09 ` [PATCH] gitweb: Make git_get_hash_by_path check type if provided Jakub Narebski
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Narebski @ 2006-09-21 12:23 UTC (permalink / raw)
To: git
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
While
git ls-tree $base -- dirname
shows dirname entry (that's what we want)
git ls-tree $base -- dirname/
shows directory _contents_.
gitweb/gitweb.perl | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index fb8d37e..403bba1 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -719,7 +719,7 @@ sub git_get_hash_by_path {
my $base = shift;
my $path = shift || return undef;
- my $tree = $base;
+ $path =~ s,/+$,,;
open my $fd, "-|", git_cmd(), "ls-tree", $base, "--", $path
or die_error(undef, "Open git-ls-tree failed");
--
1.4.2.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* [PATCH] gitweb: Make git_get_hash_by_path check type if provided
2006-09-21 12:23 [PATCH] gitweb: Strip trailing slashes from $path in git_get_hash_by_path Jakub Narebski
@ 2006-09-21 16:09 ` Jakub Narebski
0 siblings, 0 replies; 2+ messages in thread
From: Jakub Narebski @ 2006-09-21 16:09 UTC (permalink / raw)
To: git
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
This patch depends textually (as context) from the previous patch.
It can be applied using -C1 without applying previous patch first.
gitweb/gitweb.perl | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 403bba1..7ed963c 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -718,6 +718,7 @@ # get hash of given path at given ref
sub git_get_hash_by_path {
my $base = shift;
my $path = shift || return undef;
+ my $type = shift;
$path =~ s,/+$,,;
@@ -728,6 +729,10 @@ sub git_get_hash_by_path {
#'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
$line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t(.+)$/;
+ if (defined $type && $type ne $2) {
+ # type doesn't match
+ return undef;
+ }
return $3;
}
--
1.4.2.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-09-21 16:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-21 12:23 [PATCH] gitweb: Strip trailing slashes from $path in git_get_hash_by_path Jakub Narebski
2006-09-21 16:09 ` [PATCH] gitweb: Make git_get_hash_by_path check type if provided Jakub Narebski
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.