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

Re: [PATCH v2 1/1] config: learn the "hostname:" includeIf condition

From
IRIgnacio Encinas Rubio <ignacio@iencinas.com>
Date
Mar 10, 2024, 18:46 UTC
Message-ID
<9fb02065-12d2-4c92-b1a5-74c06125c692@iencinas.com>
In-Reply-To
<xmqqy1aqvx9n.fsf@gitster.g>
On 10/3/24 17:59, Junio C Hamano wrote:
Show 14 quoted lines
> Ignacio Encinas <ignacio@iencinas.com> writes:
> 
>> +test_expect_success 'conditional include, hostname' '
>> +	cat >>.git/config <<-EOF &&
>> +	[includeIf "hostname:$(hostname)a"]
> 
> This unconditionally runs the $(hostname) command assuming it exists
> everywhere, but
> 
>     $ git grep '$(hostname' t/
>     t/t6500-gc.sh:	hostname=$(hostname || echo unknown) &&
> 
> tells us that we should be prepared to meet a platform where such a
> command does not exist.
Oops, it didn't even cross my mind. Thanks for the catch!
> I have a feeling that it is better done with a test prerequisite
> than hardcoded "unknown", as xgethostname() at C level may come up
> with some random string but it is not guaranteed to be "unknown".

I agree. Not being able to query the current hostname defeats the purpose of the tests.

Show 11 quoted lines
> Perhaps have one instance of this before these added tests
> 
> 	test_lazy_prereq WORKING_HOSTNAME '
> 		hostname >/dev/null 2>&1
> 	'
> 
> and then start them with
> 
> 	test_expect_success WORKING_HOSTNAME 'hostname: includeIf' '
> 		...
> 	'
 
Thanks for providing an example. 
> or something?  Others may think of a better way to make sure this
> test does not cause false failures on platforms only because they
> lack working hostname(1) but have a working gethostname(2) and their
> xgethostname() may be working fine.

I can't think of any room for improvement other than integrating hostname (or a custom hostname) into git and using it in the tests, but I doubt it is worth it.

> Thanks.

Thank you. I will wait a couple of days to post the v3 to see if anyone has a suggestion.

Previous: Junio C HamanoNext: Junio C Hamano
Message 9 of 51 in “Add hostname condition to includeIf”
  1. 0/1 Add hostname condition to includeIfIgnacio Encinas, Mar 7, 2024
  2. 1/1 config: learn the "hostname:" includeIf conditionIgnacio Encinas, Mar 7, 2024
  3. Junio C HamanoMar 7, 2024
  4. Ignacio Encinas RubioMar 9, 2024
  5. Junio C HamanoMar 9, 2024
  6. 0/1 Add hostname condition to includeIfIgnacio Encinas, Mar 9, 2024
  7. 1/1 config: learn the "hostname:" includeIf conditionIgnacio Encinas, Mar 9, 2024
  8. Junio C HamanoMar 10, 2024
  9. Ignacio Encinas RubioMar 10, 2024
  10. Junio C HamanoMar 11, 2024
  11. Ignacio Encinas RubioMar 13, 2024
  12. Jeff KingMar 16, 2024
  13. Ignacio Encinas RubioMar 16, 2024
  14. Taylor BlauMar 16, 2024
  15. Ignacio Encinas RubioMar 16, 2024
  16. Junio C HamanoMar 16, 2024
  17. rsbecker@nexbridge.comMar 16, 2024
  18. Ignacio Encinas RubioMar 16, 2024
  19. rsbecker@nexbridge.comMar 16, 2024
  20. Jeff KingMar 18, 2024
  21. Taylor BlauMar 16, 2024
  22. Ignacio Encinas RubioMar 16, 2024
  23. 0/2 Add hostname condition to includeIfIgnacio Encinas, Mar 19, 2024
  24. 1/2 t: add a test helper for getting hostnameIgnacio Encinas, Mar 19, 2024
  25. Junio C HamanoMar 19, 2024
  26. Jeff KingMar 19, 2024
  27. Junio C HamanoMar 19, 2024
  28. Jeff KingMar 19, 2024
  29. Junio C HamanoMar 19, 2024
  30. Chris TorekMar 21, 2024
  31. Jeff KingMar 19, 2024
  32. 2/2 config: learn the "hostname:" includeIf conditionIgnacio Encinas, Mar 19, 2024
  33. Junio C HamanoMar 19, 2024
  34. Jeff KingMar 19, 2024
  35. Ignacio Encinas RubioMar 19, 2024
  36. Eric SunshineMar 19, 2024
  37. Junio C HamanoMar 19, 2024
  38. Eric SunshineMar 19, 2024
  39. Jeff KingMar 20, 2024
  40. Eric SunshineMar 20, 2024
  41. Eric SunshineMar 20, 2024
  42. Chris TorekMar 20, 2024
  43. Eric SunshineMar 20, 2024
  44. Jeff KingMar 20, 2024
  45. Junio C HamanoMar 20, 2024
  46. Dirk GoudersMar 19, 2024
  47. rsbecker@nexbridge.comMar 19, 2024
  48. Dirk GoudersMar 19, 2024
  49. rsbecker@nexbridge.comMar 19, 2024
  50. Junio C HamanoMar 19, 2024
  51. Ignacio Encinas RubioMar 19, 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.