git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
AYAbdelrazak Younes <younes@lyx.org>
Date
Oct 7, 2008, 13:10 UTC
Message-ID
<48EB5FAF.4080303@lyx.org>
In-Reply-To
<e5bfff550810070457i702c2935lfcc0b60ae3df4dc4@mail.gmail.com>
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
Previous: Abdelrazak YounesNext: Marco Costalba
Message 9 of 18 in “[QGit bug] git user settings not retrieved when launched for Windows explorer”
  1. Abdelrazak YounesOct 7, 2008
  2. Marco CostalbaOct 7, 2008
  3. Abdelrazak YounesOct 7, 2008
  4. Marco CostalbaOct 7, 2008
  5. Abdelrazak YounesOct 7, 2008
  6. Abdelrazak YounesOct 7, 2008
  7. Marco CostalbaOct 7, 2008
  8. Abdelrazak YounesOct 7, 2008
  9. Add safeguards to Git::userInfo()Abdelrazak Younes, Oct 7, 2008
  10. Marco CostalbaOct 7, 2008
  11. Marco CostalbaOct 7, 2008
  12. Abdelrazak YounesOct 7, 2008
  13. Marco CostalbaOct 7, 2008
  14. Abdelrazak YounesOct 7, 2008
  15. Marco CostalbaOct 7, 2008
  16. Abdelrazak YounesOct 7, 2008
  17. Marco CostalbaOct 7, 2008
  18. Abdelrazak YounesOct 7, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.