threads / patch / 17305

patchcygwin: Convert paths for html help from posix to windows

Subject: [PATCH] cygwin: Convert paths for html help from posix to windows

## tl;dr

6 messages between Jan 22, 2009 and Jan 26, 2009. Diffs are folded; open one to read it.

replies: 5people: 5as markdown or json

Björn Steinbrink· Jan 22, 2009, 17:16 UTC · lore

When using "git help --web" with cygwin, we used to pass the posix path to the browser, but a native windows browser will expect a windows path and is unable to make use of the given path.

So the cygwin port gets its own open_html implementation that handles the path conversion.

Reported-by: Steffen Jaeckel <jaeckel@stzedn.de>
Tested-by: Steffen Jaeckel <jaeckel@stzedn.de>
Signed-off-by: Björn Steinbrink <B.Steinbrink@gmx.de>
---
OK, I don't really know if this is the right way to do it. Maybe when
the browser was built for cygwin this breaks? I have no clue, it's
admittedly just the result of a quick glance at the code and some
googling to find the "right" cygwin function... :-/
 compat/cygwin.c |    7 +++++++
 compat/cygwin.h |    3 +++
 2 files changed, 10 insertions(+), 0 deletions(-)
Show changes to 2 files +10 −0

compat/cygwin.c, compat/cygwin.h

diff --git a/compat/cygwin.c b/compat/cygwin.c
index ebac148..70ecd2d 100644
--- a/compat/cygwin.c
+++ b/compat/cygwin.c
@@ -141,3 +141,10 @@ static int cygwin_lstat_stub(const char *file_name, struct stat *buf)
 stat_fn_t cygwin_stat_fn = cygwin_stat_stub;
 stat_fn_t cygwin_lstat_fn = cygwin_lstat_stub;
 
+void cygwin_open_html(const char *unixpath)
+{
+	char cygpath[PATH_MAX];
+
+	cygwin_conv_to_win32_path(unixpath, cygpath);
+	execl_git_cmd("web--browse", "-c", "help.browser", cygpath, NULL);
+}
diff --git a/compat/cygwin.h b/compat/cygwin.h
index a3229f5..7cbefea 100644
--- a/compat/cygwin.h
+++ b/compat/cygwin.h
@@ -7,3 +7,6 @@ extern stat_fn_t cygwin_lstat_fn;
 
 #define stat(path, buf) (*cygwin_stat_fn)(path, buf)
 #define lstat(path, buf) (*cygwin_lstat_fn)(path, buf)
+
+void cygwin_open_html(const char *path);
+#define open_html cygwin_open_html
-- 
1.6.1.230.gf873d
Junio C Hamano· Jan 22, 2009, 17:25 UTC · re: Björn Steinbrink · lore

Re: [PATCH] cygwin: Convert paths for html help from posix to windows

Björn Steinbrink <B.Steinbrink@gmx.de> writes:
> OK, I don't really know if this is the right way to do it. Maybe when
> the browser was built for cygwin this breaks? I have no clue,...

It might be simple enough to check if all it takes is to install a prepackaged browser from Cygwin suite and try to run it. Doesn't Cygwin have small ones such as lynx (or links)?

Johannes Schindelin· Jan 22, 2009, 17:30 UTC · re: Junio C Hamano · lore

Re: [PATCH] cygwin: Convert paths for html help from posix to windows

Hi,
On Thu, 22 Jan 2009, Junio C Hamano wrote:
Show 8 quoted lines
> Björn Steinbrink <B.Steinbrink@gmx.de> writes:
> 
> > OK, I don't really know if this is the right way to do it. Maybe when
> > the browser was built for cygwin this breaks? I have no clue,...
> 
> It might be simple enough to check if all it takes is to install a
> prepackaged browser from Cygwin suite and try to run it.  Doesn't Cygwin
> have small ones such as lynx (or links)?

Was it not the case that Cygwin programs could grok Windows paths, too? IIRC w3m is available, dunno about lynx.

Ciao, Dscho

Steffen Jaeckel· Jan 22, 2009, 19:34 UTC · re: Johannes Schindelin · lore

Re[2]: [PATCH] cygwin: Convert paths for html help from posix to windows

Hi,
-----Original Message-----
From: Johannes Schindelin [mailto:Johannes.Schindelin@gmx.de] 
> Hi,
> On Thu, 22 Jan 2009, Junio C Hamano wrote:
Show 8 quoted lines
>> Björn Steinbrink <B.Steinbrink@gmx.de> writes:
>> 
>> > OK, I don't really know if this is the right way to do it. Maybe when
>> > the browser was built for cygwin this breaks? I have no clue,...
>> 
>> It might be simple enough to check if all it takes is to install a
>> prepackaged browser from Cygwin suite and try to run it.  Doesn't Cygwin
>> have small ones such as lynx (or links)?
> Was it not the case that Cygwin programs could grok Windows paths, too?  
> IIRC w3m is available, dunno about lynx.
> Ciao,
> Dscho

