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

Re: [PATCH] git-web--browse: improve browser support under OS X

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 11, 2008, 03:01 UTC
Message-ID
<7vve4wb3h7.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<1202696664-1565-1-git-send-email-jaysoffian+git@gmail.com>

Because we preprocess git-web--browse.sh to create the final git-web--browse to be installed, something like "open" that is not a user but a platform preference might be better done as a build-time thing, instead of forcing everybody to spawn "uname", perhaps like this?

Also I wonder why the check for SECURITYSESSIONID your original had is not good enough for this Mac specific customization?

 Makefile           |    2 ++
 git-web--browse.sh |   18 +++++++++++++++++-
 2 files changed, 19 insertions(+), 1 deletions(-)
diff --git a/Makefile b/Makefile
index d288378..5c278d2 100644
--- a/Makefile
+++ b/Makefile
@@ -419,6 +419,7 @@ ifeq ($(uname_S),Darwin)
 	endif
 	NO_STRLCPY = YesPlease
 	NO_MEMMEM = YesPlease
+	PLATFORM_BROWSER = open
 endif
 ifeq ($(uname_S),SunOS)
 	NEEDS_SOCKET = YesPlease
@@ -840,6 +841,7 @@ $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
 	    -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
 	    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
 	    -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
+	    -e 's/@@PLATFORM_BROWSER@@/$(PLATFORM_BROWSER)/g' \
 	    $@.sh >$@+ && \
 	chmod +x $@+ && \
 	mv $@+ $@
diff --git a/git-web--browse.sh b/git-web--browse.sh
index 3ade500..61a3514 100755
--- a/git-web--browse.sh
+++ b/git-web--browse.sh
@@ -27,6 +27,8 @@ valid_tool() {
 	case "$1" in
 		firefox | iceweasel | konqueror | w3m | links | lynx | dillo)
 			;; # happy
+		"@@PLATFORM_BROWSER@@" )
+			;;
 		*)
 			return 1
 			;;
@@ -105,6 +107,20 @@ if test -z "$browser" ; then
 	browser_candidates="w3m links lynx"
     fi
 
+    # Test if the current environment is suitable for the
+    # platform preference and add it as the default
+
+    if	case "@@PLATFORM_BROWSER@@" in
+	open)
+		test -n "$SECURITYSESSIONID" ;;
+	# other platform preference come here...
+	*)
+		false ;;
+	esac
+    then
+	browser_candidates="@@PLATFORM_BROWSER@@ $browser_candidates"
+    fi
+
     for i in $browser_candidates; do
 	init_browser_path $i
 	if type "$browser_path" > /dev/null 2>&1; then
@@ -147,7 +163,7 @@ case "$browser" in
 		;;
 	esac
 	;;
-    w3m|links|lynx)
+    w3m|links|lynx|open)
 	eval "$browser_path" "$@"
 	;;
     dillo)
Previous: jaysoffian+git@gmail.comNext: Jay Soffian
Message 10 of 17 in “Improve git-help--browse browser support under OS X”
  1. Improve git-help--browse browser support under OS Xjaysoffian+git@gmail.com, Feb 8, 2008
  2. Dmitry PotapovFeb 9, 2008
  3. Jay SoffianFeb 10, 2008
  4. Dmitry PotapovFeb 10, 2008
  5. Christian CouderFeb 10, 2008
  6. Jay SoffianFeb 11, 2008
  7. Christian CouderFeb 11, 2008
  8. Jay SoffianFeb 11, 2008
  9. git-web--browse: improve browser support under OS Xjaysoffian+git@gmail.com, Feb 11, 2008
  10. Junio C HamanoFeb 11, 2008
  11. Jay SoffianFeb 11, 2008
  12. Jay SoffianFeb 12, 2008
  13. Christian CouderFeb 13, 2008
  14. Junio C HamanoFeb 13, 2008
  15. Pieter de BieFeb 13, 2008
  16. Jay SoffianFeb 14, 2008
  17. Christian CouderFeb 14, 2008

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.