Merge branch 'maint'
authorJunio C Hamano <gitster@pobox.com>
Mon, 7 Jun 2010 01:42:12 +0000 (18:42 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 7 Jun 2010 01:42:12 +0000 (18:42 -0700)
* maint:
setup: document prefix

1  2 
setup.c
diff --combined setup.c
index 5a083fa77dda016d0f3f511787ebf771aaf1be08,0e4cfe603f1afe515365c9daf1ad8406de8e7fa8..7e0460205dc1d15007849f367d21e999f2da044c
+++ b/setup.c
@@@ -323,8 -323,6 +323,8 @@@ const char *setup_git_directory_gently(
        const char *gitdirenv;
        const char *gitfile_dir;
        int len, offset, ceil_offset, root_len;
 +      int current_device = 0, one_filesystem = 1;
 +      struct stat buf;
  
        /*
         * Let's assume that we are in a git repository.
         *   etc.
         */
        offset = len = strlen(cwd);
 +      one_filesystem = !git_env_bool("GIT_DISCOVERY_ACROSS_FILESYSTEM", 0);
 +      if (one_filesystem) {
 +              if (stat(".", &buf))
 +                      die_errno("failed to stat '.'");
 +              current_device = buf.st_dev;
 +      }
        for (;;) {
                gitfile_dir = read_gitfile_gently(DEFAULT_GIT_DIR_ENVIRONMENT);
                if (gitfile_dir) {
                        }
                        die("Not a git repository (or any of the parent directories): %s", DEFAULT_GIT_DIR_ENVIRONMENT);
                }
 -              if (chdir(".."))
 +              if (one_filesystem) {
 +                      if (stat("..", &buf)) {
 +                              cwd[offset] = '\0';
 +                              die_errno("failed to stat '%s/..'", cwd);
 +                      }
 +                      if (buf.st_dev != current_device) {
 +                              if (nongit_ok) {
 +                                      if (chdir(cwd))
 +                                              die_errno("Cannot come back to cwd");
 +                                      *nongit_ok = 1;
 +                                      return NULL;
 +                              }
 +                              cwd[offset] = '\0';
 +                              die("Not a git repository (or any parent up to mount parent %s)\n"
 +                              "Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).", cwd);
 +                      }
 +              }
 +              if (chdir("..")) {
 +                      cwd[offset] = '\0';
                        die_errno("Cannot change to '%s/..'", cwd);
 +              }
        }
  
        inside_git_dir = 0;
@@@ -546,6 -519,12 +546,12 @@@ int check_repository_format(void
        return check_repository_format_gently(NULL);
  }
  
+ /*
+  * Returns the "prefix", a path to the current working directory
+  * relative to the work tree root, or NULL, if the current working
+  * directory is not a strict subdirectory of the work tree root. The
+  * prefix always ends with a '/' character.
+  */
  const char *setup_git_directory(void)
  {
        const char *retval = setup_git_directory_gently(NULL);