The intention of this patch was to hand over the url to a windows application.

In cygwin you can use lynx, links and others, but they are not as smart to use as a browser with a real gui.

Cygwin can't handle windows paths, and this patch will break cygwin based browsers like links...

My first idea was to patch the git-web--browse.sh script in the section where the browser is called. --------

Show changes to git-web--browse.sh +1 −1
diff --git a/git-web--browse.sh b/git-web--browse.sh
index 78d236b..f726f8f 100755
--- a/git-web--browse.sh
+++ b/git-web--browse.sh
@@ -143,7 +143,7 @@ case "$browser" in
        vers=$(expr "$($browser_path -version)" : '.* \([0-9][0-9]*\)\..*')
        NEWTAB='-new-tab'
        test "$vers" -lt 2 && NEWTAB=''
-       "$browser_path" $NEWTAB "$@" &
+       "$browser_path" $NEWTAB "`cygpath -w $@`" &
        ;;
     konqueror)
        case "$(basename "$browser_path")" in
--------
This solution works for cygwin internal browsers where the posix path
is required and it works for windows apps called out of the cygwin
environment as well.
This is certainely not a proper solution but I've got no other idea
how to solve the problem.

Best regards,
steffen
-- 
Steffen Jaeckel
Steinbeis-Transferzentrum/Steinbeis-Innovationszentrum 
Embedded Design und Networking
an der Berufsakademie Lörrach
Poststraße 35, 79423 Heitersheim
Leiter: Prof. Dr.-Ing. Axel Sikora
Phone: +49 7634 6949341
Mob  : +49  170 2328968
Fax  : +49 7634 5049886
www.stzedn.de

HINWEIS
Das Steinbeis Transferzentrum Embedded Design und Networking (stzedn)
an der Dualen Hochschule Baden-Württemberg/Berufsakademie Lörrach wird
vom 3.-5.3.2009 auf der Embedded World 2009 in Nürnberg mit einem Stand
vertreten sein. Bitte besuchen Sie uns in Halle 12 Stand 322h.

Zentrale: 
Steinbeis GmbH & Co. KG für Technologietransfer 
Willi-Bleicher-Straße 19, 70174 Stuttgart 
Registergericht Stuttgart HRA 12 480 

Komplementär: Steinbeis-Verwaltung-GmbH, Registergericht Stuttgart HRB 18715 
Geschäftsführer: Prof. Dr. Heinz Trasch, Prof. Dr. Michael Auer 

Der Inhalt dieser E-Mail einschließlich aller Anhänge ist vertraulich und 
ausschließlich für den bezeichneten Adressaten bestimmt. Wenn Sie nicht der 
vorgesehene Adressat dieser E-Mail oder dessen Vertreter sein sollten, so 
beachten Sie bitte, dass jede Form der Kenntnisnahme, Veröffentlichung, 
Vervielfältigung oder Weitergabe des Inhalts dieser E-Mail unzulässig ist. 
Wir bitten Sie, sich in diesem Fall mit dem Absender der E-Mail in Verbindung 
zu setzen, sowie die Originalnachricht zu löschen und alle Kopien hiervon zu 
vernichten.

This e-mail message including any attachments is for the sole use of the 
intended recipient(s) and may contain privileged or confidential information. 
Any unauthorized review, use, disclosure or distribution is prohibited. If you 
are not the intended recipient, please immediately contact the sender by reply 
e-mail and delete the original message and destroy all copies thereof.
Ramsay Jones· Jan 24, 2009, 18:51 UTC · re: Björn Steinbrink · lore

Re: [PATCH] cygwin: Convert paths for html help from posix to windows

Björn Steinbrink wrote:
Show 17 quoted lines
> When using "git help --web" with cygwin, we used to pass the posix path
> to the browser, but a native windows browser will expect a windows path
> and is unable to make use of the given path.
> 
> So the cygwin port gets its own open_html implementation that handles
> the path conversion.
> 
> Reported-by: Steffen Jaeckel <jaeckel@stzedn.de>
> Tested-by: Steffen Jaeckel <jaeckel@stzedn.de>
> 
> Signed-off-by: Björn Steinbrink <B.Steinbrink@gmx.de>
> ---
> OK, I don't really know if this is the right way to do it. Maybe when
> the browser was built for cygwin this breaks? I have no clue, it's
> admittedly just the result of a quick glance at the code and some
> googling to find the "right" cygwin function... :-/
> 
Hi Björn,

