* [PATCH] gitweb.cgi: Teach tree->raw to not require the hash of the blob
@ 2006-07-12 3:43 Luben Tuikov
2006-07-12 6:16 ` Junio C Hamano
0 siblings, 1 reply; 8+ messages in thread
From: Luben Tuikov @ 2006-07-12 3:43 UTC (permalink / raw)
To: git
[-- Attachment #1: Type: text/plain, Size: 503 bytes --]
Teach tree->raw to not require the hash of the blob, but to
figure it out from the file name. This allows to externally
link to files into the repository, such that the hash is not
required. I.e. the file obtained would be as of the HEAD
commit.
In contrast tree->blob for binary files passes the hash, as
does tree->blob->plain for "text/*" files.
Signed-off-by: Luben Tuikov <ltuikov@yahoo.com>
---
gitweb/gitweb.cgi | 20 ++++++++++++++++----
1 files changed, 16 insertions(+), 4 deletions(-)
[-- Attachment #2: pat1827152979 --]
[-- Type: application/octet-stream, Size: 2055 bytes --]
diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi
index 2e87de4..e904eb7 100755
--- a/gitweb/gitweb.cgi
+++ b/gitweb/gitweb.cgi
@@ -1521,6 +1521,14 @@ sub git_blob_plain_mimetype {
}
sub git_blob_plain {
+ if (!defined $hash) {
+ if (defined $file_name) {
+ my $base = $hash_base || git_read_head($project);
+ $hash = git_get_hash_by_path($base, $file_name, "blob") || die_error(undef, "Error lookup file.");
+ } else {
+ die_error(undef, "No file name defined.");
+ }
+ }
my $type = shift;
open my $fd, "-|", "$gitbin/git-cat-file blob $hash" or die_error("Couldn't cat $file_name, $hash");
@@ -1544,9 +1552,13 @@ sub git_blob_plain {
}
sub git_blob {
- if (!defined $hash && defined $file_name) {
- my $base = $hash_base || git_read_head($project);
- $hash = git_get_hash_by_path($base, $file_name, "blob") || die_error(undef, "Error lookup file.");
+ if (!defined $hash) {
+ if (defined $file_name) {
+ my $base = $hash_base || git_read_head($project);
+ $hash = git_get_hash_by_path($base, $file_name, "blob") || die_error(undef, "Error lookup file.");
+ } else {
+ die_error(undef, "No file name defined.");
+ }
}
my $have_blame = git_get_project_config_bool ('blame');
open my $fd, "-|", "$gitbin/git-cat-file blob $hash" or die_error(undef, "Open failed.");
@@ -1678,8 +1690,7 @@ sub git_tree {
$cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$t_hash$base_key;f=$base$t_name")}, "blob") .
# " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blame;h=$t_hash$base_key;f=$base$t_name")}, "blame") .
" | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=history;h=$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") .
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob_plain;f=$base$t_name")}, "raw") .
"</td>\n";
} elsif ($t_type eq "tree") {
print "<td class=\"list\">" .
--
1.4.1.g9ca3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] gitweb.cgi: Teach tree->raw to not require the hash of the blob
2006-07-12 3:43 [PATCH] gitweb.cgi: Teach tree->raw to not require the hash of the blob Luben Tuikov
@ 2006-07-12 6:16 ` Junio C Hamano
2006-07-12 8:32 ` Jakub Narebski
2006-07-12 17:52 ` Luben Tuikov
0 siblings, 2 replies; 8+ messages in thread
From: Junio C Hamano @ 2006-07-12 6:16 UTC (permalink / raw)
To: ltuikov; +Cc: git
Luben Tuikov <ltuikov@yahoo.com> writes:
> Teach tree->raw to not require the hash of the blob, but to
> figure it out from the file name. This allows to externally
> link to files into the repository, such that the hash is not
> required. I.e. the file obtained would be as of the HEAD
> commit.
>
> In contrast tree->blob for binary files passes the hash, as
> does tree->blob->plain for "text/*" files.
>
> Signed-off-by: Luben Tuikov <ltuikov@yahoo.com>
> ---
> gitweb/gitweb.cgi | 20 ++++++++++++++++----
> 1 files changed, 16 insertions(+), 4 deletions(-)
This has exactly the same line number problem.
@@ -1678,8 +1690,7 @@ sub git_tree {
$cgi->a({-href => "$my_uri?" . esc...
# " | " . $cgi->a({-href => "$my_uri...
" | " . $cgi->a({-href => "$my_uri...
- " | " . $cgi->a({-href => "$my_uri...
+ " | " . $cgi->a({-href => "$my_uri...
"</td>\n";
} elsif ($t_type eq "tree") {
print "<td class=\"list\">" .
You are removing one line and adding one line, so the number of
old and new lines better match.
Hand-applied, tried, got confused and dropped.
I think _allowing_ to accept filename not hash is a sane change,
and would be useful if you want to allow linking to always the
HEAD version from external sites, but I do not think listing the
raw link in the tree view without the hash is a good idea. It
makes things quite confusing that "blob" link in its
neighbourhood gives the blob from that specific version, but
"raw" gives the version from HEAD, even when you are browsing
something other than HEAD.
BTW, can somebody volunteer to be a gitweb/ "subsystem
maintainer"?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] gitweb.cgi: Teach tree->raw to not require the hash of the blob
2006-07-12 6:16 ` Junio C Hamano
@ 2006-07-12 8:32 ` Jakub Narebski
2006-07-12 18:02 ` Luben Tuikov
2006-07-12 17:52 ` Luben Tuikov
1 sibling, 1 reply; 8+ messages in thread
From: Jakub Narebski @ 2006-07-12 8:32 UTC (permalink / raw)
To: git
Junio C Hamano wrote:
> Luben Tuikov <ltuikov@yahoo.com> writes:
>
>> Teach tree->raw to not require the hash of the blob, but to
>> figure it out from the file name. This allows to externally
>> link to files into the repository, such that the hash is not
>> required. I.e. the file obtained would be as of the HEAD
>> commit.
>>
>> In contrast tree->blob for binary files passes the hash, as
>> does tree->blob->plain for "text/*" files.
> I think _allowing_ to accept filename not hash is a sane change,
> and would be useful if you want to allow linking to always the
> HEAD version from external sites, but I do not think listing the
> raw link in the tree view without the hash is a good idea. It
> makes things quite confusing that "blob" link in its
> neighbourhood gives the blob from that specific version, but
> "raw" gives the version from HEAD, even when you are browsing
> something other than HEAD.
>
> BTW, can somebody volunteer to be a gitweb/ "subsystem
> maintainer"?
I think the change to raw aka. blob_plain and not to plain is because in
plain view you have this HEAD link which takes us to HEAD revision of the
file (even if we are on different branch IIRC).
Workaround for either format is to remove 'h' (hash) parameter entirely, and
put in 'hb' (hashbase aka headref aka branch) the branch name. Gitweb then
shows the contents of latest version of the file.
BTW. sometimes you want to link to specific version of the file, and
sometimes to newest. I think it would be best (if possible, feasible, and
not too much resource consuming) that links from tree specified by hash be
to specified by hash version of file, while links from tree specified by
headref and name only would have links to latest version of the file.
--
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] gitweb.cgi: Teach tree->raw to not require the hash of the blob
2006-07-12 6:16 ` Junio C Hamano
2006-07-12 8:32 ` Jakub Narebski
@ 2006-07-12 17:52 ` Luben Tuikov
2006-07-14 5:49 ` Junio C Hamano
1 sibling, 1 reply; 8+ messages in thread
From: Luben Tuikov @ 2006-07-12 17:52 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
--- Junio C Hamano <junkio@cox.net> wrote:
> Luben Tuikov <ltuikov@yahoo.com> writes:
>
> > Teach tree->raw to not require the hash of the blob, but to
> > figure it out from the file name. This allows to externally
> > link to files into the repository, such that the hash is not
> > required. I.e. the file obtained would be as of the HEAD
> > commit.
> >
> > In contrast tree->blob for binary files passes the hash, as
> > does tree->blob->plain for "text/*" files.
> >
> > Signed-off-by: Luben Tuikov <ltuikov@yahoo.com>
> > ---
> > gitweb/gitweb.cgi | 20 ++++++++++++++++----
> > 1 files changed, 16 insertions(+), 4 deletions(-)
>
> This has exactly the same line number problem.
[cut]
> Hand-applied, tried, got confused and dropped.
I'll regenerate and send it to the list.
> I think _allowing_ to accept filename not hash is a sane change,
> and would be useful if you want to allow linking to always the
> HEAD version from external sites,
Indeed, it is useful.
> but I do not think listing the
> raw link in the tree view without the hash is a good idea. It
> makes things quite confusing that "blob" link in its
> neighbourhood gives the blob from that specific version, but
> "raw" gives the version from HEAD, even when you are browsing
> something other than HEAD.
I just thought it to be an easy place to put the "raw"-no-hash
link.
BTW, Junio, it would be a shame to lose this capability. How
would you like to proceed with this? Where would you like to
see this kind of link go?
> BTW, can somebody volunteer to be a gitweb/ "subsystem
> maintainer"?
Make sure you pick someone liberal without personal aspirations
or turning it into a personal crusade. Service to the community
(not self, or company XYZ) is best.
Luben
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] gitweb.cgi: Teach tree->raw to not require the hash of the blob
2006-07-12 8:32 ` Jakub Narebski
@ 2006-07-12 18:02 ` Luben Tuikov
2006-07-12 18:12 ` Jakub Narebski
0 siblings, 1 reply; 8+ messages in thread
From: Luben Tuikov @ 2006-07-12 18:02 UTC (permalink / raw)
To: Jakub Narebski, junkio; +Cc: git
--- Jakub Narebski <jnareb@gmail.com> wrote:
> Junio C Hamano wrote:
>
> > Luben Tuikov <ltuikov@yahoo.com> writes:
> >
> >> Teach tree->raw to not require the hash of the blob, but to
> >> figure it out from the file name. This allows to externally
> >> link to files into the repository, such that the hash is not
> >> required. I.e. the file obtained would be as of the HEAD
> >> commit.
> >>
> >> In contrast tree->blob for binary files passes the hash, as
> >> does tree->blob->plain for "text/*" files.
>
> > I think _allowing_ to accept filename not hash is a sane change,
> > and would be useful if you want to allow linking to always the
> > HEAD version from external sites, but I do not think listing the
> > raw link in the tree view without the hash is a good idea. It
> > makes things quite confusing that "blob" link in its
> > neighbourhood gives the blob from that specific version, but
> > "raw" gives the version from HEAD, even when you are browsing
> > something other than HEAD.
> >
> > BTW, can somebody volunteer to be a gitweb/ "subsystem
> > maintainer"?
>
> I think the change to raw aka. blob_plain and not to plain is because in
> plain view you have this HEAD link which takes us to HEAD revision of the
> file (even if we are on different branch IIRC).
>
> Workaround for either format is to remove 'h' (hash) parameter entirely, and
> put in 'hb' (hashbase aka headref aka branch) the branch name. Gitweb then
> shows the contents of latest version of the file.
>
> BTW. sometimes you want to link to specific version of the file, and
> sometimes to newest. I think it would be best (if possible, feasible, and
> not too much resource consuming) that links from tree specified by hash be
> to specified by hash version of file, while links from tree specified by
> headref and name only would have links to latest version of the file.
You seem to have hand-edited the mail headers to remove
Junio and myself from the CC/To headers list, but leave git@vger.
Please don't do that. Just click Reply-All and continue with your
message.
Thanks,
Luben
P.S. Restored.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] gitweb.cgi: Teach tree->raw to not require the hash of the blob
2006-07-12 18:02 ` Luben Tuikov
@ 2006-07-12 18:12 ` Jakub Narebski
0 siblings, 0 replies; 8+ messages in thread
From: Jakub Narebski @ 2006-07-12 18:12 UTC (permalink / raw)
To: ltuikov, junkio, git
On 7/12/06, Luben Tuikov <ltuikov@yahoo.com> wrote:
> You seem to have hand-edited the mail headers to remove
> Junio and myself from the CC/To headers list, but leave git@vger.
>
> Please don't do that. Just click Reply-All and continue with your
> message.
No, I've just replied from newsreader (not mail client) via GMane news
interface to git mailing list (gmane.comp.version-control.git), and I forgot
to use Reply-All, i.e. use mail as well as news interface.
Besides I seem to have problems trying to configure KNode to send
mail, especially with mixed mail+news sending.
--
Jakub Narebski
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] gitweb.cgi: Teach tree->raw to not require the hash of the blob
@ 2006-07-13 3:31 Luben Tuikov
0 siblings, 0 replies; 8+ messages in thread
From: Luben Tuikov @ 2006-07-13 3:31 UTC (permalink / raw)
To: git
[-- Attachment #1: Type: text/plain, Size: 502 bytes --]
Teach tree->raw to not require the hash of the blob, but to
figure it out from the file name. This allows to externally
link to files into the repository, such that the hash is not
required. I.e. the file obtained would be as of the HEAD
commit.
In contrast tree->blob for binary files passes the hash, as
does tree->blob->plain for "text/*" files.
Signed-off-by: Luben Tuikov <ltuikov@yahoo.com>
---
gitweb/gitweb.cgi | 20 ++++++++++++++++----
1 files changed, 16 insertions(+), 4 deletions(-)
[-- Attachment #2: pat867582916 --]
[-- Type: application/octet-stream, Size: 2055 bytes --]
diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi
index 2e87de4..e904eb7 100755
--- a/gitweb/gitweb.cgi
+++ b/gitweb/gitweb.cgi
@@ -1521,6 +1521,14 @@ sub git_blob_plain_mimetype {
}
sub git_blob_plain {
+ if (!defined $hash) {
+ if (defined $file_name) {
+ my $base = $hash_base || git_read_head($project);
+ $hash = git_get_hash_by_path($base, $file_name, "blob") || die_error(undef, "Error lookup file.");
+ } else {
+ die_error(undef, "No file name defined.");
+ }
+ }
my $type = shift;
open my $fd, "-|", "$gitbin/git-cat-file blob $hash" or die_error("Couldn't cat $file_name, $hash");
@@ -1544,9 +1552,13 @@ sub git_blob_plain {
}
sub git_blob {
- if (!defined $hash && defined $file_name) {
- my $base = $hash_base || git_read_head($project);
- $hash = git_get_hash_by_path($base, $file_name, "blob") || die_error(undef, "Error lookup file.");
+ if (!defined $hash) {
+ if (defined $file_name) {
+ my $base = $hash_base || git_read_head($project);
+ $hash = git_get_hash_by_path($base, $file_name, "blob") || die_error(undef, "Error lookup file.");
+ } else {
+ die_error(undef, "No file name defined.");
+ }
}
my $have_blame = git_get_project_config_bool ('blame');
open my $fd, "-|", "$gitbin/git-cat-file blob $hash" or die_error(undef, "Open failed.");
@@ -1678,8 +1690,7 @@ sub git_tree {
$cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$t_hash$base_key;f=$base$t_name")}, "blob") .
# " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blame;h=$t_hash$base_key;f=$base$t_name")}, "blame") .
" | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=history;h=$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") .
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob_plain;f=$base$t_name")}, "raw") .
"</td>\n";
} elsif ($t_type eq "tree") {
print "<td class=\"list\">" .
--
1.4.1.g9ca3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] gitweb.cgi: Teach tree->raw to not require the hash of the blob
2006-07-12 17:52 ` Luben Tuikov
@ 2006-07-14 5:49 ` Junio C Hamano
0 siblings, 0 replies; 8+ messages in thread
From: Junio C Hamano @ 2006-07-14 5:49 UTC (permalink / raw)
To: ltuikov; +Cc: git
Luben Tuikov <ltuikov@yahoo.com> writes:
>> I think _allowing_ to accept filename not hash is a sane change,
>> and would be useful if you want to allow linking to always the
>> HEAD version from external sites,
>
> Indeed, it is useful.
>
>> but I do not think listing the
>> raw link in the tree view without the hash is a good idea. It
>> makes things quite confusing that "blob" link in its
>> neighbourhood gives the blob from that specific version, but
>> "raw" gives the version from HEAD, even when you are browsing
>> something other than HEAD.
>
> I just thought it to be an easy place to put the "raw"-no-hash
> link.
>
> BTW, Junio, it would be a shame to lose this capability. How
> would you like to proceed with this? Where would you like to
> see this kind of link go?
My preference?
Allowing to link the HEAD version from an _external_ source is
useful (i.e. you can put a link in gitwiki to point at a file
and say "the latest is always available at this URL").
We already support these:
a=blob&f=README
a=blob&f=README&hb=HEAD
a=blob&f=README&hb=HEAD~20
but not these:
a=blob_plain&f=README
a=blob_plain&f=t/test4012.png
The last example that does not generate text is less of a
problem, thanks to your previous patch, because "sub git_blob"
supports the "filename with or without hash base" syntax and
sends the correct hash to git_blob_plain to fall back, but that
does not help for text files. This patch corrects that, which
is nice.
However, I do not think the change to "sub git_tree" makes much
sense. The links within gitweb-generated pages are about
browsing the history. As I already said, having <blob> link
that is history specific and <raw> link which is not (iow always
goes to HEAD) next to each other is confusing, and you are
making it less easy to get a raw output from a specific version
because you removed that feature from the link and replaced it
with something less useful.
If somebody wants to see what the latest version of a blob looks
like while browsing the history with gitweb, I think it is a
more natural workflow to go to <history> link and find the
latest version. So maybe you might want to add <raw> link in
the output of the history action?
Side note: right now, <history> link does not show any
history newer than the commit that has the link itself;
maybe there is a room for improvement there but we need
to be careful not to trash the webserver caching.
Obviously you could go back to the repository top page and start
digging the latest tree from the top, but that is a bit more
cumbersome.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2006-07-14 5:49 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-12 3:43 [PATCH] gitweb.cgi: Teach tree->raw to not require the hash of the blob Luben Tuikov
2006-07-12 6:16 ` Junio C Hamano
2006-07-12 8:32 ` Jakub Narebski
2006-07-12 18:02 ` Luben Tuikov
2006-07-12 18:12 ` Jakub Narebski
2006-07-12 17:52 ` Luben Tuikov
2006-07-14 5:49 ` Junio C Hamano
-- strict thread matches above, loose matches on Subject: below --
2006-07-13 3:31 Luben Tuikov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).