File tree Expand file tree Collapse file tree 6 files changed +71
-3
lines changed
docs/content/doc/advanced Expand file tree Collapse file tree 6 files changed +71
-3
lines changed Original file line number Diff line number Diff line change @@ -2256,6 +2256,17 @@ ROUTER = console
22562256; PULL = 300
22572257; GC = 60
22582258
2259+
2260+ ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2261+ ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2262+ ; ; Git Reflog timeout in days
2263+ ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2264+ ; [git.reflog]
2265+ ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2266+ ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2267+ ; ENABLED = true
2268+ ; EXPIRATION = 90
2269+
22592270; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
22602271; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
22612272; [mirror]
Original file line number Diff line number Diff line change @@ -1087,6 +1087,11 @@ Default templates for project boards:
10871087- ` DISABLE_CORE_PROTECT_NTFS ` : ** false** Set to true to forcibly set ` core.protectNTFS ` to false.
10881088- ` DISABLE_PARTIAL_CLONE ` : ** false** Disable the usage of using partial clones for git.
10891089
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+
10901095## Git - Timeout settings (` git.timeout ` )
10911096
10921097- ` 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) {
201201 return syncGitConfig ()
202202}
203203
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+
204221// syncGitConfig only modifies gitconfig, won't change global variables (otherwise there will be data-race problem)
205222func syncGitConfig () (err error ) {
206223 if err = os .MkdirAll (HomeDir (), os .ModePerm ); err != nil {
@@ -224,6 +241,16 @@ func syncGitConfig() (err error) {
224241 return err
225242 }
226243
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+
227254 if CheckGitVersionAtLeast ("2.10" ) == nil {
228255 if err := configSet ("receive.advertisePushOptions" , "true" ); err != nil {
229256 return err
Original file line number Diff line number Diff line change @@ -12,9 +12,13 @@ import (
1212
1313// Git settings
1414var 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"`
1822 MaxGitDiffLines int
1923 MaxGitDiffLineCharacters int
2024 MaxGitDiffFiles int
@@ -37,6 +41,13 @@ var Git = struct {
3741 GC int `ini:"GC"`
3842 } `ini:"git.timeout"`
3943}{
44+ Reflog : struct {
45+ Enabled bool
46+ Expiration int
47+ }{
48+ Enabled : true ,
49+ Expiration : 90 ,
50+ },
4051 DisableDiffHighlight : false ,
4152 MaxGitDiffLines : 1000 ,
4253 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
29282928config.git_max_diff_lines = Max Diff Lines (for a single file)
29292929config.git_max_diff_line_characters = Max Diff Characters (for a single line)
29302930config.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
29312933config.git_gc_args = GC Arguments
29322934config.git_migrate_timeout = Migration Timeout
29332935config.git_mirror_timeout = Mirror Update Timeout
Original file line number Diff line number Diff line change 331331 <dd>{{.Git.MaxGitDiffFiles}}</dd>
332332 <dt>{{.locale.Tr "admin.config.git_gc_args"}}</dt>
333333 <dd><code>{{.Git.GCArgs}}</code></dd>
334+
334335 <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+
335347 <dt>{{.locale.Tr "admin.config.git_migrate_timeout"}}</dt>
336348 <dd>{{.Git.Timeout.Migrate}} {{.locale.Tr "tool.raw_seconds"}}</dd>
337349 <dt>{{.locale.Tr "admin.config.git_mirror_timeout"}}</dt>
You can’t perform that action at this time.
0 commit comments