{"thread":{"id":"64301","subject":"[RFC Outreachy] Teach ci/check-whitespace to flag incomplete lines as an error","startedAt":"2025-10-11T14:25:00Z","lastAt":"2025-10-13T15:41:06Z","messageCount":4,"participants":["Bello Caleb Olamide","Junio C Hamano","Bello Olamide"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"528572","messageId":"aOporVVSRRL/v4Lq@ubuntu","threadId":"64301","inReplyTo":null,"subject":"[RFC Outreachy] Teach ci/check-whitespace to flag incomplete lines as an error","fromName":"Bello Caleb Olamide","fromEmail":"belkid98@gmail.com","sentAt":"2025-10-11T14:24:45Z","receivedAt":"2025-10-11T14:25:00Z","isPatch":false,"sender":{"key":"belkid98@gmail.com","avatar":"https://avatars.githubusercontent.com/u/73387291?v=4"},"body":"Hello,\n\nWhile going through the mailing list for some #leftoverbits, I stumbled on this converation.\nhttps://public-inbox.org/git/xmqqikla86id.fsf@gitster.g/.\n\nAfter studying the check-whitespace script, I observed that the script parses each line of the output\nof the command `git log --check --pretty=format:\"---% h% s\" \"${baseCommit}\"..` and formats the result.\n\nBut the output of the git command itself does not flag '\\no newline at end of file'\nas it is shown in git diff, in a case where the files does not contain a newline at the end of the file.\n\nOne approach I propose to take is to check the each file changed in each commit and\ncheck if it has the \\n as the last character.\n\nPlease, will this be good for a microproject and also I'll appreciate suggestions for the approach.\nThank you.\n\nBello\n"},{"id":"528579","messageId":"xmqqecr95ib0.fsf@gitster.g","threadId":"64301","inReplyTo":"aOporVVSRRL/v4Lq@ubuntu","subject":"Re: [RFC Outreachy] Teach ci/check-whitespace to flag incomplete lines as an error","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-10-11T19:50:43Z","receivedAt":"2025-10-11T19:50:46Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Bello Caleb Olamide <belkid98@gmail.com> writes:\n\n> Hello,\n>\n> While going through the mailing list for some #leftoverbits, I stumbled on this converation.\n> https://public-inbox.org/git/xmqqikla86id.fsf@gitster.g/.\n\nWelcome, and first please learn to keep your lines under readable\nwidth limit.  As an applicant to a mentoring program with this\nproject, you will be exchanging e-mails about patches, whose\ncontents are limited to 80 columns (but subtracting 1 columns for\n\"+/ /-\" prefix when a line is shown in a patch, plus several more\nfor \"> \" prefix when the message is quoted multiple times during a\ndiscussion thread, a practical line-length limit is more like 68-72\ncolumns), and you will be adding in-line comments in the middle of\nquoted patches.\n\nHence, your comments in e-mails thrown at this list are also limited\nto similar line length limit.  Otherwise they would become very hard\nto read.\n\nI'll line-wrap the quoted text below.\n\n> After studying the check-whitespace script, I observed that the\n> script parses each line of the output of the command `git log\n> --check --pretty=format:\"---% h% s\" \"${baseCommit}\"..` and formats\n> the result.\n>\n> But the output of the git command itself does not flag '\\no\n> newline at end of file' as it is shown in git diff, in a case\n> where the files does not contain a newline at the end of the file.\n\nCorrect observations.\n\n> One approach I propose to take is to check the each file changed\n> in each commit and check if it has the \\n as the last character.\n\nIf a commit changes line 4 of a 100-line file that lacked the final\nnewline, \"git log\" would show the commit, \"git log -p\" would show a\npatch to the file, but \"\\No newline\" would not be shown, because the\ncommit is not responsible for introducing an incomplete line to the\nfile.  Looking at the last byte of \"git cat-file blob $commit:$path\"\nfor commits that appear in \"git log\" output would not give us what\nwe want.  We need a mechanism that notices and warns when a commit\nmakes a file, which used to end with a newline, end in an incomplete\nline.\n\nIf you can come up with a robust way to do so in check-whitespace\nscript, with the understanding that the right solution in the longer\nterm is to teach \"git log --check\" to notice incomplete lines and\nflag it (with core.whitespace configuration and the whitespace\nattributes to enable/disable the check), it might work as a stop-gap\nmeasure.  As I said elsewhere a few days ago, doing it right would\nbe a bit too big for a microproject.\n"},{"id":"528590","messageId":"CAD=f0L-QAfMhBw1_RyLkpdntjPfu4M+temmawWGEZjAJn_iQdQ@mail.gmail.com","threadId":"64301","inReplyTo":"xmqqecr95ib0.fsf@gitster.g","subject":"Re: [RFC Outreachy] Teach ci/check-whitespace to flag incomplete lines as an error","fromName":"Bello Olamide","fromEmail":"belkid98@gmail.com","sentAt":"2025-10-12T23:41:51Z","receivedAt":"2025-10-12T23:41:51Z","isPatch":false,"sender":{"key":"belkid98@gmail.com","avatar":"https://avatars.githubusercontent.com/u/73387291?v=4"},"body":"On Sat, 11 Oct 2025 at 20:50, Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Bello Caleb Olamide <belkid98@gmail.com> writes:\n>\n> > Hello,\n> >\n> > While going through the mailing list for some #leftoverbits, I stumbled on this converation.\n> > https://public-inbox.org/git/xmqqikla86id.fsf@gitster.g/.\n>\n> Welcome, and first please learn to keep your lines under readable\n> width limit.  As an applicant to a mentoring program with this\n> project, you will be exchanging e-mails about patches, whose\n> contents are limited to 80 columns (but subtracting 1 columns for\n> \"+/ /-\" prefix when a line is shown in a patch, plus several more\n> for \"> \" prefix when the message is quoted multiple times during a\n> discussion thread, a practical line-length limit is more like 68-72\n> columns), and you will be adding in-line comments in the middle of\n> quoted patches.\n>\n> Hence, your comments in e-mails thrown at this list are also limited\n> to similar line length limit.  Otherwise they would become very hard\n> to read.\n>\nHello Junio,\nThank you for your response. I will take these into account.\n\n> I'll line-wrap the quoted text below.\n>\n> > After studying the check-whitespace script, I observed that the\n> > script parses each line of the output of the command `git log\n> > --check --pretty=format:\"---% h% s\" \"${baseCommit}\"..` and formats\n> > the result.\n> >\n> > But the output of the git command itself does not flag '\\no\n> > newline at end of file' as it is shown in git diff, in a case\n> > where the files does not contain a newline at the end of the file.\n>\n> Correct observations.\n>\n> > One approach I propose to take is to check the each file changed\n> > in each commit and check if it has the \\n as the last character.\n>\n> If a commit changes line 4 of a 100-line file that lacked the final\n> newline, \"git log\" would show the commit, \"git log -p\" would show a\n> patch to the file, but \"\\No newline\" would not be shown, because the\n> commit is not responsible for introducing an incomplete line to the\n> file.  Looking at the last byte of \"git cat-file blob $commit:$path\"\n> for commits that appear in \"git log\" output would not give us what\n> we want.  We need a mechanism that notices and warns when a commit\n> makes a file, which used to end with a newline, end in an incomplete\n> line.\n\nThank you for the clarity. This would mean to compare the relevant files in the\ncurrent commit with its parent commit and report when the current commit removes\nthe new line at the end of file which was present in the parent commit.\n\nBut how about when a file is newly added and lacks the new line?\n\n>\n> If you can come up with a robust way to do so in check-whitespace\n> script, with the understanding that the right solution in the longer\n> term is to teach \"git log --check\" to notice incomplete lines and\n> flag it (with core.whitespace configuration and the whitespace\n> attributes to enable/disable the check), it might work as a stop-gap\n> measure.  As I said elsewhere a few days ago, doing it right would\n> be a bit too big for a microproject.\n\nThank you very much. I perfectly understand this now.\nThe right way would be the better way as we can just parse the output\nin check-whitespace and it will be more interesting to work on,\nas it would greatly increase my knowledge on Git internals.\nIf this would be too big for a microproject, I will look up\na task fitting for a microproject and then push forward with this.\n\nThank you for your time,\nBello\n"},{"id":"528635","messageId":"xmqqh5w23j3k.fsf@gitster.g","threadId":"64301","inReplyTo":"CAD=f0L-QAfMhBw1_RyLkpdntjPfu4M+temmawWGEZjAJn_iQdQ@mail.gmail.com","subject":"Re: [RFC Outreachy] Teach ci/check-whitespace to flag incomplete lines as an error","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-10-13T15:41:03Z","receivedAt":"2025-10-13T15:41:06Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Bello Olamide <belkid98@gmail.com> writes:\n\n>> we want.  We need a mechanism that notices and warns when a commit\n>> makes a file, which used to end with a newline, end in an incomplete\n>> line.\n>\n> Thank you for the clarity. This would mean to compare the relevant files in the\n> current commit with its parent commit and report when the current commit removes\n> the new line at the end of file which was present in the parent commit.\n>\n> But how about when a file is newly added and lacks the new line?\n\nYes, you should notice and flag any new incomplete line that did not\nexist before that are added by the commit.\n"}]}