File tree 6 files changed +71
-3
lines changed
docs/content/doc/advanced
6 files changed +71
-3
lines changed Original file line number Diff line number Diff line change @@ -2272,6 +2272,17 @@ ROUTER = console
2272
2272
; PULL = 300
2273
2273
; GC = 60
2274
2274
2275
+
2276
+ ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2277
+ ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2278
+ ; ; Git Reflog timeout in days
2279
+ ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2280
+ ; [git.reflog]
2281
+ ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2282
+ ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2283
+ ; ENABLED = true
2284
+ ; EXPIRATION = 90
2285
+
2275
2286
; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2276
2287
; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2277
2288
; [mirror]
Original file line number Diff line number Diff line change @@ -1093,6 +1093,11 @@ Default templates for project boards:
1093
1093
- ` DISABLE_CORE_PROTECT_NTFS ` : ** false** Set to true to forcibly set ` core.protectNTFS ` to false.
1094
1094
- ` DISABLE_PARTIAL_CLONE ` : ** false** Disable the usage of using partial clones for git.
1095
1095
1096
+ ## Git - Reflog settings (` git.reflog ` )
1097
+
1098
+ - ` ENABLED ` : ** true** Set to true to enable Git to write changes to reflogs in each repo.
1099
+ - ` EXPIRATION ` : ** 90** Reflog entry lifetime, in days. Entries are removed opportunistically by Git.
1100
+
1096
1101
## Git - Timeout settings (` git.timeout ` )
1097
1102
1098
1103
- ` DEFAULT ` : ** 360** : Git operations default timeout seconds.
Original file line number Diff line number Diff line change @@ -201,6 +201,23 @@ func InitFull(ctx context.Context) (err error) {
201
201
return syncGitConfig ()
202
202
}
203
203
204
+ func enableReflogs () error {
205
+ if err := configSet ("core.logAllRefUpdates" , "true" ); err != nil {
206
+ return err
207
+ }
208
+ err := configSet ("gc.reflogExpire" , fmt .Sprintf ("%d" , setting .Git .Reflog .Expiration ))
209
+ return err
210
+ }
211
+
212
+ func disableReflogs () error {
213
+ if err := configUnsetAll ("core.logAllRefUpdates" , "true" ); err != nil {
214
+ return err
215
+ } else if err := configUnsetAll ("gc.reflogExpire" , "" ); err != nil {
216
+ return err
217
+ }
218
+ return nil
219
+ }
220
+
204
221
// syncGitConfig only modifies gitconfig, won't change global variables (otherwise there will be data-race problem)
205
222
func syncGitConfig () (err error ) {
206
223
if err = os .MkdirAll (HomeDir (), os .ModePerm ); err != nil {
@@ -224,6 +241,16 @@ func syncGitConfig() (err error) {
224
241
return err
225
242
}
226
243
244
+ if setting .Git .Reflog .Enabled {
245
+ if err := enableReflogs (); err != nil {
246
+ return err
247
+ }
248
+ } else {
249
+ if err := disableReflogs (); err != nil {
250
+ return err
251
+ }
252
+ }
253
+
227
254
if CheckGitVersionAtLeast ("2.10" ) == nil {
228
255
if err := configSet ("receive.advertisePushOptions" , "true" ); err != nil {
229
256
return err
Original file line number Diff line number Diff line change @@ -12,9 +12,13 @@ import (
12
12
13
13
// Git settings
14
14
var Git = struct {
15
- Path string
16
- HomePath string
17
- DisableDiffHighlight bool
15
+ Path string
16
+ HomePath string
17
+ DisableDiffHighlight bool
18
+ Reflog struct {
19
+ Enabled bool
20
+ Expiration int
21
+ } `ini:"git.reflog"`
18
22
MaxGitDiffLines int
19
23
MaxGitDiffLineCharacters int
20
24
MaxGitDiffFiles int
@@ -37,6 +41,13 @@ var Git = struct {
37
41
GC int `ini:"GC"`
38
42
} `ini:"git.timeout"`
39
43
}{
44
+ Reflog : struct {
45
+ Enabled bool
46
+ Expiration int
47
+ }{
48
+ Enabled : true ,
49
+ Expiration : 90 ,
50
+ },
40
51
DisableDiffHighlight : false ,
41
52
MaxGitDiffLines : 1000 ,
42
53
MaxGitDiffLineCharacters : 5000 ,
Original file line number Diff line number Diff line change @@ -2934,6 +2934,8 @@ config.git_disable_diff_highlight = Disable Diff Syntax Highlight
2934
2934
config.git_max_diff_lines = Max Diff Lines (for a single file)
2935
2935
config.git_max_diff_line_characters = Max Diff Characters (for a single line)
2936
2936
config.git_max_diff_files = Max Diff Files (to be shown)
2937
+ config.git_enable_reflogs = Enable Reflogs
2938
+ config.git_reflog_expiry_time = Expiry Time
2937
2939
config.git_gc_args = GC Arguments
2938
2940
config.git_migrate_timeout = Migration Timeout
2939
2941
config.git_mirror_timeout = Mirror Update Timeout
Original file line number Diff line number Diff line change 331
331
<dd>{{.Git.MaxGitDiffFiles}}</dd>
332
332
<dt>{{.locale.Tr "admin.config.git_gc_args"}}</dt>
333
333
<dd><code>{{.Git.GCArgs}}</code></dd>
334
+
334
335
<div class="ui divider"></div>
336
+
337
+ <dt>{{.locale.Tr "admin.config.git_enable_reflogs"}}</dt>
338
+ <dd>{{if .Git.Reflog.Enabled}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</dd>
339
+
340
+ {{if .Git.Reflog.Enabled}}
341
+ <dt>{{.locale.Tr "admin.config.git_reflog_expiry_time"}}</dt>
342
+ <dd>{{.locale.Tr "tool.days" .Git.Reflog.Expiration}}</dd>
343
+ {{end}}
344
+
345
+ <div class="ui divider"></div>
346
+
335
347
<dt>{{.locale.Tr "admin.config.git_migrate_timeout"}}</dt>
336
348
<dd>{{.Git.Timeout.Migrate}} {{.locale.Tr "tool.raw_seconds"}}</dd>
337
349
<dt>{{.locale.Tr "admin.config.git_mirror_timeout"}}</dt>
You can’t perform that action at this time.
0 commit comments