Code

gitweb: Lift any characters restriction on searched strings
[git.git] / setup.c
diff --git a/setup.c b/setup.c
index 3653092ab657942639b6183fb04b3af783b77e7a..06004f15874fbcbab50eafd272c5898a34fcdcfe 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -107,7 +107,7 @@ void verify_non_filename(const char *prefix, const char *arg)
        if (!lstat(name, &st))
                die("ambiguous argument '%s': both revision and filename\n"
                    "Use '--' to separate filenames from revisions", arg);
-       if (errno != ENOENT)
+       if (errno != ENOENT && errno != ENOTDIR)
                die("'%s': %s", arg, strerror(errno));
 }
 
@@ -189,47 +189,21 @@ int is_inside_work_tree(void)
 }
 
 /*
- * If no worktree was given, and we are outside of a default work tree,
- * now is the time to set it.
- *
- * In other words, if the user calls git with something like
- *
- *     git --git-dir=/some/where/else/.git bla
- *
- * default to /some/where/else as working directory; if the specified
- * git-dir does not end in "/.git", the cwd is used as working directory.
+ * set_work_tree() is only ever called if you set GIT_DIR explicitely.
+ * The old behaviour (which we retain here) is to set the work tree root
+ * to the cwd, unless overridden by the config, the command line, or
+ * GIT_WORK_TREE.
  */
-const char *set_work_tree(const char *dir)
+static const char *set_work_tree(const char *dir)
 {
-       char dir_buffer[PATH_MAX];
-       static char buffer[PATH_MAX + 1], *rel = NULL;
-       int len, postfix_len = strlen(DEFAULT_GIT_DIR_ENVIRONMENT) + 1;
-
-       /* strip the variable 'dir' of the postfix "/.git" if it has it */
-       len = strlen(dir);
-       if (len > postfix_len && !strcmp(dir + len - postfix_len,
-                               "/" DEFAULT_GIT_DIR_ENVIRONMENT)) {
-                       strncpy(dir_buffer, dir, len - postfix_len);
-
-               /* are we inside the default work tree? */
-               rel = get_relative_cwd(buffer, sizeof(buffer), dir_buffer);
-       }
-       /* if rel is set, the cwd is _not_ the current working tree */
-       if (rel && *rel) {
-               if (!is_absolute_path(dir))
-                       set_git_dir(make_absolute_path(dir));
-               dir = dir_buffer;
-               chdir(dir);
-               strcat(rel, "/");
-               inside_git_dir = 0;
-       } else {
-               rel = NULL;
-               dir = getcwd(buffer, sizeof(buffer));
-       }
-       git_work_tree_cfg = xstrdup(dir);
+       char buffer[PATH_MAX + 1];
+
+       if (!getcwd(buffer, sizeof(buffer)))
+               die ("Could not get the current working directory");
+       git_work_tree_cfg = xstrdup(buffer);
        inside_work_tree = 1;
 
-       return rel;
+       return NULL;
 }
 
 /*