summaryrefslogtreecommitdiff
path: root/cache.h
diff options
context:
space:
mode:
authorLibravatar Brandon Williams <bmwill@google.com>2017-06-14 11:07:37 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2017-06-15 12:56:22 -0700
commitd3fb71b3cb36971608a46744261e6b5f8802e784 (patch)
tree809de18f72641a2fd76a3ce00c5a7207a4afc3e9 /cache.h
parentconfig: don't include config.h by default (diff)
downloadtgif-d3fb71b3cb36971608a46744261e6b5f8802e784.tar.xz
setup: teach discover_git_directory to respect the commondir
Currently 'discover_git_directory' only looks at the gitdir to determine if a git directory was discovered. This causes a problem in the event that the gitdir which was discovered was in fact a per-worktree git directory and not the common git directory. This is because the repository config, which is checked to verify the repository's format, is stored in the commondir and not in the per-worktree gitdir. Correct this behavior by checking the config stored in the commondir. It will also be of use for callers to have access to the commondir, so lets also return that upon successfully discovering a git directory. Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'cache.h')
-rw-r--r--cache.h15
1 files changed, 9 insertions, 6 deletions
diff --git a/cache.h b/cache.h
index 160ff81aa7..82f39f7a9e 100644
--- a/cache.h
+++ b/cache.h
@@ -525,12 +525,15 @@ extern void set_git_work_tree(const char *tree);
extern void setup_work_tree(void);
/*
- * Find GIT_DIR of the repository that contains the current working directory,
- * without changing the working directory or other global state. The result is
- * appended to gitdir. The return value is either NULL if no repository was
- * found, or pointing to the path inside gitdir's buffer.
- */
-extern const char *discover_git_directory(struct strbuf *gitdir);
+ * Find the commondir and gitdir of the repository that contains the current
+ * working directory, without changing the working directory or other global
+ * state. The result is appended to commondir and gitdir. If the discovered
+ * gitdir does not correspond to a worktree, then 'commondir' and 'gitdir' will
+ * both have the same result appended to the buffer. The return value is
+ * either 0 upon success and non-zero if no repository was found.
+ */
+extern int discover_git_directory(struct strbuf *commondir,
+ struct strbuf *gitdir);
extern const char *setup_git_directory_gently(int *);
extern const char *setup_git_directory(void);
extern char *prefix_path(const char *prefix, int len, const char *path);