Thread (35 messages) 35 messages, 4 authors, 4d ago

Re: [PATCH 1/7] hash: use git_hash_init() consistently

From: Junio C Hamano <hidden>
Date: 2026-07-07 20:17:51

Jeff King [off-list ref] writes:
On Tue, Jul 07, 2026 at 07:39:24AM -0700, Junio C Hamano wrote:
quoted
quoted
diff --git a/object-file.c b/object-file.c
index e3c68cfb66..f292683c2d 100644
--- a/object-file.c
+++ b/object-file.c
...
-	algo->init_fn(c);
-	if (compat && compat_c)
-		compat->init_fn(compat_c);
+	git_hash_init(c, algo);
+	if (compat && compat_c) {
+		git_hash_init(compat_c, compat);
+	}
For example, it is a mystery how Coccinelle decided to add a pair of
braces around this single statement.  It should be obvious that the
corresponding single statement in the original did not need one.
Yeah, I noticed that coccinelle was eager to add braces in a few cases,
but I'm not sure why.

I had actually removed them, but either I missed these two, or more
likely I ended up re-applying the semantic patch a final time before
committing (I did a lot of "reset --hard; make hash.cocci.patch && git
apply hash.cocci.patch" while testing various refactors of the patch
itself).

I'll drop them in v2. Thanks for reading carefully.
Thanks.

If we run cocci twice, the second time it should be idempotent,
right?  So running it once, fixing these braces and then running it
again would not make us see the extra braces in the result, I guess.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help