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 @@ -2272,6 +2272,17 @@ ROUTER = console
22722272; PULL = 300
22732273; GC = 60
22742274
2275+
2276+ ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2277+ ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2278+ ; ; Git Reflog timeout in days
2279+ ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2280+ ; [git.reflog]
2281+ ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2282+ ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2283+ ; ENABLED = true
2284+ ; EXPIRATION = 90
2285+
22752286; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
22762287; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
22772288; [mirror]
Original file line number Diff line number Diff line change @@ -1093,6 +1093,11 @@ Default templates for project boards:
10931093- ` DISABLE_CORE_PROTECT_NTFS ` : ** false** Set to true to forcibly set ` core.protectNTFS ` to false.
10941094- ` DISABLE_PARTIAL_CLONE ` : ** false** Disable the usage of using partial clones for git.
10951095
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+
10961101## Git - Timeout settings (` git.timeout ` )
10971102
10981103- ` 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 @@ -2934,6 +2934,8 @@ config.git_disable_diff_highlight = Disable Diff Syntax Highlight
29342934config.git_max_diff_lines = Max Diff Lines (for a single file)
29352935config.git_max_diff_line_characters = Max Diff Characters (for a single line)
29362936config.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
29372939config.git_gc_args = GC Arguments
29382940config.git_migrate_timeout = Migration Timeout
29392941config.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