# [PATCH] gitweb: tree view: hash_base and hash are now context sensitive

12 messages from 2006-09-26 to 2006-10-02. Participants: Luben Tuikov, Jakub Narebski, Junio C Hamano.
Thread: https://gitlist.dev/t/5708

## Luben Tuikov, 2006-09-26 19:47

Subject: [PATCH] gitweb: tree view: hash_base and hash are now context sensitive
Message-ID: <20060926194706.32255.qmail@web31804.mail.mud.yahoo.com>
URL: https://gitlist.dev/e/20060926194706.32255.qmail%40web31804.mail.mud.yahoo.com

```
In tree view, by default, hash_base is HEAD and hash is the
entry equivalent.  Else the user had selected a hash_base or
hash, say by clicking on a revision or commit, in which case
those values are used.

Signed-off-by: Luben Tuikov <ltuikov@yahoo.com>
---
 gitweb/gitweb.perl |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)


diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 8e9c827..56638f2 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1625,7 +1625,7 @@ sub git_print_tree_entry {
 			              "history");
 		}
 		print " | " .
-			$cgi->a({-href => href(action=>"blob_plain", hash_base=>"HEAD",
+			$cgi->a({-href => href(action=>"blob_plain", hash_base=>$hash_base,
 					       file_name=>"$basedir$t->{'name'}")},
 				"raw");
 		print "</td>\n";
@@ -2713,14 +2713,14 @@ sub git_tree {
 	my ($ctype, $suffix, $command) = gitweb_check_feature('snapshot');
 	my $have_snapshot = (defined $ctype && defined $suffix);
 
+	if (!defined $hash_base) {
+		$hash_base = "HEAD";
+	}
 	if (!defined $hash) {
-		$hash = git_get_head_hash($project);
 		if (defined $file_name) {
-			my $base = $hash_base || $hash;
-			$hash = git_get_hash_by_path($base, $file_name, "tree");
-		}
-		if (!defined $hash_base) {
-			$hash_base = $hash;
+			$hash = git_get_hash_by_path($hash_base, $file_name, "tree");
+		} else {
+			$hash = $hash_base;
 		}
 	}
 	$/ = "\0";
-- 
1.4.2.1.g893b0

```

## Jakub Narebski, 2006-09-26 20:34

Subject: Re: [PATCH] gitweb: tree view: hash_base and hash are now context sensitive
Message-ID: <efc2t8$eti$3@sea.gmane.org>
URL: https://gitlist.dev/e/efc2t8%24eti%243%40sea.gmane.org
In-Reply-To: <20060926194706.32255.qmail@web31804.mail.mud.yahoo.com>

```
Luben Tuikov wrote:

> In tree view, by default, hash_base is HEAD and hash is the
> entry equivalent.  Else the user had selected a hash_base or
> hash, say by clicking on a revision or commit, in which case
> those values are used.

I think that this need some thinking over. For blob we have two
"base" objects: tree which have specified blob, and commit which
have tree which have specified blob. We might want to specify
that all hash*base are to the commit-ish.
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

```

## Luben Tuikov, 2006-09-26 21:17

Subject: Re: [PATCH] gitweb: tree view: hash_base and hash are now context sensitive
Message-ID: <20060926211720.21355.qmail@web31808.mail.mud.yahoo.com>
URL: https://gitlist.dev/e/20060926211720.21355.qmail%40web31808.mail.mud.yahoo.com
In-Reply-To: <efc2t8$eti$3@sea.gmane.org>

```
--- Jakub Narebski <jnareb@gmail.com> wrote:
> I think that this need some thinking over. For blob we have two
> "base" objects: tree which have specified blob, and commit which
> have tree which have specified blob. We might want to specify
> that all hash*base are to the commit-ish.

Agreed, we should always refer to the commit-ish, for obvious
reasons.

This patch doesn't make this decision though.  It simply
sets hash_base to HEAD if not defined.

Now, since "git-ls-tree" works on both commit-ish and
tree-ish, we are ok.

    Luben

```

## Junio C Hamano, 2006-09-27 06:48

Subject: Re: [PATCH] gitweb: tree view: hash_base and hash are now context sensitive
Message-ID: <7v1wpxhkj9.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7v1wpxhkj9.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <20060926211720.21355.qmail@web31808.mail.mud.yahoo.com>

```
Luben Tuikov <ltuikov@yahoo.com> writes:

> --- Jakub Narebski <jnareb@gmail.com> wrote:
>> I think that this need some thinking over. For blob we have two
>> "base" objects: tree which have specified blob, and commit which
>> have tree which have specified blob. We might want to specify
>> that all hash*base are to the commit-ish.
>
> Agreed, we should always refer to the commit-ish, for obvious
> reasons.
>
> This patch doesn't make this decision though.  It simply
> sets hash_base to HEAD if not defined.
>
> Now, since "git-ls-tree" works on both commit-ish and
> tree-ish, we are ok.

I think so, too.  Jakub?

```

## Luben Tuikov, 2006-09-27 22:53

