{"thread":{"id":"25667","subject":"[PATCH] t1020-subdirectory: test alias expansion in a subdirectory","startedAt":"2010-11-08T08:32:03Z","lastAt":"2010-11-09T01:29:07Z","messageCount":5,"participants":["Michael J Gruber","Nguyen Thai Ngoc Duy","Nguyễn Thái Ngọc Duy","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"155359","messageId":"627dc7921dc64a16063e77d542cf9edb22631ddd.1289205059.git.git@drmicha.warpmail.net","threadId":"25667","inReplyTo":null,"subject":"[PATCH] t1020-subdirectory: test alias expansion in a subdirectory","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-11-08T08:32:03Z","receivedAt":"2010-11-08T08:32:03Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Add a test for alias expansion in a subdirectory of the worktree.\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n\n---\n    65f3a9e (Remove all logic from get_git_work_tree(), 2010-11-01) breaks this test,\n    which is why I am adding it.\n    \n    In fact, we don't really have tests for alias expansion at all, but that's a different issue.\n\n t/t1020-subdirectory.sh |    8 ++++++++\n 1 files changed, 8 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh\nindex a3ac338..1fd187c 100755\n--- a/t/t1020-subdirectory.sh\n+++ b/t/t1020-subdirectory.sh\n@@ -110,6 +110,14 @@ test_expect_success 'read-tree' '\n \t)\n '\n \n+test_expect_success 'alias expansion' '\n+\t(\n+\t\tgit config alias.ss status &&\n+\t\tcd dir &&\n+\t\tgit status &&\n+\t\tgit ss\n+\t)\n+'\n test_expect_success 'no file/rev ambiguity check inside .git' '\n \tgit commit -a -m 1 &&\n \t(\n-- \n1.7.3.2.193.g78bbb\n"},{"id":"155362","messageId":"20101108102056.GA12366@do","threadId":"25667","inReplyTo":"627dc7921dc64a16063e77d542cf9edb22631ddd.1289205059.git.git@drmicha.warpmail.net","subject":"Re: [PATCH] t1020-subdirectory: test alias expansion in a subdirectory","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-11-08T10:20:56Z","receivedAt":"2010-11-08T10:20:56Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Mon, Nov 08, 2010 at 09:32:03AM +0100, Michael J Gruber wrote:\n> Add a test for alias expansion in a subdirectory of the worktree.\n> \n> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n> \n> ---\n>     65f3a9e (Remove all logic from get_git_work_tree(), 2010-11-01) breaks this test,\n>     which is why I am adding it.\n\nHow about squashing this in?\n\n--8<--\nSubject: Allow set_git_work_tree() to be called more than once\n\nUsually one of the setup functions is called once. However alias\nhandling code needs to look ahead in $GIT_DIR/config for aliases. So\nset_git_work_tree() may be called twice: once when alias is searched,\nonce when the actual command is run.\n\nLoosen the condition and let it through. We can stricten it back when\nalias handling is fixed.\n---\ndiff --git a/environment.c b/environment.c\nindex 6db00da..f0d0b07 100644\n--- a/environment.c\n+++ b/environment.c\n@@ -128,8 +128,6 @@ const char *get_git_dir(void)\n \treturn git_dir;\n }\n \n-static int git_work_tree_initialized;\n-\n /*\n  * Note.  This works only before you used a work tree.  This was added\n  * primarily to support git-clone to work in a new repository it just\n@@ -137,9 +135,7 @@ static int git_work_tree_initialized;\n  */\n void set_git_work_tree(const char *new_work_tree)\n {\n-\tif (git_work_tree_initialized)\n-\t\tdie(\"internal error: work tree has already been set\");\n-\tgit_work_tree_initialized = 1;\n+\tfree(work_tree);\n \twork_tree = xstrdup(make_absolute_path(new_work_tree));\n }\n \n--8<--\n-- \nDuy\n"},{"id":"155363","messageId":"1289211818-12594-1-git-send-email-pclouds@gmail.com","threadId":"25667","inReplyTo":"627dc7921dc64a16063e77d542cf9edb22631ddd.1289205059.git.git@drmicha.warpmail.net","subject":"[PATCH] t0001: test git init when run via an alias","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-11-08T10:23:38Z","receivedAt":"2010-11-08T10:23:38Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"From: Jonathan Nieder <jrnieder@gmail.com>\n\nAdd some tests to document the correct behavior of (possibly aliased)\ninit when run within and outside a git directory.\n\nIf I set up a simple git alias “quietinit = init --quiet”, usually it\nwill work just like ‘git init --quiet’.\n\nThere are some differences, unfortunately, since in the process of\nchecking for aliases, git has to look for a .git/config file.  If ‘git\nquietinit’ is run from a subdirectory of an existing git repository,\nthat repository’s configuration will affect the configuration of the\nnew repository.  In particular, the new repository can inherit\nbogus values for core.bare and core.worktree.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n >     In fact, we don't really have tests for alias expansion at all, but that's a different issue.\n\n It reminds me of this old patch. Let's push them together.\n\n t/t0001-init.sh |   56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 56 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t0001-init.sh b/t/t0001-init.sh\nindex 7fe8883..28c1858 100755\n--- a/t/t0001-init.sh\n+++ b/t/t0001-init.sh\n@@ -33,6 +33,62 @@ test_expect_success 'plain' '\n \tcheck_config plain/.git false unset\n '\n \n+test_expect_success 'plain nested in bare' '\n+\t(\n+\t\tunset GIT_DIR GIT_WORK_TREE &&\n+\t\tgit init --bare bare-ancestor.git &&\n+\t\tcd bare-ancestor.git &&\n+\t\tmkdir plain-nested &&\n+\t\tcd plain-nested &&\n+\t\tgit init\n+\t) &&\n+\tcheck_config bare-ancestor.git/plain-nested/.git false unset\n+'\n+\n+test_expect_success 'plain through aliased command, outside any git repo' '\n+\t(\n+\t\tunset GIT_DIR GIT_WORK_TREE GIT_CONFIG_NOGLOBAL &&\n+\t\tHOME=$(pwd)/alias-config &&\n+\t\texport HOME &&\n+\t\tmkdir alias-config &&\n+\t\techo \"[alias] aliasedinit = init\" >alias-config/.gitconfig &&\n+\n+\t\tGIT_CEILING_DIRECTORIES=$(pwd) &&\n+\t\texport GIT_CEILING_DIRECTORIES &&\n+\n+\t\tmkdir plain-aliased &&\n+\t\tcd plain-aliased &&\n+\t\tgit aliasedinit\n+\t) &&\n+\tcheck_config plain-aliased/.git false unset\n+'\n+\n+test_expect_success 'plain nested through aliased command' '\n+\t(\n+\t\tunset GIT_DIR GIT_WORK_TREE &&\n+\t\tgit init plain-ancestor-aliased &&\n+\t\tcd plain-ancestor-aliased &&\n+\t\techo \"[alias] aliasedinit = init\" >>.git/config &&\n+\t\tmkdir plain-nested &&\n+\t\tcd plain-nested &&\n+\t\tgit aliasedinit\n+\t) &&\n+\tcheck_config plain-ancestor-aliased/plain-nested/.git false unset\n+'\n+\n+test_expect_failure 'plain nested in bare through aliased command' '\n+\t(\n+\t\tunset GIT_DIR GIT_WORK_TREE &&\n+\t\tgit init --bare bare-ancestor-aliased.git &&\n+\t\tcd bare-ancestor-aliased.git &&\n+\t\techo \"[alias] aliasedinit = init\" >>config &&\n+\t\tmkdir plain-nested &&\n+\t\tcd plain-nested &&\n+\t\tgit aliasedinit\n+\t) &&\n+\tcheck_config bare-ancestor-aliased.git/plain-nested/.git false unset\n+'\n+\n test_expect_success 'plain with GIT_WORK_TREE' '\n \tif (\n \t\tunset GIT_DIR\n-- \n1.7.3.2.210.g045198\n"},{"id":"155428","messageId":"7v7hgnpnp8.fsf@alter.siamese.dyndns.org","threadId":"25667","inReplyTo":"20101108102056.GA12366@do","subject":"Re: [PATCH] t1020-subdirectory: test alias expansion in a subdirectory","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-11-08T20:25:39Z","receivedAt":"2010-11-08T20:25:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:\n\n> On Mon, Nov 08, 2010 at 09:32:03AM +0100, Michael J Gruber wrote:\n>> Add a test for alias expansion in a subdirectory of the worktree.\n>> \n>> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n>> \n>> ---\n>>     65f3a9e (Remove all logic from get_git_work_tree(), 2010-11-01) breaks this test,\n>>     which is why I am adding it.\n>\n> How about squashing this in?\n>\n> --8<--\n> Subject: Allow set_git_work_tree() to be called more than once\n>\n> Usually one of the setup functions is called once. However alias\n> handling code needs to look ahead in $GIT_DIR/config for aliases. So\n> set_git_work_tree() may be called twice: once when alias is searched,\n> once when the actual command is run.\n>\n> Loosen the condition and let it through. We can stricten it back when\n> alias handling is fixed.\n\nSounds like sweeping something under rug.  \n\nWithout this hack, alias does not work, but if your plan is to rework this\npart right when alias is fixed, then what's the point of loosening it?\nEither way your alias is broken, no?\n\nShouldn't it at least make sure that the function is giving a consistent\npicture to the outside world between the time it was called for the first\ntime and the second time?  E.g.  the second time around new-work-tree must\nbe the same as whatever was given the first time, or something.\n\n> ---\n> diff --git a/environment.c b/environment.c\n> index 6db00da..f0d0b07 100644\n> --- a/environment.c\n> +++ b/environment.c\n> @@ -128,8 +128,6 @@ const char *get_git_dir(void)\n>  \treturn git_dir;\n>  }\n>  \n> -static int git_work_tree_initialized;\n> -\n>  /*\n>   * Note.  This works only before you used a work tree.  This was added\n>   * primarily to support git-clone to work in a new repository it just\n> @@ -137,9 +135,7 @@ static int git_work_tree_initialized;\n>   */\n>  void set_git_work_tree(const char *new_work_tree)\n>  {\n> -\tif (git_work_tree_initialized)\n> -\t\tdie(\"internal error: work tree has already been set\");\n> -\tgit_work_tree_initialized = 1;\n> +\tfree(work_tree);\n>  \twork_tree = xstrdup(make_absolute_path(new_work_tree));\n>  }\n>  \n> --8<--\n> -- \n> Duy\n"},{"id":"155451","messageId":"AANLkTikwTwNDLhQU7mtKxTYHBUVQzw9tuVzSZy3utSLM@mail.gmail.com","threadId":"25667","inReplyTo":"7v7hgnpnp8.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] t1020-subdirectory: test alias expansion in a subdirectory","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-11-09T01:29:07Z","receivedAt":"2010-11-09T01:29:07Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Tue, Nov 9, 2010 at 3:25 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:\n>\n>> On Mon, Nov 08, 2010 at 09:32:03AM +0100, Michael J Gruber wrote:\n>>> Add a test for alias expansion in a subdirectory of the worktree.\n>>>\n>>> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n>>>\n>>> ---\n>>>     65f3a9e (Remove all logic from get_git_work_tree(), 2010-11-01) breaks this test,\n>>>     which is why I am adding it.\n>>\n>> How about squashing this in?\n>>\n>> --8<--\n>> Subject: Allow set_git_work_tree() to be called more than once\n>>\n>> Usually one of the setup functions is called once. However alias\n>> handling code needs to look ahead in $GIT_DIR/config for aliases. So\n>> set_git_work_tree() may be called twice: once when alias is searched,\n>> once when the actual command is run.\n>>\n>> Loosen the condition and let it through. We can stricten it back when\n>> alias handling is fixed.\n>\n> Sounds like sweeping something under rug.\n>\n> Without this hack, alias does not work, but if your plan is to rework this\n> part right when alias is fixed, then what's the point of loosening it?\n> Either way your alias is broken, no?\n>\n> Shouldn't it at least make sure that the function is giving a consistent\n> picture to the outside world between the time it was called for the first\n> time and the second time?  E.g.  the second time around new-work-tree must\n> be the same as whatever was given the first time, or something.\n\nRight. Will do that.\n-- \nDuy\n"}]}