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

Re: [PATCH 1/2] Allow git-apply to fix up the line counts

From
Johannes Sixt <j.sixt@viscovery.net>
Date
Jun 5, 2008, 14:13 UTC
Message-ID
<4847F49F.8090004@viscovery.net>
In-Reply-To
<alpine.DEB.1.00.0806051441560.21190@racer>
Johannes Schindelin schrieb:
Show 31 quoted lines
> Hi,
> 
> On Thu, 5 Jun 2008, Johannes Sixt wrote:
> 
>> Johannes Schindelin schrieb:
>>
>>> On Thu, 5 Jun 2008, Johannes Sixt wrote:
>>>
>>>> Johannes Schindelin schrieb:
>>>>> +--fixup-line-counts::
>>>>> +	Fix up the line counts (e.g. after editing the patch without
>>>>> +	adjusting the hunk headers appropriately).
>>>>>
>>>> This sort of implies that there is some kind of output that tells the 
>>>> correct line counts. But that isn't the case (if I read the patch 
>>>> correctly). So I suggest to name the option --ignore-line-counts.
>>> But there is some kind of output: the hunks themselves.
>> Is there?
> 
> Yes!
> 
>> I did this (it rewrites all line counts to 1):
>>
>> $ git diff ..HEAD~1 |
>> 	sed -e '/^@@/s/,[0-9]+ /,1 /g' |
>> 	./git-apply --fixup-line-counts
>>
>> and there was no output. Instead, the patch was applied.
> 
> As I said, the data is in the _hunks_, but I maybe should have added _not 
> in the hunk headers_.
Yes, of course.
> So in a very real sense, you edit the hunks, and the hunk headers are 
> adjusted to that.  You did not adjust the hunks, so they got applied.
Yes, of course.

But the example pretends that the hunks have been edited so heavily that they in no way match the line counts in the hunk headers.

> It seems that you think the hunk header's line counts are heeded, and the 
> hunk adjusted, with --fixup-line-counts?
NO, of course *NOT*.
>  Sorry, I find that rather 
> counterintuitive.
So would I.
Show 7 quoted lines
>>>  And the line counts are not ignored, but they are actively rewritten.
>> Of course, internally there is some sort of "output" from the fixup 
>> routine, and the line counts are rewritten and then are not ignored. But 
>> the user doesn't care about this internal procedure. From the user's 
>> perspective, the line counts of the input patch are ignored.
> 
> But they are not!
> There are _two_ things that are the line counts.  Those numbers in the 
> hunk header, and the real line counts of the hunks.
And I was always talking about the numbers in the hunk headers.
> Now, if you say they are _ignored_, would that not imply in plain English 
> that they are left unchanged (in limbo, because those two types of numbers 
> contradict each other)?

That you *internally* rewrite those numbers and then do *not* ignore them is totally pointless for the user. It's an implementation detail. The user doesn't see what is going on nor should he care. From the user's perspective, the hunk header line counts are _ignored_ (because if they were not ignored, then there would be an error message in the contradicting case).

> Okay, how about shikebedding this to --adjust-line-counts?
>From the user's perspective, nothing is "adjusted"; the hunk header line
counts are ... you guess it ... *ignored*.
-- Hannes
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 7 of 39 in “Allow git-apply to fix up the line counts”
  1. 1/2 Allow git-apply to fix up the line countsJohannes Schindelin, Jun 5, 2008
  2. 2/2 git-add: introduce --edit (to edit the diff vs. the index)Johannes Schindelin, Jun 5, 2008
  3. Johannes SixtJun 5, 2008
  4. Johannes SchindelinJun 5, 2008
  5. Johannes SixtJun 5, 2008
  6. Johannes SchindelinJun 5, 2008
  7. Johannes SixtJun 5, 2008
  8. Johannes SchindelinJun 5, 2008
  9. Johannes SixtJun 5, 2008
  10. 0/2 git add --editJohannes Schindelin, Jun 5, 2008
  11. 1/2 Allow git-apply to ignore the hunk headersJohannes Schindelin, Jun 5, 2008
  12. Junio C HamanoJun 5, 2008
  13. Johannes SchindelinJun 5, 2008
  14. 0/2 git add --editJohannes Schindelin, Jun 5, 2008
  15. 1/2 Allow git-apply to ignore the hunk headers (AKA recountdiff)Johannes Schindelin, Jun 5, 2008
  16. Junio C HamanoJun 6, 2008
  17. Johannes SchindelinJun 6, 2008
  18. Junio C HamanoJun 6, 2008
  19. Junio C HamanoJun 6, 2008
  20. Johannes SchindelinJun 6, 2008
  21. Junio C HamanoJun 6, 2008
  22. Johannes SchindelinJun 6, 2008
  23. Govind SalinasJun 6, 2008
  24. Johannes SchindelinJun 6, 2008
  25. 2/2 git-add: introduce --edit (to edit the diff vs. the index)Johannes Schindelin, Jun 5, 2008
  26. Olivier MarinJun 6, 2008
  27. Johannes SchindelinJun 6, 2008
  28. Junio C HamanoJun 6, 2008
  29. Johannes SchindelinJun 6, 2008
  30. Junio C HamanoJun 5, 2008
  31. Johannes SchindelinJun 5, 2008
  32. Paolo BonziniJun 6, 2008
  33. Johannes SchindelinJun 6, 2008
  34. Sergei OrganovJun 6, 2008
  35. Johannes SchindelinJun 6, 2008
  36. Junio C HamanoJun 6, 2008
  37. 2/2 git-add: introduce --edit (to edit the diff vs. the index)Johannes Schindelin, Jun 5, 2008
  38. Pieter de BieJun 5, 2008
  39. Junio C HamanoJun 5, 2008

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.