Fossil SCM
Minor reformatting, doc updates, and corrected duplicate display of touched file count in dry-run mode.
Commit
adbbeac1515ce9107bcd8c6c949d94510f8ac98ab96a1a778424ccdc3a68c66a
Parent
ad275f975c3c4c0…
1 file changed
+22
-19
+22
-19
| --- src/file.c | ||
| +++ src/file.c | ||
| @@ -1801,23 +1801,23 @@ | ||
| 1801 | 1801 | fossil_print("%d\n", file_directory_size(zDir, zGlob, omitDotFiles)); |
| 1802 | 1802 | } |
| 1803 | 1803 | |
| 1804 | 1804 | /* |
| 1805 | 1805 | ** Internal helper for touch_cmd(). zAbsName must be resolvable as-is |
| 1806 | -** to a file - this function does not expand/normalize it. i.e. it | |
| 1807 | -** "really should" be an absolute path. zTreeName is strictly | |
| 1808 | -** cosmetic: it is used when dryRunFlag or verboseFlag generate | |
| 1809 | -** output. It is assumed to be a repo-relative or or subdir-relative | |
| 1810 | -** filename. | |
| 1806 | +** to an existing file - this function does not expand/normalize | |
| 1807 | +** it. i.e. it "really should" be an absolute path. zTreeName is | |
| 1808 | +** strictly cosmetic: it is used when dryRunFlag or verboseFlag | |
| 1809 | +** generate output. It is assumed to be a repo-relative or or | |
| 1810 | +** subdir-relative filename. | |
| 1811 | 1811 | ** |
| 1812 | 1812 | ** newMTime is the file's new timestamp (Unix epoch). |
| 1813 | 1813 | ** |
| 1814 | 1814 | ** Returns 1 if it sets zAbsName's mtime, 0 if it does not (indicating |
| 1815 | 1815 | ** that the file already has that timestamp). Dies fatally if given an |
| 1816 | 1816 | ** unresolvable filename. If dryRunFlag is true then it outputs the |
| 1817 | 1817 | ** name of the file it would have timestamped but does not stamp the |
| 1818 | -** file. If verboseFlag is true, it outputs a message if the files | |
| 1818 | +** file. If verboseFlag is true, it outputs a message if the file's | |
| 1819 | 1819 | ** timestamp is actually modified. |
| 1820 | 1820 | */ |
| 1821 | 1821 | static int touch_cmd_stamp_one_file(char const *zAbsName, |
| 1822 | 1822 | char const *zTreeName, |
| 1823 | 1823 | i64 newMtime, int dryRunFlag, |
| @@ -1837,20 +1837,23 @@ | ||
| 1837 | 1837 | } |
| 1838 | 1838 | return 1; |
| 1839 | 1839 | } |
| 1840 | 1840 | |
| 1841 | 1841 | /* |
| 1842 | -** Internal helper for touch_cmd(). If the given name is found in the | |
| 1843 | -** given checkout version, which MUST be the checkout version | |
| 1842 | +** Internal helper for touch_cmd(). If the given file name is found in | |
| 1843 | +** the given checkout version, which MUST be the checkout version | |
| 1844 | 1844 | ** currently populating the vfile table, the vfile.mrid value for the |
| 1845 | 1845 | ** file is returned, else 0 is returned. zName must be resolvable |
| 1846 | -** as-is - this function performs neither expands nor normalizes it. | |
| 1846 | +** as-is from the vfile table - this function neither expands nor | |
| 1847 | +** normalizes it, though it does compare using the repo's | |
| 1848 | +** filename_collation() preference. | |
| 1847 | 1849 | */ |
| 1848 | 1850 | static int touch_cmd_vfile_mrid( int vid, char const *zName ){ |
| 1849 | 1851 | int mrid = 0; |
| 1850 | 1852 | static Stmt q = empty_Stmt_m; |
| 1851 | - db_static_prepare(&q, "SELECT vfile.mrid " | |
| 1853 | + db_static_prepare(&q, | |
| 1854 | + "SELECT vfile.mrid " | |
| 1852 | 1855 | "FROM vfile LEFT JOIN blob ON vfile.mrid=blob.rid " |
| 1853 | 1856 | "WHERE vid=:vid AND pathname=:pathname %s", |
| 1854 | 1857 | filename_collation()); |
| 1855 | 1858 | db_bind_int(&q, ":vid", vid); |
| 1856 | 1859 | db_bind_text(&q, ":pathname", zName); |
| @@ -1917,11 +1920,11 @@ | ||
| 1917 | 1920 | int changeCount = 0; /* Number of files touched */ |
| 1918 | 1921 | int quietFlag = 0; /* -q|--quiet */ |
| 1919 | 1922 | int timeFlag; /* -1==--checkin, 1==--checkout, 0==--now */ |
| 1920 | 1923 | i64 nowTime = 0; /* Timestamp of --now or --checkout */ |
| 1921 | 1924 | Stmt q; |
| 1922 | - Blob absBuffer = empty_blob; | |
| 1925 | + Blob absBuffer = empty_blob; /* Absolute filename buffer */ | |
| 1923 | 1926 | |
| 1924 | 1927 | verboseFlag = find_option("verbose","v",0)!=0; |
| 1925 | 1928 | quietFlag = find_option("quiet","q",0)!=0; |
| 1926 | 1929 | dryRunFlag = find_option("dry-run","n",0)!=0 |
| 1927 | 1930 | || find_option("dryrun",0,0)!=0; |
| @@ -1997,16 +2000,15 @@ | ||
| 1997 | 2000 | fossil_fatal("Could not determine out checkout version's time!"); |
| 1998 | 2001 | } |
| 1999 | 2002 | }else{ /* --checkin */ |
| 2000 | 2003 | assert(0 == nowTime); |
| 2001 | 2004 | } |
| 2002 | - if((pGlob && pGlob->nPattern>0) | |
| 2003 | - || g.argc<3 /* no non-flag arguments */ ){ | |
| 2005 | + if((pGlob && pGlob->nPattern>0) || g.argc<3){ | |
| 2004 | 2006 | /* |
| 2005 | - ** We have either globs or no trailing filenames (in which case an | |
| 2006 | - ** effective glob pattern of '*' is assumed). If there are neither | |
| 2007 | - ** globs nor filenames then we operate on all managed files. | |
| 2007 | + ** We have either (1) globs or (2) no trailing filenames. If there | |
| 2008 | + ** are neither globs nor filenames then we operate on all managed | |
| 2009 | + ** files. | |
| 2008 | 2010 | */ |
| 2009 | 2011 | db_prepare(&q, |
| 2010 | 2012 | "SELECT vfile.mrid, pathname " |
| 2011 | 2013 | "FROM vfile LEFT JOIN blob ON vfile.mrid=blob.rid " |
| 2012 | 2014 | "WHERE vid=%d", vid); |
| @@ -2037,20 +2039,19 @@ | ||
| 2037 | 2039 | ** Trailing filenames on the command line. These require extra |
| 2038 | 2040 | ** care to avoid modifying unmanaged or out-of-tree files and |
| 2039 | 2041 | ** finding an associated --checkin timestamp. |
| 2040 | 2042 | */ |
| 2041 | 2043 | int i; |
| 2042 | - Blob treeNameBuf = empty_blob; | |
| 2044 | + Blob treeNameBuf = empty_blob; /* Buffer for file_tree_name(). */ | |
| 2043 | 2045 | for( i = 2; i < g.argc; ++i, |
| 2044 | 2046 | blob_reset(&treeNameBuf) ){ |
| 2045 | 2047 | char const * zArg = g.argv[i]; |
| 2046 | 2048 | char const * zTreeFile; /* repo-relative filename */ |
| 2047 | 2049 | char const * zAbs; /* absolute filename */ |
| 2048 | 2050 | i64 newMtime = nowTime; |
| 2049 | 2051 | int nameCheck; |
| 2050 | 2052 | int fid; /* vfile.mrid of file */ |
| 2051 | - absBuffer.nUsed = 0; | |
| 2052 | 2053 | nameCheck = file_tree_name( zArg, &treeNameBuf, 0, 0 ); |
| 2053 | 2054 | if(nameCheck==0){ |
| 2054 | 2055 | if(quietFlag==0){ |
| 2055 | 2056 | fossil_print("SKIPPING out-of-tree file: %s\n", zArg); |
| 2056 | 2057 | } |
| @@ -2062,10 +2063,11 @@ | ||
| 2062 | 2063 | if(quietFlag==0){ |
| 2063 | 2064 | fossil_print("SKIPPING unmanaged file: %s\n", zArg); |
| 2064 | 2065 | } |
| 2065 | 2066 | continue; |
| 2066 | 2067 | } |
| 2068 | + absBuffer.nUsed = 0; | |
| 2067 | 2069 | blob_appendf(&absBuffer, "%s%s", g.zLocalRoot, zTreeFile); |
| 2068 | 2070 | zAbs = blob_str(&absBuffer); |
| 2069 | 2071 | if(timeFlag<0){/*--checkin*/ |
| 2070 | 2072 | if(mtime_of_manifest_file( vid, fid, &newMtime )!=0){ |
| 2071 | 2073 | fossil_fatal("Could not resolve --checkin mtime of %s", zTreeFile); |
| @@ -2081,8 +2083,9 @@ | ||
| 2081 | 2083 | db_end_transaction(0); |
| 2082 | 2084 | blob_reset(&absBuffer); |
| 2083 | 2085 | if( dryRunFlag!=0 ){ |
| 2084 | 2086 | fossil_print("dry-run: would have touched %d file(s)\n", |
| 2085 | 2087 | changeCount); |
| 2088 | + }else{ | |
| 2089 | + fossil_print("Touched %d file(s)\n", changeCount); | |
| 2086 | 2090 | } |
| 2087 | - fossil_print("Touched %d file(s)\n", changeCount); | |
| 2088 | 2091 | } |
| 2089 | 2092 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -1801,23 +1801,23 @@ | |
| 1801 | fossil_print("%d\n", file_directory_size(zDir, zGlob, omitDotFiles)); |
| 1802 | } |
| 1803 | |
| 1804 | /* |
| 1805 | ** Internal helper for touch_cmd(). zAbsName must be resolvable as-is |
| 1806 | ** to a file - this function does not expand/normalize it. i.e. it |
| 1807 | ** "really should" be an absolute path. zTreeName is strictly |
| 1808 | ** cosmetic: it is used when dryRunFlag or verboseFlag generate |
| 1809 | ** output. It is assumed to be a repo-relative or or subdir-relative |
| 1810 | ** filename. |
| 1811 | ** |
| 1812 | ** newMTime is the file's new timestamp (Unix epoch). |
| 1813 | ** |
| 1814 | ** Returns 1 if it sets zAbsName's mtime, 0 if it does not (indicating |
| 1815 | ** that the file already has that timestamp). Dies fatally if given an |
| 1816 | ** unresolvable filename. If dryRunFlag is true then it outputs the |
| 1817 | ** name of the file it would have timestamped but does not stamp the |
| 1818 | ** file. If verboseFlag is true, it outputs a message if the files |
| 1819 | ** timestamp is actually modified. |
| 1820 | */ |
| 1821 | static int touch_cmd_stamp_one_file(char const *zAbsName, |
| 1822 | char const *zTreeName, |
| 1823 | i64 newMtime, int dryRunFlag, |
| @@ -1837,20 +1837,23 @@ | |
| 1837 | } |
| 1838 | return 1; |
| 1839 | } |
| 1840 | |
| 1841 | /* |
| 1842 | ** Internal helper for touch_cmd(). If the given name is found in the |
| 1843 | ** given checkout version, which MUST be the checkout version |
| 1844 | ** currently populating the vfile table, the vfile.mrid value for the |
| 1845 | ** file is returned, else 0 is returned. zName must be resolvable |
| 1846 | ** as-is - this function performs neither expands nor normalizes it. |
| 1847 | */ |
| 1848 | static int touch_cmd_vfile_mrid( int vid, char const *zName ){ |
| 1849 | int mrid = 0; |
| 1850 | static Stmt q = empty_Stmt_m; |
| 1851 | db_static_prepare(&q, "SELECT vfile.mrid " |
| 1852 | "FROM vfile LEFT JOIN blob ON vfile.mrid=blob.rid " |
| 1853 | "WHERE vid=:vid AND pathname=:pathname %s", |
| 1854 | filename_collation()); |
| 1855 | db_bind_int(&q, ":vid", vid); |
| 1856 | db_bind_text(&q, ":pathname", zName); |
| @@ -1917,11 +1920,11 @@ | |
| 1917 | int changeCount = 0; /* Number of files touched */ |
| 1918 | int quietFlag = 0; /* -q|--quiet */ |
| 1919 | int timeFlag; /* -1==--checkin, 1==--checkout, 0==--now */ |
| 1920 | i64 nowTime = 0; /* Timestamp of --now or --checkout */ |
| 1921 | Stmt q; |
| 1922 | Blob absBuffer = empty_blob; |
| 1923 | |
| 1924 | verboseFlag = find_option("verbose","v",0)!=0; |
| 1925 | quietFlag = find_option("quiet","q",0)!=0; |
| 1926 | dryRunFlag = find_option("dry-run","n",0)!=0 |
| 1927 | || find_option("dryrun",0,0)!=0; |
| @@ -1997,16 +2000,15 @@ | |
| 1997 | fossil_fatal("Could not determine out checkout version's time!"); |
| 1998 | } |
| 1999 | }else{ /* --checkin */ |
| 2000 | assert(0 == nowTime); |
| 2001 | } |
| 2002 | if((pGlob && pGlob->nPattern>0) |
| 2003 | || g.argc<3 /* no non-flag arguments */ ){ |
| 2004 | /* |
| 2005 | ** We have either globs or no trailing filenames (in which case an |
| 2006 | ** effective glob pattern of '*' is assumed). If there are neither |
| 2007 | ** globs nor filenames then we operate on all managed files. |
| 2008 | */ |
| 2009 | db_prepare(&q, |
| 2010 | "SELECT vfile.mrid, pathname " |
| 2011 | "FROM vfile LEFT JOIN blob ON vfile.mrid=blob.rid " |
| 2012 | "WHERE vid=%d", vid); |
| @@ -2037,20 +2039,19 @@ | |
| 2037 | ** Trailing filenames on the command line. These require extra |
| 2038 | ** care to avoid modifying unmanaged or out-of-tree files and |
| 2039 | ** finding an associated --checkin timestamp. |
| 2040 | */ |
| 2041 | int i; |
| 2042 | Blob treeNameBuf = empty_blob; |
| 2043 | for( i = 2; i < g.argc; ++i, |
| 2044 | blob_reset(&treeNameBuf) ){ |
| 2045 | char const * zArg = g.argv[i]; |
| 2046 | char const * zTreeFile; /* repo-relative filename */ |
| 2047 | char const * zAbs; /* absolute filename */ |
| 2048 | i64 newMtime = nowTime; |
| 2049 | int nameCheck; |
| 2050 | int fid; /* vfile.mrid of file */ |
| 2051 | absBuffer.nUsed = 0; |
| 2052 | nameCheck = file_tree_name( zArg, &treeNameBuf, 0, 0 ); |
| 2053 | if(nameCheck==0){ |
| 2054 | if(quietFlag==0){ |
| 2055 | fossil_print("SKIPPING out-of-tree file: %s\n", zArg); |
| 2056 | } |
| @@ -2062,10 +2063,11 @@ | |
| 2062 | if(quietFlag==0){ |
| 2063 | fossil_print("SKIPPING unmanaged file: %s\n", zArg); |
| 2064 | } |
| 2065 | continue; |
| 2066 | } |
| 2067 | blob_appendf(&absBuffer, "%s%s", g.zLocalRoot, zTreeFile); |
| 2068 | zAbs = blob_str(&absBuffer); |
| 2069 | if(timeFlag<0){/*--checkin*/ |
| 2070 | if(mtime_of_manifest_file( vid, fid, &newMtime )!=0){ |
| 2071 | fossil_fatal("Could not resolve --checkin mtime of %s", zTreeFile); |
| @@ -2081,8 +2083,9 @@ | |
| 2081 | db_end_transaction(0); |
| 2082 | blob_reset(&absBuffer); |
| 2083 | if( dryRunFlag!=0 ){ |
| 2084 | fossil_print("dry-run: would have touched %d file(s)\n", |
| 2085 | changeCount); |
| 2086 | } |
| 2087 | fossil_print("Touched %d file(s)\n", changeCount); |
| 2088 | } |
| 2089 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -1801,23 +1801,23 @@ | |
| 1801 | fossil_print("%d\n", file_directory_size(zDir, zGlob, omitDotFiles)); |
| 1802 | } |
| 1803 | |
| 1804 | /* |
| 1805 | ** Internal helper for touch_cmd(). zAbsName must be resolvable as-is |
| 1806 | ** to an existing file - this function does not expand/normalize |
| 1807 | ** it. i.e. it "really should" be an absolute path. zTreeName is |
| 1808 | ** strictly cosmetic: it is used when dryRunFlag or verboseFlag |
| 1809 | ** generate output. It is assumed to be a repo-relative or or |
| 1810 | ** subdir-relative filename. |
| 1811 | ** |
| 1812 | ** newMTime is the file's new timestamp (Unix epoch). |
| 1813 | ** |
| 1814 | ** Returns 1 if it sets zAbsName's mtime, 0 if it does not (indicating |
| 1815 | ** that the file already has that timestamp). Dies fatally if given an |
| 1816 | ** unresolvable filename. If dryRunFlag is true then it outputs the |
| 1817 | ** name of the file it would have timestamped but does not stamp the |
| 1818 | ** file. If verboseFlag is true, it outputs a message if the file's |
| 1819 | ** timestamp is actually modified. |
| 1820 | */ |
| 1821 | static int touch_cmd_stamp_one_file(char const *zAbsName, |
| 1822 | char const *zTreeName, |
| 1823 | i64 newMtime, int dryRunFlag, |
| @@ -1837,20 +1837,23 @@ | |
| 1837 | } |
| 1838 | return 1; |
| 1839 | } |
| 1840 | |
| 1841 | /* |
| 1842 | ** Internal helper for touch_cmd(). If the given file name is found in |
| 1843 | ** the given checkout version, which MUST be the checkout version |
| 1844 | ** currently populating the vfile table, the vfile.mrid value for the |
| 1845 | ** file is returned, else 0 is returned. zName must be resolvable |
| 1846 | ** as-is from the vfile table - this function neither expands nor |
| 1847 | ** normalizes it, though it does compare using the repo's |
| 1848 | ** filename_collation() preference. |
| 1849 | */ |
| 1850 | static int touch_cmd_vfile_mrid( int vid, char const *zName ){ |
| 1851 | int mrid = 0; |
| 1852 | static Stmt q = empty_Stmt_m; |
| 1853 | db_static_prepare(&q, |
| 1854 | "SELECT vfile.mrid " |
| 1855 | "FROM vfile LEFT JOIN blob ON vfile.mrid=blob.rid " |
| 1856 | "WHERE vid=:vid AND pathname=:pathname %s", |
| 1857 | filename_collation()); |
| 1858 | db_bind_int(&q, ":vid", vid); |
| 1859 | db_bind_text(&q, ":pathname", zName); |
| @@ -1917,11 +1920,11 @@ | |
| 1920 | int changeCount = 0; /* Number of files touched */ |
| 1921 | int quietFlag = 0; /* -q|--quiet */ |
| 1922 | int timeFlag; /* -1==--checkin, 1==--checkout, 0==--now */ |
| 1923 | i64 nowTime = 0; /* Timestamp of --now or --checkout */ |
| 1924 | Stmt q; |
| 1925 | Blob absBuffer = empty_blob; /* Absolute filename buffer */ |
| 1926 | |
| 1927 | verboseFlag = find_option("verbose","v",0)!=0; |
| 1928 | quietFlag = find_option("quiet","q",0)!=0; |
| 1929 | dryRunFlag = find_option("dry-run","n",0)!=0 |
| 1930 | || find_option("dryrun",0,0)!=0; |
| @@ -1997,16 +2000,15 @@ | |
| 2000 | fossil_fatal("Could not determine out checkout version's time!"); |
| 2001 | } |
| 2002 | }else{ /* --checkin */ |
| 2003 | assert(0 == nowTime); |
| 2004 | } |
| 2005 | if((pGlob && pGlob->nPattern>0) || g.argc<3){ |
| 2006 | /* |
| 2007 | ** We have either (1) globs or (2) no trailing filenames. If there |
| 2008 | ** are neither globs nor filenames then we operate on all managed |
| 2009 | ** files. |
| 2010 | */ |
| 2011 | db_prepare(&q, |
| 2012 | "SELECT vfile.mrid, pathname " |
| 2013 | "FROM vfile LEFT JOIN blob ON vfile.mrid=blob.rid " |
| 2014 | "WHERE vid=%d", vid); |
| @@ -2037,20 +2039,19 @@ | |
| 2039 | ** Trailing filenames on the command line. These require extra |
| 2040 | ** care to avoid modifying unmanaged or out-of-tree files and |
| 2041 | ** finding an associated --checkin timestamp. |
| 2042 | */ |
| 2043 | int i; |
| 2044 | Blob treeNameBuf = empty_blob; /* Buffer for file_tree_name(). */ |
| 2045 | for( i = 2; i < g.argc; ++i, |
| 2046 | blob_reset(&treeNameBuf) ){ |
| 2047 | char const * zArg = g.argv[i]; |
| 2048 | char const * zTreeFile; /* repo-relative filename */ |
| 2049 | char const * zAbs; /* absolute filename */ |
| 2050 | i64 newMtime = nowTime; |
| 2051 | int nameCheck; |
| 2052 | int fid; /* vfile.mrid of file */ |
| 2053 | nameCheck = file_tree_name( zArg, &treeNameBuf, 0, 0 ); |
| 2054 | if(nameCheck==0){ |
| 2055 | if(quietFlag==0){ |
| 2056 | fossil_print("SKIPPING out-of-tree file: %s\n", zArg); |
| 2057 | } |
| @@ -2062,10 +2063,11 @@ | |
| 2063 | if(quietFlag==0){ |
| 2064 | fossil_print("SKIPPING unmanaged file: %s\n", zArg); |
| 2065 | } |
| 2066 | continue; |
| 2067 | } |
| 2068 | absBuffer.nUsed = 0; |
| 2069 | blob_appendf(&absBuffer, "%s%s", g.zLocalRoot, zTreeFile); |
| 2070 | zAbs = blob_str(&absBuffer); |
| 2071 | if(timeFlag<0){/*--checkin*/ |
| 2072 | if(mtime_of_manifest_file( vid, fid, &newMtime )!=0){ |
| 2073 | fossil_fatal("Could not resolve --checkin mtime of %s", zTreeFile); |
| @@ -2081,8 +2083,9 @@ | |
| 2083 | db_end_transaction(0); |
| 2084 | blob_reset(&absBuffer); |
| 2085 | if( dryRunFlag!=0 ){ |
| 2086 | fossil_print("dry-run: would have touched %d file(s)\n", |
| 2087 | changeCount); |
| 2088 | }else{ |
| 2089 | fossil_print("Touched %d file(s)\n", changeCount); |
| 2090 | } |
| 2091 | } |
| 2092 |