All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cygwin: Convert paths for html help from posix to windows
@ 2009-01-22 17:16 Björn Steinbrink
  2009-01-22 17:25 ` Junio C Hamano
  2009-01-24 18:51 ` Ramsay Jones
  0 siblings, 2 replies; 6+ messages in thread
From: Björn Steinbrink @ 2009-01-22 17:16 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: jaeckel, git

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(-)

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

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

* Re: [PATCH] cygwin: Convert paths for html help from posix to windows
  2009-01-22 17:16 [PATCH] cygwin: Convert paths for html help from posix to windows Björn Steinbrink
@ 2009-01-22 17:25 ` Junio C Hamano
  2009-01-22 17:30   ` Johannes Schindelin
  2009-01-24 18:51 ` Ramsay Jones
  1 sibling, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2009-01-22 17:25 UTC (permalink / raw)
  To: Björn Steinbrink; +Cc: jaeckel, git

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)?

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

* Re: [PATCH] cygwin: Convert paths for html help from posix to windows
  2009-01-22 17:25 ` Junio C Hamano
@ 2009-01-22 17:30   ` Johannes Schindelin
  2009-01-22 19:34     ` Re[2]: " Steffen Jaeckel
  0 siblings, 1 reply; 6+ messages in thread
From: Johannes Schindelin @ 2009-01-22 17:30 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Björn Steinbrink, jaeckel, git

[-- Attachment #1: Type: TEXT/PLAIN, Size: 564 bytes --]

Hi,

On Thu, 22 Jan 2009, Junio C Hamano wrote:

> 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

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

* Re[2]: [PATCH] cygwin: Convert paths for html help from posix to windows
  2009-01-22 17:30   ` Johannes Schindelin
@ 2009-01-22 19:34     ` Steffen Jaeckel
  0 siblings, 0 replies; 6+ messages in thread
From: Steffen Jaeckel @ 2009-01-22 19:34 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Junio C Hamano, Björn Steinbrink, git

Hi,

-----Original Message-----
From: Johannes Schindelin [mailto:Johannes.Schindelin@gmx.de] 

> Hi,

> On Thu, 22 Jan 2009, Junio C Hamano wrote:

>> 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.
--------
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.

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

* Re: [PATCH] cygwin: Convert paths for html help from posix to windows
  2009-01-22 17:16 [PATCH] cygwin: Convert paths for html help from posix to windows Björn Steinbrink
  2009-01-22 17:25 ` Junio C Hamano
@ 2009-01-24 18:51 ` Ramsay Jones
  2009-01-26 10:05   ` Steffen Jaeckel
  1 sibling, 1 reply; 6+ messages in thread
From: Ramsay Jones @ 2009-01-24 18:51 UTC (permalink / raw)
  To: Björn Steinbrink; +Cc: Junio C Hamano, jaeckel, git

Björn Steinbrink wrote:
> 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

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

* Re: [PATCH] cygwin: Convert paths for html help from posix to windows
  2009-01-24 18:51 ` Ramsay Jones
@ 2009-01-26 10:05   ` Steffen Jaeckel
  0 siblings, 0 replies; 6+ messages in thread
From: Steffen Jaeckel @ 2009-01-26 10:05 UTC (permalink / raw)
  To: Ramsay Jones; +Cc: Björn Steinbrink, Junio C Hamano, git

-----Original Message-----
From: Ramsay Jones [mailto:ramsay@ramsay1.demon.co.uk]

> 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

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.

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

end of thread, other threads:[~2009-01-26 10:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-22 17:16 [PATCH] cygwin: Convert paths for html help from posix to windows Björn Steinbrink
2009-01-22 17:25 ` Junio C Hamano
2009-01-22 17:30   ` Johannes Schindelin
2009-01-22 19:34     ` Re[2]: " Steffen Jaeckel
2009-01-24 18:51 ` Ramsay Jones
2009-01-26 10:05   ` Steffen Jaeckel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.