@@ -108,18 +108,20 @@ static int run_git(const char *arg, ...)
108
108
return res ;
109
109
}
110
110
111
- static int set_recommended_config (void )
111
+ static int set_recommended_config (int reconfigure )
112
112
{
113
113
struct {
114
114
const char * key ;
115
115
const char * value ;
116
+ int overwrite_on_reconfigure ;
116
117
} 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 },
121
123
#ifndef WIN32
122
- { "core.untrackedCache" , "true" },
124
+ { "core.untrackedCache" , "true" , 1 },
123
125
#else
124
126
/*
125
127
* Unfortunately, Scalar's Functional Tests demonstrated
@@ -133,28 +135,29 @@ static int set_recommended_config(void)
133
135
* Therefore, with a sad heart, we disable this very useful
134
136
* feature on Windows.
135
137
*/
136
- { "core.untrackedCache" , "false" },
138
+ { "core.untrackedCache" , "false" , 1 },
137
139
#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 },
155
157
#ifdef WIN32
156
- { "http.sslBackend" , "schannel" },
158
+ { "http.sslBackend" , "schannel" , 1 },
157
159
#endif
160
+ /* Optional */
158
161
{ "status.aheadBehind" , "false" },
159
162
{ "commitGraph.generationVersion" , "1" },
160
163
{ "core.autoCRLF" , "false" },
@@ -166,7 +169,8 @@ static int set_recommended_config(void)
166
169
char * value ;
167
170
168
171
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 )) {
170
174
trace2_data_string ("scalar" , the_repository , config [i ].key , "created" );
171
175
if (git_config_set_gently (config [i ].key ,
172
176
config [i ].value ) < 0 )
@@ -231,7 +235,7 @@ static int register_dir(void)
231
235
int res = add_or_remove_enlistment (1 );
232
236
233
237
if (!res )
234
- res = set_recommended_config ();
238
+ res = set_recommended_config (0 );
235
239
236
240
if (!res )
237
241
res = toggle_maintenance (1 );
@@ -419,7 +423,7 @@ static int cmd_clone(int argc, const char **argv)
419
423
(res = run_git ("sparse-checkout" , "init" , "--cone" , NULL )))
420
424
goto cleanup ;
421
425
422
- if (set_recommended_config ())
426
+ if (set_recommended_config (0 ))
423
427
return error (_ ("could not configure '%s'" ), dir );
424
428
425
429
if ((res = run_git ("fetch" , "--quiet" , "origin" , NULL ))) {
@@ -484,6 +488,24 @@ static int cmd_register(int argc, const char **argv)
484
488
return register_dir ();
485
489
}
486
490
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
+
487
509
static int cmd_run (int argc , const char * * argv )
488
510
{
489
511
struct option options [] = {
@@ -620,6 +642,7 @@ static struct {
620
642
{ "register" , cmd_register },
621
643
{ "unregister" , cmd_unregister },
622
644
{ "run" , cmd_run },
645
+ { "reconfigure" , cmd_reconfigure },
623
646
{ NULL , NULL },
624
647
};
625
648
0 commit comments