* [PATCH] Add test case for running from a subdirectory with GIT_WORK_TREE
@ 2007-10-27 8:19 Nguyễn Thái Ngọc Duy
2007-10-27 12:45 ` Johannes Schindelin
0 siblings, 1 reply; 4+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2007-10-27 8:19 UTC (permalink / raw)
To: git
This one is ugly (and not intended to submit to git.git), but
it shows how to reproduce the issues. You can run it with
arg "--normal" to see it works just fine without GIT_WORK_TREE.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
t/t1502-subworktree.sh | 109 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 109 insertions(+), 0 deletions(-)
create mode 100755 t/t1502-subworktree.sh
diff --git a/t/t1502-subworktree.sh b/t/t1502-subworktree.sh
new file mode 100755
index 0000000..6b8f02f
--- /dev/null
+++ b/t/t1502-subworktree.sh
@@ -0,0 +1,109 @@
+#!/bin/sh
+
+test_description='test commands on separate work tree'
+. ./test-lib.sh
+
+mkdir -p work/sub/dir || exit 1
+mv .git work
+if test "$1" = --normal; then
+ say "Normal case"
+else
+ say "Worktree case"
+fi
+test "$1" = --normal || mv work/.git repo.git || exit 1
+
+test "$1" = --normal || export GIT_DIR=$(pwd)/repo.git
+export GIT_CONFIG="$(pwd)"/$GIT_DIR/config
+test "$1" = --normal || export GIT_WORK_TREE=$(pwd)/work
+
+cd work/sub || exit 1
+
+cat >expected <<EOF
+100644 9daeafb9864cf43055ae93beb0afd6c7d144bfa4 0 dir/untracked
+EOF
+
+test_expect_success 'git-ls-files' 'test expected = "$(git ls-files --others)"'
+
+test_expect_success 'git-add' '
+ ( : > dir/untracked &&
+ git add dir/untracked &&
+ test dir/untracked = "$(git ls-files)")
+'
+test_expect_success 'git-update-index' '
+ ( echo test > dir/untracked &&
+ git update-index dir/untracked &&
+ git ls-files --stage > check &&
+ cmp expected check)
+'
+
+test_expect_success 'git-commit' 'git commit -m one'
+
+cat >expected <<EOF
+100644 blob 9daeafb9864cf43055ae93beb0afd6c7d144bfa4 dir/untracked
+EOF
+
+test_expect_success 'git-ls-tree' '
+ (git ls-tree -r HEAD > check &&
+ cmp expected check)
+'
+test_expect_success 'git-rm' '
+ (git rm --cached dir/untracked &&
+ test -z "$(git ls-files)")
+'
+test_expect_success 'git-reset' '
+ (git reset HEAD -- dir/untracked &&
+ test dir/untracked = "$(git ls-files)")
+'
+test_expect_success 'git-annotate' 'git annotate dir/untracked'
+
+test_expect_success 'git-blame' 'git blame dir/untracked'
+
+cat > patch <<EOF
+From b774efc5a2199bfc1c9c18db70363c69a5a10c86 Mon Sep 17 00:00:00 2001
+From: A U Thor <author@example.com>
+Date: Tue, 23 Oct 2007 21:17:24 +0700
+Subject: bah
+
+---
+ sub/dir/untracked | 1 +
+ 1 files changed, 1 insertions(+), 0 deletions(-)
+
+diff --git a/sub/dir/untracked b/sub/dir/untracked
+index 9daeafb..c73d3ff 100644
+--- a/sub/dir/untracked
++++ b/sub/dir/untracked
+@@ -1 +1,2 @@
+ test
++test again
+--
+1.5.3.rc4.3.gab089
+
+EOF
+
+cat > expected <<EOF
+100644 c73d3ffa5fa32888de8219e49fd45d37dc209677 0 dir/untracked
+EOF
+
+test_expect_success 'git-apply to index' '
+ (git apply --index patch &&
+ git ls-files --stage > check &&
+ cmp expected check)'
+
+test_expect_failure 'git-apply to worktree' 'test -f sub/dir/untracked'
+
+test_expect_success 'git-reset --hard' '( git reset --hard HEAD && test -z "$(git ls-files -m)")'
+
+test_expect_failure 'git-am must not be run from subdir' 'git-am -k patch'
+
+test_expect_success 'git-reset --hard' 'git reset --hard HEAD'
+
+test_expect_success 'git-am' '(cd .. && git-am -k sub/patch)'
+
+test_expect_success 'git-format-patch' '
+ (git format-patch -k HEAD^ &&
+ sed "1d;/^-- /,\$d" patch > expected &&
+ sed "1d;/^-- /,\$d" 0001-bah.patch > check &&
+ cmp expected check)
+'
+
+test_done
--
1.5.3.rc4.3.gab089
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Add test case for running from a subdirectory with GIT_WORK_TREE
2007-10-27 8:19 [PATCH] Add test case for running from a subdirectory with GIT_WORK_TREE Nguyễn Thái Ngọc Duy
@ 2007-10-27 12:45 ` Johannes Schindelin
[not found] ` <fcaeb9bf0710270557n48a01ba2w3a89f65680b946d@mail.gmail.com>
2007-10-28 0:18 ` Junio C Hamano
0 siblings, 2 replies; 4+ messages in thread
From: Johannes Schindelin @ 2007-10-27 12:45 UTC (permalink / raw)
To: Nguyễn Thái Ngọc Duy; +Cc: git
[-- Attachment #1: Type: TEXT/PLAIN, Size: 668 bytes --]
Hi,
On Sat, 27 Oct 2007, Nguyễn Thái Ngọc Duy wrote:
> +mkdir -p work/sub/dir || exit 1
> +mv .git work
> +if test "$1" = --normal; then
> + say "Normal case"
> +else
> + say "Worktree case"
> +fi
> +test "$1" = --normal || mv work/.git repo.git || exit 1
> +
> +test "$1" = --normal || export GIT_DIR=$(pwd)/repo.git
> +export GIT_CONFIG="$(pwd)"/$GIT_DIR/config
> +test "$1" = --normal || export GIT_WORK_TREE=$(pwd)/work
> +
> +cd work/sub || exit 1
Why don't you put this block into a test_expect_success? And then just
make a
for mode in normal worktree
do
...
done
Hmm? I would like to see this test case in the official git.git.
Ciao,
Dscho
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Add test case for running from a subdirectory with GIT_WORK_TREE
[not found] ` <fcaeb9bf0710270557n48a01ba2w3a89f65680b946d@mail.gmail.com>
@ 2007-10-27 13:27 ` Johannes Schindelin
0 siblings, 0 replies; 4+ messages in thread
From: Johannes Schindelin @ 2007-10-27 13:27 UTC (permalink / raw)
To: Nguyen Thai Ngoc Duy; +Cc: git
[-- Attachment #1: Type: TEXT/PLAIN, Size: 1270 bytes --]
Hi,
On Sat, 27 Oct 2007, Nguyen Thai Ngoc Duy wrote:
> On 10/27/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> > Hi,
> >
> > On Sat, 27 Oct 2007, Nguyễn Thái Ngọc Duy wrote:
> >
> > > +mkdir -p work/sub/dir || exit 1
> > > +mv .git work
> > > +if test "$1" = --normal; then
> > > + say "Normal case"
> > > +else
> > > + say "Worktree case"
> > > +fi
> > > +test "$1" = --normal || mv work/.git repo.git || exit 1
> > > +
> > > +test "$1" = --normal || export GIT_DIR=$(pwd)/repo.git
> > > +export GIT_CONFIG="$(pwd)"/$GIT_DIR/config
> > > +test "$1" = --normal || export GIT_WORK_TREE=$(pwd)/work
> > > +
> > > +cd work/sub || exit 1
> >
> > Why don't you put this block into a test_expect_success? And then just
> > make a
> >
> > for mode in normal worktree
> > do
> >
> > ...
> >
> > done
> >
> > Hmm? I would like to see this test case in the official git.git.
>
> Because after normal iteration, the test repository is no longer in
> clean state that the second iteration needs. Maybe I should just
> create another repo then set parameters properly in test_expect_*
Yes, you can do that:
test_create_repo other-repo
Another option would be that you clean up at the end of the loop.
Ciao,
Dscho
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Add test case for running from a subdirectory with GIT_WORK_TREE
2007-10-27 12:45 ` Johannes Schindelin
[not found] ` <fcaeb9bf0710270557n48a01ba2w3a89f65680b946d@mail.gmail.com>
@ 2007-10-28 0:18 ` Junio C Hamano
1 sibling, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2007-10-28 0:18 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Nguyễn Thái Ngọc Duy, git
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> On Sat, 27 Oct 2007, Nguyễn Thái Ngọc Duy wrote:
>
>> +mkdir -p work/sub/dir || exit 1
>> +mv .git work
>> +if test "$1" = --normal; then
>> + say "Normal case"
>> +else
>> + say "Worktree case"
>> +fi
>> +test "$1" = --normal || mv work/.git repo.git || exit 1
>> +
>> +test "$1" = --normal || export GIT_DIR=$(pwd)/repo.git
>> +export GIT_CONFIG="$(pwd)"/$GIT_DIR/config
>> +test "$1" = --normal || export GIT_WORK_TREE=$(pwd)/work
>> +
>> +cd work/sub || exit 1
> ...
> Hmm? I would like to see this test case in the official git.git.
Me too ;-) It would help people fix the issues.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-10-28 0:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-27 8:19 [PATCH] Add test case for running from a subdirectory with GIT_WORK_TREE Nguyễn Thái Ngọc Duy
2007-10-27 12:45 ` Johannes Schindelin
[not found] ` <fcaeb9bf0710270557n48a01ba2w3a89f65680b946d@mail.gmail.com>
2007-10-27 13:27 ` Johannes Schindelin
2007-10-28 0:18 ` Junio C Hamano
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).