Thread (28 messages) flat view 28 messages, 4 authors, 1d ago

Re: [PATCH v4 2/3] advice: introduce advice scoping mechanism

From: Junio C Hamano <hidden>
Date: 2026-09-10 15:37:02

Vsevolod Myalitsin [off-list ref] writes:
quoted hunk ↗ jump to hunk
@@ -109,8 +117,21 @@ static void vadvise(const char *advice,
 	strbuf_vaddf(&buf, advice, params);
 
 	if (setting && setting->level == ADVICE_LEVEL_NONE) {
+		const char *scope = "";
+		switch (setting->scope_hint) {
+		case CONFIG_SCOPE_LOCAL:
+		case CONFIG_SCOPE_UNKNOWN:
+			break;
+		case CONFIG_SCOPE_GLOBAL:
+			scope = " --global";
+			break;
+		case CONFIG_SCOPE_SYSTEM:
+			scope = " --system";
+			break;
+		}
make DEVELOPER=YesPlease would die due to

advice.c: In function 'vadvise':
advice.c:123:17: error: enumeration value 'CONFIG_SCOPE_WORKTREE' not handled in switch [-Werror=switch]
  123 |                 switch (setting->scope_hint) {
      |                 ^~~~~~
advice.c:123:17: error: enumeration value 'CONFIG_SCOPE_COMMAND' not handled in switch [-Werror=switch]
advice.c:123:17: error: enumeration value 'CONFIG_SCOPE_SUBMODULE' not handled in switch [-Werror=switch]

We probably should have

		default:
			BUG("advice settings at wrong config scope");

or something there.
 		strbuf_addf(&buf, turn_off_instructions,
-					setting->key);
+				scope, setting->key);
+	}
 
 	for (cp = buf.buf; *cp; cp = np) {
 		np = strchrnul(cp, '\n');
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help