All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Torsten Bögershausen" <tboegi@web.de>
To: "Benoit Pierre" <benoit.pierre@gmail.com>,
	"Torsten Bögershausen" <tboegi@web.de>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: [PATCH 3/7] test patch hunk editing with "commit -p -m"
Date: Sat, 15 Mar 2014 22:00:20 +0100	[thread overview]
Message-ID: <5324BF64.7020900@web.de> (raw)
In-Reply-To: <CA+SSzV1LcuTWMGrJrto3cJ13-MxgFsJP6z3zTYjHp=qZGPoraw@mail.gmail.com>

On 2014-03-15 17.11, Benoit Pierre wrote:
> On Sat, Mar 15, 2014 at 1:28 PM, Torsten Bögershausen <tboegi@web.de> wrote:
>> On 2014-03-11 22.03, Junio C Hamano wrote:
>>> Benoit Pierre <benoit.pierre@gmail.com> writes:
>>>
>>>> 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 | 34 ++++++++++++++++++++++++++++++++++
>>>>  1 file changed, 34 insertions(+)
>>>>  create mode 100755 t/t7513-commit_-p_-m_hunk_edit.sh
>>>>
>>>> diff --git a/t/t7513-commit_-p_-m_hunk_edit.sh b/t/t7513-commit_-p_-m_hunk_edit.sh
>>>
>>> I'll move this to t/t7514-commit-patch.sh for now while queuing.
>>
>> This line is problematic:
>>         echo e | env GIT_EDITOR="sed s/+line3\$/+line2/ -i" git commit -p -m commit2 f
>>
>> (sed -i is not portable:
>> http://pubs.opengroup.org/onlinepubs/007908799/xcu/sed.html)
>>
>> The whole test hangs in a forever loop loop under MacOS:
>> debug=t verbose=t ./t7514-commit-patch.sh
>> Stage this hunk [y,n,q,a,d,/,e,?]? @@ -1 +1,2 @@
>>  line1
>> +line3
>>
>> I think perl can be used instead of sed (but I haven't found the exact syntax yet)
> 
> Or maybe change the test to just 'touch' a temporary file or change
> its content like Jun Hao did with for its version of the tests:
> 
> https://github.com/bloomberg/git/compare/commit-patch-allow-hunk-editing
> 
> Should I make a third version? I'll simplify and move the tests to
> t/t7514-commit-patch.sh and add a test for the '--dry-run' case. And
> also:
> - 'now' => 'know' in one of the commit message
> - sign off the last patch (which I forgot to do)
> - fix the indentation in one of the patch
> 
The following works for me, (diff against pu)
(and if you want to send a 3rd version, please do so :-)

diff --git a/t/t7514-commit-patch.sh b/t/t7514-commit-patch.sh
index 1f05d32..da92669 100755
--- a/t/t7514-commit-patch.sh
+++ b/t/t7514-commit-patch.sh
@@ -25,10 +25,20 @@ test_expect_success 'setup (initial)' '
 	EOF
 '
 
+write_script .git/FAKE_EDITOR <<\EOF
+	sed -e "s/+line3\$/+line2/" <"$1" >tmp &&
+	mv -f tmp "$1"
+	exit 0
+EOF
+
 test_expect_success '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 >actual &&
-	test_cmp expect actual
+	(
+		GIT_EDITOR="\"$(pwd)/.git/FAKE_EDITOR\"" &&
+		export GIT_EDITOR &&
+		echo e | git commit -p -m commit2 file &&
+		git diff HEAD^ HEAD >actual &&
+		test_cmp expect actual
+	)
 '
 
 test_done

  reply	other threads:[~2014-03-15 21:00 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-10 18:49 [PATCH V2 0/7] fix hunk editing with 'commit -p -m' Benoit Pierre
2014-03-10 18:49 ` [PATCH 1/7] merge hook tests: fix missing '&&' in test Benoit Pierre
2014-03-10 18:49 ` [PATCH 2/7] merge hook tests: use 'test_must_fail' instead of '!' Benoit Pierre
2014-03-10 18:49 ` [PATCH 3/7] test patch hunk editing with "commit -p -m" Benoit Pierre
2014-03-10 20:20   ` Eric Sunshine
2014-03-11 18:13     ` Junio C Hamano
2014-03-10 20:30   ` Philip Oakley
2014-03-11 21:03   ` Junio C Hamano
2014-03-15 12:28     ` Torsten Bögershausen
2014-03-15 16:11       ` Benoit Pierre
2014-03-15 21:00         ` Torsten Bögershausen [this message]
2014-03-15 21:42         ` [PATCH 1/7] merge hook tests: fix missing '&&' in test Benoit Pierre
2014-03-15 21:42           ` [PATCH 2/7] merge hook tests: use 'test_must_fail' instead of '!' Benoit Pierre
2014-03-15 21:42           ` [PATCH 3/7] test patch hunk editing with "commit -p -m" Benoit Pierre
2014-03-17 18:49             ` Junio C Hamano
2014-03-17 19:46               ` Benoit Pierre
2014-03-17 19:51                 ` Eric Sunshine
2014-03-17 19:53                   ` Benoit Pierre
2014-03-17 21:33                 ` Junio C Hamano
2014-03-17 18:53             ` Junio C Hamano
2014-03-17 19:52               ` Benoit Pierre
2014-03-17 21:35                 ` Junio C Hamano
2014-03-18 10:00               ` [PATCH 1/7] merge hook tests: fix missing '&&' in test Benoit Pierre
2014-03-18 10:00                 ` [PATCH 2/7] merge hook tests: use 'test_must_fail' instead of '!' Benoit Pierre
2014-03-18 10:00                 ` [PATCH 3/7] test patch hunk editing with "commit -p -m" Benoit Pierre
2014-03-18 10:00                 ` [PATCH 4/7] commit: fix " Benoit Pierre
2014-03-19  7:32                   ` Torsten Bögershausen
2014-03-19 17:19                     ` Junio C Hamano
2014-03-18 10:00                 ` [PATCH 5/7] merge: fix GIT_EDITOR override for commit hook Benoit Pierre
2014-03-18 10:00                 ` [PATCH 6/7] merge hook tests: fix and update tests Benoit Pierre
2014-03-18 10:00                 ` [PATCH 7/7] run-command: mark run_hook_with_custom_index as deprecated Benoit Pierre
2014-03-18 18:27                 ` [PATCH 1/7] merge hook tests: fix missing '&&' in test Junio C Hamano
2014-03-15 21:42           ` [PATCH 4/7] commit: fix patch hunk editing with "commit -p -m" Benoit Pierre
2014-03-15 21:42           ` [PATCH 5/7] merge: fix GIT_EDITOR override for commit hook Benoit Pierre
2014-03-15 21:42           ` [PATCH 6/7] merge hook tests: fix and update tests Benoit Pierre
2014-03-15 21:42           ` [PATCH 7/7] run-command: mark run_hook_with_custom_index as deprecated Benoit Pierre
2014-03-10 18:49 ` [PATCH 4/7] commit: fix patch hunk editing with "commit -p -m" Benoit Pierre
2014-03-10 20:07   ` Jeff King
2014-03-11  0:45     ` Jun Hao
2014-03-11 17:56     ` Benoit Pierre
2014-03-11 18:00       ` Jeff King
2014-03-11 18:40         ` [PATCH 4/7] commit: fix patch hunk editing with Jun Hao
2014-03-11 21:02   ` [PATCH 4/7] commit: fix patch hunk editing with "commit -p -m" Junio C Hamano
2014-03-10 18:49 ` [PATCH 5/7] merge: fix GIT_EDITOR override for commit hook Benoit Pierre
2014-03-10 18:49 ` [PATCH 6/7] merge hook tests: fix and update tests Benoit Pierre
2014-03-10 20:27   ` Eric Sunshine
2014-03-10 18:49 ` [PATCH 7/7] run-command: mark run_hook_with_custom_index as deprecated Benoit Pierre
2014-03-11  1:00   ` brian m. carlson
2014-03-11 17:37     ` Benoit Pierre
2014-04-03 22:11 ` [PATCH V2 0/7] fix hunk editing with 'commit -p -m' Jonathan Nieder

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=5324BF64.7020900@web.de \
    --to=tboegi@web.de \
    --cc=benoit.pierre@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.