threads / bug / 15809

[QGit bug] git user settings not retrieved when launched for Windows explorer

Subject: [QGit bug] git user settings not retrieved when launched for Windows explorer

## tl;dr

18 messages between Oct 7, 2008 and Oct 7, 2008.

replies: 17people: 2as markdown or json

Abdelrazak Younes· Oct 7, 2008, 07:33 UTC · lore
Dear Marco,

When I double click on qgit.exe, the user name and email are not shown in the user settings (for any of the 3 combo values). But if I run qgit from the commandline at the mysysgit bash prompt, the boxes are properly filled. I would like to debug it but, as I reported last week, the MSVC project doesn't work for me.

By the way, these two edit boxes are not editable on Windows, is that on purpose? If yes, maybe we could let the user change them is 'Local config' is selected and call the appropriate git function?

Thanks, Abdel.

Marco Costalba· Oct 7, 2008, 11:10 UTC · re: Abdelrazak Younes · lore

Re: [QGit bug] git user settings not retrieved when launched for Windows explorer

On Tue, Oct 7, 2008 at 9:33 AM, Abdelrazak Younes <younes@lyx.org> wrote:
Show 8 quoted lines
> Dear Marco,
>
> When I double click on qgit.exe, the user name and email are not shown in
> the user settings (for any of the 3 combo values). But if I run qgit from
> the commandline at the mysysgit bash prompt, the boxes are properly filled.
> I would like to debug it but, as I reported last week, the MSVC project
> doesn't work for me.
>

Sound like a problem of startup directory: on the command line you start from the right directory...when you double click on which repo qgit is open ?

Marco
Abdelrazak Younes· Oct 7, 2008, 11:36 UTC · re: Marco Costalba · lore

Re: [QGit bug] git user settings not retrieved when launched for Windows explorer

On 07/10/2008 13:10, Marco Costalba wrote:
Show 16 quoted lines
> On Tue, Oct 7, 2008 at 9:33 AM, Abdelrazak Younes<younes@lyx.org>  wrote:
>    
>> Dear Marco,
>>
>> When I double click on qgit.exe, the user name and email are not shown in
>> the user settings (for any of the 3 combo values). But if I run qgit from
>> the commandline at the mysysgit bash prompt, the boxes are properly filled.
>> I would like to debug it but, as I reported last week, the MSVC project
>> doesn't work for me.
>>
>>      
>
> Sound like a problem of startup directory: on the command line you
> start from the right directory...when you double click on which repo
> qgit is open ?
>    

None of course. But when I open a repository manually I would expect that this is properly filled in.

And if I launch qgit with the context menu (right clicking a directory in the Explorer), qgit never managed to open the repository.

Abdel.
Marco Costalba· Oct 7, 2008, 11:57 UTC · re: Abdelrazak Younes · lore

Re: [QGit bug] git user settings not retrieved when launched for Windows explorer

On Tue, Oct 7, 2008 at 1:36 PM, Abdelrazak Younes <younes@lyx.org> wrote:
Show 9 quoted lines
>
>> Sound like a problem of startup directory: on the command line you
>> start from the right directory...when you double click on which repo
>> qgit is open ?
>>
>
> None of course. But when I open a repository manually I would expect that
> this is properly filled in.
>

In git.cpp, Git::userInfo() function get info about user by means of 'git config' calls, my guess (I cannot it test now) is that 'git config' does not work if we are not in a git directory.

