Skip to content

Commit c3a49e9

Browse files
committed
Get rid of "must not start with ." logic
It serves very little purpose and isn't even correct as-is.
1 parent ff1a913 commit c3a49e9

File tree

3 files changed

+12
-79
lines changed

3 files changed

+12
-79
lines changed

Diff for: README.md

+6-9
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ OPTIONS
156156
--error-file <string>, $GITSYNC_ERROR_FILE
157157
The path to an optional file into which errors will be written.
158158
This may be an absolute path or a relative path, in which case it
159-
is relative to --root. If it is relative to --root, the first path
160-
element may not start with a period.
159+
is relative to --root.
161160
162161
--exechook-backoff <duration>, $GITSYNC_EXECHOOK_BACKOFF
163162
The time to wait before retrying a failed --exechook-command. If
@@ -235,11 +234,10 @@ OPTIONS
235234
The path to at which to create a symlink which points to the
236235
current git directory, at the currently synced hash. This may be
237236
an absolute path or a relative path, in which case it is relative
238-
to --root. The last path element is the name of the link and must
239-
not start with a period. Consumers of the synced files should
240-
always use this link - it is updated atomically and should always
241-
be valid. The basename of the target of the link is the current
242-
hash. If not specified, this defaults to the leaf dir of --repo.
237+
to --root. Consumers of the synced files should always use this
238+
link - it is updated atomically and should always be valid. The
239+
basename of the target of the link is the current hash. If not
240+
specified, this defaults to the leaf dir of --repo.
243241
244242
--man
245243
Print this manual and exit.
@@ -325,8 +323,7 @@ OPTIONS
325323
--touch-file <string>, $GITSYNC_TOUCH_FILE
326324
The path to an optional file which will be touched whenever a sync
327325
completes. This may be an absolute path or a relative path, in
328-
which case it is relative to --root. If it is relative to --root,
329-
the first path element may not start with a period.
326+
which case it is relative to --root.
330327
331328
--username <string>, $GITSYNC_USERNAME
332329
The username to use for git authentication (see --password-file or

Diff for: cmd/git-sync/main.go

+6-22
Original file line numberDiff line numberDiff line change
@@ -544,10 +544,6 @@ func main() {
544544
*flVerbose = *flDeprecatedV
545545
}
546546
log := func() *logging.Logger {
547-
if strings.HasPrefix(*flErrorFile, ".") {
548-
fmt.Fprintf(os.Stderr, "ERROR: --error-file may not start with '.'\n")
549-
os.Exit(1)
550-
}
551547
dir, file := makeAbsPath(*flErrorFile, absRoot).Split()
552548
return logging.New(dir, file, *flVerbose)
553549
}()
@@ -597,9 +593,6 @@ func main() {
597593
parts := strings.Split(strings.Trim(*flRepo, "/"), "/")
598594
*flLink = parts[len(parts)-1]
599595
}
600-
if strings.HasPrefix(filepath.Base(*flLink), ".") {
601-
handleConfigError(log, true, "ERROR: --link must not start with '.'")
602-
}
603596

604597
if *flDeprecatedWait != 0 {
605598
// Back-compat
@@ -647,12 +640,6 @@ func main() {
647640
*flMaxFailures = *flDeprecatedMaxSyncFailures
648641
}
649642

650-
if *flTouchFile != "" {
651-
if strings.HasPrefix(*flTouchFile, ".") {
652-
handleConfigError(log, true, "ERROR: --touch-file may not start with '.'")
653-
}
654-
}
655-
656643
if *flDeprecatedSyncHookCommand != "" {
657644
// Back-compat
658645
log.V(0).Info("setting --exechook-command from deprecated --sync-hook-command")
@@ -2301,8 +2288,7 @@ OPTIONS
23012288
--error-file <string>, $GITSYNC_ERROR_FILE
23022289
The path to an optional file into which errors will be written.
23032290
This may be an absolute path or a relative path, in which case it
2304-
is relative to --root. If it is relative to --root, the first path
2305-
element may not start with a period.
2291+
is relative to --root.
23062292
23072293
--exechook-backoff <duration>, $GITSYNC_EXECHOOK_BACKOFF
23082294
The time to wait before retrying a failed --exechook-command. If
@@ -2387,11 +2373,10 @@ OPTIONS
23872373
The path to at which to create a symlink which points to the
23882374
current git directory, at the currently synced hash. This may be
23892375
an absolute path or a relative path, in which case it is relative
2390-
to --root. The last path element is the name of the link and must
2391-
not start with a period. Consumers of the synced files should
2392-
always use this link - it is updated atomically and should always
2393-
be valid. The basename of the target of the link is the current
2394-
hash. If not specified, this defaults to the leaf dir of --repo.
2376+
to --root. Consumers of the synced files should always use this
2377+
link - it is updated atomically and should always be valid. The
2378+
basename of the target of the link is the current hash. If not
2379+
specified, this defaults to the leaf dir of --repo.
23952380
23962381
--man
23972382
Print this manual and exit.
@@ -2484,8 +2469,7 @@ OPTIONS
24842469
--touch-file <string>, $GITSYNC_TOUCH_FILE
24852470
The path to an optional file which will be touched whenever a sync
24862471
completes. This may be an absolute path or a relative path, in
2487-
which case it is relative to --root. If it is relative to --root,
2488-
the first path element may not start with a period.
2472+
which case it is relative to --root.
24892473
24902474
--username <string>, $GITSYNC_USERNAME
24912475
The username to use for git authentication (see --password-file or

Diff for: test_e2e.sh

-48
Original file line numberDiff line numberDiff line change
@@ -2661,30 +2661,6 @@ function e2e::export_error_abs_path() {
26612661
)
26622662
}
26632663

2664-
##############################################
2665-
# Test export-error with invalid path
2666-
##############################################
2667-
function e2e::export_error_invalid_file() {
2668-
echo "$FUNCNAME" > "$REPO/file"
2669-
git -C "$REPO" commit -qam "$FUNCNAME"
2670-
2671-
(
2672-
set +o errexit
2673-
GIT_SYNC \
2674-
--repo="file://$REPO" \
2675-
--root="$ROOT" \
2676-
--link="link" \
2677-
--error-file=".error.json"
2678-
RET=$?
2679-
if [[ "$RET" != 1 ]]; then
2680-
fail "expected exit code 1, got $RET"
2681-
fi
2682-
assert_file_absent "$ROOT/link"
2683-
assert_file_absent "$ROOT/link/file"
2684-
assert_file_absent "$ROOT/.error.json"
2685-
)
2686-
}
2687-
26882664
##############################################
26892665
# Test touch-file
26902666
##############################################
@@ -2793,30 +2769,6 @@ function e2e::touch_file_abs_path() {
27932769
assert_file_absent "$ROOT/dir/touch.file"
27942770
}
27952771

2796-
##############################################
2797-
# Test touch-file with invalid path
2798-
##############################################
2799-
function e2e::touch_file_invalid_file() {
2800-
echo "$FUNCNAME" > "$REPO/file"
2801-
git -C "$REPO" commit -qam "$FUNCNAME"
2802-
2803-
(
2804-
set +o errexit
2805-
GIT_SYNC \
2806-
--repo="file://$REPO" \
2807-
--root="$ROOT" \
2808-
--link="link" \
2809-
--touch-file=".touch.file"
2810-
RET=$?
2811-
if [[ "$RET" != 1 ]]; then
2812-
fail "expected exit code 1, got $RET"
2813-
fi
2814-
assert_file_absent "$ROOT/link"
2815-
assert_file_absent "$ROOT/link/file"
2816-
assert_file_absent "$ROOT/.touch.file"
2817-
)
2818-
}
2819-
28202772
##############################################
28212773
# Test github HTTPS
28222774
# TODO: it would be better if we set up a local HTTPS server

0 commit comments

Comments
 (0)