git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/12] Incomplete lines
@ 2025-11-04  2:09 Junio C Hamano
  2025-11-04  2:09 ` [PATCH 01/12] whitespace: correct bit assignment comments Junio C Hamano
                   ` (12 more replies)
  0 siblings, 13 replies; 73+ messages in thread
From: Junio C Hamano @ 2025-11-04  2:09 UTC (permalink / raw)
  To: git

One of the common kind of whitespace errors is to lack the
terminating newline at the end of a file, but so far, neither "git
diff" or "git apply" did anything about them.

This series introduces "incomplete-line" whitespace error class,
that you can add to either the core.whitespace configuration
variable, or the whitespace attribute in your .gitattributes files.
The class is disabled by default.

When incomplete-line whitespace error is enabled, a patch file that
has "\ No newline at the end of file" line for the postimage file is
considered to introduce a whitespace error.  This is true even if
the corresponding preimage file ends in a different contents on the
final line that is incomplete.  The incomplete line marker that is
given for a context line is not considered an error.  The reasoning
is that your preimage did have incomplete line, but you did not
touch the contents on that incomplete line in your patch, so you
left the line intact.  It is not a new breakage you are responsible
for.  If the incomplete line marker follows a postimage line, on the
other hand, it means that you either made a file that used to end
with a complete line to end with an incomplete line, or the file
ended with an incomplete line before your change, and you did not
fix it even though you modified other bytes on that same last line,
which you could have easily fixed while at it, and that is flagged
as an error.

 * "git diff --check" notices and errors out.

 * "git diff" and friends highlight the offending "\ No newline ..."
   line.

 * "git apply --whitespace=(error|warn)" triggers an error, and "git
   apply --whitespace=fix" would correct it by appending a newline.

