git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] gitweb: Strip trailing slashes from $path in git_get_hash_by_path

From
Jakub Narebski <jnareb@gmail.com>
Date
Sep 21, 2006, 12:23 UTC
Message-ID
<200609211423.29729.jnareb@gmail.com>
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
Next: Jakub Narebski
Message 1 of 2 in “gitweb: Strip trailing slashes from $path in git_get_hash_by_path”
  1. gitweb: Strip trailing slashes from $path in git_get_hash_by_pathJakub Narebski, Sep 21, 2006
  2. gitweb: Make git_get_hash_by_path check type if providedJakub Narebski, Sep 21, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.