Fossil SCM

Fix "fossil sync" so that it returns non-zero if the sync fails. Add the --ping and --quiet options to "fossil sync".

drh 2025-12-30 20:11 trunk
Commit 8fa8fe8e1d150fb8bbb556e8b832d25f8d2d826619a26f89df1e17ad11d23c76
--- src/allrepo.c
+++ src/allrepo.c
@@ -330,10 +330,12 @@
330330
zCmd = "sync -autourl -R";
331331
collect_argument(&extra, "share-links",0);
332332
collect_argument(&extra, "verbose","v");
333333
collect_argument(&extra, "unversioned","u");
334334
collect_argument(&extra, "all",0);
335
+ collect_argument(&extra, "quiet","q");
336
+ collect_argument(&extra, "ping",0);
335337
}else if( fossil_strcmp(zCmd, "test-integrity")==0 ){
336338
collect_argument(&extra, "db-only", "d");
337339
collect_argument(&extra, "parse", 0);
338340
collect_argument(&extra, "quick", "q");
339341
zCmd = "test-integrity";
340342
--- src/allrepo.c
+++ src/allrepo.c
@@ -330,10 +330,12 @@
330 zCmd = "sync -autourl -R";
331 collect_argument(&extra, "share-links",0);
332 collect_argument(&extra, "verbose","v");
333 collect_argument(&extra, "unversioned","u");
334 collect_argument(&extra, "all",0);
 
 
335 }else if( fossil_strcmp(zCmd, "test-integrity")==0 ){
336 collect_argument(&extra, "db-only", "d");
337 collect_argument(&extra, "parse", 0);
338 collect_argument(&extra, "quick", "q");
339 zCmd = "test-integrity";
340
--- src/allrepo.c
+++ src/allrepo.c
@@ -330,10 +330,12 @@
330 zCmd = "sync -autourl -R";
331 collect_argument(&extra, "share-links",0);
332 collect_argument(&extra, "verbose","v");
333 collect_argument(&extra, "unversioned","u");
334 collect_argument(&extra, "all",0);
335 collect_argument(&extra, "quiet","q");
336 collect_argument(&extra, "ping",0);
337 }else if( fossil_strcmp(zCmd, "test-integrity")==0 ){
338 collect_argument(&extra, "db-only", "d");
339 collect_argument(&extra, "parse", 0);
340 collect_argument(&extra, "quick", "q");
341 zCmd = "test-integrity";
342
+31 -8
--- src/http.c
+++ src/http.c
@@ -581,11 +581,13 @@
581581
}
582582
if( rc!=200 && rc!=301 && rc!=302 && rc!=307 && rc!=308 ){
583583
int ii;
584584
for(ii=7; zLine[ii] && zLine[ii]!=' '; ii++){}
585585
while( zLine[ii]==' ' ) ii++;
586
- fossil_warning("server says: %s", &zLine[ii]);
586
+ if( (mHttpFlags & HTTP_QUIET)==0 ){
587
+ fossil_warning("server says: %s", &zLine[ii]);
588
+ }
587589
goto write_err;
588590
}
589591
if( iHttpVersion==0 ){
590592
closeConnection = 1;
591593
}else{
@@ -616,11 +618,13 @@
616618
int i, j;
617619
int wasHttps;
618620
int priorUrlFlags;
619621
620622
if ( --maxRedirect == 0){
621
- fossil_warning("redirect limit exceeded");
623
+ if( (mHttpFlags & HTTP_QUIET)==0 ){
624
+ fossil_warning("redirect limit exceeded");
625
+ }
622626
goto write_err;
623627
}
624628
for(i=9; zLine[i] && zLine[i]==' '; i++){}
625629
if( zLine[i]==0 ){
626630
fossil_warning("malformed redirect: %s", zLine);
@@ -633,23 +637,29 @@
633637
}
634638
if( (mHttpFlags & HTTP_QUIET)==0 ){
635639
fossil_print("redirect with status %d to %s\n", rc, &zLine[i]);
636640
}
637641
if( g.url.isFile || g.url.isSsh ){
638
- fossil_warning("cannot redirect from %s to %s", g.url.canonical,
639
- &zLine[i]);
642
+ if( (mHttpFlags & HTTP_QUIET)==0 ){
643
+ fossil_warning("cannot redirect from %s to %s", g.url.canonical,
644
+ &zLine[i]);
645
+ }
640646
goto write_err;
641647
}
642648
wasHttps = g.url.isHttps;
643649
priorUrlFlags = g.url.flags;
644650
url_parse(&zLine[i], 0);
645651
if( wasHttps && !g.url.isHttps ){
646
- fossil_warning("cannot redirect from HTTPS to HTTP");
652
+ if( (mHttpFlags & HTTP_QUIET)==0 ){
653
+ fossil_warning("cannot redirect from HTTPS to HTTP");
654
+ }
647655
goto write_err;
648656
}
649657
if( g.url.isSsh || g.url.isFile ){
650
- fossil_warning("cannot redirect to %s", &zLine[i]);
658
+ if( (mHttpFlags & HTTP_QUIET)==0 ){
659
+ fossil_warning("cannot redirect to %s", &zLine[i]);
660
+ }
651661
goto write_err;
652662
}
653663
transport_close(&g.url);
654664
transport_global_shutdown(&g.url);
655665
fSeenHttpAuth = 0;
@@ -704,20 +714,23 @@
704714
}
705715
return rc;
706716
}else{
707717
/* The problem could not be corrected by retrying. Report the
708718
** the error. */
709
- if( g.url.isSsh && !g.fSshTrace ){
719
+ if( mHttpFlags & HTTP_QUIET ){
720
+ /* no-op */
721
+ }else if( g.url.isSsh && !g.fSshTrace ){
710722
fossil_warning("server did not reply: "
711723
" rerun with --sshtrace for diagnostics");
712724
}else{
713725
fossil_warning("server did not reply");
714726
}
715727
goto write_err;
716728
}
717729
}
718730
if( rc!=200 ){
731
+ if( mHttpFlags & HTTP_QUIET ) goto write_err;
719732
fossil_warning("\"location:\" missing from %d redirect reply", rc);
720733
goto write_err;
721734
}
722735
723736
/*
@@ -733,10 +746,11 @@
733746
iRecvLen = transport_receive(&g.url, blob_buffer(pReply), iLength);
734747
if( mHttpFlags & HTTP_VERBOSE ){
735748
fossil_print("Reply received: %d of %d bytes\n", iRecvLen, iLength);
736749
}
737750
if( iRecvLen != iLength ){
751
+ if( mHttpFlags & HTTP_QUIET ) goto write_err;
738752
fossil_warning("response truncated: got %d bytes of %d",
739753
iRecvLen, iLength);
740754
goto write_err;
741755
}
742756
}else if( closeConnection ){
@@ -754,11 +768,13 @@
754768
if( mHttpFlags & HTTP_VERBOSE ){
755769
fossil_print("Reply received: %u bytes (w/o content-length)\n", nPrior);
756770
}
757771
}else{
758772
assert( iLength<0 && !closeConnection );
773
+ if( mHttpFlags & HTTP_QUIET ) goto write_err;
759774
fossil_warning("\"content-length\" missing from %d keep-alive reply", rc);
775
+ goto write_err;
760776
}
761777
if( isError ){
762778
char *z;
763779
int i, j;
764780
z = blob_str(pReply);
@@ -768,11 +784,17 @@
768784
if( z[i]==0 ) break;
769785
}
770786
z[j] = z[i];
771787
}
772788
z[j] = 0;
773
- fossil_warning("server sends error: %s", z);
789
+ if( mHttpFlags & HTTP_QUIET ){
790
+ /* no-op */
791
+ }else if( mHttpFlags & HTTP_VERBOSE ){
792
+ fossil_warning("server sends error: %s", z);
793
+ }else{
794
+ fossil_warning("server sends error");
795
+ }
774796
goto write_err;
775797
}
776798
if( isCompressed ) blob_uncompress(pReply, pReply);
777799
778800
/*
@@ -794,10 +816,11 @@
794816
795817
/*
796818
** Jump to here if an error is seen.
797819
*/
798820
write_err:
821
+ g.iResultCode = 1;
799822
transport_close(&g.url);
800823
return 1;
801824
}
802825
803826
/*
804827
--- src/http.c
+++ src/http.c
@@ -581,11 +581,13 @@
581 }
582 if( rc!=200 && rc!=301 && rc!=302 && rc!=307 && rc!=308 ){
583 int ii;
584 for(ii=7; zLine[ii] && zLine[ii]!=' '; ii++){}
585 while( zLine[ii]==' ' ) ii++;
586 fossil_warning("server says: %s", &zLine[ii]);
 
 
587 goto write_err;
588 }
589 if( iHttpVersion==0 ){
590 closeConnection = 1;
591 }else{
@@ -616,11 +618,13 @@
616 int i, j;
617 int wasHttps;
618 int priorUrlFlags;
619
620 if ( --maxRedirect == 0){
621 fossil_warning("redirect limit exceeded");
 
 
622 goto write_err;
623 }
624 for(i=9; zLine[i] && zLine[i]==' '; i++){}
625 if( zLine[i]==0 ){
626 fossil_warning("malformed redirect: %s", zLine);
@@ -633,23 +637,29 @@
633 }
634 if( (mHttpFlags & HTTP_QUIET)==0 ){
635 fossil_print("redirect with status %d to %s\n", rc, &zLine[i]);
636 }
637 if( g.url.isFile || g.url.isSsh ){
638 fossil_warning("cannot redirect from %s to %s", g.url.canonical,
639 &zLine[i]);
 
 
640 goto write_err;
641 }
642 wasHttps = g.url.isHttps;
643 priorUrlFlags = g.url.flags;
644 url_parse(&zLine[i], 0);
645 if( wasHttps && !g.url.isHttps ){
646 fossil_warning("cannot redirect from HTTPS to HTTP");
 
 
647 goto write_err;
648 }
649 if( g.url.isSsh || g.url.isFile ){
650 fossil_warning("cannot redirect to %s", &zLine[i]);
 
 
651 goto write_err;
652 }
653 transport_close(&g.url);
654 transport_global_shutdown(&g.url);
655 fSeenHttpAuth = 0;
@@ -704,20 +714,23 @@
704 }
705 return rc;
706 }else{
707 /* The problem could not be corrected by retrying. Report the
708 ** the error. */
709 if( g.url.isSsh && !g.fSshTrace ){
 
 
710 fossil_warning("server did not reply: "
711 " rerun with --sshtrace for diagnostics");
712 }else{
713 fossil_warning("server did not reply");
714 }
715 goto write_err;
716 }
717 }
718 if( rc!=200 ){
 
719 fossil_warning("\"location:\" missing from %d redirect reply", rc);
720 goto write_err;
721 }
722
723 /*
@@ -733,10 +746,11 @@
733 iRecvLen = transport_receive(&g.url, blob_buffer(pReply), iLength);
734 if( mHttpFlags & HTTP_VERBOSE ){
735 fossil_print("Reply received: %d of %d bytes\n", iRecvLen, iLength);
736 }
737 if( iRecvLen != iLength ){
 
738 fossil_warning("response truncated: got %d bytes of %d",
739 iRecvLen, iLength);
740 goto write_err;
741 }
742 }else if( closeConnection ){
@@ -754,11 +768,13 @@
754 if( mHttpFlags & HTTP_VERBOSE ){
755 fossil_print("Reply received: %u bytes (w/o content-length)\n", nPrior);
756 }
757 }else{
758 assert( iLength<0 && !closeConnection );
 
759 fossil_warning("\"content-length\" missing from %d keep-alive reply", rc);
 
760 }
761 if( isError ){
762 char *z;
763 int i, j;
764 z = blob_str(pReply);
@@ -768,11 +784,17 @@
768 if( z[i]==0 ) break;
769 }
770 z[j] = z[i];
771 }
772 z[j] = 0;
773 fossil_warning("server sends error: %s", z);
 
 
 
 
 
 
774 goto write_err;
775 }
776 if( isCompressed ) blob_uncompress(pReply, pReply);
777
778 /*
@@ -794,10 +816,11 @@
794
795 /*
796 ** Jump to here if an error is seen.
797 */
798 write_err:
 
