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

[PATCHv2 1/3] Add gentle version of resolve_git_dir

From
Stefan Beller <sbeller@google.com>
Date
Jan 24, 2017, 23:56 UTC
Message-ID
<20170124235651.18749-2-sbeller@google.com>
In-Reply-To
<20170124235651.18749-1-sbeller@google.com>

This follows a93bedada (setup: add gentle version of read_gitfile, 2015-06-09), and assumes the same reasoning. resolve_git_dir is unsuited for speculative calls, so we want to use the gentle version to find out about potential errors.

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 cache.h | 4 +++-
 setup.c | 4 ++--
 2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/cache.h b/cache.h
index 00a029af36..cafa3d10ae 100644
--- a/cache.h
+++ b/cache.h
@@ -509,7 +509,9 @@ extern int is_nonbare_repository_dir(struct strbuf *path);
 #define READ_GITFILE_ERR_TOO_LARGE 8
 extern const char *read_gitfile_gently(const char *path, int *return_error_code);
 #define read_gitfile(path) read_gitfile_gently((path), NULL)
-extern const char *resolve_gitdir(const char *suspect);
+extern const char *resolve_gitdir_gently(const char *suspect, int *return_error_code);
+#define resolve_gitdir(path) resolve_gitdir_gently((path), NULL)
+
 extern void set_git_work_tree(const char *tree);
 
 #define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES"
diff --git a/setup.c b/setup.c
index 1b534a7508..4605fd3c3c 100644
--- a/setup.c
+++ b/setup.c
@@ -1017,11 +1017,11 @@ const char *setup_git_directory(void)
 	return setup_git_directory_gently(NULL);
 }
 
-const char *resolve_gitdir(const char *suspect)
+const char *resolve_gitdir_gently(const char *suspect, int *return_error_code)
 {
 	if (is_git_directory(suspect))
 		return suspect;
-	return read_gitfile(suspect);
+	return read_gitfile_gently(suspect, return_error_code);
 }
 
 /* if any standard file descriptor is missing open it to /dev/null */
-- 
2.11.0.495.g04f60290a0.dirty
Previous: Stefan BellerNext: Stefan Beller
Message 6 of 13 in “submodule absorbing: fix worktree/gitdir pointers recursively for non-moves”
  1. submodule absorbing: fix worktree/gitdir pointers recursively for non-movesStefan Beller, Jan 24, 2017
  2. Brandon WilliamsJan 24, 2017
  3. Stefan BellerJan 24, 2017
  4. Brandon WilliamsJan 24, 2017
  5. 0/3 fix recursive submodule absorbingStefan Beller, Jan 24, 2017
  6. 1/3 Add gentle version of resolve_git_dirStefan Beller, Jan 24, 2017
  7. 2/3 cache.h: expose the dying procedure for reading gitlinksStefan Beller, Jan 24, 2017
  8. 3/3 submodule absorbing: fix worktree/gitdir pointers recursively for non-movesStefan Beller, Jan 24, 2017
  9. Brandon WilliamsJan 25, 2017
  10. Stefan BellerJan 25, 2017
  11. Junio C HamanoJan 25, 2017
  12. 3/3 submodule absorbing: fix worktree/gitdir pointers recursively for non-movesStefan Beller, Jan 25, 2017
  13. Brandon WilliamsJan 25, 2017

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.