# [msysgit] how to detect git.exe directory?

6 messages from 2007-12-23 to 2007-12-23. Participants: Marco Costalba, Johannes Sixt, Abdelrazak Younes.
Thread: https://gitlist.dev/t/11396

## Marco Costalba, 2007-12-23 16:25

Subject: [msysgit] how to detect git.exe directory?
Message-ID: <e5bfff550712230825o5e73bd3dm31057847106b8722@mail.gmail.com>
URL: https://gitlist.dev/e/e5bfff550712230825o5e73bd3dm31057847106b8722%40mail.gmail.com

```
Hi all,

   I'm progressing on qgit installer for windows, I have switched to
MSVC for compiling Qt4 and qgit sources and I have to say that first
results are very good, qgit.exe now seems to work without problems or
artifacts and the speed is much more similar to what we achieve under
the Linux platform (read much higher).

So it seems Qt+mingw is not the _best_ possible solution.

Anyhow, under Vista you cannot simply copy qgit.exe in the git
directory (OS barfs regarding some administrative rights, note that *I
am* the administartor!), so to make qgit.exe work git.exe file must be
in PATH.

To easy the user and allowing to call qgit.exe double clicking on a
nice desktop icon I need a way to know where git.exe is installed *at
runtime*.

So my question is: "What is the preferred way to detect git directory
at runtime for msysgit files?"

- environment variable ??

- windows registry ??

- others ?


I don't plan to use the cygwin version of git but going directly to
the "long term" solution that is msysgit.

Thanks for your help
Marco

```

## Johannes Sixt, 2007-12-23 16:35

Subject: Re: how to detect git.exe directory?
Message-ID: <200712231735.00336.johannes.sixt@telecom.at>
URL: https://gitlist.dev/e/200712231735.00336.johannes.sixt%40telecom.at
In-Reply-To: <e5bfff550712230825o5e73bd3dm31057847106b8722-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

```

On Sunday 23 December 2007 17:25, Marco Costalba wrote:
> To easy the user and allowing to call qgit.exe double clicking on a
> nice desktop icon I need a way to know where git.exe is installed *at
> runtime*.
>
> So my question is: "What is the preferred way to detect git directory
> at runtime for msysgit files?"
>
> - environment variable ??
>
> - windows registry ??
>
> - others ?

Running

	git --exec-path

should get you close to it. But I have to question why you need that path.

-- Hannes

```

## Marco Costalba, 2007-12-23 16:53

Subject: Re: how to detect git.exe directory?
Message-ID: <e5bfff550712230853u1bc0160ap936c2d0a6fe0203b@mail.gmail.com>
URL: https://gitlist.dev/e/e5bfff550712230853u1bc0160ap936c2d0a6fe0203b%40mail.gmail.com
In-Reply-To: <200712231735.00336.johannes.sixt-dl2ejS2iUSazZXS1Dc/lvw@public.gmane.org>

```

On Dec 23, 2007 5:35 PM, Johannes Sixt <johannes.sixt-dl2ejS2iUSazZXS1Dc/lvw@public.gmane.org> wrote:
> On Sunday 23 December 2007 17:25, Marco Costalba wrote:
> > To easy the user and allowing to call qgit.exe double clicking on a
> > nice desktop icon I need a way to know where git.exe is installed *at
> > runtime*.
> >
> > So my question is: "What is the preferred way to detect git directory
> > at runtime for msysgit files?"
> >
> > - environment variable ??
> >
> > - windows registry ??
> >
> > - others ?
>
> Running
>
>         git --exec-path
>
> should get you close to it. But I have to question why you need that path.
>

What I'm looking for is git.exe itself. If I run "git --exec-path" I
get something along the lines "git executable not found..."

I don't use dashed command inside qgit, so I run "git log ..." not
"git-log ...", but the git.exe should be known to qgit or in path.

Hope it's clear.

Thanks
Marco

```

## Abdelrazak Younes, 2007-12-23 19:45

