threads / discuss / 43562

Re: Show remote branches on gitweb

Subject: Re: Show remote branches on gitweb

## tl;dr

12 messages between Nov 24, 2006 and Nov 28, 2006.

replies: 11people: 4as markdown or json

Pazu· Nov 24, 2006, 20:06 UTC · lore

Show remote branches on gitweb

Is there any way to do it? I'm using git-svn to track a remote subversion repository, and it would be very nice to browse the history for a remote branch for which I didn't start a local branch yet.

-- Pazu
Jakub Narebski· Nov 24, 2006, 20:17 UTC · re: Pazu · lore
Pazu wrote:
> Is there any way to do it? I'm using git-svn to track a remote subversion
> repository, and it would be very nice to browse the history for a remote branch
> for which I didn't start a local branch yet.
Planned, not implemented yet.
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
Jakub Narebski· Nov 24, 2006, 20:56 UTC · re: Jakub Narebski · lore
Jakub Narebski wrote:
Show 7 quoted lines
> Pazu wrote:
> 
>> Is there any way to do it? I'm using git-svn to track a remote subversion
>> repository, and it would be very nice to browse the history for a remote branch
>> for which I didn't start a local branch yet.
> 
> Planned, not implemented yet.
The problem is that to implement it _well_ we have to get remotes, both
$GIT_DIR/remotes and config remote.xxx, info. And the latter (config
remotes info) needs config parsing, something we lack.
 
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
Petr Baudis· Nov 24, 2006, 23:59 UTC · re: Jakub Narebski · lore
On Fri, Nov 24, 2006 at 09:56:29PM CET, Jakub Narebski wrote:
Show 13 quoted lines
> Jakub Narebski wrote:
> 
> > Pazu wrote:
> > 
> >> Is there any way to do it? I'm using git-svn to track a remote subversion
> >> repository, and it would be very nice to browse the history for a remote branch
> >> for which I didn't start a local branch yet.
> > 
> > Planned, not implemented yet.
> 
> The problem is that to implement it _well_ we have to get remotes, both
> $GIT_DIR/remotes and config remote.xxx, info. And the latter (config
> remotes info) needs config parsing, something we lack.
Does that mean we _can_ parse $GIT_DIR/remotes? ;-)
-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
The meaning of Stonehenge in Traflamadorian, when viewed from above, is:
"Replacement part being rushed with all possible speed."
Jakub Narebski· Nov 25, 2006, 00:12 UTC · re: Petr Baudis · lore
Petr Baudis wrote:
Show 16 quoted lines
> On Fri, Nov 24, 2006 at 09:56:29PM CET, Jakub Narebski wrote:
>> Jakub Narebski wrote:
>> 
>>> Pazu wrote:
>>> 
>>>> Is there any way to do it? I'm using git-svn to track a remote subversion
>>>> repository, and it would be very nice to browse the history for a remote branch
>>>> for which I didn't start a local branch yet.
>>> 
>>> Planned, not implemented yet.
>> 
>> The problem is that to implement it _well_ we have to get remotes, both
>> $GIT_DIR/remotes and config remote.xxx, info. And the latter (config
>> remotes info) needs config parsing, something we lack.
> 
> Does that mean we _can_ parse $GIT_DIR/remotes? ;-)

No, but for implementing showing remote branches in gitweb _well_, but without frills'n'whistles, it is enough to know files in $GIT_DIR/remotes (Find::find those files), and don't need to parse remotes/ files.

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
Junio C Hamano· Nov 25, 2006, 00:40 UTC · re: Petr Baudis · lore
Petr Baudis <pasky@suse.cz> writes:
Show 5 quoted lines
>> The problem is that to implement it _well_ we have to get remotes, both
>> $GIT_DIR/remotes and config remote.xxx, info. And the latter (config
>> remotes info) needs config parsing, something we lack.
>
> Does that mean we _can_ parse $GIT_DIR/remotes? ;-)

Surely you should be able to. You are working in Perl and the remotes and config are trivially parsable text files.

Petr Baudis· Nov 25, 2006, 00:50 UTC · re: Junio C Hamano · lore
On Sat, Nov 25, 2006 at 01:40:23AM CET, Junio C Hamano wrote:
Show 10 quoted lines
> Petr Baudis <pasky@suse.cz> writes:
> 
> >> The problem is that to implement it _well_ we have to get remotes, both
> >> $GIT_DIR/remotes and config remote.xxx, info. And the latter (config
> >> remotes info) needs config parsing, something we lack.
> >
> > Does that mean we _can_ parse $GIT_DIR/remotes? ;-)
> 
> Surely you should be able to.  You are working in Perl and the
> remotes and config are trivially parsable text files.
But so is the configuration file, unless I'm missing something...?
-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
The meaning of Stonehenge in Traflamadorian, when viewed from above, is:
"Replacement part being rushed with all possible speed."
Junio C Hamano· Nov 25, 2006, 01:04 UTC · re: Petr Baudis · lore
Petr Baudis <pasky@suse.cz> writes:
Show 6 quoted lines
>> > Does that mean we _can_ parse $GIT_DIR/remotes? ;-)
>> 
>> Surely you should be able to.  You are working in Perl and the
>> remotes and config are trivially parsable text files.
>
> But so is the configuration file, unless I'm missing something...?

I do not think you are missing anything. I said that remotes and config are simple trivially parsable text files and Perl should be a pleasant tool to read them with.

So yes, we _can_ parse them, and we _can_ parse configuration file.

