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

Re: [PATCH 0/2] Trivial cleanups

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Jun 15, 2021, 08:22 UTC
Message-ID
<60c8632d60027_e633208db@natae.notmuch>
In-Reply-To
<xmqqbl87zyra.fsf@gitster.g>
Junio C Hamano wrote:
Show 7 quoted lines
> Felipe Contreras <felipe.contreras@gmail.com> writes:
> 
> > These perfeclty good patches from 2014 weren't picked with no good
> > reason.
> 
> These are safe no-op changes, but that does not mean they are good
> patches.

They are not good patches because they are no-op, they are good changes because they correct the flow of the code to match the flow in which most people think.

  18 is younger than Mary
is not a sentence most people would agree make sense.
> It goes against Documentation/CodingGuidelines to bring it
> back again now, which is a good enough reason not to look at them.

These are not style issues. Refactoring code to make it easier to understand goes beyond style.

Refactoring this:
	static int is_same_remote(struct remote *remote)
	{
		struct remote *fetch_remote = remote_get(NULL);
		return (!fetch_remote || fetch_remote == remote);
	}
	int same_remote = is_same_remote(remote);
To this:
	int same_remote = remote == remote_get(NULL);
Is more than just style.

But suit yourself. Sooner or later somebody is going to fix these glaring mistakes. And they are mistakes [1].

  Yoda conditions are widely criticized for compromising readability by
  increasing the cognitive load of reading the code.
Cheers.
[1] https://en.wikipedia.org/wiki/Yoda_conditions#Criticism
-- 
Felipe Contreras
Previous: Junio C Hamano
Message 5 of 5 in “Trivial cleanups”
  1. 0/2 Trivial cleanupsFelipe Contreras, Jun 13, 2021
  2. 1/2 config: avoid yoda conditionsFelipe Contreras, Jun 13, 2021
  3. 2/2 add: avoid yoda conditionFelipe Contreras, Jun 13, 2021
  4. Junio C HamanoJun 15, 2021
  5. Felipe ContrerasJun 15, 2021

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.