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

Re: [PATCH 5/5] patch-id: tighten code to detect the patch header

From
Patrick Steinhardt <ps@pks.im>
Date
Jul 30, 2024, 05:12 UTC
Message-ID
<Zqh2Kije5omYzDPY@tanuki>
In-Reply-To
<ZqhyI7Ta9g_4AwfI@tanuki>
On Tue, Jul 30, 2024 at 06:55:14AM +0200, Patrick Steinhardt wrote:
Show 10 quoted lines
> On Mon, Jul 29, 2024 at 01:12:42PM -0700, Junio C Hamano wrote:
> > Patrick Steinhardt <ps@pks.im> writes:
> > > On Fri, Jun 21, 2024 at 04:18:26PM -0700, Junio C Hamano wrote:
> > "Skip non-diff garbage until we see a patch" is the mechanism used
> > to skip the log message, so it would be a reasonable thing to skip
> > such no-diff garbage between patches, no?
> 
> Oh, yes, it is reasonable. I just didn't quite figure out the flow of
> the above loop when reading through the code. As you say, it is somewhat
> convoluted and not all that straight forward.

As far as I can see we didn't have a test for this yet, so I did have a quick go at it to reassure myself that things work as expected before and after your change. Feel free to pick it up if you feel like it, or to just ignore it :)

Patrick
test_expect_success 'patch-id handles diffs with garbage in between' '
	cat >diff-with-garbage <<-\EOF &&
	$(git rev-parse HEAD)
	diff --git a/bar b/bar
	index bdaf90f..31051f6 100644
	--- a/bar
	+++ b/bar
	@@ -2 +2,2 @@
	 b
	+c
	some
	garbage
	lines
	$(git rev-parse HEAD)
	diff --git a/car b/car
	index 00750ed..2ae5e34 100644
	--- a/car
	+++ b/car
	@@ -1 +1,2 @@
	 3
	+d
	EOF
	cat >diff-without-garbage <<-\EOF &&
	$(git rev-parse HEAD)
	diff --git a/bar b/bar
	index bdaf90f..31051f6 100644
	--- a/bar
	+++ b/bar
	@@ -2 +2,2 @@
	 b
	+c
	$(git rev-parse HEAD)
	diff --git a/car b/car
	index 00750ed..2ae5e34 100644
	--- a/car
	+++ b/car
	@@ -1 +1,2 @@
	 3
	+d
	EOF
	for stable in true false
	do
		test_config patchid.stable $stable &&
		git patch-id <diff-with-garbage >id-with-garbage &&
		git patch-id <diff-without-garbage >id-without-garbage &&
		test_line_count -eq 2 id-with-garbage &&
		test_cmp id-with-garbage id-without-garbage ||
		return 1
	done
'
Previous: Patrick SteinhardtNext: Junio C Hamano
Message 11 of 20 in “Tighten patch header parsing in patch-id”
  1. 0/5 Tighten patch header parsing in patch-idJunio C Hamano, Jun 21, 2024
  2. 1/5 t4204: patch-id supports various input formatJunio C Hamano, Jun 21, 2024
  3. 2/5 patch-id: call flush_current_id() only when neededJunio C Hamano, Jun 21, 2024
  4. 3/5 patch-id: make get_one_patchid() more extensibleJunio C Hamano, Jun 21, 2024
  5. Patrick SteinhardtJul 29, 2024
  6. Junio C HamanoJul 29, 2024
  7. 5/5 patch-id: tighten code to detect the patch headerJunio C Hamano, Jun 21, 2024
  8. Patrick SteinhardtJul 29, 2024
  9. Junio C HamanoJul 29, 2024
  10. Patrick SteinhardtJul 30, 2024
  11. Patrick SteinhardtJul 30, 2024
  12. 4/5 patch-id: rewrite code that detects the beginning of a patchJunio C Hamano, Jun 21, 2024
  13. Patrick SteinhardtJul 29, 2024
  14. 0/5 Tighten patch header parsing in patch-idJunio C Hamano, Jul 30, 2024
  15. 1/5 t4204: patch-id supports various input formatJunio C Hamano, Jul 30, 2024
  16. 2/5 patch-id: call flush_current_id() only when neededJunio C Hamano, Jul 30, 2024
  17. 3/5 patch-id: make get_one_patchid() more extensibleJunio C Hamano, Jul 30, 2024
  18. 4/5 patch-id: rewrite code that detects the beginning of a patchJunio C Hamano, Jul 30, 2024
  19. 5/5 patch-id: tighten code to detect the patch headerJunio C Hamano, Jul 30, 2024
  20. Patrick SteinhardtJul 30, 2024

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.