public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Matthew Hughes <matthewhughes934@gmail•com>
To: git@vger•kernel.org
Cc: Matthew Hughes <matthewhughes934@gmail•com>,
	 Derrick Stolee <stolee@gmail•com>
Subject: [PATCH 1/2] scalar: add comments when setting config
Date: Sat, 29 Nov 2025 17:22:18 +0000	[thread overview]
Message-ID: <20251129172124.4164-2-matthewhughes934@gmail.com> (raw)
In-Reply-To: <20251129172124.4164-1-matthewhughes934@gmail.com>

This is to help users understand that a change in the config was made by
`scalar` (and not e.g. manually by themselves at some point in the
past).

As discussed on a thread[1].

Link: https://lore.kernel.org/git/aMkVqNbdgxqBJ9K4@pks.im/ [1]
Co-authored-by: Derrick Stolee <stolee@gmail•com>
---
 scalar.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/scalar.c b/scalar.c
index f754311627..4bdf8cf121 100644
--- a/scalar.c
+++ b/scalar.c
@@ -19,6 +19,7 @@
 #include "help.h"
 #include "setup.h"
 #include "trace2.h"
+#include "path.h"
 
 static void setup_enlistment_directory(int argc, const char **argv,
 				       const char * const *usagestr,
@@ -102,8 +103,11 @@ static int set_scalar_config(const struct scalar_config *config, int reconfigure
 
 	if ((reconfigure && config->overwrite_on_reconfigure) ||
 	    repo_config_get_string(the_repository, config->key, &value)) {
+		char *cfg_file = repo_git_path(the_repository, "config");
+		const char *comment = " # set by git-scalar";
 		trace2_data_string("scalar", the_repository, config->key, "created");
-		res = repo_config_set_gently(the_repository, config->key, config->value);
+		res = repo_config_set_in_file_gently(the_repository, cfg_file, config->key, comment, config->value);
+		free(cfg_file);
 	} else {
 		trace2_data_string("scalar", the_repository, config->key, "exists");
 		res = 0;
-- 
2.51.0


  reply	other threads:[~2025-11-29 17:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-29 17:21 [PATCH 0/2] Update documentation/discoverability around `scalar` Matthew Hughes
2025-11-29 17:22 ` Matthew Hughes [this message]
2025-11-29 17:22 ` [PATCH 2/2] config: document `gui.GCWarning` Matthew Hughes
2025-11-29 18:03 ` [PATCH 0/2] Update documentation/discoverability around `scalar` Kristoffer Haugsbakk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251129172124.4164-2-matthewhughes934@gmail.com \
    --to=matthewhughes934@gmail$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=stolee@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox