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.
Commit
999d838de2a2c57af3cad89e00a08e09ea67665521aa2a69f194b357d4b17eb7
Parent
9179663d8c0efc0…
2 files changed
+1
-1
+18
-5
+1
-1
| --- src/allrepo.c | ||
| +++ src/allrepo.c | ||
| @@ -254,11 +254,11 @@ | ||
| 254 | 254 | }else{ |
| 255 | 255 | int n3 = (int)strlen(g.argv[3]); |
| 256 | 256 | if( strncmp(g.argv[3], "export", n3)==0 ){ |
| 257 | 257 | zCmd = "git export --if-mirrored -R"; |
| 258 | 258 | }else if( strncmp(g.argv[3], "status", n3)==0 ){ |
| 259 | - zCmd = "git status --by-all -R"; | |
| 259 | + zCmd = "git status --by-all -q -R"; | |
| 260 | 260 | quiet = 1; |
| 261 | 261 | }else{ |
| 262 | 262 | usage("git (export|status)"); |
| 263 | 263 | } |
| 264 | 264 | } |
| 265 | 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 -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 @@ | ||
| 1728 | 1728 | */ |
| 1729 | 1729 | void gitmirror_status_command(void){ |
| 1730 | 1730 | char *zMirror; |
| 1731 | 1731 | char *z; |
| 1732 | 1732 | int n, k; |
| 1733 | + int rc; | |
| 1734 | + char *zSql; | |
| 1733 | 1735 | int bQuiet = 0; |
| 1734 | 1736 | int bByAll = 0; /* Undocumented option meaning this command was invoked |
| 1735 | 1737 | ** from "fossil all" and should modify output accordingly */ |
| 1736 | 1738 | |
| 1737 | 1739 | db_find_and_open_repository(0, 0); |
| @@ -1738,13 +1740,25 @@ | ||
| 1738 | 1740 | bQuiet = find_option("quiet","q",0)!=0; |
| 1739 | 1741 | bByAll = find_option("by-all",0,0)!=0; |
| 1740 | 1742 | verify_all_options(); |
| 1741 | 1743 | zMirror = db_get("last-git-export-repo", 0); |
| 1742 | 1744 | 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); | |
| 1746 | 1760 | return; |
| 1747 | 1761 | } |
| 1748 | 1762 | if( bByAll ){ |
| 1749 | 1763 | size_t len = strlen(g.zRepositoryName); |
| 1750 | 1764 | int n; |
| @@ -1751,11 +1765,10 @@ | ||
| 1751 | 1765 | if( len>60 ) len = 60; |
| 1752 | 1766 | n = (int)(65 - len); |
| 1753 | 1767 | fossil_print("%.12c %s %.*c\n", '*', g.zRepositoryName, n, '*'); |
| 1754 | 1768 | } |
| 1755 | 1769 | fossil_print("Git mirror: %s\n", zMirror); |
| 1756 | - db_multi_exec("ATTACH '%q/.mirror_state/db' AS mirror;", zMirror); | |
| 1757 | 1770 | z = db_text(0, "SELECT datetime(value) FROM mconfig WHERE key='start'"); |
| 1758 | 1771 | if( z ){ |
| 1759 | 1772 | double rAge = db_double(0.0, "SELECT julianday('now') - value" |
| 1760 | 1773 | " FROM mconfig WHERE key='start'"); |
| 1761 | 1774 | if( rAge>1.0/86400.0 ){ |
| @@ -1786,11 +1799,11 @@ | ||
| 1786 | 1799 | }else{ |
| 1787 | 1800 | fossil_print("Status: %d check-in%s awaiting export\n", |
| 1788 | 1801 | n, n==1 ? "" : "s"); |
| 1789 | 1802 | } |
| 1790 | 1803 | 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"); | |
| 1792 | 1805 | fossil_print("Exported: %d check-ins and %d file blobs\n", k, n); |
| 1793 | 1806 | } |
| 1794 | 1807 | |
| 1795 | 1808 | /* |
| 1796 | 1809 | ** COMMAND: git* |
| 1797 | 1810 |
| --- 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 |