summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e4e3034)
raw | patch | inline | side by side (parent: e4e3034)
author | Jonathan Nieder <jrnieder@gmail.com> | |
Sat, 24 Jul 2010 11:20:15 +0000 (06:20 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 26 Jul 2010 05:09:11 +0000 (22:09 -0700) |
The repository discovery procedure looks something like this:
while (same filesystem) {
check .git in working dir
check .
chdir(..)
}
Add a function for the first step to make the actual code look a bit
closer to that pseudocode.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
while (same filesystem) {
check .git in working dir
check .
chdir(..)
}
Add a function for the first step to make the actual code look a bit
closer to that pseudocode.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
setup.c | patch | blob | history |
index 16bee6d485349602db8aa5de28b997e7ef82a731..3d25d0f205ba7ad555a7f26e40be7590ac16d926 100644 (file)
--- a/setup.c
+++ b/setup.c
return retval;
}
+static int cwd_contains_git_dir(const char **gitfile_dirp)
+{
+ const char *gitfile_dir = read_gitfile_gently(DEFAULT_GIT_DIR_ENVIRONMENT);
+ *gitfile_dirp = gitfile_dir;
+ if (gitfile_dir) {
+ if (set_git_dir(gitfile_dir))
+ die("Repository setup failed");
+ return 1;
+ }
+ return is_git_directory(DEFAULT_GIT_DIR_ENVIRONMENT);
+}
+
/*
* We cannot decide in this function whether we are in the work tree or
* not, since the config can only be read _after_ this function was called.
current_device = buf.st_dev;
}
for (;;) {
- gitfile_dir = read_gitfile_gently(DEFAULT_GIT_DIR_ENVIRONMENT);
- if (gitfile_dir) {
- if (set_git_dir(gitfile_dir))
- die("Repository setup failed");
- break;
- }
- if (is_git_directory(DEFAULT_GIT_DIR_ENVIRONMENT))
+ if (cwd_contains_git_dir(&gitfile_dir))
break;
if (is_git_directory(".")) {
inside_git_dir = 1;