On Feb 18, 2008 2:31 PM, Johannes Schindelin <Johannes.Schindelin@xxxxxx> wrote: > Hi, > > On Mon, 18 Feb 2008, Lars Hjemli wrote: > > > On Feb 18, 2008 1:17 PM, Johannes Schindelin wrote: > > > In the case of patch "1/5 => 2/5", I would even have appreciated an > > > interdiff... > > > > Sorry, but I don't think I understand what you mean by interdiff. > > The tool interdiff of patchutils is really nice: you can visualise what > would be the diff between the state after applying the first patch, and > the state after applying the second patch, without applying anything at > all: > > $ interdiff <patch1> <patch2> Ok, that sounds useful (I was kind of confused since 'man interdiff' gave me nothing: being on slackware I'm so spoiled with preinstalled dev-tools that I see no point in consulting google ;). Something like this (possibly mangled by gmail)? $ interdiff prev-patch-2 curr-patch-1 diff -u b/git-sh-setup.sh b/git-sh-setup.sh --- b/git-sh-setup.sh +++ b/git-sh-setup.sh @@ -127,11 +127,7 @@ # if we require to be in a git repository. if test -z "$NONGIT_OK" then - GIT_DIR=$(git rev-parse --git-dir) || { - exit=$? - echo >&2 "Failed to find a valid git directory." - exit $exit - } + GIT_DIR=$(git rev-parse --git-dir) || exit if [ -z "$SUBDIRECTORY_OK" ] then test -z "$(git rev-parse --show-cdup)" || { $ interdiff prev-patch-1 curr-patch-2 diff -u b/Documentation/repository-layout.txt b/Documentation/repository-layout.txt --- b/Documentation/repository-layout.txt +++ b/Documentation/repository-layout.txt @@ -5,7 +5,7 @@ directory for a repository associated with your working tree, or `'project'.git` directory for a public 'bare' repository. It is also possible to have a working tree where `.git` is a plain -ascii file containing `gitdir: <path>\n`, i.e. the path to the +ascii file containing `gitdir: <path>`, i.e. the path to the real git repository). objects:: diff -u b/environment.c b/environment.c --- b/environment.c +++ b/environment.c @@ -45,42 +45,6 @@ static const char *git_dir; static char *git_object_dir, *git_index_file, *git_refs_dir, *git_graft_file; -/* - * Try to read the location of the git directory from the .git file, - * return path to git directory if found. - * Format of the .git file is - * gitdir: <path>\n - */ -const char *read_gitfile_gently(const char *path) -{ - static char buf[PATH_MAX + 9]; /* "gitdir: " + "\n" */ - struct stat st; - int fd; - size_t len; - - if (stat(path, &st)) - return NULL; - if (!S_ISREG(st.st_mode) || st.st_size >= sizeof(buf)) - return NULL; - fd = open(path, O_RDONLY); - if (fd < 0) - return NULL; - len = read_in_full(fd, buf, sizeof(buf)); - close(fd); - if (len != st.st_size) - return NULL; - if (!len || buf[len - 1] != '\n') - return NULL; - buf[len - 1] = '\0'; - if (prefixcmp(buf, "gitdir: ")) - return NULL; -/* - if (!is_git_directory(buf + 8)) - return NULL; -*/ - return make_absolute_path(buf + 8); -} - static void setup_git_env(void) { git_dir = getenv(GIT_DIR_ENVIRONMENT); diff -u b/setup.c b/setup.c --- b/setup.c +++ b/setup.c @@ -239,6 +239,44 @@ } /* + * Try to read the location of the git directory from the .git file, + * return path to git directory if found. + */ +const char *read_gitfile_gently(const char *path) +{ + char *buf; + struct stat st; + int fd; + size_t len; + + if (stat(path, &st)) + return NULL; + if (!S_ISREG(st.st_mode)) + return NULL; + fd = open(path, O_RDONLY); + if (fd < 0) + die("Error opening %s: %s", path, strerror(errno)); + buf = xmalloc(st.st_size + 1); + len = read_in_full(fd, buf, st.st_size); + close(fd); + if (len != st.st_size) + die("Error reading %s", path); + buf[len] = '\0'; + if (prefixcmp(buf, "gitdir: ")) + die("Invalid gitfile format: %s", path); + while (buf[len - 1] == '\n' || buf[len - 1] == '\r') + len--; + if (len < 9) + die("No path in gitfile: %s", path); + buf[len] = '\0'; + if (!is_git_directory(buf + 8)) + die("Not a git repository: %s", buf + 8); + path = make_absolute_path(buf + 8); + free(buf); + return path; +} + +/* * 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. */ @@ -294,10 +332,10 @@ /* * Test in the following order (relative to the cwd): - * - .git (file containing "gitdir: <path>\n") + * - .git (file containing "gitdir: <path>") * - .git/ * - ./ (bare) - * - ../.git (file containing "gitdir: <path>\n") + * - ../.git * - ../.git/ * - ../ (bare) * - ../../.git/ @@ -306,9 +344,9 @@ offset = len = strlen(cwd); for (;;) { gitfile_dir = read_gitfile_gently(DEFAULT_GIT_DIR_ENVIRONMENT); - if (gitfile_dir && is_git_directory(gitfile_dir)) { + if (gitfile_dir) { if (set_git_dir(gitfile_dir)) - return NULL; + die("Repository setup failed"); break; } if (is_git_directory(DEFAULT_GIT_DIR_ENVIRONMENT)) -- larsh - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html