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%
No, there has not been such a change. I guess that the environment
variable HOME is
set to %APPDATA% for some reason.
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.
Comment #4 on issue 346 by johannes.schindelin: %APPDATA%/.gitconfig error
in git config --global
http://code.google.com/p/msysgit/issues/detail?id=346
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.
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".
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.
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
I posted a comment here the other day, even recieved an email about it, but
can't see
it on this webpage?
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
*/
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.