Subject: Re: [PATCH] gitweb: tree view: hash_base and hash are now context sensitive
Message-ID: <20060927225342.7695.qmail@web31801.mail.mud.yahoo.com>
URL: https://gitlist.dev/e/20060927225342.7695.qmail%40web31801.mail.mud.yahoo.com
In-Reply-To: <7v1wpxhkj9.fsf@assigned-by-dhcp.cox.net>

```
--- Junio C Hamano <junkio@cox.net> wrote:
> Luben Tuikov <ltuikov@yahoo.com> writes:
> 
> > --- Jakub Narebski <jnareb@gmail.com> wrote:
> >> I think that this need some thinking over. For blob we have two
> >> "base" objects: tree which have specified blob, and commit which
> >> have tree which have specified blob. We might want to specify
> >> that all hash*base are to the commit-ish.
> >
> > Agreed, we should always refer to the commit-ish, for obvious
> > reasons.
> >
> > This patch doesn't make this decision though.  It simply
> > sets hash_base to HEAD if not defined.
> >
> > Now, since "git-ls-tree" works on both commit-ish and
> > tree-ish, we are ok.
> 
> I think so, too.  Jakub?

Status?  I see Jakub hasn't objected, and it is really important
for us to be able to link to "latest" binary blob -- for example
a PDF spec file.

   Luben

```

## Luben Tuikov, 2006-09-28 18:52

Subject: Re: [PATCH] gitweb: tree view: hash_base and hash are now context sensitive
Message-ID: <20060928185232.96094.qmail@web31802.mail.mud.yahoo.com>
URL: https://gitlist.dev/e/20060928185232.96094.qmail%40web31802.mail.mud.yahoo.com
In-Reply-To: <20060927225342.7695.qmail@web31801.mail.mud.yahoo.com>

```
--- Luben Tuikov <ltuikov@yahoo.com> wrote:
> --- Junio C Hamano <junkio@cox.net> wrote:
> > Luben Tuikov <ltuikov@yahoo.com> writes:
> > 
> > > --- Jakub Narebski <jnareb@gmail.com> wrote:
> > >> I think that this need some thinking over. For blob we have two
> > >> "base" objects: tree which have specified blob, and commit which
> > >> have tree which have specified blob. We might want to specify
> > >> that all hash*base are to the commit-ish.
> > >
> > > Agreed, we should always refer to the commit-ish, for obvious
> > > reasons.
> > >
> > > This patch doesn't make this decision though.  It simply
> > > sets hash_base to HEAD if not defined.
> > >
> > > Now, since "git-ls-tree" works on both commit-ish and
> > > tree-ish, we are ok.
> > 
> > I think so, too.  Jakub?
> 
> Status?  I see Jakub hasn't objected, and it is really important
> for us to be able to link to "latest" binary blob -- for example
> a PDF spec file.

Junio,

What are the objections to this patch?

Thanks,
   Luben

```

## Junio C Hamano, 2006-09-29 06:06

Subject: Re: [PATCH] gitweb: tree view: hash_base and hash are now context sensitive
Message-ID: <7vmz8jp5p3.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vmz8jp5p3.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <20060928185232.96094.qmail@web31802.mail.mud.yahoo.com>

```
Luben Tuikov <ltuikov@yahoo.com> writes:

>> > > Agreed, we should always refer to the commit-ish, for obvious
>> > > reasons.
>> > >
>> > > This patch doesn't make this decision though.  It simply
>> > > sets hash_base to HEAD if not defined.
>> > >
>> > > Now, since "git-ls-tree" works on both commit-ish and
>> > > tree-ish, we are ok.
>> > 
>> > I think so, too.  Jakub?
>> 
>> Status?  I see Jakub hasn't objected, and it is really important
>> for us to be able to link to "latest" binary blob -- for example
>> a PDF spec file.
>
> Junio,
>
> What are the objections to this patch?

No objections from me --- rather lack of objections from Jakub ;-)

But the fragments do not appear to apply anymore.

@@ -1625,7 +1625,7 @@ sub git_print_tree_entry {
 			              "history");
 		}
 		print " | " .
-			$cgi->a({-href => href(action=>"blob_plain", hash_base=>"HEAD",
+			$cgi->a({-href => href(action=>"blob_plain", hash_base=>$hash_base,
 					       file_name=>"$basedir$t->{'name'}")},
 				"raw");
 		print "</td>\n";

There is no call to create blob_plain link with hash_base
hardcoded to "HEAD" in git-print-tree-entry.

Care to re-spin?

```

## Luben Tuikov, 2006-09-29 16:16

Subject: Re: [PATCH] gitweb: tree view: hash_base and hash are now context sensitive
Message-ID: <20060929161619.24848.qmail@web31806.mail.mud.yahoo.com>
URL: https://gitlist.dev/e/20060929161619.24848.qmail%40web31806.mail.mud.yahoo.com
In-Reply-To: <7vmz8jp5p3.fsf@assigned-by-dhcp.cox.net>