The organization of the series is

 * The first patch [01/12] is a clean-up we have seen earlier on the
   list already (https://lore.kernel.org/git/xmqqfrb4hyjl.fsf@gitster.g/).

 * The patches [02/12] - [08/12] are preliminary clean-up made to
   both "git diff" and "git apply" machinery.

 * The patch [09/12] shifts the bit assignment (cleaned-up in
   [01/12] without changing any values) to make room for new
   whitespace error class (which was last updated in 2007 IIRC, so
   the set of whitespace errors surprisingly haven't changed for
   quite some time).

 * The patch [10/12] teaches "git apply --whitespace=<mode>" about
   the incomplete-line error class.

 * The patch [11/12] teaches "git diff [--check]" about the
   incomplete-line error class.

 * The final patch [12/12] enables the incomplete-line error class
   for our project for C source files and shell scripts.  I didn't
   touch the cover-all * entry.

Junio C Hamano (12):
  whitespace: correct bit assignment comments
  diff: emit_line_ws_markup() if/else style fix
  diff: correct suppress_blank_empty hack
  diff: fix incorrect counting of line numbers
  diff: refactor output of incomplete line
  diff: call emit_callback ecbdata everywhere
  diff: update the way rewrite diff handles incomplete lines
  apply: revamp the parsing of incomplete lines
  whitespace: allocate a few more bits
  apply: check and fix incomplete lines
  diff: highlight and error out on incomplete lines
  attr: enable incomplete-line whitespace error for this project

 .gitattributes             |   4 +-
 apply.c                    |  70 ++++++++++++------
 diff.c                     | 148 +++++++++++++++++++++++++------------
 diff.h                     |   6 +-
 t/t4015-diff-whitespace.sh |  63 +++++++++++++++-
 t/t4124-apply-ws-rule.sh   | 112 ++++++++++++++++++++++++++++
 ws.c                       |  20 +++++
 ws.h                       |  26 ++++---
 8 files changed, 361 insertions(+), 88 deletions(-)

-- 
2.52.0-rc0


^ permalink raw reply	[flat|nested] 73+ messages in thread

end of thread, other threads:[~2025-11-23  2:35 UTC | newest]

Thread overview: 73+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-04  2:09 [PATCH 00/12] Incomplete lines Junio C Hamano
2025-11-04  2:09 ` [PATCH 01/12] whitespace: correct bit assignment comments Junio C Hamano
2025-11-04  2:09 ` [PATCH 02/12] diff: emit_line_ws_markup() if/else style fix Junio C Hamano
2025-11-04  2:09 ` [PATCH 03/12] diff: correct suppress_blank_empty hack Junio C Hamano
2025-11-04  2:09 ` [PATCH 04/12] diff: fix incorrect counting of line numbers Junio C Hamano
2025-11-10 14:54   ` Phillip Wood
2025-11-10 18:29     ` Junio C Hamano
2025-11-11 14:26       ` Phillip Wood
2025-11-11 14:37         ` Junio C Hamano
2025-11-04  2:09 ` [PATCH 05/12] diff: refactor output of incomplete line Junio C Hamano
2025-11-04  2:09 ` [PATCH 06/12] diff: call emit_callback ecbdata everywhere Junio C Hamano
2025-11-04  2:09 ` [PATCH 07/12] diff: update the way rewrite diff handles incomplete lines Junio C Hamano
2025-11-10 14:54   ` Phillip Wood
2025-11-10 18:33     ` Junio C Hamano
2025-11-04  2:09 ` [PATCH 08/12] apply: revamp the parsing of " Junio C Hamano
2025-11-04  2:09 ` [PATCH 09/12] whitespace: allocate a few more bits Junio C Hamano
2025-11-04  2:09 ` [PATCH 10/12] apply: check and fix incomplete lines Junio C Hamano
2025-11-04  2:09 ` [PATCH 11/12] diff: highlight and error out on " Junio C Hamano
2025-11-10 14:55   ` Phillip Wood
2025-11-10 18:38     ` Junio C Hamano
2025-11-10 23:56       ` D. Ben Knoble
2025-11-04  2:09 ` [PATCH 12/12] attr: enable incomplete-line whitespace error for this project Junio C Hamano
2025-11-10 14:55   ` Phillip Wood
2025-11-10 18:40     ` Junio C Hamano
2025-11-05 21:30 ` [PATCH v2 00/12] Incomplete lines Junio C Hamano
2025-11-05 21:30   ` [PATCH v2 01/12] whitespace: correct bit assignment comments Junio C Hamano
2025-11-05 21:30   ` [PATCH v2 02/12] diff: emit_line_ws_markup() if/else style fix Junio C Hamano
2025-11-05 21:30   ` [PATCH v2 03/12] diff: correct suppress_blank_empty hack Junio C Hamano
2025-11-05 21:30   ` [PATCH v2 04/12] diff: fix incorrect counting of line numbers Junio C Hamano
2025-11-05 21:30   ` [PATCH v2 05/12] diff: refactor output of incomplete line Junio C Hamano
2025-11-10 10:06     ` Patrick Steinhardt
2025-11-10 17:58       ` Junio C Hamano
2025-11-05 21:30   ` [PATCH v2 06/12] diff: call emit_callback ecbdata everywhere Junio C Hamano
2025-11-05 21:30   ` [PATCH v2 07/12] diff: update the way rewrite diff handles incomplete lines Junio C Hamano
2025-11-10 10:06     ` Patrick Steinhardt
2025-11-10 18:14       ` Junio C Hamano
2025-11-05 21:30   ` [PATCH v2 08/12] apply: revamp the parsing of " Junio C Hamano
2025-11-05 21:30   ` [PATCH v2 09/12] whitespace: allocate a few more bits and define WS_INCOMPLETE_LINE Junio C Hamano
2025-11-05 21:30   ` [PATCH v2 10/12] apply: check and fix incomplete lines Junio C Hamano
2025-11-05 21:30   ` [PATCH v2 11/12] diff: highlight and error out on " Junio C Hamano
2025-11-05 21:30   ` [PATCH v2 12/12] attr: enable incomplete-line whitespace error for this project Junio C Hamano
2025-11-10 10:09   ` [PATCH v2 00/12] Incomplete lines Patrick Steinhardt
2025-11-10 14:53   ` Phillip Wood
2025-11-11  0:04   ` [PATCH v3 " Junio C Hamano
2025-11-11  0:04     ` [PATCH v3 01/12] whitespace: correct bit assignment comments Junio C Hamano
2025-11-11  0:04     ` [PATCH v3 02/12] diff: emit_line_ws_markup() if/else style fix Junio C Hamano
2025-11-11  0:04     ` [PATCH v3 03/12] diff: correct suppress_blank_empty hack Junio C Hamano
2025-11-11  0:04     ` [PATCH v3 04/12] diff: fix incorrect counting of line numbers Junio C Hamano
2025-11-11  0:04     ` [PATCH v3 05/12] diff: refactor output of incomplete line Junio C Hamano
2025-11-11  0:04     ` [PATCH v3 06/12] diff: call emit_callback ecbdata everywhere Junio C Hamano
2025-11-11  0:04     ` [PATCH v3 07/12] diff: update the way rewrite diff handles incomplete lines Junio C Hamano
2025-11-11  0:04     ` [PATCH v3 08/12] apply: revamp the parsing of " Junio C Hamano
2025-11-11  0:04     ` [PATCH v3 09/12] whitespace: allocate a few more bits and define WS_INCOMPLETE_LINE Junio C Hamano
2025-11-11  0:04     ` [PATCH v3 10/12] apply: check and fix incomplete lines Junio C Hamano
2025-11-11  0:04     ` [PATCH v3 11/12] diff: highlight and error out on " Junio C Hamano
2025-11-11  0:04     ` [PATCH v3 12/12] attr: enable incomplete-line whitespace error for this project Junio C Hamano
2025-11-11 14:29     ` [PATCH v3 00/12] Incomplete lines Phillip Wood
2025-11-12 22:02     ` [PATCH v4 " Junio C Hamano
2025-11-12 22:02       ` [PATCH v4 01/12] whitespace: correct bit assignment comments Junio C Hamano
2025-11-12 22:02       ` [PATCH v4 02/12] diff: emit_line_ws_markup() if/else style fix Junio C Hamano
2025-11-12 22:02       ` [PATCH v4 03/12] diff: correct suppress_blank_empty hack Junio C Hamano
2025-11-12 22:02       ` [PATCH v4 04/12] diff: keep track of the type of the last line seen Junio C Hamano
2025-11-12 22:02       ` [PATCH v4 05/12] diff: refactor output of incomplete line Junio C Hamano
2025-11-12 22:02       ` [PATCH v4 06/12] diff: call emit_callback ecbdata everywhere Junio C Hamano
2025-11-12 22:02       ` [PATCH v4 07/12] diff: update the way rewrite diff handles incomplete lines Junio C Hamano
2025-11-12 22:02       ` [PATCH v4 08/12] apply: revamp the parsing of " Junio C Hamano
2025-11-12 22:02       ` [PATCH v4 09/12] whitespace: allocate a few more bits and define WS_INCOMPLETE_LINE Junio C Hamano
2025-11-12 22:02       ` [PATCH v4 10/12] apply: check and fix incomplete lines Junio C Hamano
2025-11-12 22:02       ` [PATCH v4 11/12] diff: highlight and error out on " Junio C Hamano
2025-11-12 22:02       ` [PATCH v4 12/12] attr: enable incomplete-line whitespace error for this project Junio C Hamano
2025-11-14 10:24       ` [PATCH v4 00/12] Incomplete lines Phillip Wood
2025-11-14 16:25         ` Junio C Hamano
2025-11-23  2:35           ` 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).