Skip to content

Commit 9c2b7a1

Browse files
authored
Disable core.protectNTFS (#17300) (#17302)
Backport #17300 core.protectNTFS protects NTFS from files which may be difficult to remove or interact with using the win32 api, however, it also appears to prevent such files from being entered into the git indexes - fundamentally causing breakages with PRs that affect these files. However, deliberately setting this to false may cause security issues due to the remain sparse checkout of files in the merge pipeline. The only sensible option therefore is to provide an optional setting which admins could set which would forcibly switch this off if they are affected by this issue. Fix #17092 Signed-off-by: Andrew Thornton <art27@cantab.net>
1 parent 1e278b1 commit 9c2b7a1

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

custom/conf/app.example.ini

+2
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,8 @@ PATH =
576576
;;
577577
;; (Go-Git only) Don't cache objects greater than this in memory. (Set to 0 to disable.)
578578
;LARGE_OBJECT_THRESHOLD = 1048576
579+
;; Set to true to forcibly set core.protectNTFS=false
580+
;DISABLE_CORE_PROTECT_NTFS=false
579581

580582
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
581583
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

docs/content/doc/advanced/config-cheat-sheet.en-us.md

+1
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,7 @@ NB: You must have `DISABLE_ROUTER_LOG` set to `false` for this option to take ef
839839
- `VERBOSE_PUSH`: **true**: Print status information about pushes as they are being processed.
840840
- `VERBOSE_PUSH_DELAY`: **5s**: Only print verbose information if push takes longer than this delay.
841841
- `LARGE_OBJECT_THRESHOLD`: **1048576**: (Go-Git only), don't cache objects greater than this in memory. (Set to 0 to disable.)
842+
- `DISABLE_CORE_PROTECT_NTFS`: **false** Set to true to forcibly set `core.protectNTFS` to false.
842843
## Git - Timeout settings (`git.timeout`)
843844
- `DEFAUlT`: **360**: Git operations default timeout seconds.
844845
- `MIGRATE`: **600**: Migrate external repositories timeout seconds.

modules/git/git.go

+6
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,12 @@ func Init(ctx context.Context) error {
188188
return err
189189
}
190190
}
191+
if setting.Git.DisableCoreProtectNTFS {
192+
if err := checkAndSetConfig("core.protectntfs", "false", true); err != nil {
193+
return err
194+
}
195+
GlobalCommandArgs = append(GlobalCommandArgs, "-c", "core.protectntfs=false")
196+
}
191197
return nil
192198
}
193199

modules/setting/git.go

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var (
2626
EnableAutoGitWireProtocol bool
2727
PullRequestPushMessage bool
2828
LargeObjectThreshold int64
29+
DisableCoreProtectNTFS bool
2930
Timeout struct {
3031
Default int
3132
Migrate int

0 commit comments

Comments
 (0)