From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>,
"Mark Levedahl" <mlevedahl@gmail.com>,
"Git Mailing List" <git@vger.kernel.org>
Subject: Re: [PATCH] Fix install-doc-quick target
Date: Sun, 5 Aug 2007 14:12:53 +0100 (BST) [thread overview]
Message-ID: <Pine.LNX.4.64.0708051344430.14781@racer.site> (raw)
In-Reply-To: <7vmyx6fohv.fsf_-_@assigned-by-dhcp.cox.net>
Hi,
On Sun, 5 Aug 2007, Junio C Hamano wrote:
> * I am getting the impression that the semantics of the updated
> work-tree support is as broken as the original, although the
> code that implements it is easier to read.
>
> Admittedly, this is an unorthodox corner case usage, that
> deals with a tree structure that does not have any relation
> with the current project state, and the script is started
> with a subdirectory of the current project.
I do not like the behaviour "be stupid and assume cwd to be the working
tree root, if GIT_DIR is set and GIT_WORK_TREE is not".
It bears _all_ kind of stupid connotations. Just imagine what would
happen with "git --git-dir=. add .".
IMHO the new behaviour is _better_, since you can not shoot yourself in
the foot so easily. Being able to safeguard against doing a work tree
operation inside the git directory is a direct and elegant consequence of
defaulting to $GIT_DIR/.. in case $GIT_DIR ends in "/.git", and no work
tree if $GIT_DIR does _not_ end in "/.git".
The semantics "if GIT_DIR is set, just assume the cwd to be the work tree
root unilaterally" is _broken_ as far as I am concerned.
NOTE: this change in semantics will _only_ _ever_ burn you if you set
GIT_DIR, but not GIT_WORK_TREE, in a _subdirectory_ of $GIT_DIR/.. (if it
ends in /.git, and $GIT_DIR otherwise).
So the _common_ use of setting GIT_DIR, namely something like
$ git --git-dir=/some/where/completely/different bla
is _not_ affected.
So I really think that the code in install-doc-quick.sh is not only ugly,
but also wrong. It sets the GIT_DIR to _the same_ value as the default,
to change git's idea of the _work tree_! All at the same time as it is
utterly clear that it wants to write to $HOME/share/man, but it does not
make this its working tree. No, sir. It has to play cute games with the
prefix.
However, you are the maintainer, and it is your decision. If you want the
old semantics (without sanity checks for work-tree operations inside the
git directory), here is a patch. I don't like it, but if you take it,
I'll learn to live with it.
Ciao,
Dscho
-- snipsnap --
Reinstate the old behaviour when GIT_DIR is set and GIT_WORK_TREE is unset
The old behaviour was to unilaterally default to the cwd is the work tree
when GIT_DIR was set, but GIT_WORK_TREE wasn't, no matter if we are inside
the GIT_DIR, or if GIT_DIR is actually something like ../../../.git.
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
Feel free to change the commit message.
setup.c | 50 +++++++++-----------------------------------------
1 files changed, 9 insertions(+), 41 deletions(-)
diff --git a/setup.c b/setup.c
index 4945eb3..7bcf4eb 100644
--- a/setup.c
+++ b/setup.c
@@ -189,53 +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)
{
- char dir_buffer[PATH_MAX], *rel = NULL;
- static char buffer[PATH_MAX + 1];
- int len, suffix_len = strlen(DEFAULT_GIT_DIR_ENVIRONMENT) + 1;
-
- /* strip the variable 'dir' of the postfix "/.git" if it has it */
- len = strlen(dir);
- if (len > suffix_len &&
- !strcmp(dir + len - suffix_len, "/" DEFAULT_GIT_DIR_ENVIRONMENT)) {
- if ((len - suffix_len) >= sizeof(dir_buffer))
- die("directory name too long");
- memcpy(dir_buffer, dir, len - suffix_len);
- dir_buffer[len - suffix_len] = '\0';
-
- /* are we inside the default work tree? */
- rel = get_relative_cwd(buffer, sizeof(buffer), dir_buffer);
- }
+ char buffer[PATH_MAX + 1];
- /* 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;
- if (chdir(dir))
- die("cannot chdir to %s: %s", dir, strerror(errno));
- else
- strcat(rel, "/");
- inside_git_dir = 0;
- } else {
- rel = NULL;
- dir = getcwd(buffer, sizeof(buffer));
- }
- git_work_tree_cfg = xstrdup(dir);
+ 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;
}
/*
next prev parent reply other threads:[~2007-08-05 13:13 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-04 15:07 rc4 - make quick-install-doc is broken Mark Levedahl
2007-08-04 15:38 ` Johannes Schindelin
2007-08-04 16:00 ` Mark Levedahl
2007-08-04 16:04 ` Johannes Schindelin
2007-08-04 16:14 ` Mark Levedahl
2007-08-04 16:21 ` Johannes Schindelin
2007-08-04 17:56 ` Mark Levedahl
2007-08-04 21:32 ` [PATCH] Fix quick-install-doc Johannes Schindelin
2007-08-04 22:09 ` René Scharfe
2007-08-05 7:07 ` [PATCH] Fix install-doc-quick target Junio C Hamano
2007-08-05 13:12 ` Johannes Schindelin [this message]
2007-08-05 17:54 ` Junio C Hamano
2007-08-05 18:10 ` Johannes Schindelin
2007-08-05 14:44 ` Johannes Schindelin
2007-08-06 22:43 ` [PATCH] (Really) " Mark Levedahl
2007-08-06 22:50 ` Johannes Schindelin
2007-08-06 23:07 ` Junio C Hamano
2007-08-06 23:38 ` Mark Levedahl
2007-08-06 23:43 ` Johannes Schindelin
2007-08-06 23:49 ` Mark Levedahl
2007-08-07 1:28 ` Junio C Hamano
2007-08-07 1:55 ` Mark Levedahl
2007-08-07 3:53 ` Junio C Hamano
2007-08-07 13:55 ` René Scharfe
2007-08-07 14:08 ` Johannes Schindelin
2007-08-04 16:08 ` rc4 - make quick-install-doc is broken Mark Levedahl
2007-08-04 16:16 ` Johannes Schindelin
2007-08-04 16:27 ` Mark Levedahl
2007-08-04 20:19 ` René Scharfe
2007-08-04 20:21 ` Johannes Schindelin
2007-08-04 20:45 ` Mark Levedahl
2007-08-04 21:33 ` Johannes Schindelin
2007-08-04 22:09 ` René Scharfe
2007-08-04 22:25 ` Johannes Schindelin
2007-08-04 22:37 ` Johannes Schindelin
2007-08-04 23:03 ` René Scharfe
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=Pine.LNX.4.64.0708051344430.14781@racer.site \
--to=johannes.schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=mlevedahl@gmail.com \
--cc=rene.scharfe@lsrfire.ath.cx \
/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).