git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Abdelrazak Younes <younes@lyx.org>
To: Marco Costalba <mcostalba@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: [QGIT PATCH] Add safeguards to Git::userInfo()
Date: Tue, 07 Oct 2008 15:10:07 +0200	[thread overview]
Message-ID: <48EB5FAF.4080303@lyx.org> (raw)
In-Reply-To: <e5bfff550810070457i702c2935lfcc0b60ae3df4dc4@mail.gmail.com>

On 07/10/2008 13:57, Marco Costalba wrote:
> 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

  parent reply	other threads:[~2008-10-07 13:11 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-07  7:33 [QGit bug] git user settings not retrieved when launched for Windows explorer Abdelrazak Younes
2008-10-07 11:10 ` Marco Costalba
2008-10-07 11:36   ` Abdelrazak Younes
2008-10-07 11:57     ` Marco Costalba
2008-10-07 12:08       ` Abdelrazak Younes
2008-10-07 12:31       ` Abdelrazak Younes
2008-10-07 16:48         ` Marco Costalba
2008-10-07 17:08           ` Abdelrazak Younes
2008-10-07 13:10       ` Abdelrazak Younes [this message]
2008-10-07 16:50         ` [QGIT PATCH] Add safeguards to Git::userInfo() Marco Costalba
2008-10-07 16:55           ` Marco Costalba
2008-10-07 17:38             ` Abdelrazak Younes
2008-10-07 18:03               ` Marco Costalba
2008-10-07 18:20                 ` Abdelrazak Younes
2008-10-07 18:28                   ` Marco Costalba
2008-10-07 17:12           ` Abdelrazak Younes
2008-10-07 11:16 ` [QGit bug] git user settings not retrieved when launched for Windows explorer Marco Costalba
2008-10-07 11:42   ` Abdelrazak Younes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48EB5FAF.4080303@lyx.org \
    --to=younes@lyx.org \
    --cc=git@vger.kernel.org \
    --cc=mcostalba@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).