* git apply/am whitespace errors @ 2011-09-26 19:03 neubyr 2011-09-26 19:44 ` Junio C Hamano 0 siblings, 1 reply; 3+ messages in thread From: neubyr @ 2011-09-26 19:03 UTC (permalink / raw) To: git I am getting following error while applying a patch using git-apply. {{{ /tmp/patches/ticket11/0002-Commit-for-ticket-11.patch:51: new blank line at EOF. }}} What does number '51' after colon ':' indicate? There aren't 51 lines in that patch file. Also, I had used check and stat options before applying match and it didn't indicate any warnings/errors. I tried git am interactive and it gave following error: {{{ Applying: Commit for [ticket:11]. Created a directory to download lens files and added .include_in_git empty hidden file. /tmp/galaxy/.git/rebase-apply/patch:10: new blank line at EOF. + warning: 1 line adds whitespace errors. Commit Body is: }}} I am trying to add a directory with a hidden empty file. Any elaboration on above warning/error messages will be really helpful. -- thanks, neuby.r ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: git apply/am whitespace errors 2011-09-26 19:03 git apply/am whitespace errors neubyr @ 2011-09-26 19:44 ` Junio C Hamano 2011-09-26 20:39 ` Junio C Hamano 0 siblings, 1 reply; 3+ messages in thread From: Junio C Hamano @ 2011-09-26 19:44 UTC (permalink / raw) To: neubyr; +Cc: git neubyr <neubyr@gmail.com> writes: > I am getting following error while applying a patch using git-apply. > > {{{ > /tmp/patches/ticket11/0002-Commit-for-ticket-11.patch:51: new blank line at EOF. > }}} > > What does number '51' after colon ':' indicate? Looks like "apply --whitespace=error" is not reporting the optimal line number for the blank at EOF case. It ideally should point at the line number of the offending patch in the input patch file (i.e. "cat -n .git/apply-rebase/patch" would show the "+" line that adds a blank line on 51th line), but it seems that it instead points at the beginning of the hunk that introduces the issue. E.g. if we add an empty line at the end of COPYING (which is 360 lines long), we would get a patch file that looks like this: 1 diff --git a/COPYING b/COPYING$ 2 index 536e555..ccf4c7f 100644$ 3 --- a/COPYING$ 4 +++ b/COPYING$ 5 @@ -358,3 +358,4 @@ proprietary programs. If your program is a subroutine library, you may$ 6 consider it more useful to permit linking proprietary applications with the$ 7 library. If this is what you want to do, use the GNU Lesser General$ 8 Public License instead of this License.$ 9 +$ and "git apply --whitespace=error P.diff" would report the hunk that begins at line 5 is wrong: P.diff:5: new blank line at EOF. + fatal: 1 line adds whitespace errors. when the true offending line is at line #9. ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: git apply/am whitespace errors 2011-09-26 19:44 ` Junio C Hamano @ 2011-09-26 20:39 ` Junio C Hamano 0 siblings, 0 replies; 3+ messages in thread From: Junio C Hamano @ 2011-09-26 20:39 UTC (permalink / raw) To: git; +Cc: neubyr Subject: apply --whitespace=error: correctly report new blank lines at end Earlier 77b15bb (apply --whitespace=warn/error: diagnose blank at EOF, 2009-09-03) cheated by reporting the line number of the hunk that contains the offending line that adds new blank lines at the end of the file. All other types of whitespace errors are reported with the line number in the patch file that has the actual offending text. Signed-off-by: Junio C Hamano <gitster@pobox.com> --- * This is an interim workaround. fragment->linenr was added for the specific purpose of reporting this type of error in the quoted patch, and the field is not used for any other purpose, so it may be a better fix to either rename it to hunk_linenr and use it directly without introducing a new local variable in apply_one_fragment(), or pass "linenr" as a parameter to parse_fragment() and pass it down the callchain all the way through, or something like that. builtin/apply.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) diff --git a/builtin/apply.c b/builtin/apply.c index f2edc52..092429a 100644 --- a/builtin/apply.c +++ b/builtin/apply.c @@ -2447,6 +2447,8 @@ static int apply_one_fragment(struct image *img, struct fragment *frag, char *old, *oldlines; struct strbuf newlines; int new_blank_lines_at_end = 0; + int found_new_blank_lines_at_end = 0; + int hunk_linenr = frag->linenr; unsigned long leading, trailing; int pos, applied_pos; struct image preimage; @@ -2540,14 +2542,18 @@ static int apply_one_fragment(struct image *img, struct fragment *frag, error("invalid start of line: '%c'", first); return -1; } - if (added_blank_line) + if (added_blank_line) { + if (!new_blank_lines_at_end) + found_new_blank_lines_at_end = hunk_linenr; new_blank_lines_at_end++; + } else if (is_blank_context) ; else new_blank_lines_at_end = 0; patch += len; size -= len; + hunk_linenr++; } if (inaccurate_eof && old > oldlines && old[-1] == '\n' && @@ -2629,7 +2635,8 @@ static int apply_one_fragment(struct image *img, struct fragment *frag, preimage.nr + applied_pos >= img->nr && (ws_rule & WS_BLANK_AT_EOF) && ws_error_action != nowarn_ws_error) { - record_ws_error(WS_BLANK_AT_EOF, "+", 1, frag->linenr); + record_ws_error(WS_BLANK_AT_EOF, "+", 1, + found_new_blank_lines_at_end); if (ws_error_action == correct_ws_error) { while (new_blank_lines_at_end--) remove_last_line(&postimage); -- 1.7.7.rc3 ^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-09-26 20:39 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-09-26 19:03 git apply/am whitespace errors neubyr 2011-09-26 19:44 ` Junio C Hamano 2011-09-26 20:39 ` Junio C Hamano
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).