{"thread":{"id":"28658","subject":"[PATCH 1/3] t5403.1: simplify commit creation","startedAt":"2011-10-12T09:35:03Z","lastAt":"2011-10-13T04:54:29Z","messageCount":7,"participants":["Nguyễn Thái Ngọc Duy","Johannes Sixt","Nguyen Thai Ngoc Duy","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"177434","messageId":"1318412105-13595-1-git-send-email-pclouds@gmail.com","threadId":"28658","inReplyTo":null,"subject":"[PATCH 1/3] t5403.1: simplify commit creation","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2011-10-12T09:35:03Z","receivedAt":"2011-10-12T09:35:03Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n t/t5403-post-checkout-hook.sh |    7 ++-----\n 1 files changed, 2 insertions(+), 5 deletions(-)\n\ndiff --git a/t/t5403-post-checkout-hook.sh b/t/t5403-post-checkout-hook.sh\nindex d05a913..0c126d7 100755\n--- a/t/t5403-post-checkout-hook.sh\n+++ b/t/t5403-post-checkout-hook.sh\n@@ -9,11 +9,8 @@ test_description='Test the post-checkout hook.'\n test_expect_success setup '\n \techo Data for commit0. >a &&\n \techo Data for commit0. >b &&\n-\tgit update-index --add a &&\n-\tgit update-index --add b &&\n-\ttree0=$(git write-tree) &&\n-\tcommit0=$(echo setup | git commit-tree $tree0) &&\n-\tgit update-ref refs/heads/master $commit0 &&\n+\tgit add a b &&\n+\tgit commit -m setup &&\n \tgit clone ./. clone1 &&\n \tgit clone ./. clone2 &&\n \tGIT_DIR=clone2/.git git branch new2 &&\n-- \n1.7.3.1.256.g2539c.dirty\n"},{"id":"177435","messageId":"1318412105-13595-2-git-send-email-pclouds@gmail.com","threadId":"28658","inReplyTo":"1318412105-13595-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 2/3] t5403: convert leading spaces to tabs","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2011-10-12T09:35:04Z","receivedAt":"2011-10-12T09:35:04Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The first and last tests use tabs. The rest uses spaces. Convert all\nto tabs.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n t/t5403-post-checkout-hook.sh |   46 ++++++++++++++++++++--------------------\n 1 files changed, 23 insertions(+), 23 deletions(-)\n\ndiff --git a/t/t5403-post-checkout-hook.sh b/t/t5403-post-checkout-hook.sh\nindex 0c126d7..6643f32 100755\n--- a/t/t5403-post-checkout-hook.sh\n+++ b/t/t5403-post-checkout-hook.sh\n@@ -28,44 +28,44 @@ EOF\n done\n \n test_expect_success 'post-checkout runs as expected ' '\n-        GIT_DIR=clone1/.git git checkout master &&\n-        test -e clone1/.git/post-checkout.args\n+\tGIT_DIR=clone1/.git git checkout master &&\n+\ttest -e clone1/.git/post-checkout.args\n '\n \n test_expect_success 'post-checkout receives the right arguments with HEAD unchanged ' '\n-        old=$(awk \"{print \\$1}\" clone1/.git/post-checkout.args) &&\n-        new=$(awk \"{print \\$2}\" clone1/.git/post-checkout.args) &&\n-        flag=$(awk \"{print \\$3}\" clone1/.git/post-checkout.args) &&\n-        test $old = $new -a $flag = 1\n+\told=$(awk \"{print \\$1}\" clone1/.git/post-checkout.args) &&\n+\tnew=$(awk \"{print \\$2}\" clone1/.git/post-checkout.args) &&\n+\tflag=$(awk \"{print \\$3}\" clone1/.git/post-checkout.args) &&\n+\ttest $old = $new -a $flag = 1\n '\n \n test_expect_success 'post-checkout runs as expected ' '\n-        GIT_DIR=clone1/.git git checkout master &&\n-        test -e clone1/.git/post-checkout.args\n+\tGIT_DIR=clone1/.git git checkout master &&\n+\ttest -e clone1/.git/post-checkout.args\n '\n \n test_expect_success 'post-checkout args are correct with git checkout -b ' '\n-        GIT_DIR=clone1/.git git checkout -b new1 &&\n-        old=$(awk \"{print \\$1}\" clone1/.git/post-checkout.args) &&\n-        new=$(awk \"{print \\$2}\" clone1/.git/post-checkout.args) &&\n-        flag=$(awk \"{print \\$3}\" clone1/.git/post-checkout.args) &&\n-        test $old = $new -a $flag = 1\n+\tGIT_DIR=clone1/.git git checkout -b new1 &&\n+\told=$(awk \"{print \\$1}\" clone1/.git/post-checkout.args) &&\n+\tnew=$(awk \"{print \\$2}\" clone1/.git/post-checkout.args) &&\n+\tflag=$(awk \"{print \\$3}\" clone1/.git/post-checkout.args) &&\n+\ttest $old = $new -a $flag = 1\n '\n \n test_expect_success 'post-checkout receives the right args with HEAD changed ' '\n-        GIT_DIR=clone2/.git git checkout new2 &&\n-        old=$(awk \"{print \\$1}\" clone2/.git/post-checkout.args) &&\n-        new=$(awk \"{print \\$2}\" clone2/.git/post-checkout.args) &&\n-        flag=$(awk \"{print \\$3}\" clone2/.git/post-checkout.args) &&\n-        test $old != $new -a $flag = 1\n+\tGIT_DIR=clone2/.git git checkout new2 &&\n+\told=$(awk \"{print \\$1}\" clone2/.git/post-checkout.args) &&\n+\tnew=$(awk \"{print \\$2}\" clone2/.git/post-checkout.args) &&\n+\tflag=$(awk \"{print \\$3}\" clone2/.git/post-checkout.args) &&\n+\ttest $old != $new -a $flag = 1\n '\n \n test_expect_success 'post-checkout receives the right args when not switching branches ' '\n-        GIT_DIR=clone2/.git git checkout master b &&\n-        old=$(awk \"{print \\$1}\" clone2/.git/post-checkout.args) &&\n-        new=$(awk \"{print \\$2}\" clone2/.git/post-checkout.args) &&\n-        flag=$(awk \"{print \\$3}\" clone2/.git/post-checkout.args) &&\n-        test $old = $new -a $flag = 0\n+\tGIT_DIR=clone2/.git git checkout master b &&\n+\told=$(awk \"{print \\$1}\" clone2/.git/post-checkout.args) &&\n+\tnew=$(awk \"{print \\$2}\" clone2/.git/post-checkout.args) &&\n+\tflag=$(awk \"{print \\$3}\" clone2/.git/post-checkout.args) &&\n+\ttest $old = $new -a $flag = 0\n '\n \n if test \"$(git config --bool core.filemode)\" = true; then\n-- \n1.7.3.1.256.g2539c.dirty\n"},{"id":"177436","messageId":"1318412105-13595-3-git-send-email-pclouds@gmail.com","threadId":"28658","inReplyTo":"1318412105-13595-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 3/3] t5403: do not use access repos with GIT_DIR when worktree is involved","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2011-10-12T09:35:05Z","receivedAt":"2011-10-12T09:35:05Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Setting GIT_DIR alone means worktree is current directory for legacy\nreasons. Avoid using that, instead go to the worktree and execute\ncommands there.\n\nThe troublesome command is \"GIT_DIR=clone2/.git git add clone2/b\". The\nreal worktree is clone2, but that command tells git worktree is $(pwd).\nWhat does user expect to add then? Should the new entry in index be \"b\"\nor \"clone2/b\"?\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n t/t5403-post-checkout-hook.sh |   17 ++++++++++-------\n 1 files changed, 10 insertions(+), 7 deletions(-)\n\ndiff --git a/t/t5403-post-checkout-hook.sh b/t/t5403-post-checkout-hook.sh\nindex 6643f32..3459539 100755\n--- a/t/t5403-post-checkout-hook.sh\n+++ b/t/t5403-post-checkout-hook.sh\n@@ -13,10 +13,13 @@ test_expect_success setup '\n \tgit commit -m setup &&\n \tgit clone ./. clone1 &&\n \tgit clone ./. clone2 &&\n-\tGIT_DIR=clone2/.git git branch new2 &&\n-\techo Data for commit1. >clone2/b &&\n-\tGIT_DIR=clone2/.git git add clone2/b &&\n-\tGIT_DIR=clone2/.git git commit -m new2\n+\t(\n+\t\tcd clone2 &&\n+\t\tgit branch new2 &&\n+\t\techo Data for commit1. >b &&\n+\t\tgit add b &&\n+\t\tgit commit -m new2\n+\t)\n '\n \n for clone in 1 2; do\n@@ -45,7 +48,7 @@ test_expect_success 'post-checkout runs as expected ' '\n '\n \n test_expect_success 'post-checkout args are correct with git checkout -b ' '\n-\tGIT_DIR=clone1/.git git checkout -b new1 &&\n+\t( cd clone1 && git checkout -b new1 ) &&\n \told=$(awk \"{print \\$1}\" clone1/.git/post-checkout.args) &&\n \tnew=$(awk \"{print \\$2}\" clone1/.git/post-checkout.args) &&\n \tflag=$(awk \"{print \\$3}\" clone1/.git/post-checkout.args) &&\n@@ -53,7 +56,7 @@ test_expect_success 'post-checkout args are correct with git checkout -b ' '\n '\n \n test_expect_success 'post-checkout receives the right args with HEAD changed ' '\n-\tGIT_DIR=clone2/.git git checkout new2 &&\n+\t( cd clone2 && git checkout new2 ) &&\n \told=$(awk \"{print \\$1}\" clone2/.git/post-checkout.args) &&\n \tnew=$(awk \"{print \\$2}\" clone2/.git/post-checkout.args) &&\n \tflag=$(awk \"{print \\$3}\" clone2/.git/post-checkout.args) &&\n@@ -61,7 +64,7 @@ test_expect_success 'post-checkout receives the right args with HEAD changed ' '\n '\n \n test_expect_success 'post-checkout receives the right args when not switching branches ' '\n-\tGIT_DIR=clone2/.git git checkout master b &&\n+\t( cd clone2 && git checkout master b ) &&\n \told=$(awk \"{print \\$1}\" clone2/.git/post-checkout.args) &&\n \tnew=$(awk \"{print \\$2}\" clone2/.git/post-checkout.args) &&\n \tflag=$(awk \"{print \\$3}\" clone2/.git/post-checkout.args) &&\n-- \n1.7.3.1.256.g2539c.dirty\n"},{"id":"177439","messageId":"4E95A0BF.2060003@viscovery.net","threadId":"28658","inReplyTo":"1318412105-13595-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH 1/3] t5403.1: simplify commit creation","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2011-10-12T14:14:23Z","receivedAt":"2011-10-12T14:14:23Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 10/12/2011 11:35, schrieb Nguyễn Thái Ngọc Duy:\n>  test_expect_success setup '\n>  \techo Data for commit0. >a &&\n>  \techo Data for commit0. >b &&\n> -\tgit update-index --add a &&\n> -\tgit update-index --add b &&\n> -\ttree0=$(git write-tree) &&\n> -\tcommit0=$(echo setup | git commit-tree $tree0) &&\n> -\tgit update-ref refs/heads/master $commit0 &&\n> +\tgit add a b &&\n> +\tgit commit -m setup &&\n>  \tgit clone ./. clone1 &&\n>  \tgit clone ./. clone2 &&\n>  \tGIT_DIR=clone2/.git git branch new2 &&\n\nI don't think this change is necessary. It doesn't hurt to use plumbing\ncommands here and there in the test suite to exercise them to a degree\nthat they deserve.\n\n-- Hannes\n"},{"id":"177506","messageId":"CACsJy8DuJzW-=86FOs8F4YqhG68dEzx4790vpM3D9yPfeV87qA@mail.gmail.com","threadId":"28658","inReplyTo":"4E95A0BF.2060003@viscovery.net","subject":"Re: [PATCH 1/3] t5403.1: simplify commit creation","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2011-10-13T03:54:11Z","receivedAt":"2011-10-13T03:54:11Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"2011/10/13 Johannes Sixt <j.sixt@viscovery.net>:\n> Am 10/12/2011 11:35, schrieb Nguyễn Thái Ngọc Duy:\n>>  test_expect_success setup '\n>>       echo Data for commit0. >a &&\n>>       echo Data for commit0. >b &&\n>> -     git update-index --add a &&\n>> -     git update-index --add b &&\n>> -     tree0=$(git write-tree) &&\n>> -     commit0=$(echo setup | git commit-tree $tree0) &&\n>> -     git update-ref refs/heads/master $commit0 &&\n>> +     git add a b &&\n>> +     git commit -m setup &&\n>>       git clone ./. clone1 &&\n>>       git clone ./. clone2 &&\n>>       GIT_DIR=clone2/.git git branch new2 &&\n>\n> I don't think this change is necessary. It doesn't hurt to use plumbing\n> commands here and there in the test suite to exercise them to a degree\n> that they deserve.\n\nI'm fine either way, for the record.\n-- \nDuy\n"},{"id":"177508","messageId":"7vwrc95xe5.fsf@alter.siamese.dyndns.org","threadId":"28658","inReplyTo":"1318412105-13595-3-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH 3/3] t5403: do not use access repos with GIT_DIR when worktree is involved","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-10-13T04:27:30Z","receivedAt":"2011-10-13T04:27:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:\n\n> Setting GIT_DIR alone means worktree is current directory for legacy\n> reasons. Avoid using that, instead go to the worktree and execute\n> commands there.\n>\n> The troublesome command is \"GIT_DIR=clone2/.git git add clone2/b\". The\n> real worktree is clone2, but that command tells git worktree is $(pwd).\n> What does user expect to add then? Should the new entry in index be \"b\"\n> or \"clone2/b\"?\n\nThere is no troublesomeness here, as the semantics has been clearly\ndefined and (hopefully) stayed constant before the days when GIT_WORK_TREE\nwas invented.\n\nAssuming that there is no core.worktree in clone2/.git/config and there is\nno GIT_WORK_TREE environment variable, \"GIT_DIR=$anything git add\nclone2/b\" should add a path \"clone2/b\" to the index controlled by that\n$GIT_DIR no matter where $anything is.\n\nI would like to find out the motivation behind this patch. Even though I\nfind the ancient style stale and unsightly, we would want to keep the\n(GIT_DIR is set, GIT_WORK_TREE is not set anywhere) combination working\nfor people who have work habits (read: old scripts) that rely on it. So we\nwould discourage new tests from using ancient style, but at the same time,\nwe would not want to remove _all_ existing ones.\n\nUnless we are trying to break them without knowing, and declare that we\ndeprecated it after the fact, which is not exactly the way we want to\nremove existing (mis)feature.\n\nSame comment applies to the other patch that removes the test that uses\nupdate-index && update-ref combination to a lessor degree.\n\nThe [PATCH 2/3] is a genuine improvement, though.\n\nThanks.\n"},{"id":"177510","messageId":"CACsJy8BS=z+5bALvMEAr567O2jT3ytSz9rWmvDSiRHL0Ub69wg@mail.gmail.com","threadId":"28658","inReplyTo":"7vwrc95xe5.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 3/3] t5403: do not use access repos with GIT_DIR when worktree is involved","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2011-10-13T04:54:29Z","receivedAt":"2011-10-13T04:54:29Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"2011/10/13 Junio C Hamano <gitster@pobox.com>:\n> Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:\n>\n>> Setting GIT_DIR alone means worktree is current directory for legacy\n>> reasons. Avoid using that, instead go to the worktree and execute\n>> commands there.\n>>\n>> The troublesome command is \"GIT_DIR=clone2/.git git add clone2/b\". The\n>> real worktree is clone2, but that command tells git worktree is $(pwd).\n>> What does user expect to add then? Should the new entry in index be \"b\"\n>> or \"clone2/b\"?\n>\n> There is no troublesomeness here, as the semantics has been clearly\n> defined and (hopefully) stayed constant before the days when GIT_WORK_TREE\n> was invented.\n\nIt's not wrong per se. The trouble comes from the people who reads the\ntest. It's not clear the author wants to add \"b\" or \"clone2/b\".\n\nAnother thing, because \"clone2\" has .git inside, should \"clone2\" in\nthis case be considered a submodule and \"git add\" refuse to add\nanything \"clone2/*\" but \"clone2\" itself?\n\n> Unless we are trying to break them without knowing, and declare that we\n> deprecated it after the fact, which is not exactly the way we want to\n> remove existing (mis)feature.\n\nI had problems with my read_directory() rewrite but it's been some\ntime since I touched the code. I don't remember what went wrong. Need\nto have another look.\n-- \nDuy\n"}]}