799 transport_close(&g.url);
800 return 1;
801 }
802
803 /*
804
--- src/http.c
+++ src/http.c
@@ -581,11 +581,13 @@
581 }
582 if( rc!=200 && rc!=301 && rc!=302 && rc!=307 && rc!=308 ){
583 int ii;
584 for(ii=7; zLine[ii] && zLine[ii]!=' '; ii++){}
585 while( zLine[ii]==' ' ) ii++;
586 if( (mHttpFlags & HTTP_QUIET)==0 ){
587 fossil_warning("server says: %s", &zLine[ii]);
588 }
589 goto write_err;
590 }
591 if( iHttpVersion==0 ){
592 closeConnection = 1;
593 }else{
@@ -616,11 +618,13 @@
618 int i, j;
619 int wasHttps;
620 int priorUrlFlags;
621
622 if ( --maxRedirect == 0){
623 if( (mHttpFlags & HTTP_QUIET)==0 ){
624 fossil_warning("redirect limit exceeded");
625 }
626 goto write_err;
627 }
628 for(i=9; zLine[i] && zLine[i]==' '; i++){}
629 if( zLine[i]==0 ){
630 fossil_warning("malformed redirect: %s", zLine);
@@ -633,23 +637,29 @@
637 }
638 if( (mHttpFlags & HTTP_QUIET)==0 ){
639 fossil_print("redirect with status %d to %s\n", rc, &zLine[i]);
640 }
641 if( g.url.isFile || g.url.isSsh ){
642 if( (mHttpFlags & HTTP_QUIET)==0 ){
643 fossil_warning("cannot redirect from %s to %s", g.url.canonical,
644 &zLine[i]);
645 }
646 goto write_err;
647 }
648 wasHttps = g.url.isHttps;
649 priorUrlFlags = g.url.flags;
650 url_parse(&zLine[i], 0);
651 if( wasHttps && !g.url.isHttps ){
652 if( (mHttpFlags & HTTP_QUIET)==0 ){
653 fossil_warning("cannot redirect from HTTPS to HTTP");
654 }
655 goto write_err;
656 }
657 if( g.url.isSsh || g.url.isFile ){
658 if( (mHttpFlags & HTTP_QUIET)==0 ){
659 fossil_warning("cannot redirect to %s", &zLine[i]);
660 }
661 goto write_err;
662 }
663 transport_close(&g.url);
664 transport_global_shutdown(&g.url);
665 fSeenHttpAuth = 0;
@@ -704,20 +714,23 @@
714 }
715 return rc;
716 }else{
717 /* The problem could not be corrected by retrying. Report the
718 ** the error. */
719 if( mHttpFlags & HTTP_QUIET ){
720 /* no-op */
721 }else if( g.url.isSsh && !g.fSshTrace ){
722 fossil_warning("server did not reply: "
723 " rerun with --sshtrace for diagnostics");
724 }else{
725 fossil_warning("server did not reply");
726 }
727 goto write_err;
728 }
729 }
730 if( rc!=200 ){
731 if( mHttpFlags & HTTP_QUIET ) goto write_err;
732 fossil_warning("\"location:\" missing from %d redirect reply", rc);
733 goto write_err;
734 }
735
736 /*
@@ -733,10 +746,11 @@
746 iRecvLen = transport_receive(&g.url, blob_buffer(pReply), iLength);
747 if( mHttpFlags & HTTP_VERBOSE ){
748 fossil_print("Reply received: %d of %d bytes\n", iRecvLen, iLength);
749 }
750 if( iRecvLen != iLength ){
751 if( mHttpFlags & HTTP_QUIET ) goto write_err;
752 fossil_warning("response truncated: got %d bytes of %d",
753 iRecvLen, iLength);
754 goto write_err;
755 }
756 }else if( closeConnection ){
@@ -754,11 +768,13 @@
768 if( mHttpFlags & HTTP_VERBOSE ){
769 fossil_print("Reply received: %u bytes (w/o content-length)\n", nPrior);
770 }
771 }else{
772 assert( iLength<0 && !closeConnection );
773 if( mHttpFlags & HTTP_QUIET ) goto write_err;
774 fossil_warning("\"content-length\" missing from %d keep-alive reply", rc);
775 goto write_err;
776 }
777 if( isError ){
778 char *z;
779 int i, j;
780 z = blob_str(pReply);
@@ -768,11 +784,17 @@
784 if( z[i]==0 ) break;
785 }
786 z[j] = z[i];
787 }
788 z[j] = 0;
789 if( mHttpFlags & HTTP_QUIET ){
790 /* no-op */
791 }else if( mHttpFlags & HTTP_VERBOSE ){
792 fossil_warning("server sends error: %s", z);
793 }else{
794 fossil_warning("server sends error");
795 }
796 goto write_err;
797 }
798 if( isCompressed ) blob_uncompress(pReply, pReply);
799
800 /*
@@ -794,10 +816,11 @@
816
817 /*
818 ** Jump to here if an error is seen.
819 */
820 write_err:
821 g.iResultCode = 1;
822 transport_close(&g.url);
823 return 1;
824 }
825
826 /*
827
+2 -1
--- src/main.c
+++ src/main.c
@@ -153,10 +153,11 @@
153153
char *nameOfExe; /* Full path of executable. */
154154
const char *zErrlog; /* Log errors to this file, if not NULL */
155155
const char *zPhase; /* Phase of operation, for use by the error log
156156
** and for deriving $canonical_page TH1 variable */
157157
int isConst; /* True if the output is unchanging & cacheable */
158
+ int iResultCode; /* Process reply code for commands */
158159
const char *zVfsName; /* The VFS to use for database connections */
159160
sqlite3 *db; /* The connection to the databases */
160161
sqlite3 *dbConfig; /* Separate connection for global_config table */
161162
char *zAuxSchema; /* Main repository aux-schema */
162163
int dbIgnoreErrors; /* Ignore database errors if true */
@@ -1016,11 +1017,11 @@
10161017
if( !g.isHTTP && !g.fNoThHook && (rc==TH_OK || rc==TH_CONTINUE) ){
10171018
Th_CommandNotify(pCmd->zName, pCmd->eCmdFlags);
10181019
}
10191020
}
10201021
#endif
1021
- fossil_exit(0);
1022
+ fossil_exit(g.iResultCode);
10221023
/*NOT_REACHED*/
10231024
return 0;
10241025
}
10251026
10261027
/*
10271028
--- src/main.c
+++ src/main.c
@@ -153,10 +153,11 @@
153 char *nameOfExe; /* Full path of executable. */
154 const char *zErrlog; /* Log errors to this file, if not NULL */
155 const char *zPhase; /* Phase of operation, for use by the error log
156 ** and for deriving $canonical_page TH1 variable */
157 int isConst; /* True if the output is unchanging & cacheable */
 