> And if I launch qgit with the context menu (right clicking a directory in
> the Explorer), qgit never managed to open the repository.
>
This is a bug that I never managed to get rid of :-(

It is strange because it works if you try in a subdirectory, as example try right clicking on 'src' directory of qgit project.

Thanks Marco

Abdelrazak Younes· Oct 7, 2008, 12:08 UTC · re: Marco Costalba · lore

Re: [QGit bug] git user settings not retrieved when launched for Windows explorer

On 07/10/2008 13:57, Marco Costalba wrote:
Show 16 quoted lines
> On Tue, Oct 7, 2008 at 1:36 PM, Abdelrazak Younes<younes@lyx.org>  wrote:
>    
>>> Sound like a problem of startup directory: on the command line you
>>> start from the right directory...when you double click on which repo
>>> qgit is open ?
>>>
>>>        
>> None of course. But when I open a repository manually I would expect that
>> this is properly filled in.
>>
>>      
>
> In git.cpp, Git::userInfo() function get info about user by means of
> 'git config' calls, my guess (I cannot it test now) is that 'git
> config' does not work if we are not in a git directory.
>    
OK, I'll have a look, thanks.
Show 12 quoted lines
>
>    
>> And if I launch qgit with the context menu (right clicking a directory in
>> the Explorer), qgit never managed to open the repository.
>>
>>      
>
> This is a bug that I never managed to get rid of :-(
>
> It is strange because it works if you try in a subdirectory, as
> example try right clicking on 'src' directory of qgit project.
>    

I tried and it doesn't work this way either; the statusbar tells me that this is 'Not a git archive' :-(

Abdel.
Abdelrazak Younes· Oct 7, 2008, 12:31 UTC · re: Marco Costalba · lore

Re: [QGit bug] git user settings not retrieved when launched for Windows explorer

On 07/10/2008 13:57, Marco Costalba wrote:
Show 16 quoted lines
> On Tue, Oct 7, 2008 at 1:36 PM, Abdelrazak Younes<younes@lyx.org>  wrote:
>    
>>> Sound like a problem of startup directory: on the command line you
>>> start from the right directory...when you double click on which repo
>>> qgit is open ?
>>>
>>>        
>> None of course. But when I open a repository manually I would expect that
>> this is properly filled in.
>>
>>      
>
> In git.cpp, Git::userInfo() function get info about user by means of
> 'git config' calls, my guess (I cannot it test now) is that 'git
> config' does not work if we are not in a git directory.
>    

No, 'git config user.name' works fine in any directory, even on the naked Windows console (I mean without msys bash). So that must be something else. I've traced it down to MyProcess::on_finished().

     isErrorExit =   (exitStatus != QProcess::NormalExit)
                  || (exitCode != 0 && isWinShell)
                  || !errorDesc.isEmpty()
                  ||  canceling;

At this point we have: exitStatus = NormalExit exitCode = 1 isWinShell = false errorDesc.isEmpty() returns true canceling = false

Which gives 'isErrorExit = false'. I wonder if the isWinShell test is correct?

Abdel.
Marco Costalba· Oct 7, 2008, 16:48 UTC · re: Abdelrazak Younes · lore

Re: [QGit bug] git user settings not retrieved when launched for Windows explorer

On Tue, Oct 7, 2008 at 2:31 PM, Abdelrazak Younes <younes@lyx.org> wrote:
Show 21 quoted lines
>
> No, 'git config user.name' works fine in any directory, even on the naked
> Windows console (I mean without msys bash). So that must be something else.
> I've traced it down to
> MyProcess::on_finished().
>
>    isErrorExit =   (exitStatus != QProcess::NormalExit)
>                 || (exitCode != 0 && isWinShell)
>                 || !errorDesc.isEmpty()
>                 ||  canceling;
>
> At this point we have:
> exitStatus = NormalExit
> exitCode = 1
> isWinShell = false
> errorDesc.isEmpty() returns true
> canceling = false
>
> Which gives 'isErrorExit = false'. I wonder if the isWinShell test is
> correct?
>
Hi Abdel,
I would think it is correct to return isErrorExit == false

The problem is that it seems git config return empty data if run from outside git directory...isn't it ?

Marco
Abdelrazak Younes· Oct 7, 2008, 17:08 UTC · re: Marco Costalba · lore

Re: [QGit bug] git user settings not retrieved when launched for Windows explorer

On 07/10/2008 18:48, Marco Costalba wrote:
Show 28 quoted lines
> On Tue, Oct 7, 2008 at 2:31 PM, Abdelrazak Younes<younes@lyx.org>  wrote:
>    
>> No, 'git config user.name' works fine in any directory, even on the naked
>> Windows console (I mean without msys bash). So that must be something else.
>> I've traced it down to
>> MyProcess::on_finished().
>>
>>     isErrorExit =   (exitStatus != QProcess::NormalExit)
>>                  || (exitCode != 0&&  isWinShell)
>>                  || !errorDesc.isEmpty()
>>                  ||  canceling;
>>
>> At this point we have:
>> exitStatus = NormalExit
>> exitCode = 1
>> isWinShell = false
>> errorDesc.isEmpty() returns true
>> canceling = false
>>
>> Which gives 'isErrorExit = false'. I wonder if the isWinShell test is
>> correct?
>>
>>      
>
> Hi Abdel,
>
> I would think it is correct to return isErrorExit == false
>    
OK.
> The problem is that it seems git config return empty data if run from
> outside git directory...isn't it ?
>    

No, as I said, 'git config user.name' is working just fine outside git directory.

Abdel.
Abdelrazak Younes· Oct 7, 2008, 13:10 UTC · re: Marco Costalba · lore

[QGIT PATCH] Add safeguards to Git::userInfo()

On 07/10/2008 13:57, Marco Costalba wrote:
Show 16 quoted lines
> On Tue, Oct 7, 2008 at 1:36 PM, Abdelrazak Younes<younes@lyx.org>  wrote:
>    
>>> Sound like a problem of startup directory: on the command line you
>>> start from the right directory...when you double click on which repo
>>> qgit is open ?
>>>
>>>        
>> None of course. But when I open a repository manually I would expect that
>> this is properly filled in.
>>
>>      
>
> In git.cpp, Git::userInfo() function get info about user by means of
> 'git config' calls, my guess (I cannot it test now) is that 'git
> config' does not work if we are not in a git directory.
>    

OK, with this patch, I see that the local config request is apparently successful even though the 'user' and 'email' strings stay empty. OTOH, the two global config requests fail.

---
  src/git.cpp |   19 ++++++++++++-------
  1 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/src/git.cpp b/src/git.cpp
index 4ffc4ea..e77f4a1 100755
--- a/src/git.cpp
+++ b/src/git.cpp
@@ -6,6 +6,8 @@
      Copyright: See COPYING file that comes with this distribution

  */
+#include <string>
+
  #include <QApplication>
  #include <QDateTime>
  #include <QDir>
@@ -347,13 +349,16 @@ void Git::userInfo(SList info) {

      errorReportingEnabled = false; // 'git config' could fail, see docs

-    run("git config user.name", &user);
-    run("git config user.email", &email);
-    info << "Local config" << user << email;
-
-    run("git config --global user.name", &user);
-    run("git config --global user.email", &email);
-    info << "Global config" << user << email;
+    if (bool success = run("git config user.name", &user)) {
+        success = run("git config user.email", &email);
+        if (success)
+            info << "Local config" << user << email;
+    }
+    if (bool success = run("git config --global user.name", &user)) {
+        success = run("git config --global user.email", &email);
+        if (success)
+            info << "Global config" << user << email;
+    }

      errorReportingEnabled = true;
  }
-- 
1.6.0.2.1172.ga5ed0
Marco Costalba· Oct 7, 2008, 16:50 UTC · re: Abdelrazak Younes · lore

Re: [QGIT PATCH] Add safeguards to Git::userInfo()

On Tue, Oct 7, 2008 at 3:10 PM, Abdelrazak Younes <younes@lyx.org> wrote:
>
> OK, with this patch, I see that the local config request is apparently
> successful even though the 'user' and 'email' strings stay empty.

An empty user and email it does not mean failure. Again, I would think that is git config that returns no data (without failing) if it is run from outside git directory.

Marco Costalba· Oct 7, 2008, 16:55 UTC · re: Marco Costalba · lore

Re: [QGIT PATCH] Add safeguards to Git::userInfo()

On Tue, Oct 7, 2008 at 6:50 PM, Marco Costalba <mcostalba@gmail.com> wrote:
Show 5 quoted lines
>
> An empty user and email it does not mean failure. Again, I would think
> that is git config that returns no data (without failing) if it is run
> from outside git directory.
>
Yes ! it is like this, I have finally had the possibility to test.

git config does not returns user and mail if run outside git dir because user and mail are local set.

Abdelrazak Younes· Oct 7, 2008, 17:38 UTC · re: Marco Costalba · lore

Re: [QGIT PATCH] Add safeguards to Git::userInfo()

On 07/10/2008 18:55, Marco Costalba wrote:
Show 10 quoted lines
> On Tue, Oct 7, 2008 at 6:50 PM, Marco Costalba<mcostalba@gmail.com>  wrote:
>> An empty user and email it does not mean failure. Again, I would think
>> that is git config that returns no data (without failing) if it is run
>> from outside git directory.
>>
>
> Yes ! it is like this, I have finally had the possibility to test.
>
> git config does not returns user and mail if run outside git dir
> because user and mail are local set.
So how do you explain this:

C:\>git config --global user.name Abdelrazak Younes

C:\>git config user.name Abdelrazak Younes

I get the same result in any directory, git repo or not. FYI, I never set the name locally, just once and globally.

Abdel.
Marco Costalba· Oct 7, 2008, 18:03 UTC · re: Abdelrazak Younes · lore

Re: [QGIT PATCH] Add safeguards to Git::userInfo()

On Tue, Oct 7, 2008 at 6:38 PM, Abdelrazak Younes <younes@lyx.org> wrote:
>
> So how do you explain this:
>
Form git-config(1) docs:
This command will fail if:

-The config file is invalid, ...... -you use --global option without $HOME being properly set.

So please try to comment out following line
--- a/src/git.cpp
+++ b/src/git.cpp
@@ -345,7 +345,7 @@ void Git::userInfo(SList info) {
 	info.clear();
 	info << "Environment" << user << email;

-	errorReportingEnabled = false; // 'git config' could fail, see docs
+	//errorReportingEnabled = false; // 'git config' could fail, see docs

 	run("git config user.name", &user);
 	run("git config user.email", &email);


run from double click and you probably will see an error message box
where git says $HOME is not set (I can reproduce this now).

So what I think is that when you run from command line there is the
$HOME variable set and command does not fails.


Marco
Abdelrazak Younes· Oct 7, 2008, 18:20 UTC · re: Marco Costalba · lore

Re: [QGIT PATCH] Add safeguards to Git::userInfo()

On 07/10/2008 20:03, Marco Costalba wrote:
Show 33 quoted lines
> On Tue, Oct 7, 2008 at 6:38 PM, Abdelrazak Younes<younes@lyx.org>  wrote:
>    
>> So how do you explain this:
>>
>>      
>
> Form git-config(1) docs:
>
> This command will fail if:
>
> -The config file is invalid,
> ......
> -you use --global option without $HOME being properly set.
>
>
> So please try to comment out following line
>
> --- a/src/git.cpp
> +++ b/src/git.cpp
> @@ -345,7 +345,7 @@ void Git::userInfo(SList info) {
>   	info.clear();
>   	info<<  "Environment"<<  user<<  email;
>
> -	errorReportingEnabled = false; // 'git config' could fail, see docs
> +	//errorReportingEnabled = false; // 'git config' could fail, see docs
>
>   	run("git config user.name",&user);
>   	run("git config user.email",&email);
>
>
> run from double click and you probably will see an error message box
> where git says $HOME is not set (I can reproduce this now).
>    
Right!
> So what I think is that when you run from command line there is the
> $HOME variable set and command does not fails.
>    
I see... but the only variable I have is HOMEPATH:
HOMEPATH=\Users\abdel

So I guess this was set by msysgit at installation time. But I see this variable only at the console (after typing 'set'), I don't see it in the user environment variable nor in the system one. So I guess the fix would be for msysgit to create this entry?

Thanks, Abdel.

Marco Costalba· Oct 7, 2008, 18:28 UTC · re: Abdelrazak Younes · lore

Re: [QGIT PATCH] Add safeguards to Git::userInfo()

On Tue, Oct 7, 2008 at 7:20 PM, Abdelrazak Younes <younes@lyx.org> wrote:
Show 6 quoted lines
>
> So I guess this was set by msysgit at installation time. But I see this
> variable only at the console (after typing 'set'), I don't see it in the
> user environment variable nor in the system one. So I guess the fix would be
> for msysgit to create this entry?
>

Browsing git-config docs I would think that this variable is needed so that git-config knows where to look for the git global configs file that is under user $HOME directory, see the [FILES] section in git config docs.

Thanks Marco

Abdelrazak Younes· Oct 7, 2008, 17:12 UTC · re: Marco Costalba · lore

Re: [QGIT PATCH] Add safeguards to Git::userInfo()

On 07/10/2008 18:50, Marco Costalba wrote:
Show 7 quoted lines
> On Tue, Oct 7, 2008 at 3:10 PM, Abdelrazak Younes<younes@lyx.org>  wrote:
>    
>> OK, with this patch, I see that the local config request is apparently
>> successful even though the 'user' and 'email' strings stay empty.
>>      
>
> An empty user and email it does not mean failure.

Yes, I know that but what is troublesome is that the user and email are not empty when git config is called outside of qgit. What is even more troublesome is that the two calls to 'git config --global user.xxx' fail (but don't fail when called manually at the command line).

Abdel.
Marco Costalba· Oct 7, 2008, 11:16 UTC · re: Abdelrazak Younes · lore

Re: [QGit bug] git user settings not retrieved when launched for Windows explorer

On Tue, Oct 7, 2008 at 9:33 AM, Abdelrazak Younes <younes@lyx.org> wrote:
Show 7 quoted lines
> Dear Marco,
>
>
> By the way, these two edit boxes are not editable on Windows, is that on
> purpose? If yes, maybe we could let the user change them is 'Local config'
> is selected and call the appropriate git function?
>

I know this limitation. I was just too lazy to implement edit myself...it would be a nice patch to have tough ;-)

Thanks Marco

Abdelrazak Younes· Oct 7, 2008, 11:42 UTC · re: Marco Costalba · lore

Re: [QGit bug] git user settings not retrieved when launched for Windows explorer

On 07/10/2008 13:16, Marco Costalba wrote:
Show 14 quoted lines
> On Tue, Oct 7, 2008 at 9:33 AM, Abdelrazak Younes<younes@lyx.org>  wrote:
>    
>> Dear Marco,
>>
>>
>> By the way, these two edit boxes are not editable on Windows, is that on
>> purpose? If yes, maybe we could let the user change them is 'Local config'
>> is selected and call the appropriate git function?
>>
>>      
>
> I know this limitation. I was just too lazy to implement edit
> myself...it would be a nice patch to have tough ;-)
>    

I am not sure I'll find the time to learn enough about git internals to do that kind of stuff. Maybe later.

Abdel.

← back to recent threads