Fossil

Check-in [ae012443]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Use file_tree_name(), not file_canonical_name(), as in Richard's example [c8253f4066] for "fossil ls|changes|status" too. Advantage: 1) a panic when an out-of-tree filename is given on the command line 2) shortcut when any command line argument is "." (or resolves to the top of the tree in any other way)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:ae0124439685c1102a904ce08d08afc23e062db3
User & Date: jan.nijtmans 2013-06-24 08:27:08
Context
2013-06-24
10:35
Fix the --localhost option on the "server" command. Ticket [e704dbd9676] check-in: 760eeb93 user: drh tags: trunk
09:53
rebase check-in: 50d466dc user: jan.nijtmans tags: pending-review
08:27
Use file_tree_name(), not file_canonical_name(), as in Richard's example [c8253f4066] for "fossil ls|changes|status" too. Advantage: 1) a panic when an out-of-tree filename is given on the command line 2) shortcut when any command line argument is "." (or resolves to the top of the tree in any other way) check-in: ae012443 user: jan.nijtmans tags: trunk
2013-06-22
21:45
Press "q" to exit the --tk diff window. check-in: 8db6f987 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/checkin.c.

38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54




55
56
57
58
59
60
61
62
63
64
65
66
...
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
...
274
275
276
277
278
279
280
281
282
283
284
285
286




287
288
289
290
291
292
293
294
295
296
297
298
...
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
...
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
  int cwdRelative        /* Report relative to the current working dir */
){
  Stmt q;
  int nPrefix = strlen(zPrefix);
  int nErr = 0;
  Blob rewrittenPathname;
  Blob where;
  const char *zTreeName;
  int i, nRoot;

  blob_zero(&where);
  nRoot = (int)strlen(g.zLocalRoot);
  blob_zero(&where);
  for(i=2; i<g.argc; i++) {
    Blob fname;
    file_canonical_name(g.argv[i], &fname, 0);
    zTreeName = blob_str(&fname)+nRoot;




    blob_appendf(&where, " %s (pathname=%Q %s) "
                 "OR (pathname>'%q/' %s AND pathname<'%q0' %s)",
                 (blob_size(&where)>0) ? "OR" : "AND", zTreeName,
                 filename_collation(), zTreeName, filename_collation(),
                 zTreeName, filename_collation());
  }

  db_prepare(&q,
    "SELECT pathname, deleted, chnged, rid, coalesce(origname!=pathname,0)"
    "  FROM vfile "
    " WHERE is_selected(id) %s"
    "   AND (chnged OR deleted OR rid=0 OR pathname!=origname) ORDER BY 1",
................................................................................
  int vid;
  Stmt q;
  int verboseFlag;
  int showAge;
  char *zOrderBy = "pathname";
  Blob where;
  int i;
  int nRoot;

  verboseFlag = find_option("verbose","v", 0)!=0;
  if( !verboseFlag ){
    verboseFlag = find_option("l","l", 0)!=0; /* deprecated */
  }
  showAge = find_option("age",0,0)!=0;
  db_must_be_within_tree();
................................................................................
      zOrderBy = mprintf("checkin_mtime(%d,rid) DESC", vid);
    }else{
      zOrderBy = "mtime DESC";
    }
  }
  verify_all_options();
  blob_zero(&where);
  nRoot = (int)strlen(g.zLocalRoot);
  for(i=2; i<g.argc; i++){
    Blob fname;
    const char *zTreeName;
    file_canonical_name(g.argv[i], &fname, 0);
    zTreeName = blob_str(&fname)+nRoot;




    blob_appendf(&where, " %s (pathname=%Q %s) "
                 "OR (pathname>'%q/' %s AND pathname<'%q0' %s)",
                 (blob_size(&where)>0) ? "OR" : "WHERE", zTreeName,
                 filename_collation(), zTreeName, filename_collation(),
                 zTreeName, filename_collation());
  }
  vfile_check_signature(vid, 0);
  if( showAge ){
    db_prepare(&q,
       "SELECT pathname, deleted, rid, chnged, coalesce(origname!=pathname,0),"
       "       datetime(checkin_mtime(%d,rid),'unixepoch','localtime')"
       "  FROM vfile %s"
................................................................................
    }
    free(zFullName);
  }
  db_finalize(&q);
}

