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

Re: [PATCH v3 1/3] gitweb: fix #patchNN anchors when path_info is enabled

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 18, 2011, 16:57 UTC
Message-ID
<7v7hbwxt7e.fsf@alter.siamese.dyndns.org>
In-Reply-To
<201103181359.46600.jnareb@gmail.com>
Jakub Narebski <jnareb@gmail.com> writes:
Show 9 quoted lines
> I like v2 version, and had only small corrections.  For you to not have
> to resend this patch once again, I have added those corrections and sent
> them as a patch myself.
>
> Changes from original v2 version from Kevin Cernekee:
>
> * Fix (re-add) accidentally lost in v2 '"<td class=\"link\">"' in first
>   chunk using href(-anchor => ...)
> * Reword commit message (hopefully make it better, and not only longer)
Thanks.
> * Move code that sets implicit -replay when -anchor is the only parameter
>   lower, and change order of subexpression, for better possible future
>   extendability, if there would be other cases when we would want to 
>   automatically turn on -replay.
I think you meant this part:
	# implicit -replay
	$params{-replay} = 1 if (keys %params == 1 && $params{-anchor});

But I don't think it is that much of an improvement as long as it uses the statement modifier syntax ("A if B") for a thing like this.

I will not bother rewriting the commit I made out of this patch myself, but the next person who wants to add the auto-replay for his option will first have to rewrite the above into:

	if (key %params == 1 && $params{-anchor}) {
		$params{-replay} = 1;
	}
before turning it into:
	if ((key %params == 1 && $params{-anchor}) ||
	    ("here comes my new condition")) {
		$params{-replay} = 1;
	}

anyway. If your rewrite were to a plain-vanilla "if () { ... }", it would have been a real improvement.

Besides, I find it a bad taste to use statement modifier syntax unless the modifying condition ("if B" part) is much more likely to hold true than false.

If you limit your use of statement modifiers for conditions that almost always hold true, it will become much easier to scan the code for the first time, because you can skim through and almost ignore the condition part to follow the logic for the normal case. But turning 'replay' on in a specific narrow case (and later in a specific set of narrow cases) is a complete opposite of normal codeflow.

Anyway, thanks for the clean-up.  Applied.
Previous: Jakub NarebskiNext: Jakub Narebski
Message 16 of 17 in “gitweb: fix #patchNN anchors when path_info is enabled”
  1. 1/3 gitweb: fix #patchNN anchors when path_info is enabledKevin Cernekee, Mar 17, 2011
  2. 2/3 gitweb: introduce localtime featureKevin Cernekee, Mar 17, 2011
  3. 2/3 gitweb: introduce localtime featureJakub Narebski, Mar 18, 2011
  4. Junio C HamanoMar 18, 2011
  5. Jakub NarebskiMar 18, 2011
  6. Junio C HamanoMar 18, 2011
  7. 3/3 gitweb: show alternate author/committer timesKevin Cernekee, Mar 17, 2011
  8. 3/3 gitweb: Mark "atnight" author/committer times also for 'localtime'Jakub Narebski, Mar 18, 2011
  9. Kevin CernekeeMar 18, 2011
  10. Junio C HamanoMar 18, 2011
  11. Jakub NarebskiMar 18, 2011
  12. Junio C HamanoMar 19, 2011
  13. 1/3 gitweb: fix #patchNN anchors when path_info is enabledJakub Narebski, Mar 18, 2011
  14. Kevin CernekeeMar 18, 2011
  15. 1/3 gitweb: fix #patchNN anchors when path_info is enabledJakub Narebski, Mar 18, 2011
  16. Junio C HamanoMar 18, 2011
  17. Jakub NarebskiMar 18, 2011

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.