{"thread":{"id":"20335","subject":"[RFC] Allowing new eof whitelines while still doing whitespace trailing-space fix.","startedAt":"2009-08-01T16:53:44Z","lastAt":"2009-08-01T22:14:53Z","messageCount":3,"participants":["Thell Fowler","Thell","TBFowler"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"119346","messageId":"1249145624.2774.16.camel@GWPortableVCS","threadId":"20335","inReplyTo":null,"subject":"[RFC] Allowing new eof whitelines while still doing whitespace trailing-space fix.","fromName":"Thell Fowler","fromEmail":"tbfowler4@gmail.com","sentAt":"2009-08-01T16:53:44Z","receivedAt":"2009-08-01T16:53:44Z","isPatch":false,"sender":{"key":"tbfowler4@gmail.com","avatar":"https://gravatar.com/avatar/1b038b543b3facd3ae8cbfcc05ae06547e9f2015b5e661efbec68d662955a826?d=mp&s=160"},"body":"As part of a current mirroring project of a dirty upstream repo that has\nmixed line endings and leading/trailing whitespace issues it became\napparent that the current trailing-space fixing in ws.c worked\ncorrectly, but the new_blank_lines_at_end processing in builtin-apply.c\nwould remove the newly fixed line.  Also, as noted in a previous thread,\nthere are times when adding new whitelines at eof is a needed\ncapability, yet the desire remains to correct other whitespace issues\nwithin the patch.\n\nThe patch in the follow-up post is an attempt to fix that.  This is my\nfirst git-core patch, so please be honest but gentle. :P  If the fix is\nof interest I'd be glad to go through the steps of making a test case\nand whatever else is needed.\n"},{"id":"119361","messageId":"1249164774-13617-1-git-send-email-thell@almostautomated.com","threadId":"20335","inReplyTo":"1249145624.2774.16.camel@GWPortableVCS","subject":"[PATCH] Add --allow-eof-whitelines to git-apply while still doing whitespace trailing-space fixing.","fromName":"TBFowler","fromEmail":"tbfowler4@gmail.com","sentAt":"2009-08-01T22:12:53Z","receivedAt":"2009-08-01T22:12:53Z","isPatch":true,"sender":{"key":"tbfowler4@gmail.com","avatar":"https://gravatar.com/avatar/1b038b543b3facd3ae8cbfcc05ae06547e9f2015b5e661efbec68d662955a826?d=mp&s=160"},"body":"- Added --allow-eof-whitelines to git apply to short-circuit removal of new empty lines when tailing-space is set.\n  - Added pass-through to apply from git-am.sh\n  - Added pass-through to git-am from git-rebase.sh\n  - Added the auto-completion entries.\n\nSigned-off-by: TBFowler <thell@almostautomated.com>\n---\n builtin-apply.c                        |    5 ++++-\n contrib/completion/git-completion.bash |    4 ++--\n git-am.sh                              |    3 +++\n git-rebase.sh                          |    3 +++\n 4 files changed, 12 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin-apply.c b/builtin-apply.c\nindex dc0ff5e..79be05c 100644\n--- a/builtin-apply.c\n+++ b/builtin-apply.c\n@@ -43,6 +43,7 @@ static int apply = 1;\n static int apply_in_reverse;\n static int apply_with_reject;\n static int apply_verbosely;\n+static int keep_new_eof_whitelines;\n static int no_add;\n static const char *fake_ancestor;\n static int line_termination = '\\n';\n@@ -1996,7 +1997,7 @@ static int apply_one_fragment(struct image *img, struct fragment *frag,\n \t\t\t\terror(\"invalid start of line: '%c'\", first);\n \t\t\treturn -1;\n \t\t}\n-\t\tif (added_blank_line)\n+\t\tif (added_blank_line && !keep_new_eof_whitelines)\n \t\t\tnew_blank_lines_at_end++;\n \t\telse\n \t\t\tnew_blank_lines_at_end = 0;\n@@ -3304,6 +3305,8 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix)\n \t\t{ OPTION_CALLBACK, 0, \"whitespace\", &whitespace_option, \"action\",\n \t\t\t\"detect new or modified lines that have whitespace errors\",\n \t\t\t0, option_parse_whitespace },\n+\t\tOPT_BOOLEAN(0, \"allow-eof-whitelines\", &keep_new_eof_whitelines,\n+\t\t\t\"allow processing of whitespace fix but don't suppress new whitelines at end of file\"),\n \t\tOPT_BOOLEAN('R', \"reverse\", &apply_in_reverse,\n \t\t\t\"apply the patch in reverse\"),\n \t\tOPT_BOOLEAN(0, \"unidiff-zero\", &unidiff_zero,\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 745b5fb..512b14c 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -675,7 +675,7 @@ _git_am ()\n \t\t__gitcomp \"\n \t\t\t--3way --committer-date-is-author-date --ignore-date\n \t\t\t--interactive --keep --no-utf8 --signoff --utf8\n-\t\t\t--whitespace=\n+\t\t\t--whitespace= --allow-eof-whitelines\n \t\t\t\"\n \t\treturn\n \tesac\n@@ -695,7 +695,7 @@ _git_apply ()\n \t\t\t--stat --numstat --summary --check --index\n \t\t\t--cached --index-info --reverse --reject --unidiff-zero\n \t\t\t--apply --no-add --exclude=\n-\t\t\t--whitespace= --inaccurate-eof --verbose\n+\t\t\t--whitespace= --allow-eof-whitelines --inaccurate-eof --verbose\n \t\t\t\"\n \t\treturn\n \tesac\ndiff --git a/git-am.sh b/git-am.sh\nindex d64d997..5757674 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -16,6 +16,7 @@ s,signoff       add a Signed-off-by line to the commit message\n u,utf8          recode into utf8 (default)\n k,keep          pass -k flag to git-mailinfo\n whitespace=     pass it through git-apply\n+allow-eof-whitelines        pass it through git-apply\n directory=      pass it through git-apply\n C=              pass it through git-apply\n p=              pass it through git-apply\n@@ -299,6 +300,8 @@ do\n \t\tshift; resolvemsg=$1 ;;\n \t--whitespace|--directory)\n \t\tgit_apply_opt=\"$git_apply_opt $(sq \"$1=$2\")\"; shift ;;\n+\t--allow-eof-whitelines)\n+\t\tgit_apply_opt=\"$git_apply_opt $1\" ;;\n \t-C|-p)\n \t\tgit_apply_opt=\"$git_apply_opt $(sq \"$1$2\")\"; shift ;;\n \t--patch-format)\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 18bc694..1556224 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -333,6 +333,9 @@ do\n \t\t\t;;\n \t\tesac\n \t\t;;\n+\t--allow-eof-whitelines)\n+\t\tgit_am_opt=\"$git_am_opt $1\"\n+\t\t;;\n \t--committer-date-is-author-date|--ignore-date)\n \t\tgit_am_opt=\"$git_am_opt $1\"\n \t\tforce_rebase=t\n-- \n1.6.4.rc3.dirty\n"},{"id":"119360","messageId":"loom.20090801T215905-792@post.gmane.org","threadId":"20335","inReplyTo":"1249145624.2774.16.camel@GWPortableVCS","subject":"Re: [RFC] Allowing new eof whitelines while still doing whitespace trailing-space fix.","fromName":"Thell","fromEmail":"tbfowler4@gmail.com","sentAt":"2009-08-01T22:14:53Z","receivedAt":"2009-08-01T22:14:53Z","isPatch":false,"sender":{"key":"tbfowler4@gmail.com","avatar":"https://gravatar.com/avatar/1b038b543b3facd3ae8cbfcc05ae06547e9f2015b5e661efbec68d662955a826?d=mp&s=160"},"body":"Thell Fowler <tbfowler4 <at> gmail.com> writes:\n\n...\n> The patch in the follow-up post is an attempt to fix that.\n...\n\nMy apologies; the patch post ended up being a top level post and trying to use\nimap-send with gmail to do an --in-reply-to was futile.  Using send-email worked\nin testing, so I'll give that a go with the patch here.\n\nThell\n"}]}