From: Nguyen Thai Ngoc Duy <pclouds@gmail.com>
To: Robin Rosenberg <robin.rosenberg.lists@dewire.com>
Cc: git@vger.kernel.org
Subject: Re: core.worktree bug
Date: Tue, 15 Dec 2009 23:30:42 +0700 [thread overview]
Message-ID: <20091215163042.GA14810@do> (raw)
In-Reply-To: <200912071115.48085.robin.rosenberg.lists@dewire.com>
On Mon, Dec 07, 2009 at 11:15:47AM +0100, Robin Rosenberg wrote:
> $ git config core.worktree $(cd ../r1;pwd)
> $ git status
> # On branch master
> # Changed but not updated:
> # (use "git add/rm <file>..." to update what will be committed)
> # (use "git checkout -- <file>..." to discard changes in working directory)
> #
> # deleted: f
> #
> no changes added to commit (use "git add" and/or "git commit -a")
>
> => Seems the config is actually honored even though GIT_DIR is not set.
>
> Bisect tells me 4f38f6b5bafb1f7f85c7b54d0bb0a0e977cd947c broke it. My main point is that I am
You should have CCed me.
> implementing this in JGit so I want the same behaviour. Question: Should we try to fix this
> in git so it matches the documentation or fix the documentation to match behaviour.
>
> The breakage appeared over a year ago and no one has complained.
This is, I think, due to the shared use of git_work_tree_cfg. When
setup_git_directory_gently() comes close to the end, work_tree has
been detected and set. Then check_repository_format_gently() is
called to make sure the repository is valid. Among the checks are
core.worktree check, which overrides the previously-set git_work_tree_cfg.
This might be the fix, or a start of new breakages. I'll need to look
at this again and make a proper patch message with tests if it's
really correct.
diff --git a/setup.c b/setup.c
index f67250b..1385edb 100644
--- a/setup.c
+++ b/setup.c
@@ -280,6 +280,18 @@ const char *read_gitfile_gently(const char *path)
return path;
}
+static int check_repository_work_tree(const char *var, const char *value, void *cb)
+{
+ if (strcmp(var, "core.worktree") == 0) {
+ if (!value)
+ return config_error_nonbool(var);
+ free(git_work_tree_cfg);
+ git_work_tree_cfg = xstrdup(value);
+ inside_work_tree = -1;
+ }
+ return 0;
+}
+
/*
* 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.
@@ -317,6 +329,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
if (!work_tree_env) {
retval = set_work_tree(gitdirenv);
/* config may override worktree */
+ git_config(check_repository_work_tree, NULL);
if (check_repository_format_gently(nongit_ok))
return NULL;
return retval;
@@ -394,6 +407,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
die_errno("Cannot change to '%s/..'", cwd);
}
+ git_config(check_repository_work_tree, NULL);
inside_git_dir = 0;
if (!work_tree_env)
inside_work_tree = 1;
@@ -471,12 +485,6 @@ int check_repository_format_version(const char *var, const char *value, void *cb
is_bare_repository_cfg = git_config_bool(var, value);
if (is_bare_repository_cfg == 1)
inside_work_tree = -1;
- } else if (strcmp(var, "core.worktree") == 0) {
- if (!value)
- return config_error_nonbool(var);
- free(git_work_tree_cfg);
- git_work_tree_cfg = xstrdup(value);
- inside_work_tree = -1;
}
return 0;
}
--
Duy
next prev parent reply other threads:[~2009-12-15 16:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-07 10:15 core.worktree bug Robin Rosenberg
2009-12-15 16:30 ` Nguyen Thai Ngoc Duy [this message]
2009-12-27 13:28 ` [PATCH] Fix core.worktree being used when GIT_DIR is not set Nguyễn Thái Ngọc Duy
2009-12-27 20:58 ` Junio C Hamano
2009-12-28 0:08 ` Robin Rosenberg
2009-12-28 5:41 ` Nguyen Thai Ngoc Duy
2009-12-28 5:55 ` [PATCH] Documentation: always respect core.worktree if set Nguyễn Thái Ngọc Duy
2009-12-28 9:16 ` Junio C Hamano
2009-12-29 7:48 ` Nguyễn Thái Ngọc Duy
2009-12-29 16:58 ` Junio C Hamano
2009-12-29 17:05 ` Robin Rosenberg
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=20091215163042.GA14810@do \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=robin.rosenberg.lists@dewire.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.