From: "Lars Hjemli" <hjemli@gmail.com>
To: "Johannes Schindelin" <Johannes.Schindelin@gmx.de>
Cc: git@vger.kernel.org, "Junio C Hamano" <gitster@pobox.com>
Subject: Re: [PATCH 0/5 v2] Introduce the .gitfile
Date: Mon, 18 Feb 2008 15:01:07 +0100 [thread overview]
Message-ID: <8c5c35580802180601h5cf01c5h583458fee61caa7a@mail.gmail.com> (raw)
In-Reply-To: <alpine.LSU.1.00.0802181330030.30505@racer.site>
On Feb 18, 2008 2:31 PM, Johannes Schindelin <Johannes.Schindelin@gmx.de> 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
next prev parent reply other threads:[~2008-02-18 14:01 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-18 10:44 [PATCH 0/5 v2] Introduce the .gitfile Lars Hjemli
2008-02-18 10:44 ` [PATCH 1/5] Simplify setup of $GIT_DIR in git-sh-setup.sh Lars Hjemli
2008-02-18 10:44 ` [PATCH 2/5] Add platform-independent .git "symlink" Lars Hjemli
2008-02-18 10:44 ` [PATCH 3/5] Teach resolve_gitlink_ref() about the .git file Lars Hjemli
2008-02-18 10:44 ` [PATCH 4/5] git-submodule: prepare for the .git-file Lars Hjemli
2008-02-18 10:44 ` [PATCH 5/5] Teach GIT-VERSION-GEN about the .git file Lars Hjemli
2008-02-18 12:34 ` [PATCH 2/5] Add platform-independent .git "symlink" Johannes Schindelin
2008-02-18 13:18 ` Lars Hjemli
2008-02-18 13:34 ` Jakub Narebski
2008-02-18 13:35 ` Johannes Schindelin
2008-02-18 14:04 ` Lars Hjemli
2008-02-18 14:44 ` Lars Hjemli
2008-02-18 14:54 ` Johannes Schindelin
2008-02-18 12:17 ` [PATCH 0/5 v2] Introduce the .gitfile Johannes Schindelin
2008-02-18 12:56 ` Lars Hjemli
2008-02-18 13:31 ` Johannes Schindelin
2008-02-18 14:01 ` Lars Hjemli [this message]
2008-02-18 14:12 ` Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8c5c35580802180601h5cf01c5h583458fee61caa7a@mail.gmail.com \
--to=hjemli@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).