Fossil SCM

Further improvements to "fossil all git status" output. Do not show repositories for which the git export repository does not exist or is inactive.

drh 2021-08-14 18:25 trunk
Commit 999d838de2a2c57af3cad89e00a08e09ea67665521aa2a69f194b357d4b17eb7
2 files changed +1 -1 +18 -5
+1 -1
--- src/allrepo.c
+++ src/allrepo.c
@@ -254,11 +254,11 @@
254254
}else{
255255
int n3 = (int)strlen(g.argv[3]);
256256
if( strncmp(g.argv[3], "export", n3)==0 ){
257257
zCmd = "git export --if-mirrored -R";
258258
}else if( strncmp(g.argv[3], "status", n3)==0 ){
259
- zCmd = "git status --by-all -R";
259
+ zCmd = "git status --by-all -q -R";
260260
quiet = 1;
261261
}else{
262262
usage("git (export|status)");
263263
}
264264
}
265265
--- src/allrepo.c
+++ src/allrepo.c
@@ -254,11 +254,11 @@
254 }else{
255 int n3 = (int)strlen(g.argv[3]);
256 if( strncmp(g.argv[3], "export", n3)==0 ){
257 zCmd = "git export --if-mirrored -R";
258 }else if( strncmp(g.argv[3], "status", n3)==0 ){
259 zCmd = "git status --by-all -R";
260 quiet = 1;
261 }else{
262 usage("git (export|status)");
263 }
264 }
265
--- src/allrepo.c
+++ src/allrepo.c
@@ -254,11 +254,11 @@
254 }else{
255 int n3 = (int)strlen(g.argv[3]);
256 if( strncmp(g.argv[3], "export", n3)==0 ){
257 zCmd = "git export --if-mirrored -R";
258 }else if( strncmp(g.argv[3], "status", n3)==0 ){
259 zCmd = "git status --by-all -q -R";
260 quiet = 1;
261 }else{
262 usage("git (export|status)");
263 }
264 }
265
+18 -5
--- src/export.c
+++ src/export.c
@@ -1728,10 +1728,12 @@
17281728
*/
17291729
void gitmirror_status_command(void){
17301730
char *zMirror;
17311731
char *z;
17321732
int n, k;
1733
+ int rc;
1734
+ char *zSql;
17331735
int bQuiet = 0;
17341736
int bByAll = 0; /* Undocumented option meaning this command was invoked
17351737
** from "fossil all" and should modify output accordingly */
17361738
17371739
db_find_and_open_repository(0, 0);
@@ -1738,13 +1740,25 @@
17381740
bQuiet = find_option("quiet","q",0)!=0;
17391741
bByAll = find_option("by-all",0,0)!=0;
17401742
verify_all_options();
17411743
zMirror = db_get("last-git-export-repo", 0);
17421744
if( zMirror==0 ){
1743
- if( !bQuiet && !bByAll ){
1744
- fossil_print("Git mirror: none\n");
1745
- }
1745
+ if( bQuiet ) return;
1746
+ if( bByAll ) return;
1747
+ fossil_print("Git mirror: none\n");
1748
+ return;
1749
+ }
1750
+ zSql = sqlite3_mprintf("ATTACH '%q/.mirror_state/db' AS mirror", zMirror);
1751
+ if( zSql==0 ) fossil_fatal("out of memory");
1752
+ g.dbIgnoreErrors++;
1753
+ rc = sqlite3_exec(g.db, zSql, 0, 0, 0);
1754
+ g.dbIgnoreErrors--;
1755
+ sqlite3_free(zSql);
1756
+ if( rc ){
1757
+ if( bQuiet ) return;
1758
+ if( bByAll ) return;
1759
+ fossil_print("Git mirror: %s (Inactive)\n", zMirror);
17461760
return;
17471761
}
17481762
if( bByAll ){
17491763
size_t len = strlen(g.zRepositoryName);
17501764
int n;
@@ -1751,11 +1765,10 @@
17511765
if( len>60 ) len = 60;
17521766
n = (int)(65 - len);
17531767
fossil_print("%.12c %s %.*c\n", '*', g.zRepositoryName, n, '*');
17541768
}
17551769
fossil_print("Git mirror: %s\n", zMirror);
1756
- db_multi_exec("ATTACH '%q/.mirror_state/db' AS mirror;", zMirror);
17571770
z = db_text(0, "SELECT datetime(value) FROM mconfig WHERE key='start'");
17581771
if( z ){
17591772
double rAge = db_double(0.0, "SELECT julianday('now') - value"
17601773
" FROM mconfig WHERE key='start'");
17611774
if( rAge>1.0/86400.0 ){
@@ -1786,11 +1799,11 @@
17861799
}else{
17871800
fossil_print("Status: %d check-in%s awaiting export\n",
17881801
n, n==1 ? "" : "s");
17891802
}
17901803
n = db_int(0, "SELECT count(*) FROM mmark WHERE isfile");
1791
- k = db_int(0, "SELECT count(*) FROm mmark WHERE NOT isfile");
1804
+ k = db_int(0, "SELECT count(*) FROM mmark WHERE NOT isfile");
17921805
fossil_print("Exported: %d check-ins and %d file blobs\n", k, n);
17931806
}
17941807
17951808
/*
17961809
** COMMAND: git*
17971810
--- src/export.c
+++ src/export.c
@@ -1728,10 +1728,12 @@
1728 */
1729 void gitmirror_status_command(void){
1730 char *zMirror;
1731 char *z;
1732 int n, k;
 
 
1733 int bQuiet = 0;
1734 int bByAll = 0; /* Undocumented option meaning this command was invoked
1735 ** from "fossil all" and should modify output accordingly */
1736
1737 db_find_and_open_repository(0, 0);
@@ -1738,13 +1740,25 @@
1738 bQuiet = find_option("quiet","q",0)!=0;
1739 bByAll = find_option("by-all",0,0)!=0;
1740 verify_all_options();
1741 zMirror = db_get("last-git-export-repo", 0);
1742 if( zMirror==0 ){
1743 if( !bQuiet && !bByAll ){
1744 fossil_print("Git mirror: none\n");
1745 }
 
 
 
 
 
 
 
 
 
 
 
 
1746 return;
1747 }
1748 if( bByAll ){
1749 size_t len = strlen(g.zRepositoryName);
1750 int n;
@@ -1751,11 +1765,10 @@
1751 if( len>60 ) len = 60;
1752 n = (int)(65 - len);
1753 fossil_print("%.12c %s %.*c\n", '*', g.zRepositoryName, n, '*');
1754 }
1755 fossil_print("Git mirror: %s\n", zMirror);
1756 db_multi_exec("ATTACH '%q/.mirror_state/db' AS mirror;", zMirror);
1757 z = db_text(0, "SELECT datetime(value) FROM mconfig WHERE key='start'");
1758 if( z ){
1759 double rAge = db_double(0.0, "SELECT julianday('now') - value"
1760 " FROM mconfig WHERE key='start'");
1761 if( rAge>1.0/86400.0 ){
@@ -1786,11 +1799,11 @@
1786 }else{
1787 fossil_print("Status: %d check-in%s awaiting export\n",
1788 n, n==1 ? "" : "s");
1789 }
1790 n = db_int(0, "SELECT count(*) FROM mmark WHERE isfile");
1791 k = db_int(0, "SELECT count(*) FROm mmark WHERE NOT isfile");
1792 fossil_print("Exported: %d check-ins and %d file blobs\n", k, n);
1793 }
1794
1795 /*
1796 ** COMMAND: git*
1797
--- src/export.c
+++ src/export.c
@@ -1728,10 +1728,12 @@
1728 */
1729 void gitmirror_status_command(void){
1730 char *zMirror;
1731 char *z;
1732 int n, k;
1733 int rc;
1734 char *zSql;
1735 int bQuiet = 0;
1736 int bByAll = 0; /* Undocumented option meaning this command was invoked
1737 ** from "fossil all" and should modify output accordingly */
1738
1739 db_find_and_open_repository(0, 0);
@@ -1738,13 +1740,25 @@
1740 bQuiet = find_option("quiet","q",0)!=0;
1741 bByAll = find_option("by-all",0,0)!=0;
1742 verify_all_options();
1743 zMirror = db_get("last-git-export-repo", 0);
1744 if( zMirror==0 ){
1745 if( bQuiet ) return;
1746 if( bByAll ) return;
1747 fossil_print("Git mirror: none\n");
1748 return;
1749 }
1750 zSql = sqlite3_mprintf("ATTACH '%q/.mirror_state/db' AS mirror", zMirror);
1751 if( zSql==0 ) fossil_fatal("out of memory");
1752 g.dbIgnoreErrors++;
1753 rc = sqlite3_exec(g.db, zSql, 0, 0, 0);
1754 g.dbIgnoreErrors--;
1755 sqlite3_free(zSql);
1756 if( rc ){
1757 if( bQuiet ) return;
1758 if( bByAll ) return;
1759 fossil_print("Git mirror: %s (Inactive)\n", zMirror);
1760 return;
1761 }
1762 if( bByAll ){
1763 size_t len = strlen(g.zRepositoryName);
1764 int n;
@@ -1751,11 +1765,10 @@
1765 if( len>60 ) len = 60;
1766 n = (int)(65 - len);
1767 fossil_print("%.12c %s %.*c\n", '*', g.zRepositoryName, n, '*');
1768 }
1769 fossil_print("Git mirror: %s\n", zMirror);
 
1770 z = db_text(0, "SELECT datetime(value) FROM mconfig WHERE key='start'");
1771 if( z ){
1772 double rAge = db_double(0.0, "SELECT julianday('now') - value"
1773 " FROM mconfig WHERE key='start'");
1774 if( rAge>1.0/86400.0 ){
@@ -1786,11 +1799,11 @@
1799 }else{
1800 fossil_print("Status: %d check-in%s awaiting export\n",
1801 n, n==1 ? "" : "s");
1802 }
1803 n = db_int(0, "SELECT count(*) FROM mmark WHERE isfile");
1804 k = db_int(0, "SELECT count(*) FROM mmark WHERE NOT isfile");
1805 fossil_print("Exported: %d check-ins and %d file blobs\n", k, n);
1806 }
1807
1808 /*
1809 ** COMMAND: git*
1810

Keyboard Shortcuts

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