Issue 346 in msysgit: %APPDATA%/.gitconfig error in git config --global

131 views
Skip to first unread message

codesite...@google.com

unread,
Oct 5, 2009, 8:23:16 PM10/5/09
to msy...@googlegroups.com
Status: New
Owner: ----

New issue 346 by olivier.mengue: %APPDATA%/.gitconfig error in git config
--global
http://code.google.com/p/msysgit/issues/detail?id=346

What steps will reproduce the problem?
1. git config --global user.name "Olivier Mengué"
error: could not lock config file %APPDATA%/.gitconfig: No such file or
directory

What version of the product are you using? On what operating system?
Git-1.6.4-preview20090730.exe on Windows Vista

Please provide any additional information below.
I just installed git for the first time. I'm sure there is nothing Git
related in %APPDATA%

The problem is probably that the environment variable must be expanded.

--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

codesite...@google.com

unread,
Oct 6, 2009, 6:11:32 AM10/6/09
to msy...@googlegroups.com

Comment #1 on issue 346 by patthoyts: %APPDATA%/.gitconfig error in git
config --global
http://code.google.com/p/msysgit/issues/detail?id=346

You don't say if you are using Bash or the Windows cmd prompt.
If you open a cmd prompt and enter "set APPDATA" (without the quotes) what
does it
print out (should be something like c:\Users\Olivier\AppData\Roaming)
The APPDATA environment variable is set by windows to be the location that
applications should store per-user data. I assume this is a change from
1.6.3 as
previous versions were creating .gitconfig in %USERPROFILE%

codesite...@google.com

unread,
Oct 6, 2009, 6:34:56 AM10/6/09
to msy...@googlegroups.com

Comment #2 on issue 346 by johannes.schindelin: %APPDATA%/.gitconfig error

No, there has not been such a change. I guess that the environment
variable HOME is
set to %APPDATA% for some reason.

codesite...@google.com

unread,
Oct 6, 2009, 6:46:19 PM10/6/09
to msy...@googlegroups.com

Comment #3 on issue 346 by olivier.mengue: %APPDATA%/.gitconfig error in

I'm using cmd.exe.

My HOME variable is in fact defined as %APPDATA% in the control panel.
However it is
correctly expanded to "C:\Users\Dolmen\AppData\Roaming" in the cmd.exe
shell.

So I suspect that git got the value directly from the registry instead of
using the
environment.
The registry value HKEY_CURRENT_USER\Environment\HOME is of type
REG_EXPAND_SZ so
even if it was queried directly it should have been expanded.


However I can not reproduce the problem now that I have restarted my
computer. So it
is probably a problem that may occur only just after install, may be a
Windows bug in
the "refresh environment" dispatching...

You can close the issue.

codesite...@google.com

unread,
Oct 6, 2009, 7:20:51 PM10/6/09
to msy...@googlegroups.com
Updates:
Status: Closed

Comment #4 on issue 346 by johannes.schindelin: %APPDATA%/.gitconfig error

I was tempted to mark this as "invalid", as setting HOME to something
invalid is not
intended to be handled gracefully by Git. But probably Windows fixed the
wrong
setting.

codesite...@google.com

unread,
Oct 7, 2009, 5:04:31 AM10/7/09
to msy...@googlegroups.com

Comment #5 on issue 346 by olivier.mengue: %APPDATA%/.gitconfig error in

Referencing environment variables in environment variable definition is not
invalid.
As I wrote above the control panel handles them as expected and stores them
as
REG_EXPAND_SZ.
This is not a "wrong setting".

codesite...@google.com

unread,
Oct 7, 2009, 6:17:12 AM10/7/09
to msy...@googlegroups.com

Comment #6 on issue 346 by johannes.schindelin: %APPDATA%/.gitconfig error

If you want to allow environment variables to contain environment variables
that need
to be expanded, then you open the door for infinite loops. Which is why
they are
invalid, even if some programs happen to think they are not.

Anyway, this issue is closed.

codesite...@google.com

unread,
Oct 7, 2009, 1:34:07 PM10/7/09
to msy...@googlegroups.com

Comment #7 on issue 346 by poddster: %APPDATA%/.gitconfig error in git
config --global
http://code.google.com/p/msysgit/issues/detail?id=346

Johannes, I don't think you should close this. Git is acting incorrect.
Environment
variables containing environment variables is already handled by Windows.
Infact
essential Windows variables refer to other Windows variables. You just need
to use
the API:see

%bigpoostring%=hellothere;hello there
%bigpoostring_ex%=%bigpoostring%;var1;var2
%bigpoostring_include%=%bigpoostring%;var 3;var 4;%bigpoostring_ex%
%bigpoostring_recurse%=var 5;%bigpoostring%;var 6;%bigpoostring_recurse%
%bigpoostring_recurseA%=%bigpoostring_recurse%;for;%bigpoostring_recurseB%;after
%bigpoostring_recurseB%=%bigpoostring_recurse%;forefarther;%bigpoostring_recurseA%;aftereight


#include "stdafx.h"
#include <windows.h>
#include <tchar.h>
#include <stdio.h>


int _tmain(int argc, _TCHAR* argv[])
{
char b[400];

GetEnvironmentVariableA("bigpoostring", b, 400);
printf("bigpoostring: %s\n", b);

GetEnvironmentVariableA("bigpoostring_ex", b, 400);
printf("bigpoostring_ex: %s\n", b);

GetEnvironmentVariableA("bigpoostring_include", b, 400);
printf("bigpoostring_include: %s\n", b);

GetEnvironmentVariableA("bigpoostring_recurse", b, 400);
printf("bigpoostring_recurse: %s\n", b);

GetEnvironmentVariableA("bigpoostring_recurseA", b, 400);
printf("bigpoostring_recurseA: %s\n", b);

GetEnvironmentVariableA("bigpoostring_recurseB", b, 400);
printf("bigpoostring_recurseB: %s\n", b);

return 0;
}

