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

Re: [PATCH 2/5] repo-settings: add feature.manyCommits setting

From
Derrick Stolee <stolee@gmail.com>
Date
Jul 24, 2019, 10:41 UTC
Message-ID
<bd96b1f1-3369-e130-dbed-8634589cd8e3@gmail.com>
In-Reply-To
<nycvar.QRO.7.76.6.1907231544200.21907@tvgsbejvaqbjf.bet>
On 7/23/2019 10:53 AM, Johannes Schindelin wrote:
Show 65 quoted lines
> Hi Stolee,
> 
> On Mon, 22 Jul 2019, Derrick Stolee via GitGitGadget wrote:
> 
>> From: Derrick Stolee <dstolee@microsoft.com>
>>
>> When a repo has many commits, it is helpful to write and read the
>> commit-graph file. Future changes to Git may include new config
>> settings that are benefitial in this scenario.
> 
> s/benefitial/beneficial/
> 
>>
>> Create the 'feature.manyCommits' config setting that changes the
>> default values of 'core.commitGraph' and 'gc.writeCommitGraph' to
>> true.
> 
> Great!
> 
>> diff --git a/repo-settings.c b/repo-settings.c
>> index 13a9128f62..f328602fd7 100644
>> --- a/repo-settings.c
>> +++ b/repo-settings.c
>> @@ -3,10 +3,17 @@
>>  #include "config.h"
>>  #include "repo-settings.h"
>>
>> +#define UPDATE_DEFAULT(s,v) do { if (s == -1) { s = v; } } while(0)
>> +
>>  static int git_repo_config(const char *key, const char *value, void *cb)
>>  {
>>  	struct repo_settings *rs = (struct repo_settings *)cb;
>>
>> +	if (!strcmp(key, "feature.manycommits")) {
>> +		UPDATE_DEFAULT(rs->core_commit_graph, 1);
>> +		UPDATE_DEFAULT(rs->gc_write_commit_graph, 1);
>> +		return 0;
>> +	}
>>  	if (!strcmp(key, "core.commitgraph")) {
>>  		rs->core_commit_graph = git_config_bool(key, value);
>>  		return 0;
> 
> Okay, this one is tricky. The behavior I would want is for
> `feature.manycommits` to override the _default_. And if I set
> `feature.manycommits = false` (e.g. via `git -c
> feature.manycommits=false ...`), I would want the default to "go back".
> 
> So I'd really rather see this as
> 
> 	if (!repo_config_get_bool(r, "feature.manycommits", &b) && b) {
> 		rs->core_commit_graph = 1;
> 		rs->gc_write_commit_graph = 1;
> 	}
> 
> 	[...]
> 
> 	repo_config_get_bool(r, "core.commitgraph", &rs->core_commit_graph);
> 
> I.e. override the default only if `feature.manyCommits` was true *in the
> end*.
> 
> In any case, we really need to make sure to handle the `= false` case
> correctly here. We might want to override the setting from the
> command-line, or it might be set in `~/.gitconfig` and need to be
> overridden in a local repository. We need to handle it.
I had forgotten about this interaction. Thanks for finding it!

The way I would fix it is to add an "int feature_many_commits" to the repo_settings struct, then check its value at the very end of prepare_repo_settings() and then UPDATE_DEFAULT() for the settings we want.

Thanks! -Stolee

Previous: Johannes SchindelinNext: Derrick Stolee via GitGitGadget
Message 7 of 61 in “Create 'feature.*' config area and some centralized config parsing”
  1. 0/5 Create 'feature.*' config area and some centralized config parsingDerrick Stolee via GitGitGadget, Jul 22, 2019
  2. 3/5 repo-settings: parse core.untrackedCacheDerrick Stolee via GitGitGadget, Jul 22, 2019
  3. Johannes SchindelinJul 23, 2019
  4. Derrick StoleeJul 24, 2019
  5. 2/5 repo-settings: add feature.manyCommits settingDerrick Stolee via GitGitGadget, Jul 22, 2019
  6. Johannes SchindelinJul 23, 2019
  7. Derrick StoleeJul 24, 2019
  8. 4/5 repo-settings: create feature.manyFiles settingDerrick Stolee via GitGitGadget, Jul 22, 2019
  9. 1/5 repo-settings: consolidate some config settingsDerrick Stolee via GitGitGadget, Jul 22, 2019
  10. Johannes SchindelinJul 23, 2019
  11. 5/5 repo-settings: create feature.experimental settingDerrick Stolee via GitGitGadget, Jul 22, 2019
  12. Johannes SchindelinJul 23, 2019
  13. Derrick StoleeJul 25, 2019
  14. 0/5 Create 'feature.*' config area and some centralized config parsingDerrick Stolee via GitGitGadget, Jul 25, 2019
  15. 1/5 repo-settings: consolidate some config settingsDerrick Stolee via GitGitGadget, Jul 25, 2019
  16. Johannes SchindelinJul 25, 2019
  17. 2/5 repo-settings: add feature.manyCommits settingDerrick Stolee via GitGitGadget, Jul 25, 2019
  18. 3/5 repo-settings: parse core.untrackedCacheDerrick Stolee via GitGitGadget, Jul 25, 2019
  19. Johannes SchindelinJul 25, 2019
  20. 4/5 repo-settings: create feature.manyFiles settingDerrick Stolee via GitGitGadget, Jul 25, 2019
  21. 5/5 repo-settings: create feature.experimental settingDerrick Stolee via GitGitGadget, Jul 25, 2019
  22. Johannes SchindelinJul 25, 2019
  23. 0/5 Create 'feature.*' config area and some centralized config parsingDerrick Stolee via GitGitGadget, Jul 30, 2019
  24. 2/5 repo-settings: add feature.manyCommits settingDerrick Stolee via GitGitGadget, Jul 30, 2019
  25. Junio C HamanoJul 30, 2019
  26. Johannes SchindelinJul 31, 2019
  27. Junio C HamanoJul 31, 2019
  28. Ævar Arnfjörð BjarmasonJul 31, 2019
  29. Derrick StoleeAug 1, 2019
  30. 1/5 repo-settings: consolidate some config settingsDerrick Stolee via GitGitGadget, Jul 30, 2019
  31. Junio C HamanoJul 30, 2019
  32. 4/5 repo-settings: create feature.manyFiles settingDerrick Stolee via GitGitGadget, Jul 30, 2019
  33. 5/5 repo-settings: create feature.experimental settingDerrick Stolee via GitGitGadget, Jul 30, 2019
  34. Elijah NewrenAug 8, 2019
  35. Derrick StoleeAug 8, 2019
  36. Junio C HamanoAug 8, 2019
  37. Derrick StoleeAug 8, 2019
  38. Elijah NewrenAug 8, 2019
  39. Derrick StoleeAug 8, 2019
  40. Elijah NewrenAug 8, 2019
  41. Junio C HamanoAug 8, 2019
  42. Derrick StoleeAug 8, 2019
  43. 3/5 repo-settings: parse core.untrackedCacheDerrick Stolee via GitGitGadget, Jul 30, 2019
  44. 0/6 Create 'feature.*' config area and some centralized config parsingDerrick Stolee via GitGitGadget, Aug 13, 2019
  45. 2/6 t6501: use 'git gc' in quiet modeDerrick Stolee via GitGitGadget, Aug 13, 2019
  46. 1/6 repo-settings: consolidate some config settingsDerrick Stolee via GitGitGadget, Aug 13, 2019
  47. 4/6 repo-settings: parse core.untrackedCacheDerrick Stolee via GitGitGadget, Aug 13, 2019
  48. 5/6 repo-settings: create feature.manyFiles settingDerrick Stolee via GitGitGadget, Aug 13, 2019
  49. 3/6 commit-graph: turn on commit-graph by defaultDerrick Stolee via GitGitGadget, Aug 13, 2019
  50. Junio C HamanoSep 20, 2021
  51. brian m. carlsonSep 20, 2021
  52. Phillip WoodSep 20, 2021
  53. Ævar Arnfjörð BjarmasonSep 20, 2021
  54. Jeff KingSep 20, 2021
  55. Phillip WoodSep 20, 2021
  56. Ævar Arnfjörð BjarmasonSep 20, 2021
  57. 6/6 repo-settings: create feature.experimental settingDerrick Stolee via GitGitGadget, Aug 13, 2019
  58. Junio C HamanoAug 13, 2019
  59. Junio C HamanoAug 13, 2019
  60. Derrick StoleeAug 14, 2019
  61. Derrick StoleeAug 14, 2019

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.