@@ -59,6 +59,8 @@ func runSyncLike(ctx context.Context, name string, args []string, dryRun bool, d
5959
6060 fs .StringVar (& req .Source .URL , "source-url" , "" , "source repository URL" )
6161 fs .StringVar (& req .Target .URL , "target-url" , "" , "target repository URL" )
62+ fs .BoolVar (& req .Source .FollowInfoRefsRedirect , "source-follow-info-refs-redirect" , envBool ("GITSYNC_SOURCE_FOLLOW_INFO_REFS_REDIRECT" ), "send follow-up source RPCs to the final /info/refs redirect host" )
63+ fs .BoolVar (& req .Target .FollowInfoRefsRedirect , "target-follow-info-refs-redirect" , envBool ("GITSYNC_TARGET_FOLLOW_INFO_REFS_REDIRECT" ), "send follow-up target RPCs to the final /info/refs redirect host" )
6264
6365 fs .StringVar (& sourceAuth .Token , "source-token" , envOr ("GITSYNC_SOURCE_TOKEN" , "" ), "source token/password" )
6466 fs .StringVar (& targetAuth .Token , "target-token" , envOr ("GITSYNC_TARGET_TOKEN" , "" ), "target token/password" )
@@ -163,6 +165,8 @@ func runBootstrap(ctx context.Context, args []string) error {
163165
164166 fs .StringVar (& req .Source .URL , "source-url" , "" , "source repository URL" )
165167 fs .StringVar (& req .Target .URL , "target-url" , "" , "target repository URL" )
168+ fs .BoolVar (& req .Source .FollowInfoRefsRedirect , "source-follow-info-refs-redirect" , envBool ("GITSYNC_SOURCE_FOLLOW_INFO_REFS_REDIRECT" ), "send follow-up source RPCs to the final /info/refs redirect host" )
169+ fs .BoolVar (& req .Target .FollowInfoRefsRedirect , "target-follow-info-refs-redirect" , envBool ("GITSYNC_TARGET_FOLLOW_INFO_REFS_REDIRECT" ), "send follow-up target RPCs to the final /info/refs redirect host" )
166170
167171 fs .StringVar (& sourceAuth .Token , "source-token" , envOr ("GITSYNC_SOURCE_TOKEN" , "" ), "source token/password" )
168172 fs .StringVar (& targetAuth .Token , "target-token" , envOr ("GITSYNC_TARGET_TOKEN" , "" ), "target token/password" )
@@ -237,9 +241,12 @@ func runProbe(ctx context.Context, args []string) error {
237241 var jsonOutput bool
238242 var sourceAuth gitsync.EndpointAuth
239243 var targetAuth gitsync.EndpointAuth
244+ var targetFollowInfoRefsRedirect bool
240245 req := unstable.ProbeRequest {}
241246 fs .StringVar (& req .Source .URL , "source-url" , "" , "source repository URL" )
242247 targetURL := fs .String ("target-url" , "" , "optional target repository URL" )
248+ fs .BoolVar (& req .Source .FollowInfoRefsRedirect , "source-follow-info-refs-redirect" , envBool ("GITSYNC_SOURCE_FOLLOW_INFO_REFS_REDIRECT" ), "send follow-up source RPCs to the final /info/refs redirect host" )
249+ fs .BoolVar (& targetFollowInfoRefsRedirect , "target-follow-info-refs-redirect" , envBool ("GITSYNC_TARGET_FOLLOW_INFO_REFS_REDIRECT" ), "send follow-up target RPCs to the final /info/refs redirect host" )
243250 fs .StringVar (& sourceAuth .Token , "source-token" , envOr ("GITSYNC_SOURCE_TOKEN" , "" ), "source token/password" )
244251 fs .StringVar (& targetAuth .Token , "target-token" , envOr ("GITSYNC_TARGET_TOKEN" , "" ), "target token/password" )
245252 fs .StringVar (& sourceAuth .Username , "source-username" , envOr ("GITSYNC_SOURCE_USERNAME" , "git" ), "source basic auth username" )
@@ -274,7 +281,10 @@ func runProbe(ctx context.Context, args []string) error {
274281 return usageError ("probe requires a source repository URL" )
275282 }
276283 if * targetURL != "" {
277- req .Target = & gitsync.Endpoint {URL : * targetURL }
284+ req .Target = & gitsync.Endpoint {
285+ URL : * targetURL ,
286+ FollowInfoRefsRedirect : targetFollowInfoRefsRedirect ,
287+ }
278288 }
279289
280290 result , err := unstable .New (unstable.Options {
@@ -298,6 +308,7 @@ func runFetch(ctx context.Context, args []string) error {
298308 req := unstable.FetchRequest {}
299309
300310 fs .StringVar (& req .Source .URL , "source-url" , "" , "source repository URL" )
311+ fs .BoolVar (& req .Source .FollowInfoRefsRedirect , "source-follow-info-refs-redirect" , envBool ("GITSYNC_SOURCE_FOLLOW_INFO_REFS_REDIRECT" ), "send follow-up source RPCs to the final /info/refs redirect host" )
301312 fs .StringVar (& sourceAuth .Token , "source-token" , envOr ("GITSYNC_SOURCE_TOKEN" , "" ), "source token/password" )
302313 fs .StringVar (& sourceAuth .Username , "source-username" , envOr ("GITSYNC_SOURCE_USERNAME" , "git" ), "source basic auth username" )
303314 fs .StringVar (& sourceAuth .BearerToken , "source-bearer-token" , envOr ("GITSYNC_SOURCE_BEARER_TOKEN" , "" ), "source bearer token" )
@@ -413,7 +424,141 @@ func envBool(key string) bool {
413424}
414425
415426func usageError (message string ) error {
416- usage := fmt .Sprintf ("usage:\n git-sync sync [flags] <source-url> <target-url>\n git-sync replicate [flags] <source-url> <target-url>\n git-sync plan [flags] <source-url> <target-url>\n git-sync bootstrap [flags] <source-url> <target-url>\n git-sync probe [flags] <source-url> [target-url]\n git-sync fetch [flags] <source-url>\n \n sync flags:\n --branch main,dev\n --map main:stable\n --tags\n --force\n --prune\n --stats\n --measure-memory\n --json\n --materialized-max-objects %d\n --max-pack-bytes <bytes>\n --target-max-pack-bytes <bytes>\n --protocol auto|v1|v2\n --source-token ...\n --target-token ...\n --source-username git\n --target-username git\n --source-bearer-token ...\n --target-bearer-token ...\n --source-insecure-skip-tls-verify\n --target-insecure-skip-tls-verify\n -v\n \n replicate flags:\n --branch main,dev\n --map main:stable\n --tags\n --prune\n --stats\n --measure-memory\n --json\n --max-pack-bytes <bytes>\n --target-max-pack-bytes <bytes>\n --protocol auto|v1|v2\n --source-token ...\n --target-token ...\n --source-username git\n --target-username git\n --source-bearer-token ...\n --target-bearer-token ...\n --source-insecure-skip-tls-verify\n --target-insecure-skip-tls-verify\n -v\n \n plan flags:\n --mode sync|replicate\n --branch main,dev\n --map main:stable\n --tags\n --force\n --prune\n --stats\n --measure-memory\n --json\n --max-pack-bytes <bytes>\n --target-max-pack-bytes <bytes>\n --protocol auto|v1|v2\n --source-token ...\n --target-token ...\n --source-username git\n --target-username git\n --source-bearer-token ...\n --target-bearer-token ...\n --source-insecure-skip-tls-verify\n --target-insecure-skip-tls-verify\n -v\n \n bootstrap flags:\n --branch main,dev\n --map main:stable\n --tags\n --max-pack-bytes 104857600\n --target-max-pack-bytes 1073741824\n --stats\n --measure-memory\n --json\n --protocol auto|v1|v2\n --source-token ...\n --target-token ...\n --source-username git\n --target-username git\n --source-bearer-token ...\n --target-bearer-token ...\n --source-insecure-skip-tls-verify\n --target-insecure-skip-tls-verify\n -v\n \n probe flags:\n --tags\n --stats\n --measure-memory\n --json\n --protocol auto|v1|v2\n --source-token ...\n --source-username git\n --source-bearer-token ...\n --target-token ...\n --target-username git\n --target-bearer-token ...\n --source-insecure-skip-tls-verify\n --target-insecure-skip-tls-verify\n \n fetch flags:\n --branch main,dev\n --tags\n --stats\n --measure-memory\n --json\n --protocol auto|v1|v2\n --have-ref main\n --have <hash>\n --source-token ...\n --source-username git\n --source-bearer-token ...\n --source-insecure-skip-tls-verify\n " , unstable .DefaultMaterializedMaxObjects )
427+ usage := fmt .Sprintf (`usage:
428+ git-sync sync [flags] <source-url> <target-url>
429+ git-sync replicate [flags] <source-url> <target-url>
430+ git-sync plan [flags] <source-url> <target-url>
431+ git-sync bootstrap [flags] <source-url> <target-url>
432+ git-sync probe [flags] <source-url> [target-url]
433+ git-sync fetch [flags] <source-url>
434+
435+ sync flags:
436+ --branch main,dev
437+ --map main:stable
438+ --tags
439+ --force
440+ --prune
441+ --stats
442+ --measure-memory
443+ --json
444+ --materialized-max-objects %d
445+ --max-pack-bytes <bytes>
446+ --target-max-pack-bytes <bytes>
447+ --protocol auto|v1|v2
448+ --source-token ...
449+ --target-token ...
450+ --source-username git
451+ --target-username git
452+ --source-bearer-token ...
453+ --target-bearer-token ...
454+ --source-insecure-skip-tls-verify
455+ --target-insecure-skip-tls-verify
456+ --source-follow-info-refs-redirect
457+ --target-follow-info-refs-redirect
458+ -v
459+
460+ replicate flags:
461+ --branch main,dev
462+ --map main:stable
463+ --tags
464+ --prune
465+ --stats
466+ --measure-memory
467+ --json
468+ --max-pack-bytes <bytes>
469+ --target-max-pack-bytes <bytes>
470+ --protocol auto|v1|v2
471+ --source-token ...
472+ --target-token ...
473+ --source-username git
474+ --target-username git
475+ --source-bearer-token ...
476+ --target-bearer-token ...
477+ --source-insecure-skip-tls-verify
478+ --target-insecure-skip-tls-verify
479+ --source-follow-info-refs-redirect
480+ --target-follow-info-refs-redirect
481+ -v
482+
483+ plan flags:
484+ --mode sync|replicate
485+ --branch main,dev
486+ --map main:stable
487+ --tags
488+ --force
489+ --prune
490+ --stats
491+ --measure-memory
492+ --json
493+ --max-pack-bytes <bytes>
494+ --target-max-pack-bytes <bytes>
495+ --protocol auto|v1|v2
496+ --source-token ...
497+ --target-token ...
498+ --source-username git
499+ --target-username git
500+ --source-bearer-token ...
501+ --target-bearer-token ...
502+ --source-insecure-skip-tls-verify
503+ --target-insecure-skip-tls-verify
504+ --source-follow-info-refs-redirect
505+ --target-follow-info-refs-redirect
506+ -v
507+
508+ bootstrap flags:
509+ --branch main,dev
510+ --map main:stable
511+ --tags
512+ --max-pack-bytes 104857600
513+ --target-max-pack-bytes 1073741824
514+ --stats
515+ --measure-memory
516+ --json
517+ --protocol auto|v1|v2
518+ --source-token ...
519+ --target-token ...
520+ --source-username git
521+ --target-username git
522+ --source-bearer-token ...
523+ --target-bearer-token ...
524+ --source-insecure-skip-tls-verify
525+ --target-insecure-skip-tls-verify
526+ --source-follow-info-refs-redirect
527+ --target-follow-info-refs-redirect
528+ -v
529+
530+ probe flags:
531+ --tags
532+ --stats
533+ --measure-memory
534+ --json
535+ --protocol auto|v1|v2
536+ --source-token ...
537+ --source-username git
538+ --source-bearer-token ...
539+ --target-token ...
540+ --target-username git
541+ --target-bearer-token ...
542+ --source-insecure-skip-tls-verify
543+ --target-insecure-skip-tls-verify
544+ --source-follow-info-refs-redirect
545+ --target-follow-info-refs-redirect
546+
547+ fetch flags:
548+ --branch main,dev
549+ --tags
550+ --stats
551+ --measure-memory
552+ --json
553+ --protocol auto|v1|v2
554+ --have-ref main
555+ --have <hash>
556+ --source-token ...
557+ --source-username git
558+ --source-bearer-token ...
559+ --source-insecure-skip-tls-verify
560+ --source-follow-info-refs-redirect
561+ ` , unstable .DefaultMaterializedMaxObjects )
417562 if message == "" {
418563 return errors .New (strings .TrimSpace (usage ))
419564 }
0 commit comments