Unless I'm missing something...?
Jakub Narebski· Nov 28, 2006, 15:14 UTC · re: Jakub Narebski · lore
Jakub Narebski wrote:
Show 13 quoted lines
> Jakub Narebski wrote:
> 
>> Pazu wrote:
>> 
>>> Is there any way to do it? I'm using git-svn to track a remote subversion
>>> repository, and it would be very nice to browse the history for a remote branch
>>> for which I didn't start a local branch yet.
>> 
>> Planned, not implemented yet.
> 
> The problem is that to implement it _well_ we have to get remotes, both
> $GIT_DIR/remotes and config remote.xxx, info. And the latter (config
> remotes info) needs config parsing, something we lack.
We could simplify things, and assume that remote name is _never_
hierarchical, so that remote branches names are:
  remotes/<remote>/<branch>
where <remote> does not contain '/'.

Additional problem is for "summary" view: should we limit number of heads per remote, should we sort heads inside remote, or should we also sort remotes, or should we sort remotes by time without grouping into repos?

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
Pazu· Nov 27, 2006, 19:20 UTC · re: Jakub Narebski · lore
Jakub Narebski <jnareb <at> gmail.com> writes:
Show 6 quoted lines
> > Is there any way to do it? I'm using git-svn to track a remote
> > subversion repository, and it would be very nice to browse the
> > history for a remote branch for which I didn't start a local
> >branch yet.
> 
> Planned, not implemented yet.

Probably not a technically correct solution, but the following changes did the trick for me.

--- a/gitweb.cgi	2006-11-23 11:02:34.000000000 -0200
+++ b/gitweb.cgi	2006-11-27 10:09:56.000000000 -0200
@@ -1428,8 +1431,7 @@
 
 	open my $fd, '-|', git_cmd(), 'for-each-ref',
 		($limit ? '--count='.($limit+1) : ()), '--sort=-committerdate',
-		'--format=%(objectname) %(refname) %(subject)%00%(committer)',
-		'refs/heads'
+		'--format=%(objectname) %(refname) %(subject)%00%(committer)'
 		or return;
 	while (my $line = <$fd>) {
 		my %ref_item;
@@ -1440,6 +1442,7 @@
 		my ($committer, $epoch, $tz) =
 			($committerinfo =~ /^(.*) ([0-9]+) (.*)$/);
 		$name =~ s!^refs/heads/!!;
+		$name =~ s!^refs/remotes/!!;
 
 		$ref_item{'name'}  = $name;
 		$ref_item{'id'}    = $hash;



I've just changed the git_get_heads_list function to let 'for-each-ref'
return all top refs instead of just those in refs/heads, and added a line to
remove 'refs/remotes/' from the remote branch names.

Again, probably not the right solution, but now I have remote branches listed
under "heads", and that's all I really need.

-- Pazu
Jakub Narebski· Nov 27, 2006, 19:26 UTC · re: Pazu · lore
Pazu wrote:
Show 42 quoted lines
> Jakub Narebski <jnareb <at> gmail.com> writes:
> 
>> > Is there any way to do it? I'm using git-svn to track a remote
>> > subversion repository, and it would be very nice to browse the
>> > history for a remote branch for which I didn't start a local
>> >branch yet.
>> 
>> Planned, not implemented yet.
> 
> Probably not a technically correct solution, but the following changes did the
> trick for me.
> 
> 
> --- a/gitweb.cgi      2006-11-23 11:02:34.000000000 -0200
> +++ b/gitweb.cgi      2006-11-27 10:09:56.000000000 -0200
> @@ -1428,8 +1431,7 @@
>  
>       open my $fd, '-|', git_cmd(), 'for-each-ref',
>               ($limit ? '--count='.($limit+1) : ()), '--sort=-committerdate',
> -             '--format=%(objectname) %(refname) %(subject)%00%(committer)',
> -             'refs/heads'
> +             '--format=%(objectname) %(refname) %(subject)%00%(committer)'
>               or return;
>       while (my $line = <$fd>) {
>               my %ref_item;
> @@ -1440,6 +1442,7 @@
>               my ($committer, $epoch, $tz) =
>                       ($committerinfo =~ /^(.*) ([0-9]+) (.*)$/);
>               $name =~ s!^refs/heads/!!;
> +             $name =~ s!^refs/remotes/!!;
>  
>               $ref_item{'name'}  = $name;
>               $ref_item{'id'}    = $hash;
> 
> 
> 
> I've just changed the git_get_heads_list function to let 'for-each-ref'
> return all top refs instead of just those in refs/heads, and added a line to
> remove 'refs/remotes/' from the remote branch names.
> 
> Again, probably not the right solution, but now I have remote branches listed
> under "heads", and that's all I really need.
What about tags (refs/tags/), which shouldn't be here?

Besides, it is quick'n'dirty solution; I'm not against having it as a patch in git mailing list archives, but I'd rather not have it there.

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
Pazu· Nov 28, 2006, 02:59 UTC · re: Jakub Narebski · lore
Jakub Narebski <jnareb <at> gmail.com> writes:
> What about tags (refs/tags/), which shouldn't be here?

Yeah, I just noticed that when I pointed gitweb to git's own repository (my project's repository currently has no tags). I've added a "next if $name =~ m!^refs/tags/!;" for now.

> Besides, it is quick'n'dirty solution; I'm not against having it as a patch
> in git mailing list archives, but I'd rather not have it there.

Yes, it's quick and dirty. I didn't mean to have it published anywhere (and to anyone reading this from the archives: please don't use that ugly, quick, and really dirty patch).

I posted it as a way to say that I'm one more happy git user. While one could say that hacking gitweb to achieve happiness is cheating, the fact that I *could* do that easily, even when I barely understand perl, is a really big plus for me. You guys rock, really.

-- Pazu

← back to recent threads