From: Jonathan Nieder <jrnieder@gmail.com>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] builtins: reset startup_info->have_run_setup_gitdir when unsetting up repository
Date: Sat, 27 Mar 2010 19:34:16 -0500 [thread overview]
Message-ID: <20100328003416.GA8011@progeny.tock> (raw)
In-Reply-To: <1269681184-1992-2-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy wrote:
> - alias handling will always be done before help_unknown_cmd()
> - alias handling code will search and set up repository if found
> - alias handline code will not undo repository setup
>
> These ensure that repository will always be set up (or attempted to
> set up) before help_unknown_cmd(), so there is no issue. But the setup
> dependency here is subtle. It may break some day if someone reorders
> the loop, for example.
>
> Make a note about this.
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Makes sense, thanks.
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Nguyễn Thái Ngọc Duy wrote:
> startup_info->have_run_setup_gitdir is used to guard unallowed access
> to repository. When a repository has been set up and the real command
> does not expect any setup, we should revert to the original "fresh"
> state, including startup_info->have_run_setup_gitdir. Otherwise, the
> next attempt to set up repository will fail.
[...]
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
The test this adds fails for current master, too.
The cause: core.worktree gets set to point to the trash directory.
This results from a facet of the test I was not paying attention to ---
the trash directory is a git repository itself, which poisons git with
some extra information it hadn’t learned to forget yet.
The third and fourth tests below fail in master for this reason.
The first test passes everywhere; it is just checking basic behavior.
The second test passes in master and fails in nd/setup without the
git.c hunk of your patch. It is a more targeted test, meant to check
only for the problem your patch solves.
Of course, with your patch applied, all four tests pass. Thanks.
Reviewed-and-tested-by: Jonathan Nieder <jrnieder@gmail.com>
diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index 6757734..6d6766e 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -33,6 +33,59 @@ test_expect_success 'plain' '
check_config plain/.git false unset
'
+test_expect_success 'plain nested in bare' '
+ (
+ unset GIT_DIR GIT_WORK_TREE &&
+ git init --bare bare-ancestor.git &&
+ cd bare-ancestor.git &&
+ mkdir plain-nested &&
+ cd plain-nested &&
+ git init
+ ) &&
+ check_config bare-ancestor.git/plain-nested/.git false unset
+'
+
+test_expect_success 'plain through aliased command' '
+ mkdir alias-config &&
+ echo "[alias] aliasedinit = init" >alias-config/.gitconfig &&
+ (
+ unset GIT_DIR GIT_WORK_TREE GIT_CONFIG_NOGLOBAL &&
+ GIT_CEILING_DIRECTORIES=$(pwd) &&
+ HOME=$(pwd)/alias-config &&
+ export GIT_CEILING_DIRECTORIES HOME &&
+ mkdir plain-aliased &&
+ cd plain-aliased &&
+ git aliasedinit
+ ) &&
+ check_config plain-aliased/.git false unset
+'
+
+test_expect_success 'plain nested through aliased command' '
+ (
+ unset GIT_DIR GIT_WORK_TREE &&
+ git init plain-ancestor-aliased &&
+ cd plain-ancestor-aliased &&
+ echo "[alias] aliasedinit = init" >>.git/config &&
+ mkdir plain-nested &&
+ cd plain-nested &&
+ git aliasedinit
+ ) &&
+ check_config plain-ancestor-aliased/plain-nested/.git false unset
+'
+
+test_expect_success 'plain nested in bare through aliased command' '
+ (
+ unset GIT_DIR GIT_WORK_TREE &&
+ git init --bare bare-ancestor-aliased.git &&
+ cd bare-ancestor-aliased.git &&
+ echo "[alias] aliasedinit = init" >>config &&
+ mkdir plain-nested &&
+ cd plain-nested &&
+ git aliasedinit
+ ) &&
+ check_config bare-ancestor-aliased.git/plain-nested/.git false unset
+'
+
test_expect_success 'plain with GIT_WORK_TREE' '
if (
unset GIT_DIR
prev parent reply other threads:[~2010-03-28 0:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-27 9:13 [PATCH] builtins: setup repository before print unknown command error Nguyễn Thái Ngọc Duy
2010-03-27 9:13 ` [PATCH] builtins: reset startup_info->have_run_setup_gitdir when unsetting up repository Nguyễn Thái Ngọc Duy
2010-03-27 22:38 ` Jonathan Nieder
2010-03-28 7:11 ` Nguyen Thai Ngoc Duy
2010-03-28 0:34 ` Jonathan Nieder [this message]
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=20100328003416.GA8011@progeny.tock \
--to=jrnieder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=pclouds@gmail.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).