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

Re: [PATCH] gitweb: fixes to gitweb feature check code

From
Jakub Narebski <jnareb@gmail.com>
Date
Dec 2, 2008, 01:53 UTC
Message-ID
<200812020253.09430.jnareb@gmail.com>
In-Reply-To
<1228008844-12506-1-git-send-email-giuseppe.bilotta@gmail.com>
On Sun, 30 Nov 2008, Giuseppe Bilotta wrote:
Show 11 quoted lines
> The gitweb_check_feature routine was being used for two different
> purposes: retrieving the actual feature value (such as the list of
> snapshot formats or the list of additional actions), and checking if a
> feature was enabled.
> 
> This led to subtle bugs in feature checking code: gitweb_check_feature
> would return (0) for disabled features, so its use in scalar context
> would return true instead of false.
> 
> To fix this issue and future-proof the code, we split feature value
> retrieval into its own gitweb_get_feature()function , and ensure that
  retrieval into its own gitweb_get_feature() function, and ensure that
Show 10 quoted lines
> the boolean feature check function gitweb_check_feature() always returns
> a scalar (precisely, the first/only item in the feature value list).
> 
> Usage of gitweb_check_feature() across gitweb is replaced with
> gitweb_get_feature() where appropriate, and list evaluation of
> gitweb_check_feature() is demoted to scalar evaluation to prevent
> ambiguity. The few previously incorrect uses of gitweb_check_feature()
> in scalar context are left untouched because they are now correct.
> 
> Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Acked-by: Jakub Narebski <jnareb@gmail.com>

What I like about having all this, i.e. fix, futureproof and style correction in one single patch is the fact that fix doesn't introduce strange looking (gitweb_check_feature('bool_feat'))[0]... well, except encapsulated in a subroutine.

>From all possible splits of this feature into series of up to three

patches I think I like the one with pure subroutine rename from *check* to *get* least...

-- 
Jakub Narebski
Poland
Previous: Giuseppe BilottaNext: Giuseppe Bilotta
Message 15 of 26 in “[PATCHv2 0/2] fixes to gitweb feature check code”
  1. Giuseppe BilottaNov 28, 2008
  2. 1/2 gitweb: fixes to gitweb feature check codeGiuseppe Bilotta, Nov 28, 2008
  3. 2/2 gitweb: clean up git_check_feature() callsGiuseppe Bilotta, Nov 28, 2008
  4. 2/2 gitweb: clean up gitweb_check_feature() callsGiuseppe Bilotta, Nov 29, 2008
  5. Jakub NarebskiNov 29, 2008
  6. 2/2 gitweb: clean up gitweb_check_feature() callsGiuseppe Bilotta, Nov 29, 2008
  7. Junio C HamanoNov 29, 2008
  8. Junio C HamanoNov 29, 2008
  9. 2/3 gitweb: rename gitweb_check_feature to gitweb_get_featureJunio C Hamano, Nov 29, 2008
  10. 3/3 gitweb: make gitweb_check_feature a boolean wrapperJunio C Hamano, Nov 29, 2008
  11. Giuseppe BilottaNov 29, 2008
  12. Junio C HamanoNov 30, 2008
  13. Giuseppe BilottaNov 30, 2008
  14. gitweb: fixes to gitweb feature check codeGiuseppe Bilotta, Nov 30, 2008
  15. Jakub NarebskiDec 2, 2008
  16. [PATCHv3bis] gitweb: fixes to gitweb feature check codeGiuseppe Bilotta, Dec 2, 2008
  17. Junio C HamanoDec 3, 2008
  18. Junio C HamanoDec 2, 2008
  19. Jakub NarebskiDec 3, 2008
  20. Giuseppe BilottaNov 29, 2008
  21. Junio C HamanoNov 29, 2008
  22. Jakub NarebskiNov 29, 2008
  23. Jakub NarebskiNov 29, 2008
  24. Jakub NarebskiNov 30, 2008
  25. Jakub NarebskiNov 29, 2008
  26. Giuseppe BilottaNov 29, 2008

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.