Skip to content

Commit

Permalink
git_dir holds pointers to local strings, hence MUST be const.
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
MadCoder authored and Junio C Hamano committed Aug 24, 2006
1 parent 60b7f38 commit c5fba16
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ extern int cache_errno;
#define INDEX_ENVIRONMENT "GIT_INDEX_FILE"
#define GRAFT_ENVIRONMENT "GIT_GRAFT_FILE"

extern char *get_git_dir(void);
extern const char *get_git_dir(void);
extern char *get_object_directory(void);
extern char *get_refs_directory(void);
extern char *get_index_file(void);
Expand Down
7 changes: 4 additions & 3 deletions environment.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ int zlib_compression_level = Z_DEFAULT_COMPRESSION;
int pager_in_use;
int pager_use_color = 1;

static char *git_dir, *git_object_dir, *git_index_file, *git_refs_dir,
*git_graft_file;
static const char *git_dir;
static char *git_object_dir, *git_index_file, *git_refs_dir, *git_graft_file;

static void setup_git_env(void)
{
git_dir = getenv(GIT_DIR_ENVIRONMENT);
Expand All @@ -49,7 +50,7 @@ static void setup_git_env(void)
git_graft_file = strdup(git_path("info/grafts"));
}

char *get_git_dir(void)
const char *get_git_dir(void)
{
if (!git_dir)
setup_git_env();
Expand Down

0 comments on commit c5fba16

Please sign in to comment.