Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Minor reformatting, doc updates, and corrected duplicate display of touched file count in dry-run mode. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
adbbeac1515ce9107bcd8c6c949d9451 |
| User & Date: | stephan 2019-06-13 21:28:23.713 |
Context
|
2019-06-13
| ||
| 21:49 | It turns out that fossil globally consumes the --quiet flag: touch now accounts for that. check-in: 519af48c8c user: stephan tags: trunk | |
| 21:28 | Minor reformatting, doc updates, and corrected duplicate display of touched file count in dry-run mode. check-in: adbbeac151 user: stephan tags: trunk | |
| 20:20 | Reworded misleading statements in the "touch" help. check-in: ad275f975c user: stephan tags: trunk | |
Changes
Changes to src/file.c.
| ︙ | ︙ | |||
1799 1800 1801 1802 1803 1804 1805 |
zDir = g.argv[2];
zGlob = g.argc==4 ? g.argv[3] : 0;
fossil_print("%d\n", file_directory_size(zDir, zGlob, omitDotFiles));
}
/*
** Internal helper for touch_cmd(). zAbsName must be resolvable as-is
| | | | | | | | 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 |
zDir = g.argv[2];
zGlob = g.argc==4 ? g.argv[3] : 0;
fossil_print("%d\n", file_directory_size(zDir, zGlob, omitDotFiles));
}
/*
** Internal helper for touch_cmd(). zAbsName must be resolvable as-is
** to an existing file - this function does not expand/normalize
** it. i.e. it "really should" be an absolute path. zTreeName is
** strictly cosmetic: it is used when dryRunFlag or verboseFlag
** generate output. It is assumed to be a repo-relative or or
** subdir-relative filename.
**
** newMTime is the file's new timestamp (Unix epoch).
**
** Returns 1 if it sets zAbsName's mtime, 0 if it does not (indicating
** that the file already has that timestamp). Dies fatally if given an
** unresolvable filename. If dryRunFlag is true then it outputs the
** name of the file it would have timestamped but does not stamp the
** file. If verboseFlag is true, it outputs a message if the file's
** timestamp is actually modified.
*/
static int touch_cmd_stamp_one_file(char const *zAbsName,
char const *zTreeName,
i64 newMtime, int dryRunFlag,
int verboseFlag){
i64 const currentMtime = file_mtime(zAbsName, 0);
|
| ︙ | ︙ | |||
1835 1836 1837 1838 1839 1840 1841 |
fossil_print( "touched %s\n", zTreeName );
}
}
return 1;
}
/*
| | | > | > | > | 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 |
fossil_print( "touched %s\n", zTreeName );
}
}
return 1;
}
/*
** Internal helper for touch_cmd(). If the given file name is found in
** the given checkout version, which MUST be the checkout version
** currently populating the vfile table, the vfile.mrid value for the
** file is returned, else 0 is returned. zName must be resolvable
** as-is from the vfile table - this function neither expands nor
** normalizes it, though it does compare using the repo's
** filename_collation() preference.
*/
static int touch_cmd_vfile_mrid( int vid, char const *zName ){
int mrid = 0;
static Stmt q = empty_Stmt_m;
db_static_prepare(&q,
"SELECT vfile.mrid "
"FROM vfile LEFT JOIN blob ON vfile.mrid=blob.rid "
"WHERE vid=:vid AND pathname=:pathname %s",
filename_collation());
db_bind_int(&q, ":vid", vid);
db_bind_text(&q, ":pathname", zName);
if(SQLITE_ROW==db_step(&q)){
mrid = db_column_int(&q, 0);
|
| ︙ | ︙ | |||
1915 1916 1917 1918 1919 1920 1921 | int dryRunFlag; int vid; /* Checkout version */ int changeCount = 0; /* Number of files touched */ int quietFlag = 0; /* -q|--quiet */ int timeFlag; /* -1==--checkin, 1==--checkout, 0==--now */ i64 nowTime = 0; /* Timestamp of --now or --checkout */ Stmt q; | | | 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 |
int dryRunFlag;
int vid; /* Checkout version */
int changeCount = 0; /* Number of files touched */
int quietFlag = 0; /* -q|--quiet */
int timeFlag; /* -1==--checkin, 1==--checkout, 0==--now */
i64 nowTime = 0; /* Timestamp of --now or --checkout */
Stmt q;
Blob absBuffer = empty_blob; /* Absolute filename buffer */
verboseFlag = find_option("verbose","v",0)!=0;
quietFlag = find_option("quiet","q",0)!=0;
dryRunFlag = find_option("dry-run","n",0)!=0
|| find_option("dryrun",0,0)!=0;
zGlobList = find_option("glob", "g",1);
zGlobFile = find_option("globfile", "G",1);
|
| ︙ | ︙ | |||
1995 1996 1997 1998 1999 2000 2001 |
") AS INTEGER)", vid);
if(nowTime<0){
fossil_fatal("Could not determine out checkout version's time!");
}
}else{ /* --checkin */
assert(0 == nowTime);
}
| | < | < | > | 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 |
") AS INTEGER)", vid);
if(nowTime<0){
fossil_fatal("Could not determine out checkout version's time!");
}
}else{ /* --checkin */
assert(0 == nowTime);
}
if((pGlob && pGlob->nPattern>0) || g.argc<3){
/*
** We have either (1) globs or (2) no trailing filenames. If there
** are neither globs nor filenames then we operate on all managed
** files.
*/
db_prepare(&q,
"SELECT vfile.mrid, pathname "
"FROM vfile LEFT JOIN blob ON vfile.mrid=blob.rid "
"WHERE vid=%d", vid);
while(SQLITE_ROW==db_step(&q)){
int const fid = db_column_int(&q, 0);
|
| ︙ | ︙ | |||
2035 2036 2037 2038 2039 2040 2041 |
if(g.argc>2){
/*
** Trailing filenames on the command line. These require extra
** care to avoid modifying unmanaged or out-of-tree files and
** finding an associated --checkin timestamp.
*/
int i;
| | < > | | | > | 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 |
if(g.argc>2){
/*
** Trailing filenames on the command line. These require extra
** care to avoid modifying unmanaged or out-of-tree files and
** finding an associated --checkin timestamp.
*/
int i;
Blob treeNameBuf = empty_blob; /* Buffer for file_tree_name(). */
for( i = 2; i < g.argc; ++i,
blob_reset(&treeNameBuf) ){
char const * zArg = g.argv[i];
char const * zTreeFile; /* repo-relative filename */
char const * zAbs; /* absolute filename */
i64 newMtime = nowTime;
int nameCheck;
int fid; /* vfile.mrid of file */
nameCheck = file_tree_name( zArg, &treeNameBuf, 0, 0 );
if(nameCheck==0){
if(quietFlag==0){
fossil_print("SKIPPING out-of-tree file: %s\n", zArg);
}
continue;
}
zTreeFile = blob_str(&treeNameBuf);
fid = touch_cmd_vfile_mrid( vid, zTreeFile );
if(fid==0){
if(quietFlag==0){
fossil_print("SKIPPING unmanaged file: %s\n", zArg);
}
continue;
}
absBuffer.nUsed = 0;
blob_appendf(&absBuffer, "%s%s", g.zLocalRoot, zTreeFile);
zAbs = blob_str(&absBuffer);
if(timeFlag<0){/*--checkin*/
if(mtime_of_manifest_file( vid, fid, &newMtime )!=0){
fossil_fatal("Could not resolve --checkin mtime of %s", zTreeFile);
}
}else{
assert(newMtime>0);
}
changeCount +=
touch_cmd_stamp_one_file( zAbs, zArg, newMtime,
dryRunFlag, verboseFlag );
}
}
db_end_transaction(0);
blob_reset(&absBuffer);
if( dryRunFlag!=0 ){
fossil_print("dry-run: would have touched %d file(s)\n",
changeCount);
}else{
fossil_print("Touched %d file(s)\n", changeCount);
}
}
|