summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 68698da)
raw | patch | inline | side by side (parent: 68698da)
author | Jonathan Nieder <jrnieder@gmail.com> | |
Sat, 24 Jul 2010 11:26:41 +0000 (06:26 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 26 Jul 2010 05:12:50 +0000 (22:12 -0700) |
Perhaps some day, other similar conditions (hitting the mount point,
hitting the root of the file system) will share this code.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
hitting the root of the file system) will share this code.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
setup.c | patch | blob | history |
index ec11c462669053b9841166da310457ca8c53ae48..9fc05e2c0a79df1faf313994430d0649f8231d9a 100644 (file)
--- a/setup.c
+++ b/setup.c
return NULL;
}
+static const char *setup_nongit(const char *cwd, int *nongit_ok)
+{
+ if (!nongit_ok)
+ die("Not a git repository (or any of the parent directories): %s", DEFAULT_GIT_DIR_ENVIRONMENT);
+ if (chdir(cwd))
+ die_errno("Cannot come back to cwd");
+ *nongit_ok = 1;
+ return NULL;
+}
+
/*
* 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.
return setup_bare_git_dir(work_tree_env, offset,
len, cwd, nongit_ok);
while (--offset > ceil_offset && cwd[offset] != '/');
- if (offset <= ceil_offset) {
- if (nongit_ok) {
- if (chdir(cwd))
- die_errno("Cannot come back to cwd");
- *nongit_ok = 1;
- return NULL;
- }
- die("Not a git repository (or any of the parent directories): %s", DEFAULT_GIT_DIR_ENVIRONMENT);
- }
+ if (offset <= ceil_offset)
+ return setup_nongit(cwd, nongit_ok);
if (one_filesystem) {
if (stat("..", &buf)) {
cwd[offset] = '\0';