git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] git-instaweb: Add option to reuse previous config file
@ 2010-06-01 13:44 Pavan Kumar Sunkara
  2010-06-01 20:40 ` Jakub Narebski
  2010-06-02  9:44 ` Petr Baudis
  0 siblings, 2 replies; 5+ messages in thread
From: Pavan Kumar Sunkara @ 2010-06-01 13:44 UTC (permalink / raw
  To: git, jnareb, chriscool, pasky; +Cc: Pavan Kumar Sunkara

Add an option to git-instaweb which allows the usage of the old
gitweb_config.perl situated in '.git/gitweb' dir. When the option
is in use, gitweb_conf() won't be used and thus the gitweb_config.perl
won't be overwritten.

Usage:
	git instaweb --reuse-config

Example:
	When I use git-instaweb, it is hard to add the line (Use of
highlighting support) $feature{'highlight'}{'default'] = [1]; to the
gitweb_config.perl file everytime I initiate the server. With this,
it's enough to use this option.

Also update Documentation of git-instaweb

Signed-off-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
---
 Documentation/git-instaweb.txt |    5 ++++-
 git-instaweb.sh                |    8 +++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/Documentation/git-instaweb.txt b/Documentation/git-instaweb.txt
index 2c3c4d2..0e7e20b 100644
--- a/Documentation/git-instaweb.txt
+++ b/Documentation/git-instaweb.txt
@@ -9,7 +9,7 @@ SYNOPSIS
 --------
 [verse]
 'git instaweb' [--local] [--httpd=<httpd>] [--port=<port>]
-               [--browser=<browser>]
+               [--browser=<browser>] [--reuse-config]
 'git instaweb' [--start] [--stop] [--restart]
 
 DESCRIPTION
@@ -49,6 +49,9 @@ OPTIONS
 	linkgit:git-web--browse[1] for more information about this. If
 	the script fails, the URL will be printed to stdout.
 
+--reuse-config::
+	The previous gitweb_config.perl will not be overwritten.
+
 --start::
 	Start the httpd instance and exit.  This does not generate
 	any of the configuration files for spawning a new instance.
diff --git a/git-instaweb.sh b/git-instaweb.sh
index 1af4d5a..7b8b8d1 100755
--- a/git-instaweb.sh
+++ b/git-instaweb.sh
@@ -13,6 +13,7 @@ p,port=        the port to bind to
 d,httpd=       the command to launch
 b,browser=     the browser to launch
 m,module-path= the module path (only needed for apache2)
+reuse-config	To use the previous gitweb_config.perl file from GIT_DIR. It will not be overwritten.
  Action
 stop           stop the web server
 start          start the web server
@@ -27,6 +28,7 @@ httpd="$(git config --get instaweb.httpd)"
 root="$(git config --get instaweb.gitwebdir)"
 port=$(git config --get instaweb.port)
 module_path="$(git config --get instaweb.modulepath)"
+no_reuse=true
 
 conf="$GIT_DIR/gitweb/httpd.conf"
 
@@ -171,6 +173,10 @@ do
 		shift
 		module_path="$1"
 		;;
+	--reuse-config)
+		shift
+		no_reuse=false
+		;;
 	--)
 		;;
 	*)
@@ -551,7 +557,7 @@ our \$projects_list = \$projectroot;
 EOF
 }
 
-gitweb_conf
+test "$no_reuse" = true && gitweb_conf
 
 resolve_full_httpd
 mkdir -p "$fqgitdir/gitweb/$httpd_only"
-- 
1.7.1.390.gb0a41.dirty

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] git-instaweb: Add option to reuse previous config file
  2010-06-01 13:44 [PATCH] git-instaweb: Add option to reuse previous config file Pavan Kumar Sunkara
