Skip to content

Commit 4b7b68d

Browse files
committed
EOL the --change-permissions flag
This is a breaking change. The `--change-permissions` flag was too coarse (e.g. changed directories and files alike) and not expressive (no way to say "g+w"). I doubt if anyone was using it, and if they were, the new `--group-write` is almost certainly what they want.
1 parent 58cab77 commit 4b7b68d

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

cmd/git-sync/main.go

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,6 @@ var flMaxFailures = pflag.Int("max-failures",
9797
var flGroupWrite = pflag.Bool("group-write",
9898
envBool(false, "GITSYNC_GROUP_WRITE", "GIT_SYNC_GROUP_WRITE"),
9999
"ensure that all data (repo, worktrees, etc.) is group writable")
100-
var flChmod = pflag.Int("change-permissions",
101-
envInt(0, "GITSYNC_PERMISSIONS", "GIT_SYNC_PERMISSIONS"),
102-
"optionally change permissions on the checked-out files to the specified mode")
103100

104101
var flTouchFile = pflag.String("touch-file",
105102
envString("", "GITSYNC_TOUCH_FILE", "GIT_SYNC_TOUCH_FILE"),
@@ -192,6 +189,8 @@ var flHTTPprof = pflag.Bool("http-pprof",
192189
// Obsolete flags, kept for compat.
193190
var flDeprecatedBranch = pflag.String("branch", envString("", "GIT_SYNC_BRANCH"),
194191
"DEPRECATED: use --ref instead")
192+
var flDeprecatedChmod = pflag.Int("change-permissions", envInt(0, "GIT_SYNC_PERMISSIONS"),
193+
"DEPRECATED: use --group-write instead")
195194
var flDeprecatedDest = pflag.String("dest", envString("", "GIT_SYNC_DEST"),
196195
"DEPRECATED: use --link instead")
197196
var flDeprecatedMaxSyncFailures = pflag.Int("max-sync-failures", envInt(0, "GIT_SYNC_MAX_SYNC_FAILURES"),
@@ -209,6 +208,7 @@ var flDeprecatedWait = pflag.Float64("wait", envFloat(0, "GIT_SYNC_WAIT"),
209208

210209
func init() {
211210
pflag.CommandLine.MarkDeprecated("branch", "use --ref instead")
211+
pflag.CommandLine.MarkDeprecated("change-permissions", "use --group-write instead")
212212
pflag.CommandLine.MarkDeprecated("dest", "use --link instead")
213213
pflag.CommandLine.MarkDeprecated("max-sync-failures", "use --max-failures instead")
214214
pflag.CommandLine.MarkDeprecated("rev", "use --ref instead")
@@ -482,7 +482,6 @@ type repoSync struct {
482482
depth int // for shallow sync
483483
submodules submodulesMode // how to handle submodules
484484
gc gcMode // garbage collection
485-
chmod int // mode to change repo to, or 0
486485
link absPath // absolute path to the symlink to publish
487486
authURL string // a URL to re-fetch credentials, or ""
488487
sparseFile string // path to a sparse-checkout file
@@ -609,6 +608,10 @@ func main() {
609608
handleConfigError(log, true, "ERROR: --period must be at least 10ms")
610609
}
611610

611+
if *flDeprecatedChmod != 0 {
612+
handleConfigError(log, true, "ERROR: --change-permissions is no longer supported")
613+
}
614+
612615
var syncSig syscall.Signal
613616
if *flSyncOnSignal != "" {
614617
if num, err := strconv.ParseInt(*flSyncOnSignal, 0, 0); err == nil {
@@ -795,7 +798,6 @@ func main() {
795798
depth: *flDepth,
796799
submodules: submodulesMode(*flSubmodules),
797800
gc: gcMode(*flGitGC),
798-
chmod: *flChmod,
799801
link: absLink,
800802
authURL: *flAskPassURL,
801803
sparseFile: *flSparseCheckoutFile,
@@ -1532,15 +1534,6 @@ func (git *repoSync) configureWorktree(ctx context.Context, worktree worktree) e
15321534
}
15331535
}
15341536

1535-
// Change the file permissions, if requested.
1536-
if git.chmod != 0 {
1537-
mode := fmt.Sprintf("%#o", git.chmod)
1538-
git.log.V(1).Info("changing file permissions", "mode", mode)
1539-
if _, err := git.run.Run(ctx, "", nil, "chmod", "-R", mode, worktree.Path().String()); err != nil {
1540-
return err
1541-
}
1542-
}
1543-
15441537
return nil
15451538
}
15461539

@@ -2250,9 +2243,6 @@ OPTIONS
22502243
(200) and produce a series of key=value lines, including
22512244
"username=<value>" and "password=<value>".
22522245
2253-
--change-permissions <int>, $GITSYNC_PERMISSIONS
2254-
Change permissions on the checked-out files to the specified mode.
2255-
22562246
--cookie-file <string>, $GITSYNC_COOKIE_FILE
22572247
Use a git cookiefile (/etc/git-secret/cookie_file) for
22582248
authentication.
@@ -2327,7 +2317,7 @@ OPTIONS
23272317
checked out files, worktrees, and symlink) are all group writable.
23282318
This corresponds to git's notion of a "shared repository". This is
23292319
useful in cases where data produced by git-sync is used by a
2330-
different UID.
2320+
different UID. This replaces the older --change-permissions flag.
23312321
23322322
-h, --help
23332323
Print help text and exit.

v3-to-v4.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ new `--sync-timeout` flag takes a Go-style duration string (e.g. "30s" or
9696
"0.5m"). For backwards compatibility, `--timeout` will be used if it is
9797
specified.
9898

99+
### Permissions: `--change-permissions` -> `--group-write`
100+
101+
The old `--change-permissions` flag was poorly designed and not able to express
102+
the real intentions (e.g. "allow group write" does not mean "set everything to
103+
0775"). The new `--group-write` flag should cover what people ACTUALLY are
104+
trying to do. The `--change-permissions` flag is no longer supported.
105+
99106
### Manual: `--man`
100107

101108
The new `--man` flag prints a man-page style help document and exits.

0 commit comments

Comments
 (0)