From: Eric Sunshine <sunshine@sunshineco.com>
To: Benoit Pierre <benoit.pierre@gmail.com>
Cc: Git List <git@vger.kernel.org>
Subject: Re: [PATCH 1/6] test patch hunk editing with "commit -p -m"
Date: Thu, 6 Mar 2014 17:07:13 -0500 [thread overview]
Message-ID: <CAPig+cTTCsMDJ_B73+cbedrxoEqbM_txV6JYWmCq-LyX12TpNw@mail.gmail.com> (raw)
In-Reply-To: <1394117424-29780-2-git-send-email-benoit.pierre@gmail.com>
On Thu, Mar 6, 2014 at 9:50 AM, Benoit Pierre <benoit.pierre@gmail.com> wrote:
> Add (failing) test: with commit changing the environment to let hooks
> now that no editor will be used (by setting GIT_EDITOR to ":"), the
> "edit hunk" functionality does not work (no editor is launched and the
> whole hunk is committed).
>
> Signed-off-by: Benoit Pierre <benoit.pierre@gmail.com>
> ---
> t/t7513-commit_-p_-m_hunk_edit.sh | 37 +++++++++++++++++++++++++++++++++++++
> 1 file changed, 37 insertions(+)
> create mode 100755 t/t7513-commit_-p_-m_hunk_edit.sh
A rather unusual filename.
> diff --git a/t/t7513-commit_-p_-m_hunk_edit.sh b/t/t7513-commit_-p_-m_hunk_edit.sh
> new file mode 100755
> index 0000000..e0ad905
> --- /dev/null
> +++ b/t/t7513-commit_-p_-m_hunk_edit.sh
> @@ -0,0 +1,37 @@
> +#!/bin/sh
> +
> +test_description='hunk edit with "commit -p -m"'
> +. ./test-lib.sh
> +
> +if ! test_have_prereq PERL
> +then
> + skip_all="skipping '$test_description' tests, perl not available"
> + test_done
> +fi
> +
> +test_expect_success 'setup (initial)' '
> + echo line1 >file &&
> + git add file &&
> + git commit -m commit1
Broken &&-chain.
> + echo line3 >>file
> +'
> +
> +test_expect_success 'setup expected' '
> +cat >expected <<EOF
> +diff --git a/file b/file
> +index a29bdeb..c0d0fb4 100644
> +--- a/file
> ++++ b/file
> +@@ -1 +1,2 @@
> + line1
> ++line2
> +EOF
> +'
If you use <<-EOF, you can indent the content you're dumping into
'expected', which can enhance readability. Even better, use <<-\EOF to
indicate that you don't want interpolation done within the content.
> +test_expect_failure 'edit hunk "commit -p -m message"' '
> + echo e | env GIT_EDITOR="sed s/+line3\$/+line2/ -i" git commit -p -m commit2 file &&
> + git diff HEAD^ HEAD >diff &&
> + test_cmp expected diff
> +'
If you ever add more tests, is it likely that they will be using the
same 'expected' file used by this test? If not, perhaps it makes sense
to move creation of 'expected' into the test itself.
> +test_done
> --
> 1.9.0
next prev parent reply other threads:[~2014-03-06 22:08 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-06 14:50 [PATCH 0/6] fix hunk editing with 'commit -p -m' Benoit Pierre
2014-03-06 14:50 ` [PATCH 1/6] test patch hunk editing with "commit -p -m" Benoit Pierre
2014-03-06 22:07 ` Eric Sunshine [this message]
2014-03-06 23:11 ` Junio C Hamano
2014-03-06 14:50 ` [PATCH 2/6] commit: fix " Benoit Pierre
2014-03-06 21:25 ` Junio C Hamano
2014-03-06 21:47 ` Junio C Hamano
2014-03-06 14:50 ` [PATCH 3/6] merge: fix GIT_EDITOR override for commit hook Benoit Pierre
2014-03-06 14:50 ` [PATCH 4/6] merge hook tests: fix and update tests Benoit Pierre
2014-03-06 22:11 ` Eric Sunshine
2014-03-06 14:50 ` [PATCH 5/6] merge hook tests: fix missing '&&' in test Benoit Pierre
2014-03-06 21:27 ` Junio C Hamano
2014-03-06 14:50 ` [PATCH 6/6] merge hook tests: use 'test_must_fail' instead of '!' Benoit Pierre
2014-03-06 21:29 ` Junio C Hamano
2014-03-07 0:35 ` Junio C Hamano
2014-03-06 21:15 ` [PATCH 0/6] fix hunk editing with 'commit -p -m' Junio C Hamano
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=CAPig+cTTCsMDJ_B73+cbedrxoEqbM_txV6JYWmCq-LyX12TpNw@mail.gmail.com \
--to=sunshine@sunshineco.com \
--cc=benoit.pierre@gmail.com \
--cc=git@vger.kernel.org \
/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).