@ 2010-06-01 20:40 ` Jakub Narebski
       [not found]   ` <AANLkTinmDi-4nZm9x81FlDbp9mJMLoWmom2qUKnSLIrZ@mail.gmail.com>
  2010-06-02  9:44 ` Petr Baudis
  1 sibling, 1 reply; 5+ messages in thread
From: Jakub Narebski @ 2010-06-01 20:40 UTC (permalink / raw
  To: Pavan Kumar Sunkara; +Cc: git, Christian Couder, Petr Baudis

On Tue, 1 June 2010, Pavan Kumar Sunkara wrote:

> Add an option to git-instaweb which allows the usage of the old
> gitweb_config.perl situated in '.git/gitweb' dir. When the option
> is in use, gitweb_conf() won't be used and thus the gitweb_config.perl
> won't be overwritten.

I think that the correct solution would be to avoid overwriting
(customized) git-instaweb's gitweb_config.perl, but to generate it if
it does not exist.

In addition to code change (see below), this would mean that the last
sentence of the above paragraph of the commit message would read:

  When the option is in use, gitweb_config.perl generated by
  git-instaweb won't be overwritten.

Or something like that.

> 
> Usage:
> 	git instaweb --reuse-config
> 
> Example:
> 	When I use git-instaweb, it is hard to add the line (Use of
> highlighting support) $feature{'highlight'}{'default'] = [1]; to the
> gitweb_config.perl file everytime I initiate the server. With this,
> it's enough to use this option.

Hmmm, perhaps gitweb_config.perl file used by git-instaweb should
enable all features... but some features (like mentioned above
'highlight' feature) depends on external tools to be installed (like
'highlight' being in $PATH for 'highlight' feature).

So this wouldn't solve your problem, I don't think.

> 
> Also update Documentation of git-instaweb

Actually this sentene is not strictly necessary: when adding new
option you should update manpage respectively.  It is not something
that is worth mentioning, IMVHO.

> 
> Signed-off-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
> ---

> @@ -49,6 +49,9 @@ OPTIONS
>  	linkgit:git-web--browse[1] for more information about this. If
>  	the script fails, the URL will be printed to stdout.
>  
> +--reuse-config::
> +	The previous gitweb_config.perl will not be overwritten.
> +

This can imply that if file does not exist, it would be generated.

> diff --git a/git-instaweb.sh b/git-instaweb.sh
> index 1af4d5a..7b8b8d1 100755
> --- a/git-instaweb.sh
> +++ b/git-instaweb.sh
> @@ -13,6 +13,7 @@ p,port=        the port to bind to
>  d,httpd=       the command to launch
>  b,browser=     the browser to launch
>  m,module-path= the module path (only needed for apache2)
> +reuse-config	To use the previous gitweb_config.perl file from GIT_DIR. It will not be overwritten.

First, misaligned (using TAB instead of SP, like the rest of
entries).  Second, too long.

  m,module-path= the module path (only needed for apache2)
  +reuse-config  reuse previous gitweb_config.perl from GIT_DIR

>   Action
>  stop           stop the web server
>  start          start the web server
> @@ -27,6 +28,7 @@ httpd="$(git config --get instaweb.httpd)"
>  root="$(git config --get instaweb.gitwebdir)"
>  port=$(git config --get instaweb.port)
>  module_path="$(git config --get instaweb.modulepath)"
> +no_reuse=true
>  
>  conf="$GIT_DIR/gitweb/httpd.conf"
>  
> @@ -171,6 +173,10 @@ do
>  		shift
>  		module_path="$1"
>  		;;
> +	--reuse-config)
> +		shift
> +		no_reuse=false
> +		;;
>  	--)
>  		;;
>  	*)
> @@ -551,7 +557,7 @@ our \$projects_list = \$projectroot;
>  EOF
>  }
>  
> -gitweb_conf
> +test "$no_reuse" = true && gitweb_conf

You would need to test somewhere if gitweb_config.perl file exists,
and if it does not exist generate it anyway, independent on
`--reuse-config` variable.

-- 
Jakub Narebski
Poland

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] git-instaweb: Add option to reuse previous config file
       [not found]   ` <AANLkTinmDi-4nZm9x81FlDbp9mJMLoWmom2qUKnSLIrZ@mail.gmail.com>
@ 2010-06-01 20:51     ` Pavan Kumar Sunkara
  2010-06-01 21:31     ` Jakub Narebski
  1 sibling, 0 replies; 5+ messages in thread
