git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/4] add have_git_dir() function

From
Dmitry Potapov <dpotapov@gmail.com>
Date
Sep 27, 2008, 08:41 UTC
Message-ID
<20080927084150.GA21650@dpotapov.dyndns.org>

This function is used to learn whether git_dir is already set up or not. It is necessary, because we want to read configuration in compat/cygwin.c

Signed-off-by: Dmitry Potapov <dpotapov@gmail.com>
---
 cache.h       |    1 +
 environment.c |    5 +++++
 2 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/cache.h b/cache.h
index de8c2b6..e0e46ed 100644
--- a/cache.h
+++ b/cache.h
@@ -313,6 +313,7 @@ extern int is_bare_repository(void);
 extern int is_inside_git_dir(void);
 extern char *git_work_tree_cfg;
 extern int is_inside_work_tree(void);
+extern int have_git_dir(void);
 extern const char *get_git_dir(void);
 extern char *get_object_directory(void);
 extern char *get_index_file(void);
diff --git a/environment.c b/environment.c
index 0c6d11f..0693cd9 100644
--- a/environment.c
+++ b/environment.c
@@ -80,6 +80,11 @@ int is_bare_repository(void)
 	return is_bare_repository_cfg && !get_git_work_tree();
 }
 
+int have_git_dir(void)
+{
+	return !!git_dir;
+}
+
 const char *get_git_dir(void)
 {
 	if (!git_dir)
-- 
1.6.0.2.237.g0297e5
Message 1 of 1 in “add have_git_dir() function”
  1. 2/4 add have_git_dir() functionDmitry Potapov, Sep 27, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.