Fossil SCM
Add the ability to specify directories and files on the "fossil ls" command.
Commit
04803ae4ab7442daf15a85f0da945bf2f246d535
Parent
5aa2aee95fc5761…
1 file changed
+34
-6
+34
-6
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -217,14 +217,15 @@ | ||
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | /* |
| 220 | 220 | ** COMMAND: ls |
| 221 | 221 | ** |
| 222 | -** Usage: %fossil ls ?OPTIONS? ?VERSION? | |
| 222 | +** Usage: %fossil ls ?OPTIONS? ?VERSION? ?FILENAMES? | |
| 223 | 223 | ** |
| 224 | 224 | ** Show the names of all files in the current checkout. The -v provides |
| 225 | -** extra information about each file. | |
| 225 | +** extra information about each file. If FILENAMES are included, the only | |
| 226 | +** the files listed (or their children if they are directories) are shown. | |
| 226 | 227 | ** |
| 227 | 228 | ** Options: |
| 228 | 229 | ** --age Show when each file was committed |
| 229 | 230 | ** -v|--verbose Provide extra information about each file. |
| 230 | 231 | ** |
| @@ -234,10 +235,13 @@ | ||
| 234 | 235 | int vid; |
| 235 | 236 | Stmt q; |
| 236 | 237 | int verboseFlag; |
| 237 | 238 | int showAge; |
| 238 | 239 | char *zOrderBy = "pathname"; |
| 240 | + Blob where; | |
| 241 | + int i; | |
| 242 | + int nRoot; | |
| 239 | 243 | |
| 240 | 244 | verboseFlag = find_option("verbose","v", 0)!=0; |
| 241 | 245 | if( !verboseFlag ){ |
| 242 | 246 | verboseFlag = find_option("l","l", 0)!=0; /* deprecated */ |
| 243 | 247 | } |
| @@ -250,25 +254,49 @@ | ||
| 250 | 254 | }else{ |
| 251 | 255 | zOrderBy = "mtime DESC"; |
| 252 | 256 | } |
| 253 | 257 | } |
| 254 | 258 | verify_all_options(); |
| 259 | + blob_zero(&where); | |
| 260 | + nRoot = (int)strlen(g.zLocalRoot); | |
| 261 | + for(i=2; i<g.argc; i++){ | |
| 262 | + Blob fname; | |
| 263 | + file_canonical_name(g.argv[i], &fname, 0); | |
| 264 | + if( blob_size(&where)>0 ){ | |
| 265 | + blob_append(&where, " OR ", -1); | |
| 266 | + }else{ | |
| 267 | + blob_append(&where, " WHERE ", -1); | |
| 268 | + } | |
| 269 | + if( file_wd_isdir(blob_str(&fname))==1 ){ | |
| 270 | + const char *zFormat; | |
| 271 | + if( filenames_are_case_sensitive() ){ | |
| 272 | + zFormat = "(pathname GLOB '%q/*')"; | |
| 273 | + }else{ | |
| 274 | + zFormat = "(pathname LIKE '%q/%%')"; | |
| 275 | + } | |
| 276 | + blob_appendf(&where, zFormat, blob_str(&fname)+nRoot); | |
| 277 | + }else{ | |
| 278 | + blob_appendf(&where, "(pathname=%Q %s)", | |
| 279 | + blob_str(&fname)+nRoot, filename_collation()); | |
| 280 | + } | |
| 281 | + } | |
| 255 | 282 | vfile_check_signature(vid, 0); |
| 256 | 283 | if( showAge ){ |
| 257 | 284 | db_prepare(&q, |
| 258 | 285 | "SELECT pathname, deleted, rid, chnged, coalesce(origname!=pathname,0)," |
| 259 | 286 | " datetime(checkin_mtime(%d,rid),'unixepoch','localtime')" |
| 260 | - " FROM vfile" | |
| 261 | - " ORDER BY %s", vid, zOrderBy | |
| 287 | + " FROM vfile %s" | |
| 288 | + " ORDER BY %s", vid, blob_str(&where), zOrderBy | |
| 262 | 289 | ); |
| 263 | 290 | }else{ |
| 264 | 291 | db_prepare(&q, |
| 265 | 292 | "SELECT pathname, deleted, rid, chnged, coalesce(origname!=pathname,0)" |
| 266 | - " FROM vfile" | |
| 267 | - " ORDER BY %s", zOrderBy | |
| 293 | + " FROM vfile %s" | |
| 294 | + " ORDER BY %s", blob_str(&where), zOrderBy | |
| 268 | 295 | ); |
| 269 | 296 | } |
| 297 | + blob_reset(&where); | |
| 270 | 298 | while( db_step(&q)==SQLITE_ROW ){ |
| 271 | 299 | const char *zPathname = db_column_text(&q,0); |
| 272 | 300 | int isDeleted = db_column_int(&q, 1); |
| 273 | 301 | int isNew = db_column_int(&q,2)==0; |
| 274 | 302 | int chnged = db_column_int(&q,3); |
| 275 | 303 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -217,14 +217,15 @@ | |
| 217 | } |
| 218 | |
| 219 | /* |
| 220 | ** COMMAND: ls |
| 221 | ** |
| 222 | ** Usage: %fossil ls ?OPTIONS? ?VERSION? |
| 223 | ** |
| 224 | ** Show the names of all files in the current checkout. The -v provides |
| 225 | ** extra information about each file. |
| 226 | ** |
| 227 | ** Options: |
| 228 | ** --age Show when each file was committed |
| 229 | ** -v|--verbose Provide extra information about each file. |
| 230 | ** |
| @@ -234,10 +235,13 @@ | |
| 234 | int vid; |
| 235 | Stmt q; |
| 236 | int verboseFlag; |
| 237 | int showAge; |
| 238 | char *zOrderBy = "pathname"; |
| 239 | |
| 240 | verboseFlag = find_option("verbose","v", 0)!=0; |
| 241 | if( !verboseFlag ){ |
| 242 | verboseFlag = find_option("l","l", 0)!=0; /* deprecated */ |
| 243 | } |
| @@ -250,25 +254,49 @@ | |
| 250 | }else{ |
| 251 | zOrderBy = "mtime DESC"; |
| 252 | } |
| 253 | } |
| 254 | verify_all_options(); |
| 255 | vfile_check_signature(vid, 0); |
| 256 | if( showAge ){ |
| 257 | db_prepare(&q, |
| 258 | "SELECT pathname, deleted, rid, chnged, coalesce(origname!=pathname,0)," |
| 259 | " datetime(checkin_mtime(%d,rid),'unixepoch','localtime')" |
| 260 | " FROM vfile" |
| 261 | " ORDER BY %s", vid, zOrderBy |
| 262 | ); |
| 263 | }else{ |
| 264 | db_prepare(&q, |
| 265 | "SELECT pathname, deleted, rid, chnged, coalesce(origname!=pathname,0)" |
| 266 | " FROM vfile" |
| 267 | " ORDER BY %s", zOrderBy |
| 268 | ); |
| 269 | } |
| 270 | while( db_step(&q)==SQLITE_ROW ){ |
| 271 | const char *zPathname = db_column_text(&q,0); |
| 272 | int isDeleted = db_column_int(&q, 1); |
| 273 | int isNew = db_column_int(&q,2)==0; |
| 274 | int chnged = db_column_int(&q,3); |
| 275 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -217,14 +217,15 @@ | |
| 217 | } |
| 218 | |
| 219 | /* |
| 220 | ** COMMAND: ls |
| 221 | ** |
| 222 | ** Usage: %fossil ls ?OPTIONS? ?VERSION? ?FILENAMES? |
| 223 | ** |
| 224 | ** Show the names of all files in the current checkout. The -v provides |
| 225 | ** extra information about each file. If FILENAMES are included, the only |
| 226 | ** the files listed (or their children if they are directories) are shown. |
| 227 | ** |
| 228 | ** Options: |
| 229 | ** --age Show when each file was committed |
| 230 | ** -v|--verbose Provide extra information about each file. |
| 231 | ** |
| @@ -234,10 +235,13 @@ | |
| 235 | int vid; |
| 236 | Stmt q; |
| 237 | int verboseFlag; |
| 238 | int showAge; |
| 239 | char *zOrderBy = "pathname"; |
| 240 | Blob where; |
| 241 | int i; |
| 242 | int nRoot; |
| 243 | |
| 244 | verboseFlag = find_option("verbose","v", 0)!=0; |
| 245 | if( !verboseFlag ){ |
| 246 | verboseFlag = find_option("l","l", 0)!=0; /* deprecated */ |
| 247 | } |
| @@ -250,25 +254,49 @@ | |
| 254 | }else{ |
| 255 | zOrderBy = "mtime DESC"; |
| 256 | } |
| 257 | } |
| 258 | verify_all_options(); |
| 259 | blob_zero(&where); |
| 260 | nRoot = (int)strlen(g.zLocalRoot); |
| 261 | for(i=2; i<g.argc; i++){ |
| 262 | Blob fname; |
| 263 | file_canonical_name(g.argv[i], &fname, 0); |
| 264 | if( blob_size(&where)>0 ){ |
| 265 | blob_append(&where, " OR ", -1); |
| 266 | }else{ |
| 267 | blob_append(&where, " WHERE ", -1); |
| 268 | } |
| 269 | if( file_wd_isdir(blob_str(&fname))==1 ){ |
| 270 | const char *zFormat; |
| 271 | if( filenames_are_case_sensitive() ){ |
| 272 | zFormat = "(pathname GLOB '%q/*')"; |
| 273 | }else{ |
| 274 | zFormat = "(pathname LIKE '%q/%%')"; |
| 275 | } |
| 276 | blob_appendf(&where, zFormat, blob_str(&fname)+nRoot); |
| 277 | }else{ |
| 278 | blob_appendf(&where, "(pathname=%Q %s)", |
| 279 | blob_str(&fname)+nRoot, filename_collation()); |
| 280 | } |
| 281 | } |
| 282 | vfile_check_signature(vid, 0); |
| 283 | if( showAge ){ |
| 284 | db_prepare(&q, |
| 285 | "SELECT pathname, deleted, rid, chnged, coalesce(origname!=pathname,0)," |
| 286 | " datetime(checkin_mtime(%d,rid),'unixepoch','localtime')" |
| 287 | " FROM vfile %s" |
| 288 | " ORDER BY %s", vid, blob_str(&where), zOrderBy |
| 289 | ); |
| 290 | }else{ |
| 291 | db_prepare(&q, |
| 292 | "SELECT pathname, deleted, rid, chnged, coalesce(origname!=pathname,0)" |
| 293 | " FROM vfile %s" |
| 294 | " ORDER BY %s", blob_str(&where), zOrderBy |
| 295 | ); |
| 296 | } |
| 297 | blob_reset(&where); |
| 298 | while( db_step(&q)==SQLITE_ROW ){ |
| 299 | const char *zPathname = db_column_text(&q,0); |
| 300 | int isDeleted = db_column_int(&q, 1); |
| 301 | int isNew = db_column_int(&q,2)==0; |
| 302 | int chnged = db_column_int(&q,3); |
| 303 |