From: Pavan Kumar Sunkara @ 2010-06-01 20:51 UTC (permalink / raw
  To: Git List

2010/6/2 Jakub Narebski <jnareb@gmail.com>
>
> On Tue, 1 June 2010, Pavan Kumar Sunkara wrote:
>
> > Add an option to git-instaweb which allows the usage of the old
> > gitweb_config.perl situated in '.git/gitweb' dir. When the option
> > is in use, gitweb_conf() won't be used and thus the gitweb_config.perl
> > won't be overwritten.
>
> I think that the correct solution would be to avoid overwriting
> (customized) git-instaweb's gitweb_config.perl, but to generate it if
> it does not exist.
>

So, you say that there is no use of this option ?
Well, what happens if someone want's to overwrite their gitweb_config.perl ?

>
> In addition to code change (see below), this would mean that the last
> sentence of the above paragraph of the commit message would read:
>
>  When the option is in use, gitweb_config.perl generated by
>  git-instaweb won't be overwritten.
>
> Or something like that.
>

Ok.

>
> >
> > Usage:
> >       git instaweb --reuse-config
> >
> > Example:
> >       When I use git-instaweb, it is hard to add the line (Use of
> > highlighting support) $feature{'highlight'}{'default'] = [1]; to the
> > gitweb_config.perl file everytime I initiate the server. With this,
> > it's enough to use this option.
>
> Hmmm, perhaps gitweb_config.perl file used by git-instaweb should
> enable all features... but some features (like mentioned above
> 'highlight' feature) depends on external tools to be installed (like
> 'highlight' being in $PATH for 'highlight' feature).
>
> So this wouldn't solve your problem, I don't think.
>

Yeah. That is why I came up with this. I am tired of adding extra
lines in the file everytime I start the server.

>
> >
> > Also update Documentation of git-instaweb
>
> Actually this sentene is not strictly necessary: when adding new
> option you should update manpage respectively.  It is not something
> that is worth mentioning, IMVHO.
>

I don't know that. Sorry.

>
> >
> > Signed-off-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
> > ---
>
> > @@ -49,6 +49,9 @@ OPTIONS
> >       linkgit:git-web--browse[1] for more information about this. If
> >       the script fails, the URL will be printed to stdout.
> >
> > +--reuse-config::
> > +     The previous gitweb_config.perl will not be overwritten.
> > +
>
> This can imply that if file does not exist, it would be generated.
>
> > diff --git a/git-instaweb.sh b/git-instaweb.sh
> > index 1af4d5a..7b8b8d1 100755
> > --- a/git-instaweb.sh
> > +++ b/git-instaweb.sh
> > @@ -13,6 +13,7 @@ p,port=        the port to bind to
> >  d,httpd=       the command to launch
> >  b,browser=     the browser to launch
> >  m,module-path= the module path (only needed for apache2)
> > +reuse-config To use the previous gitweb_config.perl file from GIT_DIR. It will not be overwritten.
>
> First, misaligned (using TAB instead of SP, like the rest of
> entries).  Second, too long.
>
>  m,module-path= the module path (only needed for apache2)
>  +reuse-config  reuse previous gitweb_config.perl from GIT_DIR
>
Ok.

>
> >   Action
> >  stop           stop the web server
> >  start          start the web server
> > @@ -27,6 +28,7 @@ httpd="$(git config --get instaweb.httpd)"
> >  root="$(git config --get instaweb.gitwebdir)"
> >  port=$(git config --get instaweb.port)
> >  module_path="$(git config --get instaweb.modulepath)"
> > +no_reuse=true
> >
> >  conf="$GIT_DIR/gitweb/httpd.conf"
> >
> > @@ -171,6 +173,10 @@ do
> >               shift
> >               module_path="$1"
> >               ;;
> > +     --reuse-config)
> > +             shift
> > +             no_reuse=false
> > +             ;;
> >       --)
> >               ;;
> >       *)
> > @@ -551,7 +557,7 @@ our \$projects_list = \$projectroot;
> >  EOF
> >  }
> >
> > -gitweb_conf
> > +test "$no_reuse" = true && gitweb_conf
>
> You would need to test somewhere if gitweb_config.perl file exists,
> and if it does not exist generate it anyway, independent on
> `--reuse-config` variable.
>

Ok. Please answer the above question, so that I can prepare another version.
Thanks,
Pavan.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] git-instaweb: Add option to reuse previous config file
       [not found]   ` <AANLkTinmDi-4nZm9x81FlDbp9mJMLoWmom2qUKnSLIrZ@mail.gmail.com>
  2010-06-01 20:51     ` Pavan Kumar Sunkara