I had the same problem. However, rather than modifying git, I created a firefox wrapper script (in ~/bin) which used the cygpath command line tool to do the path conversion. Also, if you use "git instaweb", you also need to filter out http URLs and pass them through un-molested by cygpath (it turns http://localhost into http:\localhost).

My script is clearly a "quick hack" just to get something working for me, but you may find it useful as a starting point for your own ("proper" ;-) script, so I've included it below.

HTH, Ramsay Jones

-->8-- #!/bin/sh #

while test $# != 0
do
    case "$1" in
	-version)
	    echo "firefox 1.5.0.2"
	    exit 0
	    ;;
	-new-tab)
	    echo "-new-tab not supported"
	    exit 1
	    ;;
	--)
	    shift
	    break
	    ;;
	-*)
	    echo "option '$1' not supported"
	    exit 1
	    ;;
	*)
	    break
	    ;;
    esac
    shift
done
if test "$1" = ""
then
	p=
else
	case "$1" in
	    http*)
		p="$1"
		;;
	    *)
		p="$(cygpath -w "$1")"
		;;
	esac
fi
"/cygdrive/c/Program Files/Mozilla Firefox/firefox.exe" "$p"
exit 0
Steffen Jaeckel· Jan 26, 2009, 10:05 UTC · re: Ramsay Jones · lore

Re: [PATCH] cygwin: Convert paths for html help from posix to windows

-----Original Message-----
From: Ramsay Jones [mailto:ramsay@ramsay1.demon.co.uk]
> Hi Björn,
Show 5 quoted lines
> I had the same problem. However, rather than modifying git, I created a
> firefox wrapper script (in ~/bin) which used the cygpath command line
> tool to do the path conversion. Also, if you use "git instaweb", you
> also need to filter out http URLs and pass them through un-molested
> by cygpath (it turns http://localhost into http:\localhost).
> My script is clearly a "quick hack" just to get something working for
> me, but you may find it useful as a starting point for your own
> ("proper" ;-) script, so I've included it below.
> HTH,
> Ramsay Jones
Hi Ramsay,

thanks for this idea. I solved the problem by using the bash script included below.

Cheerz, Steffen

>sj

#!/bin/sh #

ff="/cygdrive/c/Programme/Mozilla Firefox/firefox.exe"
while test $# != 0
do
    case "$1" in
        -version)
            echo $("$ff" "-version")
            exit 0
            ;;
        -new-tab)
            p=
            case "$2" in
                http*)
                    p="$2"
                    ;;
                *)
                    # check if file exists
                    if [ -e "$2" ]
                    then
                      p="$(cygpath -w "$2")"
                    fi
                    ;;
            esac
            # check if $p has been set, otherwise exit with error
            if [ "$p" ]
            then
              $("$ff" "$p")
              exit 0
            else
              exit 1
            fi
            ;;
    esac
    shift
done
exit 1
-- 
Steffen Jaeckel
Steinbeis-Transferzentrum/Steinbeis-Innovationszentrum 
Embedded Design und Networking
an der Berufsakademie Lörrach
Poststraße 35, 79423 Heitersheim
Leiter: Prof. Dr.-Ing. Axel Sikora
Phone: +49 7634 6949341
Mob  : +49  170 2328968
Fax  : +49 7634 5049886
www.stzedn.de

HINWEIS
Das Steinbeis Transferzentrum Embedded Design und Networking (stzedn)
an der Dualen Hochschule Baden-Württemberg/Berufsakademie Lörrach wird
vom 3.-5.3.2009 auf der Embedded World 2009 in Nürnberg mit einem Stand
vertreten sein. Bitte besuchen Sie uns in Halle 12 Stand 322h.

Zentrale: 
Steinbeis GmbH & Co. KG für Technologietransfer 
Willi-Bleicher-Straße 19, 70174 Stuttgart 
Registergericht Stuttgart HRA 12 480 

Komplementär: Steinbeis-Verwaltung-GmbH, Registergericht Stuttgart HRB 18715 
Geschäftsführer: Prof. Dr. Heinz Trasch, Prof. Dr. Michael Auer 

Der Inhalt dieser E-Mail einschließlich aller Anhänge ist vertraulich und 
ausschließlich für den bezeichneten Adressaten bestimmt. Wenn Sie nicht der 
vorgesehene Adressat dieser E-Mail oder dessen Vertreter sein sollten, so 
beachten Sie bitte, dass jede Form der Kenntnisnahme, Veröffentlichung, 
Vervielfältigung oder Weitergabe des Inhalts dieser E-Mail unzulässig ist. 
Wir bitten Sie, sich in diesem Fall mit dem Absender der E-Mail in Verbindung 
zu setzen, sowie die Originalnachricht zu löschen und alle Kopien hiervon zu 
vernichten.

This e-mail message including any attachments is for the sole use of the 
intended recipient(s) and may contain privileged or confidential information. 
Any unauthorized review, use, disclosure or distribution is prohibited. If you 
are not the intended recipient, please immediately contact the sender by reply 
e-mail and delete the original message and destroy all copies thereof.

← back to recent threads