* [PATCH 1/3] t5403.1: simplify commit creation
@ 2011-10-12 9:35 Nguyễn Thái Ngọc Duy
2011-10-12 9:35 ` [PATCH 2/3] t5403: convert leading spaces to tabs Nguyễn Thái Ngọc Duy
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2011-10-12 9:35 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
t/t5403-post-checkout-hook.sh | 7 ++-----
1 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/t/t5403-post-checkout-hook.sh b/t/t5403-post-checkout-hook.sh
index d05a913..0c126d7 100755
--- a/t/t5403-post-checkout-hook.sh
+++ b/t/t5403-post-checkout-hook.sh
@@ -9,11 +9,8 @@ test_description='Test the post-checkout hook.'
test_expect_success setup '
echo Data for commit0. >a &&
echo Data for commit0. >b &&
- git update-index --add a &&
- git update-index --add b &&
- tree0=$(git write-tree) &&
- commit0=$(echo setup | git commit-tree $tree0) &&
- git update-ref refs/heads/master $commit0 &&
+ git add a b &&
+ git commit -m setup &&
git clone ./. clone1 &&
git clone ./. clone2 &&
GIT_DIR=clone2/.git git branch new2 &&
--
1.7.3.1.256.g2539c.dirty
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/3] t5403: convert leading spaces to tabs
2011-10-12 9:35 [PATCH 1/3] t5403.1: simplify commit creation Nguyễn Thái Ngọc Duy
@ 2011-10-12 9:35 ` Nguyễn Thái Ngọc Duy
2011-10-12 9:35 ` [PATCH 3/3] t5403: do not use access repos with GIT_DIR when worktree is involved Nguyễn Thái Ngọc Duy
2011-10-12 14:14 ` [PATCH 1/3] t5403.1: simplify commit creation Johannes Sixt
2 siblings, 0 replies; 7+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2011-10-12 9:35 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy
The first and last tests use tabs. The rest uses spaces. Convert all
to tabs.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
t/t5403-post-checkout-hook.sh | 46 ++++++++++++++++++++--------------------
1 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/t/t5403-post-checkout-hook.sh b/t/t5403-post-checkout-hook.sh
index 0c126d7..6643f32 100755
--- a/t/t5403-post-checkout-hook.sh
+++ b/t/t5403-post-checkout-hook.sh
@@ -28,44 +28,44 @@ EOF
done
test_expect_success 'post-checkout runs as expected ' '
- GIT_DIR=clone1/.git git checkout master &&
- test -e clone1/.git/post-checkout.args
+ GIT_DIR=clone1/.git git checkout master &&
+ test -e clone1/.git/post-checkout.args
'
test_expect_success 'post-checkout receives the right arguments with HEAD unchanged ' '
- old=$(awk "{print \$1}" clone1/.git/post-checkout.args) &&
- new=$(awk "{print \$2}" clone1/.git/post-checkout.args) &&
- flag=$(awk "{print \$3}" clone1/.git/post-checkout.args) &&
- test $old = $new -a $flag = 1
+ old=$(awk "{print \$1}" clone1/.git/post-checkout.args) &&
+ new=$(awk "{print \$2}" clone1/.git/post-checkout.args) &&
+ flag=$(awk "{print \$3}" clone1/.git/post-checkout.args) &&
+ test $old = $new -a $flag = 1
'
test_expect_success 'post-checkout runs as expected ' '
- GIT_DIR=clone1/.git git checkout master &&
- test -e clone1/.git/post-checkout.args
+ GIT_DIR=clone1/.git git checkout master &&
+ test -e clone1/.git/post-checkout.args
'
test_expect_success 'post-checkout args are correct with git checkout -b ' '
- GIT_DIR=clone1/.git git checkout -b new1 &&
- old=$(awk "{print \$1}" clone1/.git/post-checkout.args) &&
- new=$(awk "{print \$2}" clone1/.git/post-checkout.args) &&
- flag=$(awk "{print \$3}" clone1/.git/post-checkout.args) &&
- test $old = $new -a $flag = 1
+ GIT_DIR=clone1/.git git checkout -b new1 &&
+ old=$(awk "{print \$1}" clone1/.git/post-checkout.args) &&
+ new=$(awk "{print \$2}" clone1/.git/post-checkout.args) &&
+ flag=$(awk "{print \$3}" clone1/.git/post-checkout.args) &&
+ test $old = $new -a $flag = 1
'
test_expect_success 'post-checkout receives the right args with HEAD changed ' '
- GIT_DIR=clone2/.git git checkout new2 &&
- old=$(awk "{print \$1}" clone2/.git/post-checkout.args) &&
- new=$(awk "{print \$2}" clone2/.git/post-checkout.args) &&
- flag=$(awk "{print \$3}" clone2/.git/post-checkout.args) &&
- test $old != $new -a $flag = 1
+ GIT_DIR=clone2/.git git checkout new2 &&
+ old=$(awk "{print \$1}" clone2/.git/post-checkout.args) &&
+ new=$(awk "{print \$2}" clone2/.git/post-checkout.args) &&
+ flag=$(awk "{print \$3}" clone2/.git/post-checkout.args) &&
+ test $old != $new -a $flag = 1
'
test_expect_success 'post-checkout receives the right args when not switching branches ' '
- GIT_DIR=clone2/.git git checkout master b &&
- old=$(awk "{print \$1}" clone2/.git/post-checkout.args) &&
- new=$(awk "{print \$2}" clone2/.git/post-checkout.args) &&
- flag=$(awk "{print \$3}" clone2/.git/post-checkout.args) &&
- test $old = $new -a $flag = 0
+ GIT_DIR=clone2/.git git checkout master b &&
+ old=$(awk "{print \$1}" clone2/.git/post-checkout.args) &&
+ new=$(awk "{print \$2}" clone2/.git/post-checkout.args) &&
+ flag=$(awk "{print \$3}" clone2/.git/post-checkout.args) &&
+ test $old = $new -a $flag = 0
'
if test "$(git config --bool core.filemode)" = true; then
--
1.7.3.1.256.g2539c.dirty
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/3] t5403: do not use access repos with GIT_DIR when worktree is involved
2011-10-12 9:35 [PATCH 1/3] t5403.1: simplify commit creation Nguyễn Thái Ngọc Duy
2011-10-12 9:35 ` [PATCH 2/3] t5403: convert leading spaces to tabs Nguyễn Thái Ngọc Duy
@ 2011-10-12 9:35 ` Nguyễn Thái Ngọc Duy
2011-10-13 4:27 ` Junio C Hamano
2011-10-12 14:14 ` [PATCH 1/3] t5403.1: simplify commit creation Johannes Sixt
2 siblings, 1 reply; 7+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2011-10-12 9:35 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy
Setting GIT_DIR alone means worktree is current directory for legacy
reasons. Avoid using that, instead go to the worktree and execute
commands there.
The troublesome command is "GIT_DIR=clone2/.git git add clone2/b". The
real worktree is clone2, but that command tells git worktree is $(pwd).
What does user expect to add then? Should the new entry in index be "b"
or "clone2/b"?
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
t/t5403-post-checkout-hook.sh | 17 ++++++++++-------
1 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/t/t5403-post-checkout-hook.sh b/t/t5403-post-checkout-hook.sh
index 6643f32..3459539 100755
--- a/t/t5403-post-checkout-hook.sh
+++ b/t/t5403-post-checkout-hook.sh
@@ -13,10 +13,13 @@ test_expect_success setup '
git commit -m setup &&
git clone ./. clone1 &&
git clone ./. clone2 &&
- GIT_DIR=clone2/.git git branch new2 &&
- echo Data for commit1. >clone2/b &&
- GIT_DIR=clone2/.git git add clone2/b &&
- GIT_DIR=clone2/.git git commit -m new2
+ (
+ cd clone2 &&
+ git branch new2 &&
+ echo Data for commit1. >b &&
+ git add b &&
+ git commit -m new2
+ )
'
for clone in 1 2; do
@@ -45,7 +48,7 @@ test_expect_success 'post-checkout runs as expected ' '
'
test_expect_success 'post-checkout args are correct with git checkout -b ' '
- GIT_DIR=clone1/.git git checkout -b new1 &&
+ ( cd clone1 && git checkout -b new1 ) &&
old=$(awk "{print \$1}" clone1/.git/post-checkout.args) &&
new=$(awk "{print \$2}" clone1/.git/post-checkout.args) &&
flag=$(awk "{print \$3}" clone1/.git/post-checkout.args) &&
@@ -53,7 +56,7 @@ test_expect_success 'post-checkout args are correct with git checkout -b ' '
'
test_expect_success 'post-checkout receives the right args with HEAD changed ' '
- GIT_DIR=clone2/.git git checkout new2 &&
+ ( cd clone2 && git checkout new2 ) &&
old=$(awk "{print \$1}" clone2/.git/post-checkout.args) &&
new=$(awk "{print \$2}" clone2/.git/post-checkout.args) &&
flag=$(awk "{print \$3}" clone2/.git/post-checkout.args) &&
@@ -61,7 +64,7 @@ test_expect_success 'post-checkout receives the right args with HEAD changed ' '
'
test_expect_success 'post-checkout receives the right args when not switching branches ' '
- GIT_DIR=clone2/.git git checkout master b &&
+ ( cd clone2 && git checkout master b ) &&
old=$(awk "{print \$1}" clone2/.git/post-checkout.args) &&
new=$(awk "{print \$2}" clone2/.git/post-checkout.args) &&
flag=$(awk "{print \$3}" clone2/.git/post-checkout.args) &&
--
1.7.3.1.256.g2539c.dirty
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 3/3] t5403: do not use access repos with GIT_DIR when worktree is involved
2011-10-12 9:35 ` [PATCH 3/3] t5403: do not use access repos with GIT_DIR when worktree is involved Nguyễn Thái Ngọc Duy
@ 2011-10-13 4:27 ` Junio C Hamano
2011-10-13 4:54 ` Nguyen Thai Ngoc Duy
0 siblings, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2011-10-13 4:27 UTC (permalink / raw)
To: Nguyễn Thái Ngọc Duy; +Cc: git
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
> Setting GIT_DIR alone means worktree is current directory for legacy
> reasons. Avoid using that, instead go to the worktree and execute
> commands there.
>
> The troublesome command is "GIT_DIR=clone2/.git git add clone2/b". The
> real worktree is clone2, but that command tells git worktree is $(pwd).
> What does user expect to add then? Should the new entry in index be "b"
> or "clone2/b"?
There is no troublesomeness here, as the semantics has been clearly
defined and (hopefully) stayed constant before the days when GIT_WORK_TREE
was invented.
Assuming that there is no core.worktree in clone2/.git/config and there is
no GIT_WORK_TREE environment variable, "GIT_DIR=$anything git add
clone2/b" should add a path "clone2/b" to the index controlled by that
$GIT_DIR no matter where $anything is.
I would like to find out the motivation behind this patch. Even though I
find the ancient style stale and unsightly, we would want to keep the
(GIT_DIR is set, GIT_WORK_TREE is not set anywhere) combination working
for people who have work habits (read: old scripts) that rely on it. So we
would discourage new tests from using ancient style, but at the same time,
we would not want to remove _all_ existing ones.
Unless we are trying to break them without knowing, and declare that we
deprecated it after the fact, which is not exactly the way we want to
remove existing (mis)feature.
Same comment applies to the other patch that removes the test that uses
update-index && update-ref combination to a lessor degree.
The [PATCH 2/3] is a genuine improvement, though.
Thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 3/3] t5403: do not use access repos with GIT_DIR when worktree is involved
2011-10-13 4:27 ` Junio C Hamano
@ 2011-10-13 4:54 ` Nguyen Thai Ngoc Duy
0 siblings, 0 replies; 7+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2011-10-13 4:54 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
2011/10/13 Junio C Hamano <gitster@pobox.com>:
> Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
>
>> Setting GIT_DIR alone means worktree is current directory for legacy
>> reasons. Avoid using that, instead go to the worktree and execute
>> commands there.
>>
>> The troublesome command is "GIT_DIR=clone2/.git git add clone2/b". The
>> real worktree is clone2, but that command tells git worktree is $(pwd).
>> What does user expect to add then? Should the new entry in index be "b"
>> or "clone2/b"?
>
> There is no troublesomeness here, as the semantics has been clearly
> defined and (hopefully) stayed constant before the days when GIT_WORK_TREE
> was invented.
It's not wrong per se. The trouble comes from the people who reads the
test. It's not clear the author wants to add "b" or "clone2/b".
Another thing, because "clone2" has .git inside, should "clone2" in
this case be considered a submodule and "git add" refuse to add
anything "clone2/*" but "clone2" itself?
> Unless we are trying to break them without knowing, and declare that we
> deprecated it after the fact, which is not exactly the way we want to
> remove existing (mis)feature.
I had problems with my read_directory() rewrite but it's been some
time since I touched the code. I don't remember what went wrong. Need
to have another look.
--
Duy
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] t5403.1: simplify commit creation
2011-10-12 9:35 [PATCH 1/3] t5403.1: simplify commit creation Nguyễn Thái Ngọc Duy
2011-10-12 9:35 ` [PATCH 2/3] t5403: convert leading spaces to tabs Nguyễn Thái Ngọc Duy
2011-10-12 9:35 ` [PATCH 3/3] t5403: do not use access repos with GIT_DIR when worktree is involved Nguyễn Thái Ngọc Duy
@ 2011-10-12 14:14 ` Johannes Sixt
2011-10-13 3:54 ` Nguyen Thai Ngoc Duy
2 siblings, 1 reply; 7+ messages in thread
From: Johannes Sixt @ 2011-10-12 14:14 UTC (permalink / raw)
To: Nguyễn Thái Ngọc Duy; +Cc: git, Junio C Hamano
Am 10/12/2011 11:35, schrieb Nguyễn Thái Ngọc Duy:
> test_expect_success setup '
> echo Data for commit0. >a &&
> echo Data for commit0. >b &&
> - git update-index --add a &&
> - git update-index --add b &&
> - tree0=$(git write-tree) &&
> - commit0=$(echo setup | git commit-tree $tree0) &&
> - git update-ref refs/heads/master $commit0 &&
> + git add a b &&
> + git commit -m setup &&
> git clone ./. clone1 &&
> git clone ./. clone2 &&
> GIT_DIR=clone2/.git git branch new2 &&
I don't think this change is necessary. It doesn't hurt to use plumbing
commands here and there in the test suite to exercise them to a degree
that they deserve.
-- Hannes
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] t5403.1: simplify commit creation
2011-10-12 14:14 ` [PATCH 1/3] t5403.1: simplify commit creation Johannes Sixt
@ 2011-10-13 3:54 ` Nguyen Thai Ngoc Duy
0 siblings, 0 replies; 7+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2011-10-13 3:54 UTC (permalink / raw)
To: Johannes Sixt; +Cc: git, Junio C Hamano
2011/10/13 Johannes Sixt <j.sixt@viscovery.net>:
> Am 10/12/2011 11:35, schrieb Nguyễn Thái Ngọc Duy:
>> test_expect_success setup '
>> echo Data for commit0. >a &&
>> echo Data for commit0. >b &&
>> - git update-index --add a &&
>> - git update-index --add b &&
>> - tree0=$(git write-tree) &&
>> - commit0=$(echo setup | git commit-tree $tree0) &&
>> - git update-ref refs/heads/master $commit0 &&
>> + git add a b &&
>> + git commit -m setup &&
>> git clone ./. clone1 &&
>> git clone ./. clone2 &&
>> GIT_DIR=clone2/.git git branch new2 &&
>
> I don't think this change is necessary. It doesn't hurt to use plumbing
> commands here and there in the test suite to exercise them to a degree
> that they deserve.
I'm fine either way, for the record.
--
Duy
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2011-10-13 4:55 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-12 9:35 [PATCH 1/3] t5403.1: simplify commit creation Nguyễn Thái Ngọc Duy
2011-10-12 9:35 ` [PATCH 2/3] t5403: convert leading spaces to tabs Nguyễn Thái Ngọc Duy
2011-10-12 9:35 ` [PATCH 3/3] t5403: do not use access repos with GIT_DIR when worktree is involved Nguyễn Thái Ngọc Duy
2011-10-13 4:27 ` Junio C Hamano
2011-10-13 4:54 ` Nguyen Thai Ngoc Duy
2011-10-12 14:14 ` [PATCH 1/3] t5403.1: simplify commit creation Johannes Sixt
2011-10-13 3:54 ` Nguyen Thai Ngoc Duy
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).