From: Junio C Hamano <gitster@pobox.com>
To: Bello Caleb Olamide <belkid98@gmail.com>
Cc: git@vger.kernel.org, christian.couder@gmail.com,
usmanakinyemi202@gmail.com
Subject: Re: [RFC Outreachy] Teach ci/check-whitespace to flag incomplete lines as an error
Date: Sat, 11 Oct 2025 12:50:43 -0700 [thread overview]
Message-ID: <xmqqecr95ib0.fsf@gitster.g> (raw)
In-Reply-To: <aOporVVSRRL/v4Lq@ubuntu> (Bello Caleb Olamide's message of "Sat, 11 Oct 2025 14:24:45 +0000")
Bello Caleb Olamide <belkid98@gmail.com> writes:
> Hello,
>
> While going through the mailing list for some #leftoverbits, I stumbled on this converation.
> https://public-inbox.org/git/xmqqikla86id.fsf@gitster.g/.
Welcome, and first please learn to keep your lines under readable
width limit. As an applicant to a mentoring program with this
project, you will be exchanging e-mails about patches, whose
contents are limited to 80 columns (but subtracting 1 columns for
"+/ /-" prefix when a line is shown in a patch, plus several more
for "> " prefix when the message is quoted multiple times during a
discussion thread, a practical line-length limit is more like 68-72
columns), and you will be adding in-line comments in the middle of
quoted patches.
Hence, your comments in e-mails thrown at this list are also limited
to similar line length limit. Otherwise they would become very hard
to read.
I'll line-wrap the quoted text below.
> After studying the check-whitespace script, I observed that the
> script parses each line of the output of the command `git log
> --check --pretty=format:"---% h% s" "${baseCommit}"..` and formats
> the result.
>
> But the output of the git command itself does not flag '\no
> newline at end of file' as it is shown in git diff, in a case
> where the files does not contain a newline at the end of the file.
Correct observations.
> One approach I propose to take is to check the each file changed
> in each commit and check if it has the \n as the last character.
If a commit changes line 4 of a 100-line file that lacked the final
newline, "git log" would show the commit, "git log -p" would show a
patch to the file, but "\No newline" would not be shown, because the
commit is not responsible for introducing an incomplete line to the
file. Looking at the last byte of "git cat-file blob $commit:$path"
for commits that appear in "git log" output would not give us what
we want. We need a mechanism that notices and warns when a commit
makes a file, which used to end with a newline, end in an incomplete
line.
If you can come up with a robust way to do so in check-whitespace
script, with the understanding that the right solution in the longer
term is to teach "git log --check" to notice incomplete lines and
flag it (with core.whitespace configuration and the whitespace
attributes to enable/disable the check), it might work as a stop-gap
measure. As I said elsewhere a few days ago, doing it right would
be a bit too big for a microproject.
next prev parent reply other threads:[~2025-10-11 19:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-11 14:24 [RFC Outreachy] Teach ci/check-whitespace to flag incomplete lines as an error Bello Caleb Olamide
2025-10-11 19:50 ` Junio C Hamano [this message]
2025-10-12 23:41 ` Bello Olamide
2025-10-13 15:41 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqecr95ib0.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=belkid98@gmail.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=usmanakinyemi202@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).