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

Re: ignore blank line removals

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 15, 2016, 18:51 UTC
Message-ID
<xmqqr36ctw47.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<CALj-rGdRDa0EU6AeMHWYketr5QBOnV7-3RKraiuPCk=Aepz=pQ@mail.gmail.com>
John Rood <mr.john.rood@gmail.com> writes:
Show 21 quoted lines
> On Thu, Nov 3, 2016 at 10:57 AM, John Rood <mr.john.rood@gmail.com> wrote:
>> If the contents of a file initially are:
>>   one
>>
>>   three
>> and on branch A there is a commit, removing the blank line:
>>   one
>>   three
>> and on branch B there is a commit, adding 'two':
>>   one
>>   two
>>   three
>> Normally, if you try to merge A into B (or B into A), git recognizes a
>> decision needs to be made between removing the second line or add
>> "two" to the second line. It would be convenient to have a merge
>> strategy that defaults to the latter in cases where the removed line
>> was a blank line (or a line containing only whitespace) ...something
>> like -Xignore-blank-line-removals.
>
> Is there any push-back on this, or is there a backlog that we can add
> this feature to?

If you mean by "push-back" objections that say "this feature is evil and should not be added to Git, ever", I do not think we saw any on the list. The lack of response is most likely that everybody thought "Meh." aka "It is not useful/interesting/valuable enough feature to bother discussing."

One thing I wondered was what you would want if the contents were one/three without blank, A added blank between the two and B replaced blank with two. As your example shows, in the filetype you are dealing with, a blank line has no significant meaning (otherwise you won't be ignoring the change A made to remove the blank in your original example). The outcome desired by you may be one/two/three without any blank in that case because of that. Which would lead to the suspicion that ignore-blank-line-removals is not a good general feature (i.e. in this other example, you want to ignore blank line addition). Which further leads to the suspicion that the desire you expressed in the original post is not well thought through to be a useful specifification to build anything out of (yet), but is merely a potentially interesting discussion starter. And nobody so far found it interesting enough to spend time discussing it further to make the wish detailed enough to be called a "design" of a new feature.

Having said all that.

I suspect that you may not have to make any change to Git to do what you want; can't you just use the 'merge' attribute with a custom 3-way merge driver that removes an empty line?

Previous: John RoodNext: John Rood
Message 3 of 4 in “ignore blank line removals”
  1. John RoodNov 3, 2016
  2. John RoodNov 15, 2016
  3. Junio C HamanoNov 15, 2016
  4. John RoodNov 15, 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.