Fossil SCM

Per forum discussion: when the calculated timestamp of a to-be-touched file is 0, emit a warning and do not set the timestamp. As-yet-uncommitted merges can cause mtime_of_manifest_file() to calculate a time of zero: https://fossil-scm.org/forum/forumpost/6e49ee3725

stephan 2019-06-14 19:16 trunk
Commit 29f450a5328c25dc3f3011e69314657cf4c80d97156a63fda5d4fc46961dfc00
1 file changed +37 -15
+37 -15
--- src/file.c
+++ src/file.c
@@ -1803,28 +1803,45 @@
18031803
18041804
/*
18051805
** Internal helper for touch_cmd(). zAbsName must be resolvable as-is
18061806
** to an existing file - this function does not expand/normalize
18071807
** 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.
1808
+** strictly cosmetic: it is used when dryRunFlag, verboseFlag, or
1809
+** quietFlag generate output, and is assumed to be a repo-relative or
1810
+** or subdir-relative filename.
18111811
**
18121812
** newMTime is the file's new timestamp (Unix epoch).
18131813
**
18141814
** 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.
1815
+** that the file already has that timestamp or a warning was emitted).
1816
+** Dies fatally if given an unresolvable filename. If dryRunFlag is
1817
+** true then it outputs the name of the file it would have timestamped
1818
+** but does not stamp the file. If verboseFlag is true, it outputs a
1819
+** message if the file's timestamp is actually modified. If quietFlag
1820
+** is true then the output of non-fatal warning messages is
1821
+** suppressed.
1822
+**
1823
+** As a special case, if newMTime is 0 then this function emits a
1824
+** warning (unless quietFlag is true), does NOT set the timestamp, and
1825
+** returns 0. The timestamp is known to be zero when
1826
+** mtime_of_manifest_file() is asked to provide the timestamp for a
1827
+** file which is currently undergoing an uncommitted merge (though
1828
+** this may depend on exactly where that merge is happening the
1829
+** history of the project).
18201830
*/
18211831
static int touch_cmd_stamp_one_file(char const *zAbsName,
18221832
char const *zTreeName,
18231833
i64 newMtime, int dryRunFlag,
1824
- int verboseFlag){
1825
- i64 const currentMtime = file_mtime(zAbsName, 0);
1834
+ int verboseFlag, int quietFlag){
1835
+ i64 currentMtime;
1836
+ if(newMtime==0){
1837
+ if( quietFlag==0 ){
1838
+ fossil_print("SKIPPING timestamp of 0: %s\n", zTreeName);
1839
+ }
1840
+ return 0;
1841
+ }
1842
+ currentMtime = file_mtime(zAbsName, 0);
18261843
if(currentMtime<0){
18271844
fossil_fatal("Cannot stat file: %s\n", zAbsName);
18281845
}else if(currentMtime==newMtime){
18291846
return 0;
18301847
}else if( dryRunFlag!=0 ){
@@ -1892,11 +1909,11 @@
18921909
** fossil-conventional glob list file.
18931910
** -v|-verbose Outputs extra information about its globs
18941911
** and each file it touches.
18951912
** -n|--dry-run Outputs which files would require touching,
18961913
** but does not touch them.
1897
-** -q|--quiet Suppress warnings when skipping unmanaged
1914
+** -q|--quiet Suppress warnings, e.g. when skipping unmanaged
18981915
** or out-of-tree files.
18991916
**
19001917
** Only one of --now, --checkin, and --checkout may be used. The
19011918
** default is --now.
19021919
**
@@ -1906,10 +1923,15 @@
19061923
** currently-checked-out version. Note that all glob patterns provided
19071924
** via these flags are always evaluated as if they are relative to the
19081925
** top of the source tree, not the current working (sub)directory.
19091926
** Filenames provided without these flags, on the other hand, are
19101927
** treated as relative to the current directory.
1928
+**
1929
+** As a special case, files currently undergoing an uncommitted merge
1930
+** might not get timestamped with --checkin because it may be
1931
+** impossible for fossil to choose between multiple potential
1932
+** timestamps. A non-fatal warning is emitted for such cases.
19111933
**
19121934
*/
19131935
void touch_cmd(){
19141936
const char * zGlobList; /* -g List of glob patterns */
19151937
const char * zGlobFile; /* -G File of glob patterns */
@@ -2024,12 +2046,12 @@
20242046
}
20252047
blob_appendf( &absBuffer, "%s%s", g.zLocalRoot, zName );
20262048
zAbs = blob_str(&absBuffer);
20272049
if( newMtime || mtime_of_manifest_file(vid, fid, &newMtime)==0 ){
20282050
changeCount +=
2029
- touch_cmd_stamp_one_file( zAbs, zName, newMtime,
2030
- dryRunFlag, verboseFlag );
2051
+ touch_cmd_stamp_one_file( zAbs, zName, newMtime, dryRunFlag,
2052
+ verboseFlag, quietFlag );
20312053
}
20322054
}
20332055
db_finalize(&q);
20342056
}
20352057
glob_free(pGlob);
@@ -2074,12 +2096,12 @@
20742096
}
20752097
}else{
20762098
assert(newMtime>0);
20772099
}
20782100
changeCount +=
2079
- touch_cmd_stamp_one_file( zAbs, zArg, newMtime,
2080
- dryRunFlag, verboseFlag );
2101
+ touch_cmd_stamp_one_file( zAbs, zArg, newMtime, dryRunFlag,
2102
+ verboseFlag, quietFlag );
20812103
}
20822104
}
20832105
db_end_transaction(0);
20842106
blob_reset(&absBuffer);
20852107
if( dryRunFlag!=0 ){
20862108
--- src/file.c
+++ src/file.c
@@ -1803,28 +1803,45 @@
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,
1824 int verboseFlag){
1825 i64 const currentMtime = file_mtime(zAbsName, 0);
 
 
 
 
 
 
 
1826 if(currentMtime<0){
1827 fossil_fatal("Cannot stat file: %s\n", zAbsName);
1828 }else if(currentMtime==newMtime){
1829 return 0;
1830 }else if( dryRunFlag!=0 ){
@@ -1892,11 +1909,11 @@
1892 ** fossil-conventional glob list file.
1893 ** -v|-verbose Outputs extra information about its globs
1894 ** and each file it touches.
1895 ** -n|--dry-run Outputs which files would require touching,
1896 ** but does not touch them.
1897 ** -q|--quiet Suppress warnings when skipping unmanaged
1898 ** or out-of-tree files.
1899 **
1900 ** Only one of --now, --checkin, and --checkout may be used. The
1901 ** default is --now.
1902 **
@@ -1906,10 +1923,15 @@
1906 ** currently-checked-out version. Note that all glob patterns provided
1907 ** via these flags are always evaluated as if they are relative to the
1908 ** top of the source tree, not the current working (sub)directory.
1909 ** Filenames provided without these flags, on the other hand, are
1910 ** treated as relative to the current directory.
 
 
 
 
 
1911 **
1912 */
1913 void touch_cmd(){
1914 const char * zGlobList; /* -g List of glob patterns */
1915 const char * zGlobFile; /* -G File of glob patterns */
@@ -2024,12 +2046,12 @@
2024 }
2025 blob_appendf( &absBuffer, "%s%s", g.zLocalRoot, zName );
2026 zAbs = blob_str(&absBuffer);
2027 if( newMtime || mtime_of_manifest_file(vid, fid, &newMtime)==0 ){
2028 changeCount +=
2029 touch_cmd_stamp_one_file( zAbs, zName, newMtime,
2030 dryRunFlag, verboseFlag );
2031 }
2032 }
2033 db_finalize(&q);
2034 }
2035 glob_free(pGlob);
@@ -2074,12 +2096,12 @@
2074 }
2075 }else{
2076 assert(newMtime>0);
2077 }
2078 changeCount +=
2079 touch_cmd_stamp_one_file( zAbs, zArg, newMtime,
2080 dryRunFlag, verboseFlag );
2081 }
2082 }
2083 db_end_transaction(0);
2084 blob_reset(&absBuffer);
2085 if( dryRunFlag!=0 ){
2086
--- src/file.c
+++ src/file.c
@@ -1803,28 +1803,45 @@
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, verboseFlag, or
1809 ** quietFlag generate output, and is assumed to be a repo-relative or
1810 ** or 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 or a warning was emitted).
1816 ** Dies fatally if given an unresolvable filename. If dryRunFlag is
1817 ** true then it outputs the name of the file it would have timestamped
1818 ** but does not stamp the file. If verboseFlag is true, it outputs a
1819 ** message if the file's timestamp is actually modified. If quietFlag
1820 ** is true then the output of non-fatal warning messages is
1821 ** suppressed.
1822 **
1823 ** As a special case, if newMTime is 0 then this function emits a
1824 ** warning (unless quietFlag is true), does NOT set the timestamp, and
1825 ** returns 0. The timestamp is known to be zero when
1826 ** mtime_of_manifest_file() is asked to provide the timestamp for a
1827 ** file which is currently undergoing an uncommitted merge (though
1828 ** this may depend on exactly where that merge is happening the
1829 ** history of the project).
1830 */
1831 static int touch_cmd_stamp_one_file(char const *zAbsName,
1832 char const *zTreeName,
1833 i64 newMtime, int dryRunFlag,
1834 int verboseFlag, int quietFlag){
1835 i64 currentMtime;
1836 if(newMtime==0){
1837 if( quietFlag==0 ){
1838 fossil_print("SKIPPING timestamp of 0: %s\n", zTreeName);
1839 }
1840 return 0;
1841 }
1842 currentMtime = file_mtime(zAbsName, 0);
1843 if(currentMtime<0){
1844 fossil_fatal("Cannot stat file: %s\n", zAbsName);
1845 }else if(currentMtime==newMtime){
1846 return 0;
1847 }else if( dryRunFlag!=0 ){
@@ -1892,11 +1909,11 @@
1909 ** fossil-conventional glob list file.
1910 ** -v|-verbose Outputs extra information about its globs
1911 ** and each file it touches.
1912 ** -n|--dry-run Outputs which files would require touching,
1913 ** but does not touch them.
1914 ** -q|--quiet Suppress warnings, e.g. when skipping unmanaged
1915 ** or out-of-tree files.
1916 **
1917 ** Only one of --now, --checkin, and --checkout may be used. The
1918 ** default is --now.
1919 **
@@ -1906,10 +1923,15 @@
1923 ** currently-checked-out version. Note that all glob patterns provided
1924 ** via these flags are always evaluated as if they are relative to the
1925 ** top of the source tree, not the current working (sub)directory.
1926 ** Filenames provided without these flags, on the other hand, are
1927 ** treated as relative to the current directory.
1928 **
1929 ** As a special case, files currently undergoing an uncommitted merge
1930 ** might not get timestamped with --checkin because it may be
1931 ** impossible for fossil to choose between multiple potential
1932 ** timestamps. A non-fatal warning is emitted for such cases.
1933 **
1934 */
1935 void touch_cmd(){
1936 const char * zGlobList; /* -g List of glob patterns */
1937 const char * zGlobFile; /* -G File of glob patterns */
@@ -2024,12 +2046,12 @@
2046 }
2047 blob_appendf( &absBuffer, "%s%s", g.zLocalRoot, zName );
2048 zAbs = blob_str(&absBuffer);
2049 if( newMtime || mtime_of_manifest_file(vid, fid, &newMtime)==0 ){
2050 changeCount +=
2051 touch_cmd_stamp_one_file( zAbs, zName, newMtime, dryRunFlag,
2052 verboseFlag, quietFlag );
2053 }
2054 }
2055 db_finalize(&q);
2056 }
2057 glob_free(pGlob);
@@ -2074,12 +2096,12 @@
2096 }
2097 }else{
2098 assert(newMtime>0);
2099 }
2100 changeCount +=
2101 touch_cmd_stamp_one_file( zAbs, zArg, newMtime, dryRunFlag,
2102 verboseFlag, quietFlag );
2103 }
2104 }
2105 db_end_transaction(0);
2106 blob_reset(&absBuffer);
2107 if( dryRunFlag!=0 ){
2108

Keyboard Shortcuts

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