Index: src/add.c ================================================================== --- src/add.c +++ src/add.c @@ -91,11 +91,11 @@ if( cachedManifest == -1 ){ Blob repo; cachedManifest = db_get_boolean("manifest",0); blob_zero(&repo); - if( file_tree_name(g.zRepositoryName, &repo, 0) ){ + if( file_tree_name(g.zRepositoryName, &repo, 0, 0) ){ const char *zRepo = blob_str(&repo); azRepo[0] = zRepo; azRepo[1] = mprintf("%s-journal", zRepo); azRepo[2] = mprintf("%s-wal", zRepo); azRepo[3] = mprintf("%s-shm", zRepo); @@ -201,11 +201,11 @@ const char *zReserved; /* Name of a reserved file */ Blob repoName; /* Treename of the repository */ Stmt loop; /* SQL to loop over all files to add */ int (*xCmp)(const char*,const char*); - if( !file_tree_name(g.zRepositoryName, &repoName, 0) ){ + if( !file_tree_name(g.zRepositoryName, &repoName, 0, 0) ){ blob_zero(&repoName); zRepo = ""; }else{ zRepo = blob_str(&repoName); } @@ -307,11 +307,11 @@ int isDir; Blob fullName; /* file_tree_name() throws a fatal error if g.argv[i] is outside of the ** checkout. */ - file_tree_name(g.argv[i], &fullName, 1); + file_tree_name(g.argv[i], &fullName, 0, 1); blob_reset(&fullName); file_canonical_name(g.argv[i], &fullName, 0); zName = blob_str(&fullName); isDir = file_wd_isdir(zName); @@ -365,11 +365,11 @@ if( !tableCreated ){ db_multi_exec("CREATE TEMP TABLE fremove(x TEXT PRIMARY KEY %s)", filename_collation()); tableCreated = 1; } - file_canonical_name(zOldName, &fullOldName, 0); + file_tree_name(zOldName, &fullOldName, 1, 1); db_multi_exec("INSERT INTO fremove VALUES('%q');", blob_str(&fullOldName)); blob_reset(&fullOldName); } /* @@ -384,20 +384,22 @@ */ static void process_files_to_remove( int dryRunFlag /* Zero to actually operate on the file-system. */ ){ Stmt remove; - db_prepare(&remove, "SELECT x FROM fremove ORDER BY x;"); - while( db_step(&remove)==SQLITE_ROW ){ - const char *zOldName = db_column_text(&remove, 0); - if( !dryRunFlag ){ - file_delete(zOldName); - } - fossil_print("DELETED_FILE %s\n", zOldName); - } - db_finalize(&remove); - db_multi_exec("DROP TABLE fremove;"); + if( db_table_exists(db_name("temp"), "fremove") ){ + db_prepare(&remove, "SELECT x FROM fremove ORDER BY x;"); + while( db_step(&remove)==SQLITE_ROW ){ + const char *zOldName = db_column_text(&remove, 0); + if( !dryRunFlag ){ + file_delete(zOldName); + } + fossil_print("DELETED_FILE %s\n", zOldName); + } + db_finalize(&remove); + db_multi_exec("DROP TABLE fremove;"); + } } /* ** COMMAND: rm ** COMMAND: delete @@ -464,11 +466,11 @@ filename_collation()); for(i=2; i0 && zLocalRoot[nLocalRoot-1]=='/' ); @@ -1066,11 +1092,15 @@ } /* Special case. zOrigName refers to g.zLocalRoot directory. */ if( (nFull==nLocalRoot-1 && xCmp(zLocalRoot, zFull, nFull)==0) || (nFull==1 && zFull[0]=='/' && nLocalRoot==1 && zLocalRoot[0]=='/') ){ - blob_append(pOut, ".", 1); + if( absolute ){ + blob_append(pOut, zLocalRoot, nLocalRoot); + }else{ + blob_append(pOut, ".", 1); + } blob_reset(&localRoot); blob_reset(&full); return 1; } @@ -1080,11 +1110,20 @@ if( errFatal ){ fossil_fatal("file outside of checkout tree: %s", zOrigName); } return 0; } - blob_append(pOut, &zFull[nLocalRoot], nFull-nLocalRoot); + if( absolute ){ + if( !file_is_absolute_path(zOrigName) ){ + blob_append(pOut, zLocalRoot, nLocalRoot); + } + blob_append(pOut, zOrigName, -1); + blob_resize(pOut, file_simplify_name(blob_buffer(pOut), + blob_size(pOut), 0)); + }else{ + blob_append(pOut, &zFull[nLocalRoot], nFull-nLocalRoot); + } blob_reset(&localRoot); blob_reset(&full); return 1; } @@ -1092,20 +1131,22 @@ ** COMMAND: test-tree-name ** ** Test the operation of the tree name generator. ** ** Options: +** --absolute Return an absolute path instead of a relative one. ** --case-sensitive B Enable or disable case-sensitive filenames. B is ** a boolean: "yes", "no", "true", "false", etc. */ void cmd_test_tree_name(void){ int i; Blob x; + int absoluteFlag = find_option("absolute",0,0)!=0; db_find_and_open_repository(0,0); blob_zero(&x); for(i=2; i2 ){ for(i=2; i 0x0
------------------- END TRACE LOG -------------------}} } else { - test th1-trace-2 {[string map [list \r\n \n] [string trim $RESULT]] eq \ + test th1-trace-2 {[normalize_result] eq \ {------------------ BEGIN TRACE LOG ------------------ th1-init 0x0 => 0x0
th1-setup {} => TH_OK
------------------- END TRACE LOG -------------------}} @@ -614,17 +614,17 @@ ############################################################################### fossil test-th-eval --th-trace "trace {this is a trace message.}" if {$th1Hooks} { - test th1-trace-4 {[string map [list \r\n \n] [string trim $RESULT]] eq \ + test th1-trace-4 {[normalize_result] eq \ {------------------ BEGIN TRACE LOG ------------------ th1-init 0x0 => 0x0
this is a trace message. ------------------- END TRACE LOG -------------------}} } else { - test th1-trace-4 {[string map [list \r\n \n] [string trim $RESULT]] eq \ + test th1-trace-4 {[normalize_result] eq \ {------------------ BEGIN TRACE LOG ------------------ th1-init 0x0 => 0x0
th1-setup {} => TH_OK
this is a trace message. ------------------- END TRACE LOG -------------------}}