output:
bigpoostring: hellothere;hello there
bigpoostring_ex: hellothere;hello there;var1;var2
bigpoostring_include: hellothere;hello there;var 3;var 4;hellothere;hello
there;var1;var2
bigpoostring_recurse: var 5;hellothere;hello there;var
6;%bigpoostring_recurse%
bigpoostring_recurseA: var 5;hellothere;hello there;var
6;%bigpoostring_recurse%;for;%bigpoostring_recurseB%;after
bigpoostring_recurseB: var 5;hellothere;hello there;var
6;%bigpoostring_recurse%;forefarther;var 5;hellothere;hello there;var
6;%bigpoostring_recurse%;for;%bigpoostring_recurseB%;after;aftereight

codesite...@google.com

unread,
Oct 13, 2009, 12:34:59 PM10/13/09
to msy...@googlegroups.com

Comment #8 on issue 346 by poddster: %APPDATA%/.gitconfig error in git
config --global
http://code.google.com/p/msysgit/issues/detail?id=346

I posted a comment here the other day, even recieved an email about it, but
can't see
it on this webpage?

codesite...@google.com

unread,
Oct 13, 2009, 12:48:14 PM10/13/09
to msy...@googlegroups.com

Comment #9 on issue 346 by poddster: %APPDATA%/.gitconfig error in git
config --global
http://code.google.com/p/msysgit/issues/detail?id=346

Well, given that the last message worked, he's the original:

Johannes, I don't think you should close this. Git is acting incorrect.
Environment
variables containing environment variables is already handled by Windows.
Infact
essential Windows variables refer to other Windows variables. You just need
to use

the Windows API.

/*


%bigpoostring%=hellothere;hello there
%bigpoostring_ex%=%bigpoostring%;var1;var2
%bigpoostring_include%=%bigpoostring%;var 3;var 4;%bigpoostring_ex%
%bigpoostring_recurse%=var 5;%bigpoostring%;var 6;%bigpoostring_recurse%
%bigpoostring_recurseA%=%bigpoostring_recurse%;for;%bigpoostring_recurseB%;after
%bigpoostring_recurseB%=%bigpoostring_recurse%;forefarther;%bigpoostring_recurseA%;aftereight

*/

#include "stdafx.h"
#include <windows.h>
#include <tchar.h>
#include <stdio.h>


int _tmain(int argc, _TCHAR* argv[])
{
char b[400];

GetEnvironmentVariableA("bigpoostring", b, 400);
printf("bigpoostring: %s\n", b);

GetEnvironmentVariableA("bigpoostring_ex", b, 400);
printf("bigpoostring_ex: %s\n", b);

GetEnvironmentVariableA("bigpoostring_include", b, 400);
printf("bigpoostring_include: %s\n", b);

GetEnvironmentVariableA("bigpoostring_recurse", b, 400);
printf("bigpoostring_recurse: %s\n", b);

GetEnvironmentVariableA("bigpoostring_recurseA", b, 400);
printf("bigpoostring_recurseA: %s\n", b);

GetEnvironmentVariableA("bigpoostring_recurseB", b, 400);
printf("bigpoostring_recurseB: %s\n", b);

return 0;
}

/*


output:
bigpoostring: hellothere;hello there
bigpoostring_ex: hellothere;hello there;var1;var2
bigpoostring_include: hellothere;hello there;var 3;var 4;hellothere;hello
there;var1;var2
bigpoostring_recurse: var 5;hellothere;hello there;var
6;%bigpoostring_recurse%
bigpoostring_recurseA: var 5;hellothere;hello there;var
6;%bigpoostring_recurse%;for;%bigpoostring_recurseB%;after
bigpoostring_recurseB: var 5;hellothere;hello there;var
6;%bigpoostring_recurse%;forefarther;var 5;hellothere;hello there;var
6;%bigpoostring_recurse%;for;%bigpoostring_recurseB%;after;aftereight

*/

codesite...@google.com

unread,
Oct 13, 2009, 1:21:10 PM10/13/09
to msy...@googlegroups.com

Comment #10 on issue 346 by kusmabite: %APPDATA%/.gitconfig error in git
config --global
http://code.google.com/p/msysgit/issues/detail?id=346

No, it does not work. I guess it's your environment-editor that expands
these
variables, not GetEnvironmentVariableA.

Here's a self-contained test:

--->8---

#include <stdio.h>
#include <stdlib.h>
#include <windows.h>

int main() {
char temp[256];
putenv("DOES_NOT=does");

/* unix style */
putenv("TEST=$DOES_NOT work");
printf("getenv() %s expand unix style variables\n", getenv("TEST"));

/* windows style */
putenv("TEST=%DOES_NOT% work");
printf("getenv() %s expand windows style variables\n", getenv("TEST"));

/* using win32 */
GetEnvironmentVariableA("TEST", temp, 256);
printf("GetEnvironmentVariableA() %s expand windows style variables,
either\n", temp);
}

--->8---

$ gcc getenv-test.c && ./a.exe
getenv() $DOES_NOT work expand unix style variables
getenv() %DOES_NOT% work expand windows style variables
GetEnvironmentVariableA() %DOES_NOT% work expand windows style variables,
either

Now let this issue rest in peace.

Reply all
Reply to author
Forward
0 new messages