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 @@ -2256,6 +2256,17 @@ ROUTER = console
2256
2256
; PULL = 300
2257
2257
; GC = 60
2258
2258
2259
+
2260
+ ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2261
+ ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2262
+ ; ; Git Reflog timeout in days
2263
+ ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2264
+ ; [git.reflog]
2265
+ ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2266
+ ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2267
+ ; ENABLED = true
2268
+ ; EXPIRATION = 90
2269
+
2259
2270
; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2260
2271
; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2261
2272
; [mirror]
Original file line number Diff line number Diff line change @@ -1087,6 +1087,11 @@ Default templates for project boards:
1087
1087
- ` DISABLE_CORE_PROTECT_NTFS ` : ** false** Set to true to forcibly set ` core.protectNTFS ` to false.
1088
1088
- ` DISABLE_PARTIAL_CLONE ` : ** false** Disable the usage of using partial clones for git.
1089
1089
1090
+ ## Git - Reflog settings (` git.reflog ` )
1091
+
1092
+ - ` ENABLED ` : ** true** Set to true to enable Git to write changes to reflogs in each repo.
1093
+ - ` EXPIRATION ` : ** 90** Reflog entry lifetime, in days. Entries are removed opportunistically by Git.
1094
+
1090
1095
## Git - Timeout settings (` git.timeout ` )
1091
1096
1092
1097
- ` 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 @@ -2928,6 +2928,8 @@ config.git_disable_diff_highlight = Disable Diff Syntax Highlight
2928
2928
config.git_max_diff_lines = Max Diff Lines (for a single file)
2929
2929
config.git_max_diff_line_characters = Max Diff Characters (for a single line)
2930
2930
config.git_max_diff_files = Max Diff Files (to be shown)
2931
+ config.git_enable_reflogs = Enable Reflogs
2932
+ config.git_reflog_expiry_time = Expiry Time
2931
2933
config.git_gc_args = GC Arguments
2932
2934
config.git_migrate_timeout = Migration Timeout
2933
2935
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