git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git add without whitespace

From
Junio C Hamano <gitster@pobox.com>
Date
May 30, 2016, 22:00 UTC
Message-ID
<xmqq8tyr8aur.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<CAHd499Drdt6GoScdksNNWLrsvG3Dex7fTYNhatL-qboCPW5RZQ@mail.gmail.com>
Robert Dailey <rcdailey.lists@gmail.com> writes:
> I like your solution better than mine because it utilizes the rules
> defined in .gitattributes.

A difference that may be more important is that I do not do generation of a patch or application of it without ignoring whitespaces with things like -w and --ignore-whitespace. That way, if my edit is a correction of existing whitespace breakage (e.g. I noticed a line that is indented by 8 spaces, and I corrected it by replacing them with one tab), that is shown as a change by "diff" and kept in the result. I suspect that your "diff -w | apply --ignore" will ignore that manual fix?

> What does the checkout at the end do? That part confuses me (granted
> I'm not well-versed with bash script).

I correct whitespace-broken updates the user (i.e. I) made in her working tree file by adding a corrected version to the index, and then I checkout the result out of the index to the working tree.

That corrects the breakage in both the index and the working tree, so that my further edit to the file will start from a ws-corrected version.

Previous: Robert DaileyNext: Robert Dailey
Message 4 of 8 in “git add without whitespace”
  1. Robert DaileyMay 30, 2016
  2. Junio C HamanoMay 30, 2016
  3. Robert DaileyMay 30, 2016
  4. Junio C HamanoMay 30, 2016
  5. Robert DaileyMay 31, 2016
  6. Junio C HamanoMay 31, 2016
  7. Christian NeukirchenMay 31, 2016
  8. demerphqMay 31, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.