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

[PATCH 3/4] git-instaweb: Move all actions at the end of script

From
Jakub Narebski <jnareb@gmail.com>
Date
Jun 23, 2011, 20:59 UTC
Message-ID
<20110623195652.18265.50516.stgit@localhost.localdomain>
In-Reply-To
<20110623194624.18265.82482.stgit@localhost.localdomain>
As a nice side-effect now the order of parameters does not matter:
  $ git instaweb --httpd=apache2 --start
is now (after this patch) the same as
  $ git instaweb --start --httpd=apache2

Before this commit --start, --stop, --restart (and their subcommand versions start, stop, restart) exited immediately.

This is preparatory work for making start/restart check that correct configuration is set up; this change was required to have access in start_httpd to requested web browser etc.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
Unfortunately there are no tests for git-instaweb, so I couldn't test
if it is really no much of a functional change.

BTW. if you thought of a better subject for this commit, please speak up.

 git-instaweb.sh |   27 ++++++++++++++++++++-------
 1 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/git-instaweb.sh b/git-instaweb.sh
index 2be22a0..9a2f20f 100755
--- a/git-instaweb.sh
+++ b/git-instaweb.sh
@@ -27,6 +27,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)"
+action="browse"
 
 conf="$GIT_DIR/gitweb/httpd.conf"
 
@@ -148,17 +149,13 @@ while test $# != 0
 do
 	case "$1" in
 	--stop|stop)
-		stop_httpd
-		exit 0
+		action="stop"
 		;;
 	--start|start)
-		start_httpd
-		exit 0
+		action="start"
 		;;
 	--restart|restart)
-		stop_httpd
-		start_httpd
-		exit 0
+		action="restart"
 		;;
 	-l|--local)
 		local=true
@@ -611,6 +608,22 @@ configure_httpd() {
 	esac
 }
 
+case "$action" in
+stop)
+	stop_httpd
+	exit 0
+	;;
+start)
+	start_httpd
+	exit 0
+	;;
+restart)
+	stop_httpd
+	start_httpd
+	exit 0
+	;;
+esac
+
 gitweb_conf
 
 resolve_full_httpd
Previous: Jakub NarebskiNext: Jakub Narebski
Message 8 of 10 in “Having some problem with instaweb”
  1. Gurjeet SinghJun 23, 2011
  2. Jakub NarebskiJun 23, 2011
  3. Gurjeet SinghJun 23, 2011
  4. Jakub NarebskiJun 23, 2011
  5. 0/4 git-instaweb: Improving handling of --start/--restartJakub Narebski, Jun 23, 2011
  6. 1/4 git-instaweb: Extract configuring web server into configure_httpdJakub Narebski, Jun 23, 2011
  7. 2/4 git-instaweb: Use $conf, not $fqgitdir/gitweb/httpd.confJakub Narebski, Jun 23, 2011
  8. 3/4 git-instaweb: Move all actions at the end of scriptJakub Narebski, Jun 23, 2011
  9. 4/4 git-instaweb: Check that correct config file exists for (re)startJakub Narebski, Jun 23, 2011
  10. Eric WongJun 28, 2011

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.