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

Re: [PATCH v4] blame: print unblamable and ignored commits in porcelain mode

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Apr 2, 2025, 13:07 UTC
Message-ID
<494c9e59-b7b2-4a1c-ad41-3a7fc72503c9@gmail.com>
In-Reply-To
<CAOLa=ZQMYn2eYndX0saTKnuzAacjtNZeTb9PCrcNC50nneAq5g@mail.gmail.com>

[Restoring cc to the mailing list that I accidentally dropped in my previous message]

On 01/04/2025 17:57, Karthik Nayak wrote:
Show 51 quoted lines
> Phillip Wood <phillip.wood123@gmail.com> writes:
>> On 31/03/2025 16:25, Karthik Nayak wrote:
>>> phillip.wood123@gmail.com writes:
>>>> On 30/03/2025 21:43, Karthik Nayak wrote:
>>>>>
>>>>> +for opt in --porcelain --line-porcelain
>>>>> +do
>>>>> +	test_expect_success "mark_unblamable_lines with $opt" '
>>>>> +		sha=$(git rev-parse Y) &&
>>>>> +
>>>>> +		git -c blame.markUnblamableLines=false blame $opt --ignore-rev Y file >raw &&
>>>>> +		sed -e "s/^\ty3/unblamable\n&/" raw >expect &&
>>>>> +		cp expect raw &&
>>>>> +		sed -e "s/^\ty4/unblamable\n&/" raw >expect &&
>>>>
>>>> Thanks for improving the test. Unfortunately using '\n' in the
>>>> replacement text is not portable [1] (the normal backslash escapes are
>>>> allowed in the pattern though so the '\t' is fine). One has to write a
>>>> literal newline escaped with a backslash. However here we want to insert
>>>> a whole new line of text into the output without changing the original
>>>> so I would write it as
>>>
>>> Thanks for bringing this to my notice. I didn't know.
>>>
>>>>        sed -e "/^\ty3/a\\" -e unblamable -e "/^\ty4/a\\" -e unblamable \
>>>> 	raw >expect
>>>
>>> This appends 'unblamable' to the next line, but we want to prepend it.
>>
>> Sorry, I misread the original. If you use 'i' instead of 'a' that will
>> insert a new line before the current one.
> 
> Seems like this won't work either, since MacOS complains [1] about it:
> 
>    expecting success of 8013.16 'mark_ignored_lines with --line-porcelain':
>    		sha=$(git rev-parse Y) &&
>    		git -c blame.markIgnoredLines=false blame $opt --ignore-rev Z file >raw &&
>    		sed -e "/^	line-one-Z/i\\" -e ignored \
>    		    -e "/^	line-two-Z/i\\" -e ignored \
>    			raw >expect &&
>    		git -c blame.markIgnoredLines=true blame $opt --ignore-rev Z file >actual &&
>    		test_cmp expect actual
>    	
>    +++ git rev-parse Y
>    ++ sha=e0d35d6f2d5fab63267e58d684cea1ECG86f12b1
>    ++ git -c blame.markIgnoredLines=false blame --line-porcelain
> --ignore-rev Z file
>    ++ sed -e '/^	line-one-Z/i\' -e ignored -e '/^	line-two-Z/i\' -e ignored raw
>    sed: 1: "ignored
>    ": command i expects \ followed by text
>    error: last command exited with $?=1

Oh, that's a pain, I thought it was supposed to treat each '-e' as a separate line.

Show 11 quoted lines
> I did have success [2] with using a heredoc instead:
> 
> 	cat > sedscript <<- 'EOF' &&
> 	/^	y3/i\\
> 	unblamable
> 	/^	y4/i\\
> 	unblamable
> 	EOF
> 	sed -f sedscript raw >expect &&
> 
> What do you think about this?

I think that's the best way then. We could pass a multiline string with '-e' but then we wouldn't be able to indent the "unblamable" lines.

Best Wishes
Phillip
> [1]: https://gitlab.com/gitlab-org/git/-/jobs/9581456879
> [2]: https://gitlab.com/gitlab-org/git/-/pipelines/1746265204
Previous: Junio C Hamano
Message 28 of 28 in “blame: fix unblamable and ignored lines in porcelain mode”
  1. blame: fix unblamable and ignored lines in porcelain modeKarthik Nayak, Mar 21, 2025
  2. Junio C HamanoMar 23, 2025
  3. Patrick SteinhardtMar 24, 2025
  4. Toon ClaesMar 24, 2025
  5. Karthik NayakMar 24, 2025
  6. Toon ClaesMar 25, 2025
  7. Karthik NayakMar 25, 2025
  8. Junio C HamanoMar 25, 2025
  9. Karthik NayakMar 24, 2025
  10. Karthik NayakMar 24, 2025
  11. blame: print unblamable and ignored commits in porcelain modeKarthik Nayak, Mar 26, 2025
  12. Eric SunshineMar 26, 2025
  13. Karthik NayakMar 27, 2025
  14. Junio C HamanoMar 29, 2025
  15. Patrick SteinhardtMar 28, 2025
  16. Karthik NayakMar 29, 2025
  17. blame: print unblamable and ignored commits in porcelain modeKarthik Nayak, Mar 29, 2025
  18. Junio C HamanoMar 30, 2025
  19. Phillip WoodMar 30, 2025
  20. blame: print unblamable and ignored commits in porcelain modeKarthik Nayak, Mar 30, 2025
  21. Patrick SteinhardtMar 31, 2025
  22. Karthik NayakMar 31, 2025
  23. phillip.wood123@gmail.comMar 31, 2025
  24. Phillip WoodMar 31, 2025
  25. blame: print unblamable and ignored commits in porcelain modeKarthik Nayak, Apr 3, 2025
  26. Phillip WoodApr 4, 2025
  27. Junio C HamanoApr 8, 2025
  28. Phillip WoodApr 2, 2025

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.