Subject: Re: [msysgit] how to detect git.exe directory?
Message-ID: <476EBADE.6080805@free.fr>
URL: https://gitlist.dev/e/476EBADE.6080805%40free.fr
In-Reply-To: <e5bfff550712230825o5e73bd3dm31057847106b8722@mail.gmail.com>

```
Marco Costalba wrote:
> Hi all,
> 
>    I'm progressing on qgit installer for windows, I have switched to
> MSVC for compiling Qt4 and qgit sources and I have to say that first
> results are very good, qgit.exe now seems to work without problems or
> artifacts and the speed is much more similar to what we achieve under
> the Linux platform (read much higher).

Glad you manage to do it by yourself. Sorry for not going further with 
compilation as I promised but the git repository had only a MSVC2008 
solution file and I have only MSVC2005 here. I tried to adapt our CMake 
files to qgit but failed...

> 
> So it seems Qt+mingw is not the _best_ possible solution.

I told you that ;-)

> 
> Anyhow, under Vista you cannot simply copy qgit.exe in the git
> directory (OS barfs regarding some administrative rights, note that *I
> am* the administartor!), so to make qgit.exe work git.exe file must be
> in PATH.
> 
> To easy the user and allowing to call qgit.exe double clicking on a
> nice desktop icon I need a way to know where git.exe is installed *at
> runtime*.
> 
> So my question is: "What is the preferred way to detect git directory
> at runtime for msysgit files?"

If you use QProcess to launch git, maybe you could just use 
QProcess::workingDirectory()?

Abdel.

```

## Abdelrazak Younes, 2007-12-23 19:51

Subject: Re: how to detect git.exe directory?
Message-ID: <fkme88$rc1$1@ger.gmane.org>
URL: https://gitlist.dev/e/fkme88%24rc1%241%40ger.gmane.org
In-Reply-To: <e5bfff550712230853u1bc0160ap936c2d0a6fe0203b-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

```

Marco Costalba wrote:
> 
> What I'm looking for is git.exe itself. If I run "git --exec-path" I
> get something along the lines "git executable not found..."
> 
> I don't use dashed command inside qgit, so I run "git log ..." not
> "git-log ...", but the git.exe should be known to qgit or in path.

If you're planning to create an installer for qgit, a good solution 
would be to ask the user to manually point to the msysgit installation 
directory if not found in the path. Then the installer could just save 
the directory to an ini file along 'qgit.exe'.

Abdel.

```

## Marco Costalba, 2007-12-23 20:04

Subject: Re: [msysgit] how to detect git.exe directory?
Message-ID: <e5bfff550712231204m6dad571ct8c2f5e2eb4a23de0@mail.gmail.com>
URL: https://gitlist.dev/e/e5bfff550712231204m6dad571ct8c2f5e2eb4a23de0%40mail.gmail.com
In-Reply-To: <476EBADE.6080805@free.fr>

```
On Dec 23, 2007 8:45 PM, Abdelrazak Younes <younes.a@free.fr> wrote:
> Marco Costalba wrote:
> > Hi all,
> >
> Glad you manage to do it by yourself. Sorry for not going further with
> compilation as I promised but the git repository had only a MSVC2008
> solution file and I have only MSVC2005 here. I tried to adapt our CMake
> files to qgit but failed...
>

Don't worry, I have installed MSVC2008, compiled Qt4 (and everithing
went smooth) and bruefly tested qgit: it really seems to work, now
following steps are:

- Detect git.exe directory at runtime also when is not in PATH (see below)

- Manage to package qgit and others needed files in a windows
installer (I know very little about this)

>
> > So my question is: "What is the preferred way to detect git directory
> > at runtime for msysgit files?"
>
> If you use QProcess to launch git, maybe you could just use
> QProcess::workingDirectory()?
>

It's not the repository that I don't find, but the git binary
directory. I explain better. If I open a console under windows with
cmd.exe and type "git" when I hit enter button I have an error message
that says that "command git is not known"

This is because git.exe directory is _not_ (normally) in PATH
environment variable.

So, or msysgit installation *modifies* the user PATH adding the bin
directory, or I have to found git bin directory myself and manage to
add to the PATH of qgit process environment.

The question is: "How I find git.exe??"

Marco

```
