Thread (7 messages) flat view 7 messages, 4 authors, 2016-06-15

Re: [PATCH] Teach 'git-apply --whitespace=strip' to remove empty lines at the end of file

From: Marco Costalba <hidden>
Date: 2016-06-15 22:43:11

Possibly related (same subject, not in this thread)

On 5/20/07, Junio C Hamano [off-list ref] wrote:
"Marco Costalba" [off-list ref] writes:
quoted
Ok. This is take 3. It works correctly on standard patches and also on
u0 example that you gave above.

This patch is on top of git 1.5.2

Please check it.
I think the checks and actions are at the right places (I
haven't looked very closely nor tried to run it yet).
quoted
builtin-apply.c |   34 ++++++++++++++++++++++++++++++++++
1 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/builtin-apply.c b/builtin-apply.c
index 0399743..6032f78 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
...
@@ -1770,6 +1800,10 @@ static int apply_one_fragment(struct buffer_desc *desc,
              if (match_beginning && offset)
                      offset = -1;
              if (offset >= 0) {
+
+                     if (desc->size - oldsize - offset == 0) /* end of file? */
+                             newsize -= trailing_added_lines;
+
                      int diff = newsize - oldsize;
                      unsigned long size = desc->size + diff;
                      unsigned long alloc = desc->alloc;
But we have kept our sources -Wdeclaration-after-statement
clean so far
??????

Wie bitte?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help