158 const char *zVfsName; /* The VFS to use for database connections */
159 sqlite3 *db; /* The connection to the databases */
160 sqlite3 *dbConfig; /* Separate connection for global_config table */
161 char *zAuxSchema; /* Main repository aux-schema */
162 int dbIgnoreErrors; /* Ignore database errors if true */
@@ -1016,11 +1017,11 @@
1016 if( !g.isHTTP && !g.fNoThHook && (rc==TH_OK || rc==TH_CONTINUE) ){
1017 Th_CommandNotify(pCmd->zName, pCmd->eCmdFlags);
1018 }
1019 }
1020 #endif
1021 fossil_exit(0);
1022 /*NOT_REACHED*/
1023 return 0;
1024 }
1025
1026 /*
1027
--- src/main.c
+++ src/main.c
@@ -153,10 +153,11 @@
153 char *nameOfExe; /* Full path of executable. */
154 const char *zErrlog; /* Log errors to this file, if not NULL */
155 const char *zPhase; /* Phase of operation, for use by the error log
156 ** and for deriving $canonical_page TH1 variable */
157 int isConst; /* True if the output is unchanging & cacheable */
158 int iResultCode; /* Process reply code for commands */
159 const char *zVfsName; /* The VFS to use for database connections */
160 sqlite3 *db; /* The connection to the databases */
161 sqlite3 *dbConfig; /* Separate connection for global_config table */
162 char *zAuxSchema; /* Main repository aux-schema */
163 int dbIgnoreErrors; /* Ignore database errors if true */
@@ -1016,11 +1017,11 @@
1017 if( !g.isHTTP && !g.fNoThHook && (rc==TH_OK || rc==TH_CONTINUE) ){
1018 Th_CommandNotify(pCmd->zName, pCmd->eCmdFlags);
1019 }
1020 }
1021 #endif
1022 fossil_exit(g.iResultCode);
1023 /*NOT_REACHED*/
1024 return 0;
1025 }
1026
1027 /*
1028
+16 -4
--- src/sync.c
+++ src/sync.c
@@ -23,11 +23,11 @@
2323
2424
/*
2525
** Explain what type of sync operation is about to occur
2626
*/
2727
static void sync_explain(unsigned syncFlags){
28
- if( g.url.isAlias ){
28
+ if( g.url.isAlias && (syncFlags & SYNC_QUIET)==0 ){
2929
const char *url;
3030
if( g.url.useProxy ){
3131
url = g.url.proxyUrlCanonical;
3232
}else{
3333
url = g.url.canonical;
@@ -36,10 +36,12 @@
3636
fossil_print("Sync with %s\n", url);
3737
}else if( syncFlags & SYNC_PUSH ){
3838
fossil_print("Push to %s\n", url);
3939
}else if( syncFlags & SYNC_PULL ){
4040
fossil_print("Pull from %s\n", url);
41
+ }else if( syncFlags & SYNC_PING ){
42
+ fossil_print("Ping %s\n", url);
4143
}
4244
}
4345
}
4446
4547
@@ -482,12 +484,14 @@
482484
** -B|--httpauth USER:PASS Credentials for the simple HTTP auth protocol,
483485
** if required by the remote website
484486
** --ipv4 Use only IPv4, not IPv6
485487
** --no-http-compression Do not compress HTTP traffic
486488
** --once Do not remember URL for subsequent syncs
489
+** --ping Just verify that the server is alive
487490
** --proxy PROXY Use the specified HTTP proxy
488491
** --private Sync private branches too
492
+** -q|--quiet Omit all output
489493
** -R|--repository REPO Local repository to sync with
490494
** --ssl-identity FILE Local SSL credentials, if requested by remote
491495
** --ssh-command SSH Use SSH as the "ssh" command
492496
** --transport-command CMD Use external command CMD to move message
493497
** between the client and the server
@@ -502,19 +506,27 @@
502506
void sync_cmd(void){
503507
unsigned configFlags = 0;
504508
unsigned syncFlags = SYNC_PUSH|SYNC_PULL;
505509
if( find_option("unversioned","u",0)!=0 ){
506510
syncFlags |= SYNC_UNVERSIONED;
511
+ }
512
+ if( find_option("ping",0,0)!=0 ){
513
+ syncFlags = SYNC_PING;
514
+ }
515
+ if( find_option("quiet","q",0)!=0 ){
516
+ syncFlags |= SYNC_QUIET;
507517
}
508518
process_sync_args(&configFlags, &syncFlags, 0, 0);
509519
510520
/* We should be done with options.. */
511521
verify_all_options();
512522
513
- if( db_get_boolean("dont-push",0) ) syncFlags &= ~SYNC_PUSH;
514
- if( (syncFlags & SYNC_PUSH)==0 ){
515
- fossil_warning("pull only: the 'dont-push' option is set");
523
+ if( (syncFlags & SYNC_PING)==0 ){
524
+ if( db_get_boolean("dont-push",0) ) syncFlags &= ~SYNC_PUSH;
525
+ if( (syncFlags & SYNC_PUSH)==0 ){
526
+ fossil_warning("pull only: the 'dont-push' option is set");
527
+ }
516528
}
517529
client_sync_all_urls(syncFlags, configFlags, 0, 0);
518530
}
519531
520532
/*
521533
--- src/sync.c
+++ src/sync.c
@@ -23,11 +23,11 @@
23
24 /*
25 ** Explain what type of sync operation is about to occur
26 */
27 static void sync_explain(unsigned syncFlags){
28 if( g.url.isAlias ){
29 const char *url;
30 if( g.url.useProxy ){
31 url = g.url.proxyUrlCanonical;
32 }else{
33 url = g.url.canonical;
@@ -36,10 +36,12 @@
36 fossil_print("Sync with %s\n", url);
37 }else if( syncFlags & SYNC_PUSH ){
38 fossil_print("Push to %s\n", url);
39 }else if( syncFlags & SYNC_PULL ){
40 fossil_print("Pull from %s\n", url);
 
 
41 }
42 }
43 }
44
45
@@ -482,12 +484,14 @@
482 ** -B|--httpauth USER:PASS Credentials for the simple HTTP auth protocol,
483 ** if required by the remote website
484 ** --ipv4 Use only IPv4, not IPv6
485 ** --no-http-compression Do not compress HTTP traffic
486 ** --once Do not remember URL for subsequent syncs
 
487 ** --proxy PROXY Use the specified HTTP proxy
488 ** --private Sync private branches too
 
489 ** -R|--repository REPO Local repository to sync with
490 ** --ssl-identity FILE Local SSL credentials, if requested by remote
491 ** --ssh-command SSH Use SSH as the "ssh" command
492 ** --transport-command CMD Use external command CMD to move message
493 ** between the client and the server
@@ -502,19 +506,27 @@
502 void sync_cmd(void){
503 unsigned configFlags = 0;
504 unsigned syncFlags = SYNC_PUSH|SYNC_PULL;
505 if( find_option("unversioned","u",0)!=0 ){
506 syncFlags |= SYNC_UNVERSIONED;
 
 
 
 
 
 
507 }
508 process_sync_args(&configFlags, &syncFlags, 0, 0);
509
510 /* We should be done with options.. */
511 verify_all_options();
512
513 if( db_get_boolean("dont-push",0) ) syncFlags &= ~SYNC_PUSH;
514 if( (syncFlags & SYNC_PUSH)==0 ){
515 fossil_warning("pull only: the 'dont-push' option is set");
 
 
516 }
517 client_sync_all_urls(syncFlags, configFlags, 0, 0);
518 }
519
520 /*
521
--- src/sync.c
+++ src/sync.c
@@ -23,11 +23,11 @@
23
24 /*
25 ** Explain what type of sync operation is about to occur
26 */
27 static void sync_explain(unsigned syncFlags){
28 if( g.url.isAlias && (syncFlags & SYNC_QUIET)==0 ){
29 const char *url;
30 if( g.url.useProxy ){
31 url = g.url.proxyUrlCanonical;
32 }else{
33 url = g.url.canonical;
@@ -36,10 +36,12 @@
36 fossil_print("Sync with %s\n", url);
37 }else if( syncFlags & SYNC_PUSH ){
38 fossil_print("Push to %s\n", url);
39 }else if( syncFlags & SYNC_PULL ){
40 fossil_print("Pull from %s\n", url);
41 }else if( syncFlags & SYNC_PING ){
42 fossil_print("Ping %s\n", url);
43 }
44 }
45 }
46
47
@@ -482,12 +484,14 @@
484 ** -B|--httpauth USER:PASS Credentials for the simple HTTP auth protocol,
485 ** if required by the remote website
486 ** --ipv4 Use only IPv4, not IPv6
487 ** --no-http-compression Do not compress HTTP traffic
488 ** --once Do not remember URL for subsequent syncs
489 ** --ping Just verify that the server is alive
490 ** --proxy PROXY Use the specified HTTP proxy
491 ** --private Sync private branches too
492 ** -q|--quiet Omit all output
493 ** -R|--repository REPO Local repository to sync with
494 ** --ssl-identity FILE Local SSL credentials, if requested by remote
495 ** --ssh-command SSH Use SSH as the "ssh" command
496 ** --transport-command CMD Use external command CMD to move message
497 ** between the client and the server
@@ -502,19 +506,27 @@
506 void sync_cmd(void){
507 unsigned configFlags = 0;
508 unsigned syncFlags = SYNC_PUSH|SYNC_PULL;
509 if( find_option("unversioned","u",0)!=0 ){
510 syncFlags |= SYNC_UNVERSIONED;
511 }
512 if( find_option("ping",0,0)!=0 ){
513 syncFlags = SYNC_PING;
514 }
515 if( find_option("quiet","q",0)!=0 ){
516 syncFlags |= SYNC_QUIET;
517 }
518 process_sync_args(&configFlags, &syncFlags, 0, 0);
519
520 /* We should be done with options.. */
521 verify_all_options();
522
523 if( (syncFlags & SYNC_PING)==0 ){
524 if( db_get_boolean("dont-push",0) ) syncFlags &= ~SYNC_PUSH;
525 if( (syncFlags & SYNC_PUSH)==0 ){
526 fossil_warning("pull only: the 'dont-push' option is set");
527 }
528 }
529 client_sync_all_urls(syncFlags, configFlags, 0, 0);
530 }
531
532 /*
533
+15 -3
--- src/xfer.c
+++ src/xfer.c
@@ -2049,10 +2049,12 @@
20492049
#define SYNC_CKIN_LOCK 0x02000 /* Lock the current check-in */
20502050
#define SYNC_NOHTTPCOMPRESS 0x04000 /* Do not compression HTTP messages */
20512051
#define SYNC_ALLURL 0x08000 /* The --all flag - sync to all URLs */
20522052
#define SYNC_SHARE_LINKS 0x10000 /* Request alternate repo links */
20532053
#define SYNC_XVERBOSE 0x20000 /* Extra verbose. Network traffic */
2054
+#define SYNC_PING 0x40000 /* Verify server is alive */
2055
+#define SYNC_QUIET 0x80000 /* No output */
20542056
#endif
20552057
20562058
/*
20572059
** Floating-point absolute value
20582060
*/
@@ -2115,11 +2117,12 @@
21152117
unsigned int mHttpFlags;/* Flags for the http_exchange() subsystem */
21162118
const int bOutIsTty = fossil_isatty(fossil_fileno(stdout));
21172119
21182120
if( pnRcvd ) *pnRcvd = 0;
21192121
if( db_get_boolean("dont-push", 0) ) syncFlags &= ~SYNC_PUSH;
2120
- if( (syncFlags & (SYNC_PUSH|SYNC_PULL|SYNC_CLONE|SYNC_UNVERSIONED))==0
2122
+ if( (syncFlags & (SYNC_PUSH|SYNC_PULL|SYNC_CLONE|SYNC_UNVERSIONED|SYNC_PING))
2123
+ ==0
21212124
&& configRcvMask==0
21222125
&& configSendMask==0
21232126
){
21242127
return 0; /* Nothing to do */
21252128
}
@@ -2410,10 +2413,13 @@
24102413
mHttpFlags |= HTTP_NOCOMPRESS;
24112414
}
24122415
if( syncFlags & SYNC_XVERBOSE ){
24132416
mHttpFlags |= HTTP_VERBOSE;
24142417
}
2418
+ if( syncFlags & SYNC_QUIET ){
2419
+ mHttpFlags |= HTTP_QUIET;
2420
+ }
24152421
24162422
/* Do the round-trip to the server */
24172423
if( http_exchange(&send, &recv, mHttpFlags, MAX_REDIRECTS, 0) ){
24182424
nErr++;
24192425
go = 2;
@@ -2431,10 +2437,12 @@
24312437
nArtifactSent += xfer.nFileSent + xfer.nDeltaSent;
24322438
if( syncFlags & SYNC_VERBOSE ){
24332439
fossil_print(zValueFormat /*works-like:"%s%d%d%d%d"*/, "Sent:",
24342440
blob_size(&send), nCardSent+xfer.nGimmeSent+xfer.nIGotSent,
24352441
xfer.nFileSent, xfer.nDeltaSent);
2442
+ }else if( syncFlags & SYNC_QUIET ){
2443
+ /* No-op */
24362444
}else{
24372445
if( bOutIsTty!=0 ){
24382446
fossil_print(zBriefFormat /*works-like:"%d%d%d"*/,
24392447
nRoundtrip, nArtifactSent, nArtifactRcvd);
24402448
}
@@ -2954,10 +2962,12 @@
29542962
origConfigRcvMask = 0;
29552963
if( nCardRcvd>0 && (syncFlags & SYNC_VERBOSE) ){
29562964
fossil_print(zValueFormat /*works-like:"%s%d%d%d%d"*/, "Received:",
29572965
blob_size(&recv), nCardRcvd,
29582966
xfer.nFileRcvd, xfer.nDeltaRcvd + xfer.nDanglingFile);
2967
+ }else if( syncFlags && SYNC_QUIET ){
2968
+ /* No-op */
29592969
}else{
29602970
if( bOutIsTty!=0 ){
29612971
fossil_print(zBriefFormat /*works-like:"%d%d%d"*/,
29622972
nRoundtrip, nArtifactSent, nArtifactRcvd);
29632973
}
@@ -3016,18 +3026,20 @@
30163026
}else if( rSkew*24.0*3600.0 < -10.0 ){
30173027
fossil_warning("*** time skew *** server is slow by %s",
30183028
db_timespan_name(-rSkew));
30193029
g.clockSkewSeen = 1;
30203030
}
3021
- if( bOutIsTty==0 ){
3031
+ if( bOutIsTty==0 && (syncFlags & SYNC_QUIET)==0 ){
30223032
fossil_print(zBriefFormat /*works-like:"%d%d%d"*/,
30233033
nRoundtrip, nArtifactSent, nArtifactRcvd);
30243034
fossil_force_newline();
30253035
}
30263036
fossil_force_newline();
30273037
if( g.zHttpCmd==0 ){
3028
- if( syncFlags & SYNC_VERBOSE ){
3038
+ if( syncFlags & SYNC_QUIET ){
3039
+ /* no-op */
3040
+ }else if( syncFlags & SYNC_VERBOSE ){
30293041
fossil_print(
30303042
"%s done, wire bytes sent: %lld received: %lld remote: %s%s\n",
30313043
zOpType, nSent, nRcvd,
30323044
(g.url.name && g.url.name[0]!='\0') ? g.url.name : "",
30333045
(g.zIpAddr && g.zIpAddr[0]!='\0'
30343046
--- src/xfer.c
+++ src/xfer.c
@@ -2049,10 +2049,12 @@
2049 #define SYNC_CKIN_LOCK 0x02000 /* Lock the current check-in */
2050 #define SYNC_NOHTTPCOMPRESS 0x04000 /* Do not compression HTTP messages */
2051 #define SYNC_ALLURL 0x08000 /* The --all flag - sync to all URLs */
2052 #define SYNC_SHARE_LINKS 0x10000 /* Request alternate repo links */
2053 #define SYNC_XVERBOSE 0x20000 /* Extra verbose. Network traffic */
 
 
2054 #endif
2055
2056 /*
2057 ** Floating-point absolute value
2058 */
@@ -2115,11 +2117,12 @@
2115 unsigned int mHttpFlags;/* Flags for the http_exchange() subsystem */
2116 const int bOutIsTty = fossil_isatty(fossil_fileno(stdout));
2117
2118 if( pnRcvd ) *pnRcvd = 0;
2119 if( db_get_boolean("dont-push", 0) ) syncFlags &= ~SYNC_PUSH;
2120 if( (syncFlags & (SYNC_PUSH|SYNC_PULL|SYNC_CLONE|SYNC_UNVERSIONED))==0
 
2121 && configRcvMask==0
2122 && configSendMask==0
2123 ){
2124 return 0; /* Nothing to do */
2125 }
@@ -2410,10 +2413,13 @@
2410 mHttpFlags |= HTTP_NOCOMPRESS;
2411 }
2412 if( syncFlags & SYNC_XVERBOSE ){
2413 mHttpFlags |= HTTP_VERBOSE;
2414 }
 
 
 
2415
2416 /* Do the round-trip to the server */
2417 if( http_exchange(&send, &recv, mHttpFlags, MAX_REDIRECTS, 0) ){
2418 nErr++;
2419 go = 2;
@@ -2431,10 +2437,12 @@
2431 nArtifactSent += xfer.nFileSent + xfer.nDeltaSent;
2432 if( syncFlags & SYNC_VERBOSE ){
2433 fossil_print(zValueFormat /*works-like:"%s%d%d%d%d"*/, "Sent:",
2434 blob_size(&send), nCardSent+xfer.nGimmeSent+xfer.nIGotSent,
2435 xfer.nFileSent, xfer.nDeltaSent);
 
 
2436 }else{
2437 if( bOutIsTty!=0 ){
2438 fossil_print(zBriefFormat /*works-like:"%d%d%d"*/,
2439 nRoundtrip, nArtifactSent, nArtifactRcvd);
2440 }
@@ -2954,10 +2962,12 @@
2954 origConfigRcvMask = 0;
2955 if( nCardRcvd>0 && (syncFlags & SYNC_VERBOSE) ){
2956 fossil_print(zValueFormat /*works-like:"%s%d%d%d%d"*/, "Received:",
2957 blob_size(&recv), nCardRcvd,
2958 xfer.nFileRcvd, xfer.nDeltaRcvd + xfer.nDanglingFile);
 
 
2959 }else{
2960 if( bOutIsTty!=0 ){
2961 fossil_print(zBriefFormat /*works-like:"%d%d%d"*/,
2962 nRoundtrip, nArtifactSent, nArtifactRcvd);
2963 }
@@ -3016,18 +3026,20 @@
3016 }else if( rSkew*24.0*3600.0 < -10.0 ){
3017 fossil_warning("*** time skew *** server is slow by %s",
3018 db_timespan_name(-rSkew));
3019 g.clockSkewSeen = 1;
3020 }
3021 if( bOutIsTty==0 ){
3022 fossil_print(zBriefFormat /*works-like:"%d%d%d"*/,
3023 nRoundtrip, nArtifactSent, nArtifactRcvd);
3024 fossil_force_newline();
3025 }
3026 fossil_force_newline();
3027 if( g.zHttpCmd==0 ){
3028 if( syncFlags & SYNC_VERBOSE ){
 
 
3029 fossil_print(
3030 "%s done, wire bytes sent: %lld received: %lld remote: %s%s\n",
3031 zOpType, nSent, nRcvd,
3032 (g.url.name && g.url.name[0]!='\0') ? g.url.name : "",
3033 (g.zIpAddr && g.zIpAddr[0]!='\0'
3034
--- src/xfer.c
+++ src/xfer.c
@@ -2049,10 +2049,12 @@
2049 #define SYNC_CKIN_LOCK 0x02000 /* Lock the current check-in */
2050 #define SYNC_NOHTTPCOMPRESS 0x04000 /* Do not compression HTTP messages */
2051 #define SYNC_ALLURL 0x08000 /* The --all flag - sync to all URLs */
2052 #define SYNC_SHARE_LINKS 0x10000 /* Request alternate repo links */
2053 #define SYNC_XVERBOSE 0x20000 /* Extra verbose. Network traffic */
2054 #define SYNC_PING 0x40000 /* Verify server is alive */
2055 #define SYNC_QUIET 0x80000 /* No output */
2056 #endif
2057
2058 /*
2059 ** Floating-point absolute value
2060 */
@@ -2115,11 +2117,12 @@
2117 unsigned int mHttpFlags;/* Flags for the http_exchange() subsystem */
2118 const int bOutIsTty = fossil_isatty(fossil_fileno(stdout));
2119
2120 if( pnRcvd ) *pnRcvd = 0;
2121 if( db_get_boolean("dont-push", 0) ) syncFlags &= ~SYNC_PUSH;
2122 if( (syncFlags & (SYNC_PUSH|SYNC_PULL|SYNC_CLONE|SYNC_UNVERSIONED|SYNC_PING))
2123 ==0
2124 && configRcvMask==0
2125 && configSendMask==0
2126 ){
2127 return 0; /* Nothing to do */
2128 }
@@ -2410,10 +2413,13 @@
2413 mHttpFlags |= HTTP_NOCOMPRESS;
2414 }
2415 if( syncFlags & SYNC_XVERBOSE ){
2416 mHttpFlags |= HTTP_VERBOSE;
2417 }
2418 if( syncFlags & SYNC_QUIET ){
2419 mHttpFlags |= HTTP_QUIET;
2420 }
2421
2422 /* Do the round-trip to the server */
2423 if( http_exchange(&send, &recv, mHttpFlags, MAX_REDIRECTS, 0) ){
2424 nErr++;
2425 go = 2;
@@ -2431,10 +2437,12 @@
2437 nArtifactSent += xfer.nFileSent + xfer.nDeltaSent;
2438 if( syncFlags & SYNC_VERBOSE ){
2439 fossil_print(zValueFormat /*works-like:"%s%d%d%d%d"*/, "Sent:",
2440 blob_size(&send), nCardSent+xfer.nGimmeSent+xfer.nIGotSent,
2441 xfer.nFileSent, xfer.nDeltaSent);
2442 }else if( syncFlags & SYNC_QUIET ){
2443 /* No-op */
2444 }else{
2445 if( bOutIsTty!=0 ){
2446 fossil_print(zBriefFormat /*works-like:"%d%d%d"*/,
2447 nRoundtrip, nArtifactSent, nArtifactRcvd);
2448 }
@@ -2954,10 +2962,12 @@
2962 origConfigRcvMask = 0;
2963 if( nCardRcvd>0 && (syncFlags & SYNC_VERBOSE) ){
2964 fossil_print(zValueFormat /*works-like:"%s%d%d%d%d"*/, "Received:",
2965 blob_size(&recv), nCardRcvd,
2966 xfer.nFileRcvd, xfer.nDeltaRcvd + xfer.nDanglingFile);
2967 }else if( syncFlags && SYNC_QUIET ){
2968 /* No-op */
2969 }else{
2970 if( bOutIsTty!=0 ){
2971 fossil_print(zBriefFormat /*works-like:"%d%d%d"*/,
2972 nRoundtrip, nArtifactSent, nArtifactRcvd);
2973 }
@@ -3016,18 +3026,20 @@
3026 }else if( rSkew*24.0*3600.0 < -10.0 ){
3027 fossil_warning("*** time skew *** server is slow by %s",
3028 db_timespan_name(-rSkew));
3029 g.clockSkewSeen = 1;
3030 }
3031 if( bOutIsTty==0 && (syncFlags & SYNC_QUIET)==0 ){
3032 fossil_print(zBriefFormat /*works-like:"%d%d%d"*/,
3033 nRoundtrip, nArtifactSent, nArtifactRcvd);
3034 fossil_force_newline();
3035 }
3036 fossil_force_newline();
3037 if( g.zHttpCmd==0 ){
3038 if( syncFlags & SYNC_QUIET ){
3039 /* no-op */
3040 }else if( syncFlags & SYNC_VERBOSE ){
3041 fossil_print(
3042 "%s done, wire bytes sent: %lld received: %lld remote: %s%s\n",
3043 zOpType, nSent, nRcvd,
3044 (g.url.name && g.url.name[0]!='\0') ? g.url.name : "",
3045 (g.zIpAddr && g.zIpAddr[0]!='\0'
3046

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button