From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Cc: Johannes Sixt <j.sixt@viscovery.net>,
Junio C Hamano <gitster@pobox.com>,
Mark Lodato <lodatom@gmail.com>
Subject: [PATCH v2 1/3] cache.h: drop LOCAL_REPO_ENV_SIZE
Date: Fri, 8 Mar 2013 04:29:08 -0500 [thread overview]
Message-ID: <20130308092907.GA1923@sigill.intra.peff.net> (raw)
In-Reply-To: <20130308092824.GA9127@sigill.intra.peff.net>
We keep a static array of variables that should be cleared
when invoking a sub-process on another repo. We statically
size the array with the LOCAL_REPO_ENV_SIZE macro so that
any readers do not have to count it themselves.
As it turns out, no readers actually use the macro, and it
creates a maintenance headache, as modifications to the
array need to happen in two places (one to add the new
element, and another to bump the size).
Since it's NULL-terminated, we can just drop the size macro
entirely. While we're at it, we'll clean up some comments
around it, and add a new mention of it at the top of the
list of environment variable macros. Even though
local_repo_env is right below that list, it's easy to miss,
and additions to that list should consider local_repo_env.
Signed-off-by: Jeff King <peff@peff.net>
---
cache.h | 12 ++++++------
environment.c | 6 ++----
2 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/cache.h b/cache.h
index e493563..b90044a 100644
--- a/cache.h
+++ b/cache.h
@@ -341,6 +341,7 @@ static inline enum object_type object_type(unsigned int mode)
OBJ_BLOB;
}
+/* Double-check local_repo_env below if you add to this list. */
#define GIT_DIR_ENVIRONMENT "GIT_DIR"
#define GIT_NAMESPACE_ENVIRONMENT "GIT_NAMESPACE"
#define GIT_WORK_TREE_ENVIRONMENT "GIT_WORK_TREE"
@@ -365,13 +366,12 @@ static inline enum object_type object_type(unsigned int mode)
#define GIT_LITERAL_PATHSPECS_ENVIRONMENT "GIT_LITERAL_PATHSPECS"
/*
- * Repository-local GIT_* environment variables
- * The array is NULL-terminated to simplify its usage in contexts such
- * environment creation or simple walk of the list.
- * The number of non-NULL entries is available as a macro.
+ * Repository-local GIT_* environment variables; these will be cleared
+ * when git spawns a sub-process that runs inside another repository.
+ * The array is NULL-terminated, which makes it easy to pass in the "env"
+ * parameter of a run-command invocation, or to do a simple walk.
*/
-#define LOCAL_REPO_ENV_SIZE 9
-extern const char *const local_repo_env[LOCAL_REPO_ENV_SIZE + 1];
+extern const char * const local_repo_env[];
extern int is_bare_repository_cfg;
extern int is_bare_repository(void);
diff --git a/environment.c b/environment.c
index 89d6c70..dc73927 100644
--- a/environment.c
+++ b/environment.c
@@ -83,11 +83,9 @@ static char *git_object_dir, *git_index_file, *git_graft_file;
static char *git_object_dir, *git_index_file, *git_graft_file;
/*
- * Repository-local GIT_* environment variables
- * Remember to update local_repo_env_size in cache.h when
- * the size of the list changes
+ * Repository-local GIT_* environment variables; see cache.h for details.
*/
-const char * const local_repo_env[LOCAL_REPO_ENV_SIZE + 1] = {
+const char * const local_repo_env[] = {
ALTERNATE_DB_ENVIRONMENT,
CONFIG_ENVIRONMENT,
CONFIG_DATA_ENVIRONMENT,
--
1.8.2.rc2.4.g3e774bb
next prev parent reply other threads:[~2013-03-08 9:29 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-07 22:47 [BUG] bare repository detection does not work with aliases Mark Lodato
2013-03-08 5:48 ` Jeff King
2013-03-08 6:27 ` Junio C Hamano
2013-03-08 6:37 ` Jeff King
2013-03-08 7:15 ` [PATCH] setup: suppress implicit "." work-tree for bare repos Jeff King
2013-03-08 7:44 ` Johannes Sixt
2013-03-08 8:42 ` Jeff King
2013-03-08 9:28 ` [PATCHv2] setup and GIT_IMPLICIT_WORK_TREE Jeff King
2013-03-08 9:29 ` Jeff King [this message]
2013-03-08 9:30 ` [PATCH v2 2/3] environment: add GIT_PREFIX to local_repo_env Jeff King
2013-03-08 21:39 ` Eric Sunshine
2013-03-08 21:44 ` Jeff King
2013-03-08 23:03 ` Junio C Hamano
2013-03-08 9:32 ` [PATCH v2 3/3] setup: suppress implicit "." work-tree for bare repos Jeff King
2013-03-08 7:54 ` [PATCH] " Junio C Hamano
2013-03-08 8:43 ` Jeff King
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=20130308092907.GA1923@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=j.sixt@viscovery.net \
--cc=lodatom@gmail.com \
/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).