Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow git config to append a comment after a newly-added/-set/-replaced value #1680

Closed
dscho opened this issue Mar 1, 2024 · 3 comments
Closed
Labels
good first issue Good for newcomers

Comments

@dscho
Copy link
Member

dscho commented Mar 1, 2024

It is all nice and good to be able to call git config this.that something to configure something programmatically, but there is no way to leave a comment right now. It would be nice to say something like git config --comment="I added this. -- banksy" this.that something and end up with a config containing this:

[this]
  that = something # I added this. -- banksy

To accomplish this, one would need to:

  • modify the write_pair() function, adding another function parameter (const char *comment?) that is then also appended to &sb, if non-NULL
  • modify the function signature of git_config_set_multivar_in_file_gently() to accept the same parameter, adjusting all its callers to simply pass NULL
  • pass this parameter in the two callers of write_pair() in the git_config_set_multivar_in_file_gently() function (#1, #2
  • append a new file-local variable to builtin/config.c's list of file-local variables and add a command-line option to git config's, then ensuring that cmd_config() verifies that this option is only used in conjunction with ACTION_SET_ALL, ACTION_ADD or ACTION_REPLACE_ALL, otherwise error out with an error message
  • modify cmd_config() to pass the comment to git_config_set_multivar_in_file_gently() when setting/adding/replacing (#1, #2, #3; there are two more callers, but they are unsetters)
  • document the option in Documentation/git-config.txt
  • add a test case to t/t1300-config.sh.

See also https://discord.com/channels/1042895022950994071/1213052410281467906/1213052410281467906

@dscho dscho added the good first issue Good for newcomers label Mar 1, 2024
@rseichter
Copy link

Thank you for taking the time to write up this issue. I didn't expect my question in Discord and our subsequent brief discussion to lead us here, but surprises do happen. 😉

@rseichter
Copy link

@dscho I took my first baby steps in #1681. Your hints were very useful, and I only made modifications in a small number of additional places the compiler complained about. My manual tests worked, but before I invest more time in updating docs and the Git test suite, I'd like to hear your take on the changes I made so far. Cheers.

@dscho dscho linked a pull request Mar 3, 2024 that will close this issue
@LemmingAvalanche
Copy link

PR closed since this is in master 3256584 (Merge branch 'rs/config-comment', 2024-04-05)

I guess this can be closed?

@dscho dscho closed this as completed Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants