* [MinGW PATCH] git clone was failing with 'invalid object name HEAD' if ran from cmd.exe directly
@ 2007-08-06 9:44 Dmitry Kakurin
2007-08-06 10:42 ` Johannes Schindelin
0 siblings, 1 reply; 7+ messages in thread
From: Dmitry Kakurin @ 2007-08-06 9:44 UTC (permalink / raw)
To: git
environment.c caches results of many getenv calls.
Under MinGW setenv(X) invalidates all previous values returned by getenv(X)
so cached values become dangling pointers.
Added cache-aware function set_git_dir to complement get_git_dir
Signed-off-by: Dmitry Kakurin <Dmitry.Kakurin@gmail.com>
---
builtin-init-db.c | 4 +---
cache.h | 1 +
environment.c | 6 ++++++
git.c | 6 +++---
path.c | 2 +-
setup.c | 6 +++---
7 files changed, 21 insertions(+), 10 deletions(-)
create mode 100644 config.mak
diff --git a/builtin-init-db.c b/builtin-init-db.c
index 5c0feba..62e579d 100644
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
@@ -344,9 +344,7 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
/*
* Set up the default .git directory contents
*/
- git_dir = getenv(GIT_DIR_ENVIRONMENT);
- if (!git_dir)
- git_dir = DEFAULT_GIT_DIR_ENVIRONMENT;
+ git_dir = get_git_dir();
safe_create_dir(git_dir, 0);
/* Check to see if the repository version is right.
diff --git a/cache.h b/cache.h
index 91e9f71..bc2916e 100644
--- a/cache.h
+++ b/cache.h
@@ -210,6 +210,7 @@ extern int is_bare_repository(void);
extern int is_inside_git_dir(void);
extern int is_inside_work_tree(void);
extern const char *get_git_dir(void);
+extern void set_git_dir(const char *newDir);
extern char *get_object_directory(void);
extern char *get_refs_directory(void);
extern char *get_index_file(void);
diff --git a/environment.c b/environment.c
index f83fb9e..6ea7088 100644
--- a/environment.c
+++ b/environment.c
@@ -80,6 +80,12 @@ const char *get_git_dir(void)
return git_dir;
}
+void set_git_dir(const char *newDir)
+{
+ setenv(GIT_DIR_ENVIRONMENT, newDir, 1);
+ git_dir = NULL; // reset cache
+}
+
char *get_object_directory(void)
{
if (!git_object_dir)
diff --git a/git.c b/git.c
index 210a763..53dfa05 100644
--- a/git.c
+++ b/git.c
@@ -67,14 +67,14 @@ static int handle_options(const char*** argv, int* argc, int* envchanged)
fprintf(stderr, "No directory given for --git-dir.\n" );
usage(git_usage_string);
}
- setenv(GIT_DIR_ENVIRONMENT, (*argv)[1], 1);
+ set_git_dir( (*argv)[1] );
if (envchanged)
*envchanged = 1;
(*argv)++;
(*argc)--;
handled++;
} else if (!prefixcmp(cmd, "--git-dir=")) {
- setenv(GIT_DIR_ENVIRONMENT, cmd + 10, 1);
+ set_git_dir(cmd + 10);
if (envchanged)
*envchanged = 1;
} else if (!strcmp(cmd, "--work-tree")) {
@@ -93,7 +93,7 @@ static int handle_options(const char*** argv, int* argc, int* envchanged)
*envchanged = 1;
} else if (!strcmp(cmd, "--bare")) {
static char git_dir[PATH_MAX+1];
- setenv(GIT_DIR_ENVIRONMENT, getcwd(git_dir, sizeof(git_dir)), 1);
+ set_git_dir(getcwd(git_dir, sizeof(git_dir)));
if (envchanged)
*envchanged = 1;
} else {
diff --git a/path.c b/path.c
index 8a06cf7..14af033 100644
--- a/path.c
+++ b/path.c
@@ -266,7 +266,7 @@ char *enter_repo(char *path, int strict)
if (access("objects", X_OK) == 0 && access("refs", X_OK) == 0 &&
validate_headref("HEAD") == 0) {
- setenv(GIT_DIR_ENVIRONMENT, ".", 1);
+ set_git_dir(".");
check_repository_format();
return path;
}
diff --git a/setup.c b/setup.c
index 47cd790..c5cf3ea 100644
--- a/setup.c
+++ b/setup.c
@@ -292,7 +292,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
}
die("Not a git repository");
}
- setenv(GIT_DIR_ENVIRONMENT, cwd, 1);
+ set_git_dir(cwd);
gitdirenv = getenv(GIT_DIR_ENVIRONMENT);
if (!gitdirenv)
die("getenv after setenv failed");
@@ -332,8 +332,8 @@ const char *setup_git_directory_gently(int *nongit_ok)
* In case there is a work tree we may change the directory,
* therefore make GIT_DIR an absolute path.
*/
- if ( !is_absolute_path( gitdirenv ) ) {
- setenv(GIT_DIR_ENVIRONMENT, gitdir, 1);
+ if (!is_absolute_path(gitdirenv)) {
+ set_git_dir(gitdir);
gitdirenv = getenv(GIT_DIR_ENVIRONMENT);
if (!gitdirenv)
die("getenv after setenv failed");
--
1.5.3.GIT
- Dmitry
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [MinGW PATCH] git clone was failing with 'invalid object name HEAD' if ran from cmd.exe directly
2007-08-06 9:44 [MinGW PATCH] git clone was failing with 'invalid object name HEAD' if ran from cmd.exe directly Dmitry Kakurin
@ 2007-08-06 10:42 ` Johannes Schindelin
2007-08-06 21:51 ` Dmitry Kakurin
2007-08-06 21:55 ` Dmitry Kakurin
0 siblings, 2 replies; 7+ messages in thread
From: Johannes Schindelin @ 2007-08-06 10:42 UTC (permalink / raw)
To: Dmitry Kakurin; +Cc: git
Hi,
On Mon, 6 Aug 2007, Dmitry Kakurin wrote:
> environment.c caches results of many getenv calls. Under MinGW setenv(X)
> invalidates all previous values returned by getenv(X) so cached values
> become dangling pointers.
>
> Added cache-aware function set_git_dir to complement get_git_dir
The real problem here: mingw.git did not merge with upstream git.git in a
long time (mainly because its maintainer is on holiday). In the meantime,
set_git_dir() is already there!
I had more problems than I thought with setting up a fork of mingw.git.
It seems that the relative alternates path to mingw.git is followed, but
not that one from mingw.git to git.git. So I could upload, but not fetch.
So I propose to use http://repo.or.cz/w/git/mingw4msysgit.git/ in the
meantime. (Just give me your account name, and you'll be able to push to
it.)
BTW your patch was white-space mangled.
Ciao,
Dscho
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [MinGW PATCH] git clone was failing with 'invalid object name HEAD' if ran from cmd.exe directly
2007-08-06 10:42 ` Johannes Schindelin
@ 2007-08-06 21:51 ` Dmitry Kakurin
2007-08-06 21:55 ` Dmitry Kakurin
1 sibling, 0 replies; 7+ messages in thread
From: Dmitry Kakurin @ 2007-08-06 21:51 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git
On 8/6/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> long time (mainly because its maintainer is on holiday). In the meantime,
> set_git_dir() is already there!
I didn't know that.
> BTW your patch was white-space mangled.
I'll be sending patches as attachments from now on.
- Dmitry
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [MinGW PATCH] git clone was failing with 'invalid object name HEAD' if ran from cmd.exe directly
2007-08-06 10:42 ` Johannes Schindelin
2007-08-06 21:51 ` Dmitry Kakurin
@ 2007-08-06 21:55 ` Dmitry Kakurin
2007-08-06 21:56 ` Johannes Schindelin
1 sibling, 1 reply; 7+ messages in thread
From: Dmitry Kakurin @ 2007-08-06 21:55 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git
On 8/6/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> I had more problems than I thought with setting up a fork of mingw.git.
> It seems that the relative alternates path to mingw.git is followed, but
> not that one from mingw.git to git.git. So I could upload, but not fetch.
Does it mean that fork of a fork does not work on repo.or.cz?
- Dmitry
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [MinGW PATCH] git clone was failing with 'invalid object name HEAD' if ran from cmd.exe directly
2007-08-06 21:55 ` Dmitry Kakurin
@ 2007-08-06 21:56 ` Johannes Schindelin
2007-08-06 22:32 ` Dmitry Kakurin
0 siblings, 1 reply; 7+ messages in thread
From: Johannes Schindelin @ 2007-08-06 21:56 UTC (permalink / raw)
To: Dmitry Kakurin; +Cc: git
Hi,
On Mon, 6 Aug 2007, Dmitry Kakurin wrote:
> On 8/6/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> > I had more problems than I thought with setting up a fork of mingw.git.
> > It seems that the relative alternates path to mingw.git is followed, but
> > not that one from mingw.git to git.git. So I could upload, but not fetch.
>
> Does it mean that fork of a fork does not work on repo.or.cz?
Yes, at the moment it does not work. Therefore I set up
git/mingw4msysgit.git, for the time being.
Ciao,
Dscho
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [MinGW PATCH] git clone was failing with 'invalid object name HEAD' if ran from cmd.exe directly
2007-08-06 21:56 ` Johannes Schindelin
@ 2007-08-06 22:32 ` Dmitry Kakurin
2007-08-06 22:48 ` Johannes Schindelin
0 siblings, 1 reply; 7+ messages in thread
From: Dmitry Kakurin @ 2007-08-06 22:32 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git
On 8/6/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> > Does it mean that fork of a fork does not work on repo.or.cz?
>
> Yes, at the moment it does not work. Therefore I set up
> git/mingw4msysgit.git, for the time being.
That's too bad.
I was thinking about adopting distributed dev model for MinGW port of Git:
we all would fork off mingw.git on repo.or.cz and then we would pull
from each other instead of exchanging patches thru e-mail.
Personally I don't like email patch exchange process.
Can this problem on repo.or.cs be fixed? Did Petr reply?
- Dmitry
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [MinGW PATCH] git clone was failing with 'invalid object name HEAD' if ran from cmd.exe directly
2007-08-06 22:32 ` Dmitry Kakurin
@ 2007-08-06 22:48 ` Johannes Schindelin
0 siblings, 0 replies; 7+ messages in thread
From: Johannes Schindelin @ 2007-08-06 22:48 UTC (permalink / raw)
To: Dmitry Kakurin; +Cc: git
Hi,
On Mon, 6 Aug 2007, Dmitry Kakurin wrote:
> On 8/6/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
>
> > > Does it mean that fork of a fork does not work on repo.or.cz?
> >
> > Yes, at the moment it does not work. Therefore I set up
> > git/mingw4msysgit.git, for the time being.
>
> That's too bad. I was thinking about adopting distributed dev model for
> MinGW port of Git: we all would fork off mingw.git on repo.or.cz and
> then we would pull from each other instead of exchanging patches thru
> e-mail. Personally I don't like email patch exchange process.
We can still do that. Just set up a fork of _git.git_, and initialise it
with mingw4msysgit.git.
> Can this problem on repo.or.cs be fixed? Did Petr reply?
I think it can. But Pasky seems to be extraordinarily busy these days.
So no, I got no reply besides a message on IRC that he'll try to do
something about the situation tonight.
Ciao,
Dscho
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2007-08-06 22:48 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-06 9:44 [MinGW PATCH] git clone was failing with 'invalid object name HEAD' if ran from cmd.exe directly Dmitry Kakurin
2007-08-06 10:42 ` Johannes Schindelin
2007-08-06 21:51 ` Dmitry Kakurin
2007-08-06 21:55 ` Dmitry Kakurin
2007-08-06 21:56 ` Johannes Schindelin
2007-08-06 22:32 ` Dmitry Kakurin
2007-08-06 22:48 ` Johannes Schindelin
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).