Fossil SCM
Merge working directory relative file listings for changes and extras commands into ben-testing.
Commit
8320393b2fa0f672045e489d0fd72f652fb85088
Parent
74d65bab28c8c27…
2 files changed
+52
-15
+52
-15
+52
-15
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -32,60 +32,72 @@ | ||
| 32 | 32 | ** are not true files results in a fatal error. |
| 33 | 33 | */ |
| 34 | 34 | static void status_report( |
| 35 | 35 | Blob *report, /* Append the status report here */ |
| 36 | 36 | const char *zPrefix, /* Prefix on each line of the report */ |
| 37 | - int missingIsFatal /* MISSING and NOT_A_FILE are fatal errors */ | |
| 37 | + int missingIsFatal, /* MISSING and NOT_A_FILE are fatal errors */ | |
| 38 | + int cwdRelative /* Report relative to the current working dir */ | |
| 38 | 39 | ){ |
| 39 | 40 | Stmt q; |
| 40 | 41 | int nPrefix = strlen(zPrefix); |
| 41 | 42 | int nErr = 0; |
| 43 | + Blob rewrittenPathname; | |
| 42 | 44 | db_prepare(&q, |
| 43 | 45 | "SELECT pathname, deleted, chnged, rid, coalesce(origname!=pathname,0)" |
| 44 | 46 | " FROM vfile " |
| 45 | 47 | " WHERE file_is_selected(id)" |
| 46 | 48 | " AND (chnged OR deleted OR rid=0 OR pathname!=origname) ORDER BY 1" |
| 47 | 49 | ); |
| 50 | + blob_zero(&rewrittenPathname); | |
| 48 | 51 | while( db_step(&q)==SQLITE_ROW ){ |
| 49 | 52 | const char *zPathname = db_column_text(&q,0); |
| 53 | + const char *zDisplayName = zPathname; | |
| 50 | 54 | int isDeleted = db_column_int(&q, 1); |
| 51 | 55 | int isChnged = db_column_int(&q,2); |
| 52 | 56 | int isNew = db_column_int(&q,3)==0; |
| 53 | 57 | int isRenamed = db_column_int(&q,4); |
| 54 | 58 | char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname); |
| 59 | + if( cwdRelative ){ | |
| 60 | + file_relative_name(zFullName, &rewrittenPathname); | |
| 61 | + zDisplayName = blob_str(&rewrittenPathname); | |
| 62 | + if( zDisplayName[0]=='.' && zDisplayName[1]=='/' ){ | |
| 63 | + zDisplayName += 2; /* no unnecessary ./ prefix */ | |
| 64 | + } | |
| 65 | + } | |
| 55 | 66 | blob_append(report, zPrefix, nPrefix); |
| 56 | 67 | if( isDeleted ){ |
| 57 | - blob_appendf(report, "DELETED %s\n", zPathname); | |
| 68 | + blob_appendf(report, "DELETED %s\n", zDisplayName); | |
| 58 | 69 | }else if( !file_isfile(zFullName) ){ |
| 59 | 70 | if( file_access(zFullName, 0)==0 ){ |
| 60 | - blob_appendf(report, "NOT_A_FILE %s\n", zPathname); | |
| 71 | + blob_appendf(report, "NOT_A_FILE %s\n", zDisplayName); | |
| 61 | 72 | if( missingIsFatal ){ |
| 62 | - fossil_warning("not a file: %s", zPathname); | |
| 73 | + fossil_warning("not a file: %s", zDisplayName); | |
| 63 | 74 | nErr++; |
| 64 | 75 | } |
| 65 | 76 | }else{ |
| 66 | - blob_appendf(report, "MISSING %s\n", zPathname); | |
| 77 | + blob_appendf(report, "MISSING %s\n", zDisplayName); | |
| 67 | 78 | if( missingIsFatal ){ |
| 68 | - fossil_warning("missing file: %s", zPathname); | |
| 79 | + fossil_warning("missing file: %s", zDisplayName); | |
| 69 | 80 | nErr++; |
| 70 | 81 | } |
| 71 | 82 | } |
| 72 | 83 | }else if( isNew ){ |
| 73 | - blob_appendf(report, "ADDED %s\n", zPathname); | |
| 84 | + blob_appendf(report, "ADDED %s\n", zDisplayName); | |
| 74 | 85 | }else if( isDeleted ){ |
| 75 | - blob_appendf(report, "DELETED %s\n", zPathname); | |
| 86 | + blob_appendf(report, "DELETED %s\n", zDisplayName); | |
| 76 | 87 | }else if( isChnged==2 ){ |
| 77 | - blob_appendf(report, "UPDATED_BY_MERGE %s\n", zPathname); | |
| 88 | + blob_appendf(report, "UPDATED_BY_MERGE %s\n", zDisplayName); | |
| 78 | 89 | }else if( isChnged==3 ){ |
| 79 | - blob_appendf(report, "ADDED_BY_MERGE %s\n", zPathname); | |
| 90 | + blob_appendf(report, "ADDED_BY_MERGE %s\n", zDisplayName); | |
| 80 | 91 | }else if( isChnged==1 ){ |
| 81 | - blob_appendf(report, "EDITED %s\n", zPathname); | |
| 92 | + blob_appendf(report, "EDITED %s\n", zDisplayName); | |
| 82 | 93 | }else if( isRenamed ){ |
| 83 | - blob_appendf(report, "RENAMED %s\n", zPathname); | |
| 94 | + blob_appendf(report, "RENAMED %s\n", zDisplayName); | |
| 84 | 95 | } |
| 85 | 96 | free(zFullName); |
| 86 | 97 | } |
| 98 | + blob_reset(&rewrittenPathname); | |
| 87 | 99 | db_finalize(&q); |
| 88 | 100 | db_prepare(&q, "SELECT uuid FROM vmerge JOIN blob ON merge=rid" |
| 89 | 101 | " WHERE id=0"); |
| 90 | 102 | while( db_step(&q)==SQLITE_ROW ){ |
| 91 | 103 | blob_append(report, zPrefix, nPrefix); |
| @@ -107,20 +119,24 @@ | ||
| 107 | 119 | ** |
| 108 | 120 | ** Options: |
| 109 | 121 | ** |
| 110 | 122 | ** --sha1sum Verify file status using SHA1 hashing rather |
| 111 | 123 | ** than relying on file mtimes. |
| 124 | +** | |
| 125 | +** --non-relative Don't display filenames relative to the current | |
| 126 | +** working directory. | |
| 112 | 127 | */ |
| 113 | 128 | void changes_cmd(void){ |
| 114 | 129 | Blob report; |
| 115 | 130 | int vid; |
| 116 | 131 | int useSha1sum = find_option("sha1sum", 0, 0)!=0; |
| 132 | + int nonRelative = find_option("non-relative", 0, 0)!=0; | |
| 117 | 133 | db_must_be_within_tree(); |
| 118 | 134 | blob_zero(&report); |
| 119 | 135 | vid = db_lget_int("checkout", 0); |
| 120 | 136 | vfile_check_signature(vid, 0, useSha1sum); |
| 121 | - status_report(&report, "", 0); | |
| 137 | + status_report(&report, "", 0, !nonRelative); | |
| 122 | 138 | blob_write_to_file(&report, "-"); |
| 123 | 139 | } |
| 124 | 140 | |
| 125 | 141 | /* |
| 126 | 142 | ** COMMAND: status |
| @@ -131,10 +147,13 @@ | ||
| 131 | 147 | ** |
| 132 | 148 | ** Options: |
| 133 | 149 | ** |
| 134 | 150 | ** --sha1sum Verify file status using SHA1 hashing rather |
| 135 | 151 | ** than relying on file mtimes. |
| 152 | +** | |
| 153 | +** --non-relative Don't display filenames relative to the current | |
| 154 | +** working directory. | |
| 136 | 155 | */ |
| 137 | 156 | void status_cmd(void){ |
| 138 | 157 | int vid; |
| 139 | 158 | db_must_be_within_tree(); |
| 140 | 159 | /* 012345678901234 */ |
| @@ -212,20 +231,26 @@ | ||
| 212 | 231 | ** ignored but can be included by adding the --dotfiles option. |
| 213 | 232 | ** |
| 214 | 233 | ** The GLOBPATTERN is a comma-separated list of GLOB expressions for |
| 215 | 234 | ** files that are ignored. The GLOBPATTERN specified by the "ignore-glob" |
| 216 | 235 | ** is used if the --ignore option is omitted. |
| 236 | +** | |
| 237 | +** Filenames are displayed relative to the current working directory | |
| 238 | +** unless the --non-relative option is used. | |
| 217 | 239 | */ |
| 218 | 240 | void extra_cmd(void){ |
| 219 | 241 | Blob path; |
| 220 | 242 | Blob repo; |
| 221 | 243 | Stmt q; |
| 222 | 244 | int n; |
| 223 | 245 | const char *zIgnoreFlag = find_option("ignore",0,1); |
| 224 | 246 | int allFlag = find_option("dotfiles",0,0)!=0; |
| 247 | + int cwdRelative = !(find_option("non-relative", 0, 0)!=0); | |
| 225 | 248 | int outputManifest; |
| 226 | 249 | Glob *pIgnore; |
| 250 | + Blob rewrittenPathname; | |
| 251 | + const char *zPathname, *zDisplayName; | |
| 227 | 252 | |
| 228 | 253 | db_must_be_within_tree(); |
| 229 | 254 | outputManifest = db_get_versionable_setting_boolean("manifest",0); |
| 230 | 255 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 231 | 256 | n = strlen(g.zLocalRoot); |
| @@ -243,13 +268,25 @@ | ||
| 243 | 268 | fossil_all_reserved_names() |
| 244 | 269 | ); |
| 245 | 270 | if( file_tree_name(g.zRepositoryName, &repo, 0) ){ |
| 246 | 271 | db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo); |
| 247 | 272 | } |
| 273 | + blob_zero(&rewrittenPathname); | |
| 248 | 274 | while( db_step(&q)==SQLITE_ROW ){ |
| 249 | - fossil_print("%s\n", db_column_text(&q, 0)); | |
| 275 | + zDisplayName = zPathname = db_column_text(&q, 0); | |
| 276 | + if( cwdRelative ) { | |
| 277 | + char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname); | |
| 278 | + file_relative_name(zFullName, &rewrittenPathname); | |
| 279 | + free(zFullName); | |
| 280 | + zDisplayName = blob_str(&rewrittenPathname); | |
| 281 | + if( zDisplayName[0]=='.' && zDisplayName[1]=='/' ){ | |
| 282 | + zDisplayName += 2; /* no unnecessary ./ prefix */ | |
| 283 | + } | |
| 284 | + } | |
| 285 | + fossil_print("%s\n", zDisplayName); | |
| 250 | 286 | } |
| 287 | + blob_reset(&rewrittenPathname); | |
| 251 | 288 | db_finalize(&q); |
| 252 | 289 | } |
| 253 | 290 | |
| 254 | 291 | /* |
| 255 | 292 | ** COMMAND: clean |
| @@ -367,11 +404,11 @@ | ||
| 367 | 404 | "# PRIVATE BRANCH: This check-in will be private and will not sync to\n" |
| 368 | 405 | "# repositories.\n" |
| 369 | 406 | "#\n", -1 |
| 370 | 407 | ); |
| 371 | 408 | } |
| 372 | - status_report(&text, "# ", 1); | |
| 409 | + status_report(&text, "# ", 1, 0); | |
| 373 | 410 | zEditor = db_get("editor", 0); |
| 374 | 411 | if( zEditor==0 ){ |
| 375 | 412 | zEditor = getenv("VISUAL"); |
| 376 | 413 | } |
| 377 | 414 | if( zEditor==0 ){ |
| 378 | 415 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -32,60 +32,72 @@ | |
| 32 | ** are not true files results in a fatal error. |
| 33 | */ |
| 34 | static void status_report( |
| 35 | Blob *report, /* Append the status report here */ |
| 36 | const char *zPrefix, /* Prefix on each line of the report */ |
| 37 | int missingIsFatal /* MISSING and NOT_A_FILE are fatal errors */ |
| 38 | ){ |
| 39 | Stmt q; |
| 40 | int nPrefix = strlen(zPrefix); |
| 41 | int nErr = 0; |
| 42 | db_prepare(&q, |
| 43 | "SELECT pathname, deleted, chnged, rid, coalesce(origname!=pathname,0)" |
| 44 | " FROM vfile " |
| 45 | " WHERE file_is_selected(id)" |
| 46 | " AND (chnged OR deleted OR rid=0 OR pathname!=origname) ORDER BY 1" |
| 47 | ); |
| 48 | while( db_step(&q)==SQLITE_ROW ){ |
| 49 | const char *zPathname = db_column_text(&q,0); |
| 50 | int isDeleted = db_column_int(&q, 1); |
| 51 | int isChnged = db_column_int(&q,2); |
| 52 | int isNew = db_column_int(&q,3)==0; |
| 53 | int isRenamed = db_column_int(&q,4); |
| 54 | char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname); |
| 55 | blob_append(report, zPrefix, nPrefix); |
| 56 | if( isDeleted ){ |
| 57 | blob_appendf(report, "DELETED %s\n", zPathname); |
| 58 | }else if( !file_isfile(zFullName) ){ |
| 59 | if( file_access(zFullName, 0)==0 ){ |
| 60 | blob_appendf(report, "NOT_A_FILE %s\n", zPathname); |
| 61 | if( missingIsFatal ){ |
| 62 | fossil_warning("not a file: %s", zPathname); |
| 63 | nErr++; |
| 64 | } |
| 65 | }else{ |
| 66 | blob_appendf(report, "MISSING %s\n", zPathname); |
| 67 | if( missingIsFatal ){ |
| 68 | fossil_warning("missing file: %s", zPathname); |
| 69 | nErr++; |
| 70 | } |
| 71 | } |
| 72 | }else if( isNew ){ |
| 73 | blob_appendf(report, "ADDED %s\n", zPathname); |
| 74 | }else if( isDeleted ){ |
| 75 | blob_appendf(report, "DELETED %s\n", zPathname); |
| 76 | }else if( isChnged==2 ){ |
| 77 | blob_appendf(report, "UPDATED_BY_MERGE %s\n", zPathname); |
| 78 | }else if( isChnged==3 ){ |
| 79 | blob_appendf(report, "ADDED_BY_MERGE %s\n", zPathname); |
| 80 | }else if( isChnged==1 ){ |
| 81 | blob_appendf(report, "EDITED %s\n", zPathname); |
| 82 | }else if( isRenamed ){ |
| 83 | blob_appendf(report, "RENAMED %s\n", zPathname); |
| 84 | } |
| 85 | free(zFullName); |
| 86 | } |
| 87 | db_finalize(&q); |
| 88 | db_prepare(&q, "SELECT uuid FROM vmerge JOIN blob ON merge=rid" |
| 89 | " WHERE id=0"); |
| 90 | while( db_step(&q)==SQLITE_ROW ){ |
| 91 | blob_append(report, zPrefix, nPrefix); |
| @@ -107,20 +119,24 @@ | |
| 107 | ** |
| 108 | ** Options: |
| 109 | ** |
| 110 | ** --sha1sum Verify file status using SHA1 hashing rather |
| 111 | ** than relying on file mtimes. |
| 112 | */ |
| 113 | void changes_cmd(void){ |
| 114 | Blob report; |
| 115 | int vid; |
| 116 | int useSha1sum = find_option("sha1sum", 0, 0)!=0; |
| 117 | db_must_be_within_tree(); |
| 118 | blob_zero(&report); |
| 119 | vid = db_lget_int("checkout", 0); |
| 120 | vfile_check_signature(vid, 0, useSha1sum); |
| 121 | status_report(&report, "", 0); |
| 122 | blob_write_to_file(&report, "-"); |
| 123 | } |
| 124 | |
| 125 | /* |
| 126 | ** COMMAND: status |
| @@ -131,10 +147,13 @@ | |
| 131 | ** |
| 132 | ** Options: |
| 133 | ** |
| 134 | ** --sha1sum Verify file status using SHA1 hashing rather |
| 135 | ** than relying on file mtimes. |
| 136 | */ |
| 137 | void status_cmd(void){ |
| 138 | int vid; |
| 139 | db_must_be_within_tree(); |
| 140 | /* 012345678901234 */ |
| @@ -212,20 +231,26 @@ | |
| 212 | ** ignored but can be included by adding the --dotfiles option. |
| 213 | ** |
| 214 | ** The GLOBPATTERN is a comma-separated list of GLOB expressions for |
| 215 | ** files that are ignored. The GLOBPATTERN specified by the "ignore-glob" |
| 216 | ** is used if the --ignore option is omitted. |
| 217 | */ |
| 218 | void extra_cmd(void){ |
| 219 | Blob path; |
| 220 | Blob repo; |
| 221 | Stmt q; |
| 222 | int n; |
| 223 | const char *zIgnoreFlag = find_option("ignore",0,1); |
| 224 | int allFlag = find_option("dotfiles",0,0)!=0; |
| 225 | int outputManifest; |
| 226 | Glob *pIgnore; |
| 227 | |
| 228 | db_must_be_within_tree(); |
| 229 | outputManifest = db_get_versionable_setting_boolean("manifest",0); |
| 230 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 231 | n = strlen(g.zLocalRoot); |
| @@ -243,13 +268,25 @@ | |
| 243 | fossil_all_reserved_names() |
| 244 | ); |
| 245 | if( file_tree_name(g.zRepositoryName, &repo, 0) ){ |
| 246 | db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo); |
| 247 | } |
| 248 | while( db_step(&q)==SQLITE_ROW ){ |
| 249 | fossil_print("%s\n", db_column_text(&q, 0)); |
| 250 | } |
| 251 | db_finalize(&q); |
| 252 | } |
| 253 | |
| 254 | /* |
| 255 | ** COMMAND: clean |
| @@ -367,11 +404,11 @@ | |
| 367 | "# PRIVATE BRANCH: This check-in will be private and will not sync to\n" |
| 368 | "# repositories.\n" |
| 369 | "#\n", -1 |
| 370 | ); |
| 371 | } |
| 372 | status_report(&text, "# ", 1); |
| 373 | zEditor = db_get("editor", 0); |
| 374 | if( zEditor==0 ){ |
| 375 | zEditor = getenv("VISUAL"); |
| 376 | } |
| 377 | if( zEditor==0 ){ |
| 378 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -32,60 +32,72 @@ | |
| 32 | ** are not true files results in a fatal error. |
| 33 | */ |
| 34 | static void status_report( |
| 35 | Blob *report, /* Append the status report here */ |
| 36 | const char *zPrefix, /* Prefix on each line of the report */ |
| 37 | int missingIsFatal, /* MISSING and NOT_A_FILE are fatal errors */ |
| 38 | int cwdRelative /* Report relative to the current working dir */ |
| 39 | ){ |
| 40 | Stmt q; |
| 41 | int nPrefix = strlen(zPrefix); |
| 42 | int nErr = 0; |
| 43 | Blob rewrittenPathname; |
| 44 | db_prepare(&q, |
| 45 | "SELECT pathname, deleted, chnged, rid, coalesce(origname!=pathname,0)" |
| 46 | " FROM vfile " |
| 47 | " WHERE file_is_selected(id)" |
| 48 | " AND (chnged OR deleted OR rid=0 OR pathname!=origname) ORDER BY 1" |
| 49 | ); |
| 50 | blob_zero(&rewrittenPathname); |
| 51 | while( db_step(&q)==SQLITE_ROW ){ |
| 52 | const char *zPathname = db_column_text(&q,0); |
| 53 | const char *zDisplayName = zPathname; |
| 54 | int isDeleted = db_column_int(&q, 1); |
| 55 | int isChnged = db_column_int(&q,2); |
| 56 | int isNew = db_column_int(&q,3)==0; |
| 57 | int isRenamed = db_column_int(&q,4); |
| 58 | char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname); |
| 59 | if( cwdRelative ){ |
| 60 | file_relative_name(zFullName, &rewrittenPathname); |
| 61 | zDisplayName = blob_str(&rewrittenPathname); |
| 62 | if( zDisplayName[0]=='.' && zDisplayName[1]=='/' ){ |
| 63 | zDisplayName += 2; /* no unnecessary ./ prefix */ |
| 64 | } |
| 65 | } |
| 66 | blob_append(report, zPrefix, nPrefix); |
| 67 | if( isDeleted ){ |
| 68 | blob_appendf(report, "DELETED %s\n", zDisplayName); |
| 69 | }else if( !file_isfile(zFullName) ){ |
| 70 | if( file_access(zFullName, 0)==0 ){ |
| 71 | blob_appendf(report, "NOT_A_FILE %s\n", zDisplayName); |
| 72 | if( missingIsFatal ){ |
| 73 | fossil_warning("not a file: %s", zDisplayName); |
| 74 | nErr++; |
| 75 | } |
| 76 | }else{ |
| 77 | blob_appendf(report, "MISSING %s\n", zDisplayName); |
| 78 | if( missingIsFatal ){ |
| 79 | fossil_warning("missing file: %s", zDisplayName); |
| 80 | nErr++; |
| 81 | } |
| 82 | } |
| 83 | }else if( isNew ){ |
| 84 | blob_appendf(report, "ADDED %s\n", zDisplayName); |
| 85 | }else if( isDeleted ){ |
| 86 | blob_appendf(report, "DELETED %s\n", zDisplayName); |
| 87 | }else if( isChnged==2 ){ |
| 88 | blob_appendf(report, "UPDATED_BY_MERGE %s\n", zDisplayName); |
| 89 | }else if( isChnged==3 ){ |
| 90 | blob_appendf(report, "ADDED_BY_MERGE %s\n", zDisplayName); |
| 91 | }else if( isChnged==1 ){ |
| 92 | blob_appendf(report, "EDITED %s\n", zDisplayName); |
| 93 | }else if( isRenamed ){ |
| 94 | blob_appendf(report, "RENAMED %s\n", zDisplayName); |
| 95 | } |
| 96 | free(zFullName); |
| 97 | } |
| 98 | blob_reset(&rewrittenPathname); |
| 99 | db_finalize(&q); |
| 100 | db_prepare(&q, "SELECT uuid FROM vmerge JOIN blob ON merge=rid" |
| 101 | " WHERE id=0"); |
| 102 | while( db_step(&q)==SQLITE_ROW ){ |
| 103 | blob_append(report, zPrefix, nPrefix); |
| @@ -107,20 +119,24 @@ | |
| 119 | ** |
| 120 | ** Options: |
| 121 | ** |
| 122 | ** --sha1sum Verify file status using SHA1 hashing rather |
| 123 | ** than relying on file mtimes. |
| 124 | ** |
| 125 | ** --non-relative Don't display filenames relative to the current |
| 126 | ** working directory. |
| 127 | */ |
| 128 | void changes_cmd(void){ |
| 129 | Blob report; |
| 130 | int vid; |
| 131 | int useSha1sum = find_option("sha1sum", 0, 0)!=0; |
| 132 | int nonRelative = find_option("non-relative", 0, 0)!=0; |
| 133 | db_must_be_within_tree(); |
| 134 | blob_zero(&report); |
| 135 | vid = db_lget_int("checkout", 0); |
| 136 | vfile_check_signature(vid, 0, useSha1sum); |
| 137 | status_report(&report, "", 0, !nonRelative); |
| 138 | blob_write_to_file(&report, "-"); |
| 139 | } |
| 140 | |
| 141 | /* |
| 142 | ** COMMAND: status |
| @@ -131,10 +147,13 @@ | |
| 147 | ** |
| 148 | ** Options: |
| 149 | ** |
| 150 | ** --sha1sum Verify file status using SHA1 hashing rather |
| 151 | ** than relying on file mtimes. |
| 152 | ** |
| 153 | ** --non-relative Don't display filenames relative to the current |
| 154 | ** working directory. |
| 155 | */ |
| 156 | void status_cmd(void){ |
| 157 | int vid; |
| 158 | db_must_be_within_tree(); |
| 159 | /* 012345678901234 */ |
| @@ -212,20 +231,26 @@ | |
| 231 | ** ignored but can be included by adding the --dotfiles option. |
| 232 | ** |
| 233 | ** The GLOBPATTERN is a comma-separated list of GLOB expressions for |
| 234 | ** files that are ignored. The GLOBPATTERN specified by the "ignore-glob" |
| 235 | ** is used if the --ignore option is omitted. |
| 236 | ** |
| 237 | ** Filenames are displayed relative to the current working directory |
| 238 | ** unless the --non-relative option is used. |
| 239 | */ |
| 240 | void extra_cmd(void){ |
| 241 | Blob path; |
| 242 | Blob repo; |
| 243 | Stmt q; |
| 244 | int n; |
| 245 | const char *zIgnoreFlag = find_option("ignore",0,1); |
| 246 | int allFlag = find_option("dotfiles",0,0)!=0; |
| 247 | int cwdRelative = !(find_option("non-relative", 0, 0)!=0); |
| 248 | int outputManifest; |
| 249 | Glob *pIgnore; |
| 250 | Blob rewrittenPathname; |
| 251 | const char *zPathname, *zDisplayName; |
| 252 | |
| 253 | db_must_be_within_tree(); |
| 254 | outputManifest = db_get_versionable_setting_boolean("manifest",0); |
| 255 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 256 | n = strlen(g.zLocalRoot); |
| @@ -243,13 +268,25 @@ | |
| 268 | fossil_all_reserved_names() |
| 269 | ); |
| 270 | if( file_tree_name(g.zRepositoryName, &repo, 0) ){ |
| 271 | db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo); |
| 272 | } |
| 273 | blob_zero(&rewrittenPathname); |
| 274 | while( db_step(&q)==SQLITE_ROW ){ |
| 275 | zDisplayName = zPathname = db_column_text(&q, 0); |
| 276 | if( cwdRelative ) { |
| 277 | char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname); |
| 278 | file_relative_name(zFullName, &rewrittenPathname); |
| 279 | free(zFullName); |
| 280 | zDisplayName = blob_str(&rewrittenPathname); |
| 281 | if( zDisplayName[0]=='.' && zDisplayName[1]=='/' ){ |
| 282 | zDisplayName += 2; /* no unnecessary ./ prefix */ |
| 283 | } |
| 284 | } |
| 285 | fossil_print("%s\n", zDisplayName); |
| 286 | } |
| 287 | blob_reset(&rewrittenPathname); |
| 288 | db_finalize(&q); |
| 289 | } |
| 290 | |
| 291 | /* |
| 292 | ** COMMAND: clean |
| @@ -367,11 +404,11 @@ | |
| 404 | "# PRIVATE BRANCH: This check-in will be private and will not sync to\n" |
| 405 | "# repositories.\n" |
| 406 | "#\n", -1 |
| 407 | ); |
| 408 | } |
| 409 | status_report(&text, "# ", 1, 0); |
| 410 | zEditor = db_get("editor", 0); |
| 411 | if( zEditor==0 ){ |
| 412 | zEditor = getenv("VISUAL"); |
| 413 | } |
| 414 | if( zEditor==0 ){ |
| 415 |
+52
-15
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -32,60 +32,72 @@ | ||
| 32 | 32 | ** are not true files results in a fatal error. |
| 33 | 33 | */ |
| 34 | 34 | static void status_report( |
| 35 | 35 | Blob *report, /* Append the status report here */ |
| 36 | 36 | const char *zPrefix, /* Prefix on each line of the report */ |
| 37 | - int missingIsFatal /* MISSING and NOT_A_FILE are fatal errors */ | |
| 37 | + int missingIsFatal, /* MISSING and NOT_A_FILE are fatal errors */ | |
| 38 | + int cwdRelative /* Report relative to the current working dir */ | |
| 38 | 39 | ){ |
| 39 | 40 | Stmt q; |
| 40 | 41 | int nPrefix = strlen(zPrefix); |
| 41 | 42 | int nErr = 0; |
| 43 | + Blob rewrittenPathname; | |
| 42 | 44 | db_prepare(&q, |
| 43 | 45 | "SELECT pathname, deleted, chnged, rid, coalesce(origname!=pathname,0)" |
| 44 | 46 | " FROM vfile " |
| 45 | 47 | " WHERE file_is_selected(id)" |
| 46 | 48 | " AND (chnged OR deleted OR rid=0 OR pathname!=origname) ORDER BY 1" |
| 47 | 49 | ); |
| 50 | + blob_zero(&rewrittenPathname); | |
| 48 | 51 | while( db_step(&q)==SQLITE_ROW ){ |
| 49 | 52 | const char *zPathname = db_column_text(&q,0); |
| 53 | + const char *zDisplayName = zPathname; | |
| 50 | 54 | int isDeleted = db_column_int(&q, 1); |
| 51 | 55 | int isChnged = db_column_int(&q,2); |
| 52 | 56 | int isNew = db_column_int(&q,3)==0; |
| 53 | 57 | int isRenamed = db_column_int(&q,4); |
| 54 | 58 | char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname); |
| 59 | + if( cwdRelative ){ | |
| 60 | + file_relative_name(zFullName, &rewrittenPathname); | |
| 61 | + zDisplayName = blob_str(&rewrittenPathname); | |
| 62 | + if( zDisplayName[0]=='.' && zDisplayName[1]=='/' ){ | |
| 63 | + zDisplayName += 2; /* no unnecessary ./ prefix */ | |
| 64 | + } | |
| 65 | + } | |
| 55 | 66 | blob_append(report, zPrefix, nPrefix); |
| 56 | 67 | if( isDeleted ){ |
| 57 | - blob_appendf(report, "DELETED %s\n", zPathname); | |
| 68 | + blob_appendf(report, "DELETED %s\n", zDisplayName); | |
| 58 | 69 | }else if( !file_isfile(zFullName) ){ |
| 59 | 70 | if( file_access(zFullName, 0)==0 ){ |
| 60 | - blob_appendf(report, "NOT_A_FILE %s\n", zPathname); | |
| 71 | + blob_appendf(report, "NOT_A_FILE %s\n", zDisplayName); | |
| 61 | 72 | if( missingIsFatal ){ |
| 62 | - fossil_warning("not a file: %s", zPathname); | |
| 73 | + fossil_warning("not a file: %s", zDisplayName); | |
| 63 | 74 | nErr++; |
| 64 | 75 | } |
| 65 | 76 | }else{ |
| 66 | - blob_appendf(report, "MISSING %s\n", zPathname); | |
| 77 | + blob_appendf(report, "MISSING %s\n", zDisplayName); | |
| 67 | 78 | if( missingIsFatal ){ |
| 68 | - fossil_warning("missing file: %s", zPathname); | |
| 79 | + fossil_warning("missing file: %s", zDisplayName); | |
| 69 | 80 | nErr++; |
| 70 | 81 | } |
| 71 | 82 | } |
| 72 | 83 | }else if( isNew ){ |
| 73 | - blob_appendf(report, "ADDED %s\n", zPathname); | |
| 84 | + blob_appendf(report, "ADDED %s\n", zDisplayName); | |
| 74 | 85 | }else if( isDeleted ){ |
| 75 | - blob_appendf(report, "DELETED %s\n", zPathname); | |
| 86 | + blob_appendf(report, "DELETED %s\n", zDisplayName); | |
| 76 | 87 | }else if( isChnged==2 ){ |
| 77 | - blob_appendf(report, "UPDATED_BY_MERGE %s\n", zPathname); | |
| 88 | + blob_appendf(report, "UPDATED_BY_MERGE %s\n", zDisplayName); | |
| 78 | 89 | }else if( isChnged==3 ){ |
| 79 | - blob_appendf(report, "ADDED_BY_MERGE %s\n", zPathname); | |
| 90 | + blob_appendf(report, "ADDED_BY_MERGE %s\n", zDisplayName); | |
| 80 | 91 | }else if( isChnged==1 ){ |
| 81 | - blob_appendf(report, "EDITED %s\n", zPathname); | |
| 92 | + blob_appendf(report, "EDITED %s\n", zDisplayName); | |
| 82 | 93 | }else if( isRenamed ){ |
| 83 | - blob_appendf(report, "RENAMED %s\n", zPathname); | |
| 94 | + blob_appendf(report, "RENAMED %s\n", zDisplayName); | |
| 84 | 95 | } |
| 85 | 96 | free(zFullName); |
| 86 | 97 | } |
| 98 | + blob_reset(&rewrittenPathname); | |
| 87 | 99 | db_finalize(&q); |
| 88 | 100 | db_prepare(&q, "SELECT uuid FROM vmerge JOIN blob ON merge=rid" |
| 89 | 101 | " WHERE id=0"); |
| 90 | 102 | while( db_step(&q)==SQLITE_ROW ){ |
| 91 | 103 | blob_append(report, zPrefix, nPrefix); |
| @@ -107,20 +119,24 @@ | ||
| 107 | 119 | ** |
| 108 | 120 | ** Options: |
| 109 | 121 | ** |
| 110 | 122 | ** --sha1sum Verify file status using SHA1 hashing rather |
| 111 | 123 | ** than relying on file mtimes. |
| 124 | +** | |
| 125 | +** --non-relative Don't display filenames relative to the current | |
| 126 | +** working directory. | |
| 112 | 127 | */ |
| 113 | 128 | void changes_cmd(void){ |
| 114 | 129 | Blob report; |
| 115 | 130 | int vid; |
| 116 | 131 | int useSha1sum = find_option("sha1sum", 0, 0)!=0; |
| 132 | + int nonRelative = find_option("non-relative", 0, 0)!=0; | |
| 117 | 133 | db_must_be_within_tree(); |
| 118 | 134 | blob_zero(&report); |
| 119 | 135 | vid = db_lget_int("checkout", 0); |
| 120 | 136 | vfile_check_signature(vid, 0, useSha1sum); |
| 121 | - status_report(&report, "", 0); | |
| 137 | + status_report(&report, "", 0, !nonRelative); | |
| 122 | 138 | blob_write_to_file(&report, "-"); |
| 123 | 139 | } |
| 124 | 140 | |
| 125 | 141 | /* |
| 126 | 142 | ** COMMAND: status |
| @@ -131,10 +147,13 @@ | ||
| 131 | 147 | ** |
| 132 | 148 | ** Options: |
| 133 | 149 | ** |
| 134 | 150 | ** --sha1sum Verify file status using SHA1 hashing rather |
| 135 | 151 | ** than relying on file mtimes. |
| 152 | +** | |
| 153 | +** --non-relative Don't display filenames relative to the current | |
| 154 | +** working directory. | |
| 136 | 155 | */ |
| 137 | 156 | void status_cmd(void){ |
| 138 | 157 | int vid; |
| 139 | 158 | db_must_be_within_tree(); |
| 140 | 159 | /* 012345678901234 */ |
| @@ -212,20 +231,26 @@ | ||
| 212 | 231 | ** ignored but can be included by adding the --dotfiles option. |
| 213 | 232 | ** |
| 214 | 233 | ** The GLOBPATTERN is a comma-separated list of GLOB expressions for |
| 215 | 234 | ** files that are ignored. The GLOBPATTERN specified by the "ignore-glob" |
| 216 | 235 | ** is used if the --ignore option is omitted. |
| 236 | +** | |
| 237 | +** Filenames are displayed relative to the current working directory | |
| 238 | +** unless the --non-relative option is used. | |
| 217 | 239 | */ |
| 218 | 240 | void extra_cmd(void){ |
| 219 | 241 | Blob path; |
| 220 | 242 | Blob repo; |
| 221 | 243 | Stmt q; |
| 222 | 244 | int n; |
| 223 | 245 | const char *zIgnoreFlag = find_option("ignore",0,1); |
| 224 | 246 | int allFlag = find_option("dotfiles",0,0)!=0; |
| 247 | + int cwdRelative = !(find_option("non-relative", 0, 0)!=0); | |
| 225 | 248 | int outputManifest; |
| 226 | 249 | Glob *pIgnore; |
| 250 | + Blob rewrittenPathname; | |
| 251 | + const char *zPathname, *zDisplayName; | |
| 227 | 252 | |
| 228 | 253 | db_must_be_within_tree(); |
| 229 | 254 | outputManifest = db_get_versionable_setting_boolean("manifest",0); |
| 230 | 255 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 231 | 256 | n = strlen(g.zLocalRoot); |
| @@ -243,13 +268,25 @@ | ||
| 243 | 268 | fossil_all_reserved_names() |
| 244 | 269 | ); |
| 245 | 270 | if( file_tree_name(g.zRepositoryName, &repo, 0) ){ |
| 246 | 271 | db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo); |
| 247 | 272 | } |
| 273 | + blob_zero(&rewrittenPathname); | |
| 248 | 274 | while( db_step(&q)==SQLITE_ROW ){ |
| 249 | - fossil_print("%s\n", db_column_text(&q, 0)); | |
| 275 | + zDisplayName = zPathname = db_column_text(&q, 0); | |
| 276 | + if( cwdRelative ) { | |
| 277 | + char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname); | |
| 278 | + file_relative_name(zFullName, &rewrittenPathname); | |
| 279 | + free(zFullName); | |
| 280 | + zDisplayName = blob_str(&rewrittenPathname); | |
| 281 | + if( zDisplayName[0]=='.' && zDisplayName[1]=='/' ){ | |
| 282 | + zDisplayName += 2; /* no unnecessary ./ prefix */ | |
| 283 | + } | |
| 284 | + } | |
| 285 | + fossil_print("%s\n", zDisplayName); | |
| 250 | 286 | } |
| 287 | + blob_reset(&rewrittenPathname); | |
| 251 | 288 | db_finalize(&q); |
| 252 | 289 | } |
| 253 | 290 | |
| 254 | 291 | /* |
| 255 | 292 | ** COMMAND: clean |
| @@ -367,11 +404,11 @@ | ||
| 367 | 404 | "# PRIVATE BRANCH: This check-in will be private and will not sync to\n" |
| 368 | 405 | "# repositories.\n" |
| 369 | 406 | "#\n", -1 |
| 370 | 407 | ); |
| 371 | 408 | } |
| 372 | - status_report(&text, "# ", 1); | |
| 409 | + status_report(&text, "# ", 1, 0); | |
| 373 | 410 | zEditor = db_get("editor", 0); |
| 374 | 411 | if( zEditor==0 ){ |
| 375 | 412 | zEditor = getenv("VISUAL"); |
| 376 | 413 | } |
| 377 | 414 | if( zEditor==0 ){ |
| 378 | 415 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -32,60 +32,72 @@ | |
| 32 | ** are not true files results in a fatal error. |
| 33 | */ |
| 34 | static void status_report( |
| 35 | Blob *report, /* Append the status report here */ |
| 36 | const char *zPrefix, /* Prefix on each line of the report */ |
| 37 | int missingIsFatal /* MISSING and NOT_A_FILE are fatal errors */ |
| 38 | ){ |
| 39 | Stmt q; |
| 40 | int nPrefix = strlen(zPrefix); |
| 41 | int nErr = 0; |
| 42 | db_prepare(&q, |
| 43 | "SELECT pathname, deleted, chnged, rid, coalesce(origname!=pathname,0)" |
| 44 | " FROM vfile " |
| 45 | " WHERE file_is_selected(id)" |
| 46 | " AND (chnged OR deleted OR rid=0 OR pathname!=origname) ORDER BY 1" |
| 47 | ); |
| 48 | while( db_step(&q)==SQLITE_ROW ){ |
| 49 | const char *zPathname = db_column_text(&q,0); |
| 50 | int isDeleted = db_column_int(&q, 1); |
| 51 | int isChnged = db_column_int(&q,2); |
| 52 | int isNew = db_column_int(&q,3)==0; |
| 53 | int isRenamed = db_column_int(&q,4); |
| 54 | char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname); |
| 55 | blob_append(report, zPrefix, nPrefix); |
| 56 | if( isDeleted ){ |
| 57 | blob_appendf(report, "DELETED %s\n", zPathname); |
| 58 | }else if( !file_isfile(zFullName) ){ |
| 59 | if( file_access(zFullName, 0)==0 ){ |
| 60 | blob_appendf(report, "NOT_A_FILE %s\n", zPathname); |
| 61 | if( missingIsFatal ){ |
| 62 | fossil_warning("not a file: %s", zPathname); |
| 63 | nErr++; |
| 64 | } |
| 65 | }else{ |
| 66 | blob_appendf(report, "MISSING %s\n", zPathname); |
| 67 | if( missingIsFatal ){ |
| 68 | fossil_warning("missing file: %s", zPathname); |
| 69 | nErr++; |
| 70 | } |
| 71 | } |
| 72 | }else if( isNew ){ |
| 73 | blob_appendf(report, "ADDED %s\n", zPathname); |
| 74 | }else if( isDeleted ){ |
| 75 | blob_appendf(report, "DELETED %s\n", zPathname); |
| 76 | }else if( isChnged==2 ){ |
| 77 | blob_appendf(report, "UPDATED_BY_MERGE %s\n", zPathname); |
| 78 | }else if( isChnged==3 ){ |
| 79 | blob_appendf(report, "ADDED_BY_MERGE %s\n", zPathname); |
| 80 | }else if( isChnged==1 ){ |
| 81 | blob_appendf(report, "EDITED %s\n", zPathname); |
| 82 | }else if( isRenamed ){ |
| 83 | blob_appendf(report, "RENAMED %s\n", zPathname); |
| 84 | } |
| 85 | free(zFullName); |
| 86 | } |
| 87 | db_finalize(&q); |
| 88 | db_prepare(&q, "SELECT uuid FROM vmerge JOIN blob ON merge=rid" |
| 89 | " WHERE id=0"); |
| 90 | while( db_step(&q)==SQLITE_ROW ){ |
| 91 | blob_append(report, zPrefix, nPrefix); |
| @@ -107,20 +119,24 @@ | |
| 107 | ** |
| 108 | ** Options: |
| 109 | ** |
| 110 | ** --sha1sum Verify file status using SHA1 hashing rather |
| 111 | ** than relying on file mtimes. |
| 112 | */ |
| 113 | void changes_cmd(void){ |
| 114 | Blob report; |
| 115 | int vid; |
| 116 | int useSha1sum = find_option("sha1sum", 0, 0)!=0; |
| 117 | db_must_be_within_tree(); |
| 118 | blob_zero(&report); |
| 119 | vid = db_lget_int("checkout", 0); |
| 120 | vfile_check_signature(vid, 0, useSha1sum); |
| 121 | status_report(&report, "", 0); |
| 122 | blob_write_to_file(&report, "-"); |
| 123 | } |
| 124 | |
| 125 | /* |
| 126 | ** COMMAND: status |
| @@ -131,10 +147,13 @@ | |
| 131 | ** |
| 132 | ** Options: |
| 133 | ** |
| 134 | ** --sha1sum Verify file status using SHA1 hashing rather |
| 135 | ** than relying on file mtimes. |
| 136 | */ |
| 137 | void status_cmd(void){ |
| 138 | int vid; |
| 139 | db_must_be_within_tree(); |
| 140 | /* 012345678901234 */ |
| @@ -212,20 +231,26 @@ | |
| 212 | ** ignored but can be included by adding the --dotfiles option. |
| 213 | ** |
| 214 | ** The GLOBPATTERN is a comma-separated list of GLOB expressions for |
| 215 | ** files that are ignored. The GLOBPATTERN specified by the "ignore-glob" |
| 216 | ** is used if the --ignore option is omitted. |
| 217 | */ |
| 218 | void extra_cmd(void){ |
| 219 | Blob path; |
| 220 | Blob repo; |
| 221 | Stmt q; |
| 222 | int n; |
| 223 | const char *zIgnoreFlag = find_option("ignore",0,1); |
| 224 | int allFlag = find_option("dotfiles",0,0)!=0; |
| 225 | int outputManifest; |
| 226 | Glob *pIgnore; |
| 227 | |
| 228 | db_must_be_within_tree(); |
| 229 | outputManifest = db_get_versionable_setting_boolean("manifest",0); |
| 230 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 231 | n = strlen(g.zLocalRoot); |
| @@ -243,13 +268,25 @@ | |
| 243 | fossil_all_reserved_names() |
| 244 | ); |
| 245 | if( file_tree_name(g.zRepositoryName, &repo, 0) ){ |
| 246 | db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo); |
| 247 | } |
| 248 | while( db_step(&q)==SQLITE_ROW ){ |
| 249 | fossil_print("%s\n", db_column_text(&q, 0)); |
| 250 | } |
| 251 | db_finalize(&q); |
| 252 | } |
| 253 | |
| 254 | /* |
| 255 | ** COMMAND: clean |
| @@ -367,11 +404,11 @@ | |
| 367 | "# PRIVATE BRANCH: This check-in will be private and will not sync to\n" |
| 368 | "# repositories.\n" |
| 369 | "#\n", -1 |
| 370 | ); |
| 371 | } |
| 372 | status_report(&text, "# ", 1); |
| 373 | zEditor = db_get("editor", 0); |
| 374 | if( zEditor==0 ){ |
| 375 | zEditor = getenv("VISUAL"); |
| 376 | } |
| 377 | if( zEditor==0 ){ |
| 378 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -32,60 +32,72 @@ | |
| 32 | ** are not true files results in a fatal error. |
| 33 | */ |
| 34 | static void status_report( |
| 35 | Blob *report, /* Append the status report here */ |
| 36 | const char *zPrefix, /* Prefix on each line of the report */ |
| 37 | int missingIsFatal, /* MISSING and NOT_A_FILE are fatal errors */ |
| 38 | int cwdRelative /* Report relative to the current working dir */ |
| 39 | ){ |
| 40 | Stmt q; |
| 41 | int nPrefix = strlen(zPrefix); |
| 42 | int nErr = 0; |
| 43 | Blob rewrittenPathname; |
| 44 | db_prepare(&q, |
| 45 | "SELECT pathname, deleted, chnged, rid, coalesce(origname!=pathname,0)" |
| 46 | " FROM vfile " |
| 47 | " WHERE file_is_selected(id)" |
| 48 | " AND (chnged OR deleted OR rid=0 OR pathname!=origname) ORDER BY 1" |
| 49 | ); |
| 50 | blob_zero(&rewrittenPathname); |
| 51 | while( db_step(&q)==SQLITE_ROW ){ |
| 52 | const char *zPathname = db_column_text(&q,0); |
| 53 | const char *zDisplayName = zPathname; |
| 54 | int isDeleted = db_column_int(&q, 1); |
| 55 | int isChnged = db_column_int(&q,2); |
| 56 | int isNew = db_column_int(&q,3)==0; |
| 57 | int isRenamed = db_column_int(&q,4); |
| 58 | char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname); |
| 59 | if( cwdRelative ){ |
| 60 | file_relative_name(zFullName, &rewrittenPathname); |
| 61 | zDisplayName = blob_str(&rewrittenPathname); |
| 62 | if( zDisplayName[0]=='.' && zDisplayName[1]=='/' ){ |
| 63 | zDisplayName += 2; /* no unnecessary ./ prefix */ |
| 64 | } |
| 65 | } |
| 66 | blob_append(report, zPrefix, nPrefix); |
| 67 | if( isDeleted ){ |
| 68 | blob_appendf(report, "DELETED %s\n", zDisplayName); |
| 69 | }else if( !file_isfile(zFullName) ){ |
| 70 | if( file_access(zFullName, 0)==0 ){ |
| 71 | blob_appendf(report, "NOT_A_FILE %s\n", zDisplayName); |
| 72 | if( missingIsFatal ){ |
| 73 | fossil_warning("not a file: %s", zDisplayName); |
| 74 | nErr++; |
| 75 | } |
| 76 | }else{ |
| 77 | blob_appendf(report, "MISSING %s\n", zDisplayName); |
| 78 | if( missingIsFatal ){ |
| 79 | fossil_warning("missing file: %s", zDisplayName); |
| 80 | nErr++; |
| 81 | } |
| 82 | } |
| 83 | }else if( isNew ){ |
| 84 | blob_appendf(report, "ADDED %s\n", zDisplayName); |
| 85 | }else if( isDeleted ){ |
| 86 | blob_appendf(report, "DELETED %s\n", zDisplayName); |
| 87 | }else if( isChnged==2 ){ |
| 88 | blob_appendf(report, "UPDATED_BY_MERGE %s\n", zDisplayName); |
| 89 | }else if( isChnged==3 ){ |
| 90 | blob_appendf(report, "ADDED_BY_MERGE %s\n", zDisplayName); |
| 91 | }else if( isChnged==1 ){ |
| 92 | blob_appendf(report, "EDITED %s\n", zDisplayName); |
| 93 | }else if( isRenamed ){ |
| 94 | blob_appendf(report, "RENAMED %s\n", zDisplayName); |
| 95 | } |
| 96 | free(zFullName); |
| 97 | } |
| 98 | blob_reset(&rewrittenPathname); |
| 99 | db_finalize(&q); |
| 100 | db_prepare(&q, "SELECT uuid FROM vmerge JOIN blob ON merge=rid" |
| 101 | " WHERE id=0"); |
| 102 | while( db_step(&q)==SQLITE_ROW ){ |
| 103 | blob_append(report, zPrefix, nPrefix); |
| @@ -107,20 +119,24 @@ | |
| 119 | ** |
| 120 | ** Options: |
| 121 | ** |
| 122 | ** --sha1sum Verify file status using SHA1 hashing rather |
| 123 | ** than relying on file mtimes. |
| 124 | ** |
| 125 | ** --non-relative Don't display filenames relative to the current |
| 126 | ** working directory. |
| 127 | */ |
| 128 | void changes_cmd(void){ |
| 129 | Blob report; |
| 130 | int vid; |
| 131 | int useSha1sum = find_option("sha1sum", 0, 0)!=0; |
| 132 | int nonRelative = find_option("non-relative", 0, 0)!=0; |
| 133 | db_must_be_within_tree(); |
| 134 | blob_zero(&report); |
| 135 | vid = db_lget_int("checkout", 0); |
| 136 | vfile_check_signature(vid, 0, useSha1sum); |
| 137 | status_report(&report, "", 0, !nonRelative); |
| 138 | blob_write_to_file(&report, "-"); |
| 139 | } |
| 140 | |
| 141 | /* |
| 142 | ** COMMAND: status |
| @@ -131,10 +147,13 @@ | |
| 147 | ** |
| 148 | ** Options: |
| 149 | ** |
| 150 | ** --sha1sum Verify file status using SHA1 hashing rather |
| 151 | ** than relying on file mtimes. |
| 152 | ** |
| 153 | ** --non-relative Don't display filenames relative to the current |
| 154 | ** working directory. |
| 155 | */ |
| 156 | void status_cmd(void){ |
| 157 | int vid; |
| 158 | db_must_be_within_tree(); |
| 159 | /* 012345678901234 */ |
| @@ -212,20 +231,26 @@ | |
| 231 | ** ignored but can be included by adding the --dotfiles option. |
| 232 | ** |
| 233 | ** The GLOBPATTERN is a comma-separated list of GLOB expressions for |
| 234 | ** files that are ignored. The GLOBPATTERN specified by the "ignore-glob" |
| 235 | ** is used if the --ignore option is omitted. |
| 236 | ** |
| 237 | ** Filenames are displayed relative to the current working directory |
| 238 | ** unless the --non-relative option is used. |
| 239 | */ |
| 240 | void extra_cmd(void){ |
| 241 | Blob path; |
| 242 | Blob repo; |
| 243 | Stmt q; |
| 244 | int n; |
| 245 | const char *zIgnoreFlag = find_option("ignore",0,1); |
| 246 | int allFlag = find_option("dotfiles",0,0)!=0; |
| 247 | int cwdRelative = !(find_option("non-relative", 0, 0)!=0); |
| 248 | int outputManifest; |
| 249 | Glob *pIgnore; |
| 250 | Blob rewrittenPathname; |
| 251 | const char *zPathname, *zDisplayName; |
| 252 | |
| 253 | db_must_be_within_tree(); |
| 254 | outputManifest = db_get_versionable_setting_boolean("manifest",0); |
| 255 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 256 | n = strlen(g.zLocalRoot); |
| @@ -243,13 +268,25 @@ | |
| 268 | fossil_all_reserved_names() |
| 269 | ); |
| 270 | if( file_tree_name(g.zRepositoryName, &repo, 0) ){ |
| 271 | db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo); |
| 272 | } |
| 273 | blob_zero(&rewrittenPathname); |
| 274 | while( db_step(&q)==SQLITE_ROW ){ |
| 275 | zDisplayName = zPathname = db_column_text(&q, 0); |
| 276 | if( cwdRelative ) { |
| 277 | char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname); |
| 278 | file_relative_name(zFullName, &rewrittenPathname); |
| 279 | free(zFullName); |
| 280 | zDisplayName = blob_str(&rewrittenPathname); |
| 281 | if( zDisplayName[0]=='.' && zDisplayName[1]=='/' ){ |
| 282 | zDisplayName += 2; /* no unnecessary ./ prefix */ |
| 283 | } |
| 284 | } |
| 285 | fossil_print("%s\n", zDisplayName); |
| 286 | } |
| 287 | blob_reset(&rewrittenPathname); |
| 288 | db_finalize(&q); |
| 289 | } |
| 290 | |
| 291 | /* |
| 292 | ** COMMAND: clean |
| @@ -367,11 +404,11 @@ | |
| 404 | "# PRIVATE BRANCH: This check-in will be private and will not sync to\n" |
| 405 | "# repositories.\n" |
| 406 | "#\n", -1 |
| 407 | ); |
| 408 | } |
| 409 | status_report(&text, "# ", 1, 0); |
| 410 | zEditor = db_get("editor", 0); |
| 411 | if( zEditor==0 ){ |
| 412 | zEditor = getenv("VISUAL"); |
| 413 | } |
| 414 | if( zEditor==0 ){ |
| 415 |