@@ -108,18 +108,20 @@ static int run_git(const char *arg, ...)
108108 return res ;
109109}
110110
111- static int set_recommended_config (void )
111+ static int set_recommended_config (int reconfigure )
112112{
113113 struct {
114114 const char * key ;
115115 const char * value ;
116+ int overwrite_on_reconfigure ;
116117 } config [] = {
117- { "am.keepCR" , "true" },
118- { "core.FSCache" , "true" },
119- { "core.multiPackIndex" , "true" },
120- { "core.preloadIndex" , "true" },
118+ /* Required */
119+ { "am.keepCR" , "true" , 1 },
120+ { "core.FSCache" , "true" , 1 },
121+ { "core.multiPackIndex" , "true" , 1 },
122+ { "core.preloadIndex" , "true" , 1 },
121123#ifndef WIN32
122- { "core.untrackedCache" , "true" },
124+ { "core.untrackedCache" , "true" , 1 },
123125#else
124126 /*
125127 * Unfortunately, Scalar's Functional Tests demonstrated
@@ -133,28 +135,29 @@ static int set_recommended_config(void)
133135 * Therefore, with a sad heart, we disable this very useful
134136 * feature on Windows.
135137 */
136- { "core.untrackedCache" , "false" },
138+ { "core.untrackedCache" , "false" , 1 },
137139#endif
138- { "core.logAllRefUpdates" , "true" },
139- { "credential.https://dev.azure.com.useHttpPath" , "true" },
140- { "credential.validate" , "false" }, /* GCM4W-only */
141- { "gc.auto" , "0" },
142- { "gui.GCWarning" , "false" },
143- { "index.threads" , "true" },
144- { "index.version" , "4" },
145- { "merge.stat" , "false" },
146- { "merge.renames" , "true" },
147- { "pack.useBitmaps" , "false" },
148- { "pack.useSparse" , "true" },
149- { "receive.autoGC" , "false" },
150- { "reset.quiet" , "true" },
151- { "feature.manyFiles" , "false" },
152- { "feature.experimental" , "false" },
153- { "fetch.unpackLimit" , "1" },
154- { "fetch.writeCommitGraph" , "false" },
140+ { "core.logAllRefUpdates" , "true" , 1 },
141+ { "credential.https://dev.azure.com.useHttpPath" , "true" , 1 },
142+ { "credential.validate" , "false" , 1 }, /* GCM4W-only */
143+ { "gc.auto" , "0" , 1 },
144+ { "gui.GCWarning" , "false" , 1 },
145+ { "index.threads" , "true" , 1 },
146+ { "index.version" , "4" , 1 },
147+ { "merge.stat" , "false" , 1 },
148+ { "merge.renames" , "true" , 1 },
149+ { "pack.useBitmaps" , "false" , 1 },
150+ { "pack.useSparse" , "true" , 1 },
151+ { "receive.autoGC" , "false" , 1 },
152+ { "reset.quiet" , "true" , 1 },
153+ { "feature.manyFiles" , "false" , 1 },
154+ { "feature.experimental" , "false" , 1 },
155+ { "fetch.unpackLimit" , "1" , 1 },
156+ { "fetch.writeCommitGraph" , "false" , 1 },
155157#ifdef WIN32
156- { "http.sslBackend" , "schannel" },
158+ { "http.sslBackend" , "schannel" , 1 },
157159#endif
160+ /* Optional */
158161 { "status.aheadBehind" , "false" },
159162 { "commitGraph.generationVersion" , "1" },
160163 { "core.autoCRLF" , "false" },
@@ -166,7 +169,8 @@ static int set_recommended_config(void)
166169 char * value ;
167170
168171 for (i = 0 ; config [i ].key ; i ++ ) {
169- if (git_config_get_string (config [i ].key , & value )) {
172+ if ((reconfigure && config [i ].overwrite_on_reconfigure ) ||
173+ git_config_get_string (config [i ].key , & value )) {
170174 trace2_data_string ("scalar" , the_repository , config [i ].key , "created" );
171175 if (git_config_set_gently (config [i ].key ,
172176 config [i ].value ) < 0 )
@@ -231,7 +235,7 @@ static int register_dir(void)
231235 int res = add_or_remove_enlistment (1 );
232236
233237 if (!res )
234- res = set_recommended_config ();
238+ res = set_recommended_config (0 );
235239
236240 if (!res )
237241 res = toggle_maintenance (1 );
@@ -419,7 +423,7 @@ static int cmd_clone(int argc, const char **argv)
419423 (res = run_git ("sparse-checkout" , "init" , "--cone" , NULL )))
420424 goto cleanup ;
421425
422- if (set_recommended_config ())
426+ if (set_recommended_config (0 ))
423427 return error (_ ("could not configure '%s'" ), dir );
424428
425429 if ((res = run_git ("fetch" , "--quiet" , "origin" , NULL ))) {
@@ -484,6 +488,24 @@ static int cmd_register(int argc, const char **argv)
484488 return register_dir ();
485489}
486490
491+ static int cmd_reconfigure (int argc , const char * * argv )
492+ {
493+ struct option options [] = {
494+ OPT_END (),
495+ };
496+ const char * const usage [] = {
497+ N_ ("scalar reconfigure [<enlistment>]" ),
498+ NULL
499+ };
500+
501+ argc = parse_options (argc , argv , NULL , options ,
502+ usage , 0 );
503+
504+ setup_enlistment_directory (argc , argv , usage , options , NULL );
505+
506+ return set_recommended_config (1 );
507+ }
508+
487509static int cmd_run (int argc , const char * * argv )
488510{
489511 struct option options [] = {
@@ -620,6 +642,7 @@ static struct {
620642 { "register" , cmd_register },
621643 { "unregister" , cmd_unregister },
622644 { "run" , cmd_run },
645+ { "reconfigure" , cmd_reconfigure },
623646 { NULL , NULL },
624647};
625648
0 commit comments