```
--- Junio C Hamano <junkio@cox.net> wrote:
> > What are the objections to this patch?
> 
> No objections from me --- rather lack of objections from Jakub ;-)

We haven't heard anything from him, and on our last correspondence
in this thread it seemed we're in agreement.

> But the fragments do not appear to apply anymore.
[...]
> There is no call to create blob_plain link with hash_base
> hardcoded to "HEAD" in git-print-tree-entry.
> 
> Care to re-spin?

Doing it right now.

Thanks,
   Luben

```

## Jakub Narebski, 2006-09-29 20:35

Subject: Re: [PATCH] gitweb: tree view: hash_base and hash are now context sensitive
Message-ID: <200609292235.27478.jnareb@gmail.com>
URL: https://gitlist.dev/e/200609292235.27478.jnareb%40gmail.com
In-Reply-To: <20060929161619.24848.qmail@web31806.mail.mud.yahoo.com>

```
Luben Tuikov wrote:
> --- Junio C Hamano <junkio@cox.net> wrote:
> > > What are the objections to this patch?
> > 
> > No objections from me --- rather lack of objections from Jakub ;-)
> 
> We haven't heard anything from him, and on our last correspondence
> in this thread it seemed we're in agreement.

As a interim solution it is a good idea, moreover with using $hash_base
defaulting to HEAD instead of using HEAD literaly.

The correct solution would be to make "html" page (i.e. "blob" not 
"blob_plain" view) also for binary files. <img> element for image/*
mimetype, perhaps <embed> or <object>, or just plain link for other
binary (not text/* or some application/*) types

I was AFK for few days.
-- 
Jakub Narebski
Poland

```

## Luben Tuikov, 2006-09-29 23:30

Subject: Re: [PATCH] gitweb: tree view: hash_base and hash are now context sensitive
Message-ID: <20060929233037.42926.qmail@web31808.mail.mud.yahoo.com>
URL: https://gitlist.dev/e/20060929233037.42926.qmail%40web31808.mail.mud.yahoo.com
In-Reply-To: <200609292235.27478.jnareb@gmail.com>

```
--- Jakub Narebski <jnareb@gmail.com> wrote:
> As a interim solution it is a good idea, moreover with using $hash_base
> defaulting to HEAD instead of using HEAD literaly.
> 
> The correct solution would be to make "html" page (i.e. "blob" not 
> "blob_plain" view) also for binary files. <img> element for image/*
> mimetype, perhaps <embed> or <object>, or just plain link for other
> binary (not text/* or some application/*) types

We already do have a hash_base context. It is what allows us to
"select" a revision from shortlog and ask "tree", "history", etc
from there on, having set "h" and/or "hb".

What this patch does is simply set "h" and/or "hb" to
the string "HEAD" instead of the string "<SHA1 of HEAD>" when
h/hb is not defined.

    Luben


> 
> I was AFK for few days.
> -- 
> Jakub Narebski
> Poland
> 

```

## Jakub Narebski, 2006-10-01 22:27

Subject: Re: [PATCH] gitweb: tree view: hash_base and hash are now context sensitive
Message-ID: <efpfc3$765$1@sea.gmane.org>
URL: https://gitlist.dev/e/efpfc3%24765%241%40sea.gmane.org
In-Reply-To: <20060929233037.42926.qmail@web31808.mail.mud.yahoo.com>

```
Luben Tuikov wrote:

> What this patch does is simply set "h" and/or "hb" to
> the string "HEAD" instead of the string "<SHA1 of HEAD>" when
> h/hb is not defined.

I guess there it is a good idea, but we should always think
over if we want "constant" link, always showing the same thing,
or a "variable" (or "news") link, showing current version.

Explicit sha1 hash as 'h'/'hb' gives persistent, cacheable link,
while e.g. "HEAD" gives "variable" link.
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

```

## Luben Tuikov, 2006-10-02 19:51

Subject: Re: [PATCH] gitweb: tree view: hash_base and hash are now context sensitive
Message-ID: <20061002195110.33802.qmail@web31801.mail.mud.yahoo.com>
URL: https://gitlist.dev/e/20061002195110.33802.qmail%40web31801.mail.mud.yahoo.com
In-Reply-To: <efpfc3$765$1@sea.gmane.org>

```
--- Jakub Narebski <jnareb@gmail.com> wrote:
> Luben Tuikov wrote:
> 
> > What this patch does is simply set "h" and/or "hb" to
> > the string "HEAD" instead of the string "<SHA1 of HEAD>" when
> > h/hb is not defined.
> 
> I guess there it is a good idea, but we should always think
> over if we want "constant" link, always showing the same thing,
> or a "variable" (or "news") link, showing current version.
> 
> Explicit sha1 hash as 'h'/'hb' gives persistent, cacheable link,
> while e.g. "HEAD" gives "variable" link.

Exactly what is wanted by people using git in a work environment.

   Luben
P.S. Please don't edit out the CC list leaving only git in. Click
"Reply-all" please, just like everyone else does.

```
