{"thread":{"id":"14276","subject":"[PATCH] git-apply tests need to be portable","startedAt":"2008-07-03T16:00:20Z","lastAt":"2008-07-04T18:39:23Z","messageCount":3,"participants":["Don Zickus","Johannes Sixt","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"82132","messageId":"1215100820-23140-1-git-send-email-dzickus@redhat.com","threadId":"14276","inReplyTo":null,"subject":"[PATCH] git-apply tests need to be portable","fromName":"Don Zickus","fromEmail":"dzickus@redhat.com","sentAt":"2008-07-03T16:00:20Z","receivedAt":"2008-07-03T16:00:20Z","isPatch":true,"sender":{"key":"dzickus@redhat.com","avatar":null},"body":"When I created the tests for my git-apply patch, I accidently used the '-i'\nflag for sed.  Not all versions of sed handle this flag, so I converted\nthose instances to output to a temp file and move that temp file back to the\noriginal file.\n\nThanks to Jim Meyering for noticing this!\n\n---\n\nJunio, I am not sure if you want me to resend the whole patch again or is a\nsmall update like this preferred.  I am indifferent either way.\n\nCheers,\nDon\n---\n t/t4127-apply-same-fn.sh |   33 ++++++++++++++++++++++-----------\n 1 files changed, 22 insertions(+), 11 deletions(-)\n\ndiff --git a/t/t4127-apply-same-fn.sh b/t/t4127-apply-same-fn.sh\nindex 2a6ed77..2726a29 100755\n--- a/t/t4127-apply-same-fn.sh\n+++ b/t/t4127-apply-same-fn.sh\n@@ -14,10 +14,12 @@ test_expect_success setup '\n \tgit commit -m initial\n '\n test_expect_success 'apply same filename with independent changes' '\n-\tsed -i -e \"s/^d/z/\" same_fn &&\n+\tsed -e \"s/^d/z/\" same_fn > f &&\n+\tmv f same_fn &&\n \tgit diff > patch0 &&\n \tgit add same_fn &&\n-\tsed -i -e \"s/^i/y/\" same_fn &&\n+\tsed -e \"s/^i/y/\" same_fn > f &&\n+\tmv f same_fn &&\n \tgit diff >> patch0 &&\n \tcp same_fn same_fn2 &&\n \tgit reset --hard &&\n@@ -27,10 +29,12 @@ test_expect_success 'apply same filename with independent changes' '\n \n test_expect_success 'apply same filename with overlapping changes' '\n \tgit reset --hard\n-\tsed -i -e \"s/^d/z/\" same_fn &&\n+\tsed -e \"s/^d/z/\" same_fn > f &&\n+\tmv f same_fn &&\n \tgit diff > patch0 &&\n \tgit add same_fn &&\n-\tsed -i -e \"s/^e/y/\" same_fn &&\n+\tsed -e \"s/^e/y/\" same_fn > f &&\n+\tmv f same_fn &&\n \tgit diff >> patch0 &&\n \tcp same_fn same_fn2 &&\n \tgit reset --hard &&\n@@ -41,10 +45,12 @@ test_expect_success 'apply same filename with overlapping changes' '\n test_expect_success 'apply same new filename after rename' '\n \tgit reset --hard\n \tgit mv same_fn new_fn\n-\tsed -i -e \"s/^d/z/\" new_fn &&\n+\tsed -e \"s/^d/z/\" new_fn > f &&\n+\tmv f new_fn &&\n \tgit add new_fn &&\n \tgit diff -M --cached > patch1 &&\n-\tsed -i -e \"s/^e/y/\" new_fn &&\n+\tsed -e \"s/^e/y/\" new_fn > f &&\n+\tmv f new_fn &&\n \tgit diff >> patch1 &&\n \tcp new_fn new_fn2 &&\n \tgit reset --hard &&\n@@ -55,11 +61,13 @@ test_expect_success 'apply same new filename after rename' '\n test_expect_success 'apply same old filename after rename -- should fail.' '\n \tgit reset --hard\n \tgit mv same_fn new_fn\n-\tsed -i -e \"s/^d/z/\" new_fn &&\n+\tsed -e \"s/^d/z/\" new_fn > f &&\n+\tmv f new_fn &&\n \tgit add new_fn &&\n \tgit diff -M --cached > patch1 &&\n \tgit mv new_fn same_fn\n-\tsed -i -e \"s/^e/y/\" same_fn &&\n+\tsed -e \"s/^e/y/\" same_fn > f &&\n+\tmv f same_fn &&\n \tgit diff >> patch1 &&\n \tgit reset --hard &&\n \ttest_must_fail git apply patch1\n@@ -68,15 +76,18 @@ test_expect_success 'apply same old filename after rename -- should fail.' '\n test_expect_success 'apply A->B (rename), C->A (rename), A->A -- should pass.' '\n \tgit reset --hard\n \tgit mv same_fn new_fn\n-\tsed -i -e \"s/^d/z/\" new_fn &&\n+\tsed -e \"s/^d/z/\" new_fn > f &&\n+\tmv f new_fn &&\n \tgit add new_fn &&\n \tgit diff -M --cached > patch1 &&\n \tgit commit -m \"a rename\" &&\n \tgit mv other_fn same_fn\n-\tsed -i -e \"s/^e/y/\" same_fn &&\n+\tsed -e \"s/^e/y/\" same_fn > f &&\n+\tmv f same_fn &&\n \tgit add same_fn &&\n \tgit diff -M --cached >> patch1 &&\n-\tsed -i -e \"s/^g/x/\" same_fn &&\n+\tsed -e \"s/^g/x/\" same_fn > f &&\n+\tmv f same_fn &&\n \tgit diff >> patch1 &&\n \tgit reset --hard HEAD^ &&\n \tgit apply patch1\n-- \n1.5.6.rc2.48.g13da\n"},{"id":"82206","messageId":"486DC687.4070307@viscovery.net","threadId":"14276","inReplyTo":"1215100820-23140-1-git-send-email-dzickus@redhat.com","subject":"[PATCH] t4127-apply-same-fn: Avoid sed -i","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2008-07-04T06:43:19Z","receivedAt":"2008-07-04T06:43:19Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"From: Johannes Sixt <johannes.sixt@telecom.at>\n\nSigned-off-by: Johannes Sixt <johannes.sixt@telecom.at>\n---\nDon Zickus schrieb:\n> When I created the tests for my git-apply patch, I accidently used the '-i'\n> flag for sed.  Not all versions of sed handle this flag, so I converted\n> those instances to output to a temp file and move that temp file back to the\n> original file.\n\nI had this alternate patch in my tree, but forgot to submit it.\n\n-- Hannes\n\n t/t4127-apply-same-fn.sh |   27 ++++++++++++++++-----------\n 1 files changed, 16 insertions(+), 11 deletions(-)\n\ndiff --git a/t/t4127-apply-same-fn.sh b/t/t4127-apply-same-fn.sh\nindex 2a6ed77..1f859dd 100755\n--- a/t/t4127-apply-same-fn.sh\n+++ b/t/t4127-apply-same-fn.sh\n@@ -4,6 +4,11 @@ test_description='apply same filename'\n\n . ./test-lib.sh\n\n+modify () {\n+\tsed -e \"$1\" < \"$2\" > \"$2\".x &&\n+\tmv \"$2\".x \"$2\"\n+}\n+\n test_expect_success setup '\n \tfor i in a b c d e f g h i j k l m\n \tdo\n@@ -14,10 +19,10 @@ test_expect_success setup '\n \tgit commit -m initial\n '\n test_expect_success 'apply same filename with independent changes' '\n-\tsed -i -e \"s/^d/z/\" same_fn &&\n+\tmodify \"s/^d/z/\" same_fn &&\n \tgit diff > patch0 &&\n \tgit add same_fn &&\n-\tsed -i -e \"s/^i/y/\" same_fn &&\n+\tmodify \"s/^i/y/\" same_fn &&\n \tgit diff >> patch0 &&\n \tcp same_fn same_fn2 &&\n \tgit reset --hard &&\n@@ -27,10 +32,10 @@ test_expect_success 'apply same filename with independent changes' '\n\n test_expect_success 'apply same filename with overlapping changes' '\n \tgit reset --hard\n-\tsed -i -e \"s/^d/z/\" same_fn &&\n+\tmodify \"s/^d/z/\" same_fn &&\n \tgit diff > patch0 &&\n \tgit add same_fn &&\n-\tsed -i -e \"s/^e/y/\" same_fn &&\n+\tmodify \"s/^e/y/\" same_fn &&\n \tgit diff >> patch0 &&\n \tcp same_fn same_fn2 &&\n \tgit reset --hard &&\n@@ -41,10 +46,10 @@ test_expect_success 'apply same filename with overlapping changes' '\n test_expect_success 'apply same new filename after rename' '\n \tgit reset --hard\n \tgit mv same_fn new_fn\n-\tsed -i -e \"s/^d/z/\" new_fn &&\n+\tmodify \"s/^d/z/\" new_fn &&\n \tgit add new_fn &&\n \tgit diff -M --cached > patch1 &&\n-\tsed -i -e \"s/^e/y/\" new_fn &&\n+\tmodify \"s/^e/y/\" new_fn &&\n \tgit diff >> patch1 &&\n \tcp new_fn new_fn2 &&\n \tgit reset --hard &&\n@@ -55,11 +60,11 @@ test_expect_success 'apply same new filename after rename' '\n test_expect_success 'apply same old filename after rename -- should fail.' '\n \tgit reset --hard\n \tgit mv same_fn new_fn\n-\tsed -i -e \"s/^d/z/\" new_fn &&\n+\tmodify \"s/^d/z/\" new_fn &&\n \tgit add new_fn &&\n \tgit diff -M --cached > patch1 &&\n \tgit mv new_fn same_fn\n-\tsed -i -e \"s/^e/y/\" same_fn &&\n+\tmodify \"s/^e/y/\" same_fn &&\n \tgit diff >> patch1 &&\n \tgit reset --hard &&\n \ttest_must_fail git apply patch1\n@@ -68,15 +73,15 @@ test_expect_success 'apply same old filename after rename -- should fail.' '\n test_expect_success 'apply A->B (rename), C->A (rename), A->A -- should pass.' '\n \tgit reset --hard\n \tgit mv same_fn new_fn\n-\tsed -i -e \"s/^d/z/\" new_fn &&\n+\tmodify \"s/^d/z/\" new_fn &&\n \tgit add new_fn &&\n \tgit diff -M --cached > patch1 &&\n \tgit commit -m \"a rename\" &&\n \tgit mv other_fn same_fn\n-\tsed -i -e \"s/^e/y/\" same_fn &&\n+\tmodify \"s/^e/y/\" same_fn &&\n \tgit add same_fn &&\n \tgit diff -M --cached >> patch1 &&\n-\tsed -i -e \"s/^g/x/\" same_fn &&\n+\tmodify \"s/^g/x/\" same_fn &&\n \tgit diff >> patch1 &&\n \tgit reset --hard HEAD^ &&\n \tgit apply patch1\n-- \n1.5.6.1.1099.ge791.dirty\n"},{"id":"82245","messageId":"alpine.DEB.1.00.0807041938360.9925@racer","threadId":"14276","inReplyTo":"486DC687.4070307@viscovery.net","subject":"Re: [PATCH] t4127-apply-same-fn: Avoid sed -i","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-07-04T18:39:23Z","receivedAt":"2008-07-04T18:39:23Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 4 Jul 2008, Johannes Sixt wrote:\n\n> > When I created the tests for my git-apply patch, I accidently used the \n> > '-i' flag for sed.\n\nMaybe we should modify our hooks so that this is warned about?  While at \nit, we could warn about quoted \"wc -l\", too...\n\nCiao,\nDscho\n"}]}