From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Steffen Prohaska <prohaska@zib.de>
Cc: Johannes Sixt <j.sixt@viscovery.net>,
Junio C Hamano <gitster@pobox.com>,
git@vger.kernel.org, Dmitry Kakurin <Dmitry.Kakurin@gmail.com>
Subject: Re: [PATCH 3/3] Replace setenv(GIT_DIR_ENVIRONMENT, ...) with set_git_dir()
Date: Thu, 22 Nov 2007 22:09:10 +0000 (GMT) [thread overview]
Message-ID: <Pine.LNX.4.64.0711222149390.27959@racer.site> (raw)
In-Reply-To: <3B6B19E6-255F-4D8F-B6A3-255A9E8E0AB0@zib.de>
Hi,
On Thu, 22 Nov 2007, Steffen Prohaska wrote:
> Yes, and apparently even nobody knows how to trigger the problem on
> Windows.
A quick and easy way would be to instrument getenv(), unsetenv() and
setenv(), which would trigger an error. Something like this (but you
will have to put in a few "extern called_getenv; called_getenv = 0;",
since already a simple git-init fails because of setup_path()):
-- snipsnap --
[PATCH] Instrument getenv(), setenv(), unsetenv() and putenv()
... for finding places where a pointer obtained by getenv() could
be invalidated later.
---
environment.c | 1 +
git-compat-util.h | 31 +++++++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/environment.c b/environment.c
index ce75e98..027340e 100644
--- a/environment.c
+++ b/environment.c
@@ -9,6 +9,7 @@
*/
#include "cache.h"
+int called_setenv, called_getenv;
char git_default_email[MAX_GITNAME];
char git_default_name[MAX_GITNAME];
int trust_executable_bit = 1;
diff --git a/git-compat-util.h b/git-compat-util.h
index 79eb10e..a41469b 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -427,4 +427,35 @@ static inline int strtol_i(char const *s, int base, int *result)
return 0;
}
+extern int called_setenv, called_getenv;
+static inline char *test_getenv(const char *name)
+{
+ if (!called_setenv)
+ warning ("called test_getenv %s", name);
+ called_getenv = 1;
+ return getenv(name);
+}
+static inline int test_setenv(const char *name, const char *value, int overwrite)
+{
+ if (!called_setenv && called_getenv)
+ die ("getenv was called before setenv(%s, %s, %d)",
+ name, value, overwrite);
+ return setenv(name, value, overwrite);
+}
+static inline int test_unsetenv(const char *name)
+{
+ if (!called_setenv && called_getenv)
+ die ("getenv was called before unsetenv(%s)", name);
+ return unsetenv(name);
+}
+static inline int test_putenv(char *string)
+{
+ if (!called_setenv && called_getenv)
+ die ("getenv was called before putenv(%s)", string);
+ return putenv(string);
+}
+#define getenv test_getenv
+#define setenv test_setenv
+#define unsetenv test_unsetenv
+
#endif
next prev parent reply other threads:[~2007-11-22 22:09 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-21 20:27 [PATCH 0/3] msysgit fallout Steffen Prohaska
2007-11-21 20:27 ` [PATCH 1/3] sha1_file.c: Fix size_t related printf format warnings Steffen Prohaska
2007-11-21 20:27 ` [PATCH 2/3] builtin-init-db: use get_git_dir() instead of getenv() Steffen Prohaska
2007-11-21 20:27 ` [PATCH 3/3] Replace setenv(GIT_DIR_ENVIRONMENT, ...) with set_git_dir() Steffen Prohaska
2007-11-22 1:22 ` Johannes Schindelin
2007-11-22 2:34 ` Junio C Hamano
2007-11-22 6:13 ` Steffen Prohaska
2007-11-22 7:52 ` Junio C Hamano
2007-11-22 8:31 ` Steffen Prohaska
2007-11-22 9:58 ` Johannes Sixt
2007-11-22 17:56 ` Steffen Prohaska
2007-11-22 22:09 ` Johannes Schindelin [this message]
2008-01-01 18:52 ` Steffen Prohaska
2008-01-03 4:07 ` Dmitry Kakurin
2008-01-03 6:02 ` Steffen Prohaska
2008-01-03 6:26 ` Dmitry Kakurin
2008-01-03 7:53 ` Steffen Prohaska
2007-11-22 7:29 ` Johannes Sixt
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=Pine.LNX.4.64.0711222149390.27959@racer.site \
--to=johannes.schindelin@gmx.de \
--cc=Dmitry.Kakurin@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=j.sixt@viscovery.net \
--cc=prohaska@zib.de \
/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).