@ 2010-06-01 21:31     ` Jakub Narebski
  1 sibling, 0 replies; 5+ messages in thread
From: Jakub Narebski @ 2010-06-01 21:31 UTC (permalink / raw
  To: Pavan Kumar Sunkara; +Cc: git, Christian Couder, Petr Baudis

Pavan Kumar Sunkara wrote:
> 2010/6/2 Jakub Narebski <jnareb@gmail.com>
> 
> > On Tue, 1 June 2010, Pavan Kumar Sunkara wrote:
> >
> > > Add an option to git-instaweb which allows the usage of the old
> > > gitweb_config.perl situated in '.git/gitweb' dir. When the option
> > > is in use, gitweb_conf() won't be used and thus the gitweb_config.perl
> > > won't be overwritten.
> >
> > I think that the correct solution would be to avoid overwriting
> > (customized) git-instaweb's gitweb_config.perl, but to generate it if
> > it does not exist.
> 
> So, you say that there is no use of this option ?
> Well, what happens if someone want's to overwrite their 
> gitweb_config.perl?

No, I am not saying that.

If git-instaweb is invoked *without* --reuse-config, the gitweb_config.perl
would be regenerated whether it exists or not, overwriting your changes.

If git-instaweb is invoked *with* --reuse-config, the gitweb_config.perl
would be generated if it does not exist (so if you delete gitweb_config.perl
and then run 'git instaweb --reuse-config' it would not fail), and reused
if it does exist.

  test "$no_reuse" = true || test ! -e "$GITWEB_CONFIG" && gitweb_conf

or something like that (the test if $GITWEB_CONFIG file exists might be
moved to the fragment of code that sets no_reuse to true instead).

-- 
Jakub Narebski
Poland

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] git-instaweb: Add option to reuse previous config file
  2010-06-01 13:44 [PATCH] git-instaweb: Add option to reuse previous config file Pavan Kumar Sunkara
  2010-06-01 20:40 ` Jakub Narebski
@ 2010-06-02  9:44 ` Petr Baudis
  1 sibling, 0 replies; 5+ messages in thread
From: Petr Baudis @ 2010-06-02  9:44 UTC (permalink / raw
  To: Pavan Kumar Sunkara, Jakub Narebski; +Cc: git, chriscool

On Tue, Jun 01, 2010 at 07:14:05PM +0530, Pavan Kumar Sunkara wrote:
> @@ -551,7 +557,7 @@ our \$projects_list = \$projectroot;
>  EOF
>  }
>  
> -gitweb_conf
> +test "$no_reuse" = true && gitweb_conf
>  
>  resolve_full_httpd
>  mkdir -p "$fqgitdir/gitweb/$httpd_only"

It is a better style to write:

	test "$no_reuse" = false || gitweb_conf

The reason is that the script can then be easily run with set -e. But I
know that the rest of git-instaweb doesn't really follow this
convention, so this is just a nitpick. (Moreover, why do you have option
--reuse-config but variable no_reuse with an oppposite meaning?)

On Tue, Jun 01, 2010 at 11:31:37PM +0200, Jakub Narebski wrote:
> If git-instaweb is invoked *without* --reuse-config, the gitweb_config.perl
> would be regenerated whether it exists or not, overwriting your changes.
> 
> If git-instaweb is invoked *with* --reuse-config, the gitweb_config.perl
> would be generated if it does not exist (so if you delete gitweb_config.perl
> and then run 'git instaweb --reuse-config' it would not fail), and reused
> if it does exist.

That sounds like a good idea, but I think at that point --reuse-config
gets to be a way too misleading name. --keep-config might be tiny bit
better, but not a lot.

>   test "$no_reuse" = true || test ! -e "$GITWEB_CONFIG" && gitweb_conf
> 
> or something like that (the test if $GITWEB_CONFIG file exists might be
> moved to the fragment of code that sets no_reuse to true instead).

BTW, I think at the point you have to chain more than two pieces at once
in the boolean sequence, it gets clearer to write an if. Just my
personal opinion, though. (Mainly because I can never remember the
priorities. ;-)


-- 
				Petr "Pasky" Baudis
The true meaning of life is to plant a tree under whose shade
you will never sit.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-06-02  9:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-01 13:44 [PATCH] git-instaweb: Add option to reuse previous config file Pavan Kumar Sunkara
2010-06-01 20:40 ` Jakub Narebski
     [not found]   ` <AANLkTinmDi-4nZm9x81FlDbp9mJMLoWmom2qUKnSLIrZ@mail.gmail.com>
2010-06-01 20:51     ` Pavan Kumar Sunkara
2010-06-01 21:31     ` Jakub Narebski
2010-06-02  9:44 ` Petr Baudis

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).