/*
** Create a TEMP table named SFILE and add all unmanaged files named on the command-line 
** to that table.  If directories are named, then add all unmanged files contained
** underneath those directories.  If there are no files or directories named on the
** command-line, then add all unmanaged files anywhere in the checkout.
*/
static void locate_unmanaged_files(
  int argc,              /* Number of command-line arguments to examine */
  char **argv,           /* values of command-line arguments */
  unsigned scanFlags,    /* Zero or more SCAN_xxx flags */
................................................................................
    for(i=0; i<argc; i++){
      file_canonical_name(argv[i], &name, 0);
      zName = blob_str(&name);
      isDir = file_wd_isdir(zName);
      if( isDir==1 ){
        vfile_scan(&name, nRoot-1, scanFlags, pIgnore1, pIgnore2);
      }else if( isDir==0 ){
        fossil_warning("not found: %s", zName);
      }else if( file_access(zName, R_OK) ){
        fossil_fatal("cannot open %s", zName);
      }else{
        db_multi_exec(
           "INSERT OR IGNORE INTO sfile(x) VALUES(%Q)",
           &zName[nRoot]
        );
      }
      blob_reset(&name);







|
|


<
<


|
|
>
>
>
>


|
|
|







 







|







 







<


<
|
|
>
>
>
>


|
|
|







 







|
|







 







|

|







38
39
40
41
42
43
44
45
46
47
48


49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
...
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
...
276
277
278
279
280
281
282

283
284

285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
...
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
...
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
  int cwdRelative        /* Report relative to the current working dir */
){
  Stmt q;
  int nPrefix = strlen(zPrefix);
  int nErr = 0;
  Blob rewrittenPathname;
  Blob where;
  const char *zName;
  int i;

  blob_zero(&where);


  for(i=2; i<g.argc; i++) {
    Blob fname;
    file_tree_name(g.argv[i], &fname, 1);
    zName = blob_str(&fname);
    if( fossil_strcmp(zName, ".")==0 ) {
      blob_reset(&where);
      break;
    }
    blob_appendf(&where, " %s (pathname=%Q %s) "
                 "OR (pathname>'%q/' %s AND pathname<'%q0' %s)",
                 (blob_size(&where)>0) ? "OR" : "AND", zName,
                 filename_collation(), zName, filename_collation(),
                 zName, filename_collation());
  }

  db_prepare(&q,
    "SELECT pathname, deleted, chnged, rid, coalesce(origname!=pathname,0)"
    "  FROM vfile "
    " WHERE is_selected(id) %s"
    "   AND (chnged OR deleted OR rid=0 OR pathname!=origname) ORDER BY 1",
................................................................................
  int vid;
  Stmt q;
  int verboseFlag;
  int showAge;
  char *zOrderBy = "pathname";
  Blob where;
  int i;
  const char *zName;

  verboseFlag = find_option("verbose","v", 0)!=0;
  if( !verboseFlag ){
    verboseFlag = find_option("l","l", 0)!=0; /* deprecated */
  }
  showAge = find_option("age",0,0)!=0;
  db_must_be_within_tree();
................................................................................
      zOrderBy = mprintf("checkin_mtime(%d,rid) DESC", vid);
    }else{
      zOrderBy = "mtime DESC";
    }
  }
  verify_all_options();
  blob_zero(&where);

  for(i=2; i<g.argc; i++){
    Blob fname;

    file_tree_name(g.argv[i], &fname, 1);
    zName = blob_str(&fname);
    if( fossil_strcmp(zName, ".")==0 ) {
      blob_reset(&where);
      break;
    }
    blob_appendf(&where, " %s (pathname=%Q %s) "
                 "OR (pathname>'%q/' %s AND pathname<'%q0' %s)",
                 (blob_size(&where)>0) ? "OR" : "WHERE", zName,
                 filename_collation(), zName, filename_collation(),
                 zName, filename_collation());
  }
  vfile_check_signature(vid, 0);
  if( showAge ){
    db_prepare(&q,
       "SELECT pathname, deleted, rid, chnged, coalesce(origname!=pathname,0),"
       "       datetime(checkin_mtime(%d,rid),'unixepoch','localtime')"
       "  FROM vfile %s"
................................................................................
    }
    free(zFullName);
  }
  db_finalize(&q);
}

/*
** Create a TEMP table named SFILE and add all unmanaged files named on the command-line
** to that table.  If directories are named, then add all unmanaged files contained
** underneath those directories.  If there are no files or directories named on the
** command-line, then add all unmanaged files anywhere in the checkout.
*/
static void locate_unmanaged_files(
  int argc,              /* Number of command-line arguments to examine */
  char **argv,           /* values of command-line arguments */
  unsigned scanFlags,    /* Zero or more SCAN_xxx flags */
................................................................................
    for(i=0; i<argc; i++){
      file_canonical_name(argv[i], &name, 0);
      zName = blob_str(&name);
      isDir = file_wd_isdir(zName);
      if( isDir==1 ){
        vfile_scan(&name, nRoot-1, scanFlags, pIgnore1, pIgnore2);
      }else if( isDir==0 ){
        fossil_warning("not found: %s", &zName[nRoot]);
      }else if( file_access(zName, R_OK) ){
        fossil_fatal("cannot open %s", &zName[nRoot]);
      }else{
        db_multi_exec(
           "INSERT OR IGNORE INTO sfile(x) VALUES(%Q)",
           &zName[nRoot]
        );
      }
      blob_reset(&name);