Fossil SCM
report renamed state when file is both edited and renamed In `fossil {changes,status}` and the commit description shown in the editor with `fossil commit`, show the original and renamed path annotation if the file has been renamed and edited. Prior to this, the file was only reported as edited, which can be confusing. Reported by James Cook [forum:5a4c530e6b]. Discussed with stephan@ and danield@, plus some forum members. While here, make sure we honour the relative-paths setting/option when displaying the original pathname in the renamed case.
Commit
ca9d0ddf064a7885c4abfaa69dc94398d639667720e16ef4a64816230a5d847d
Parent
c6115dbf8326d66…
1 file changed
+25
-17
+25
-17
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -121,11 +121,11 @@ | ||
| 121 | 121 | Blob *report, /* Append the status report here */ |
| 122 | 122 | unsigned flags /* Filter and other configuration flags */ |
| 123 | 123 | ){ |
| 124 | 124 | Stmt q; |
| 125 | 125 | int nErr = 0; |
| 126 | - Blob rewrittenPathname; | |
| 126 | + Blob rewrittenOrigName, rewrittenPathname; | |
| 127 | 127 | Blob sql = BLOB_INITIALIZER, where = BLOB_INITIALIZER; |
| 128 | 128 | const char *zName; |
| 129 | 129 | int i; |
| 130 | 130 | |
| 131 | 131 | /* Skip the file report if no files are requested at all. */ |
| @@ -205,10 +205,11 @@ | ||
| 205 | 205 | db_bind_int(&q, ":vid", db_lget_int("checkout", 0)); |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | /* Execute the query and assemble the report. */ |
| 209 | 209 | blob_zero(&rewrittenPathname); |
| 210 | + blob_zero(&rewrittenOrigName); | |
| 210 | 211 | while( db_step(&q)==SQLITE_ROW ){ |
| 211 | 212 | const char *zPathname = db_column_text(&q, 0); |
| 212 | 213 | const char *zClass = 0; |
| 213 | 214 | int isManaged = db_column_int(&q, 7); |
| 214 | 215 | const char *zMtime = db_column_text(&q, 1); |
| @@ -268,18 +269,21 @@ | ||
| 268 | 269 | && file_contains_merge_marker(zFullName) ){ |
| 269 | 270 | zClass = "CONFLICT"; |
| 270 | 271 | }else if( (flags & (C_EDITED | C_CHANGED)) && isChnged |
| 271 | 272 | && (isChnged<2 || isChnged>9) ){ |
| 272 | 273 | zClass = "EDITED"; |
| 273 | - }else if( (flags & C_RENAMED) && isRenamed ){ | |
| 274 | - zClass = "RENAMED"; | |
| 275 | - zOrigName = db_column_text(&q,8); | |
| 276 | 274 | }else if( (flags & C_UNCHANGED) && isManaged && !isNew |
| 277 | 275 | && !isChnged && !isRenamed ){ |
| 278 | 276 | zClass = "UNCHANGED"; |
| 279 | 277 | }else if( (flags & C_EXTRA) && !isManaged ){ |
| 280 | 278 | zClass = "EXTRA"; |
| 279 | + } | |
| 280 | + if( (flags & C_RENAMED) && isRenamed ){ | |
| 281 | + zOrigName = db_column_text(&q,8); | |
| 282 | + if( zClass==0 ){ | |
| 283 | + zClass = "RENAMED"; | |
| 284 | + } | |
| 281 | 285 | } |
| 282 | 286 | |
| 283 | 287 | /* Only report files for which a change classification was determined. */ |
| 284 | 288 | if( zClass ){ |
| 285 | 289 | if( flags & C_COMMENT ){ |
| @@ -295,30 +299,34 @@ | ||
| 295 | 299 | if( flags & C_SIZE ){ |
| 296 | 300 | blob_appendf(report, "%7d ", size); |
| 297 | 301 | } |
| 298 | 302 | if( flags & C_RELPATH ){ |
| 299 | 303 | /* If C_RELPATH, display paths relative to current directory. */ |
| 300 | - const char *zDisplayName; | |
| 301 | 304 | file_relative_name(zFullName, &rewrittenPathname, 0); |
| 302 | - zDisplayName = blob_str(&rewrittenPathname); | |
| 303 | - if( zDisplayName[0]=='.' && zDisplayName[1]=='/' ){ | |
| 304 | - zDisplayName += 2; /* no unnecessary ./ prefix */ | |
| 305 | + zPathname = blob_str(&rewrittenPathname); | |
| 306 | + if( zPathname[0]=='.' && zPathname[1]=='/' ){ | |
| 307 | + zPathname += 2; /* no unnecessary ./ prefix */ | |
| 305 | 308 | } |
| 306 | 309 | if( (flags & (C_FILTER ^ C_RENAMED)) && zOrigName ){ |
| 307 | - blob_appendf(report, "%s -> %s", zOrigName, zDisplayName); | |
| 308 | - }else{ | |
| 309 | - blob_append(report, zDisplayName, -1); | |
| 310 | - } | |
| 311 | - }else{ | |
| 312 | - /* If not C_RELPATH, display paths relative to project root. */ | |
| 313 | - blob_append(report, zPathname, -1); | |
| 314 | - } | |
| 315 | - blob_append(report, "\n", 1); | |
| 310 | + char *zOrigFullName = mprintf("%s%s", g.zLocalRoot, zOrigName); | |
| 311 | + file_relative_name(zOrigFullName, &rewrittenOrigName, 0); | |
| 312 | + zOrigName = blob_str(&rewrittenOrigName); | |
| 313 | + fossil_free(zOrigFullName); | |
| 314 | + if( zOrigName[0]=='.' && zOrigName[1]=='/' ){ | |
| 315 | + zOrigName += 2; /* no unnecessary ./ prefix */ | |
| 316 | + } | |
| 317 | + } | |
| 318 | + } | |
| 319 | + if( (flags & (C_FILTER ^ C_RENAMED)) && zOrigName ){ | |
| 320 | + blob_appendf(report, "%s -> ", zOrigName); | |
| 321 | + } | |
| 322 | + blob_appendf(report, "%s\n", zPathname); | |
| 316 | 323 | } |
| 317 | 324 | free(zFullName); |
| 318 | 325 | } |
| 319 | 326 | blob_reset(&rewrittenPathname); |
| 327 | + blob_reset(&rewrittenOrigName); | |
| 320 | 328 | db_finalize(&q); |
| 321 | 329 | |
| 322 | 330 | /* If C_MERGE, put merge contributors at the end of the report. */ |
| 323 | 331 | skipFiles: |
| 324 | 332 | if( flags & C_MERGE ){ |
| 325 | 333 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -121,11 +121,11 @@ | |
| 121 | Blob *report, /* Append the status report here */ |
| 122 | unsigned flags /* Filter and other configuration flags */ |
| 123 | ){ |
| 124 | Stmt q; |
| 125 | int nErr = 0; |
| 126 | Blob rewrittenPathname; |
| 127 | Blob sql = BLOB_INITIALIZER, where = BLOB_INITIALIZER; |
| 128 | const char *zName; |
| 129 | int i; |
| 130 | |
| 131 | /* Skip the file report if no files are requested at all. */ |
| @@ -205,10 +205,11 @@ | |
| 205 | db_bind_int(&q, ":vid", db_lget_int("checkout", 0)); |
| 206 | } |
| 207 | |
| 208 | /* Execute the query and assemble the report. */ |
| 209 | blob_zero(&rewrittenPathname); |
| 210 | while( db_step(&q)==SQLITE_ROW ){ |
| 211 | const char *zPathname = db_column_text(&q, 0); |
| 212 | const char *zClass = 0; |
| 213 | int isManaged = db_column_int(&q, 7); |
| 214 | const char *zMtime = db_column_text(&q, 1); |
| @@ -268,18 +269,21 @@ | |
| 268 | && file_contains_merge_marker(zFullName) ){ |
| 269 | zClass = "CONFLICT"; |
| 270 | }else if( (flags & (C_EDITED | C_CHANGED)) && isChnged |
| 271 | && (isChnged<2 || isChnged>9) ){ |
| 272 | zClass = "EDITED"; |
| 273 | }else if( (flags & C_RENAMED) && isRenamed ){ |
| 274 | zClass = "RENAMED"; |
| 275 | zOrigName = db_column_text(&q,8); |
| 276 | }else if( (flags & C_UNCHANGED) && isManaged && !isNew |
| 277 | && !isChnged && !isRenamed ){ |
| 278 | zClass = "UNCHANGED"; |
| 279 | }else if( (flags & C_EXTRA) && !isManaged ){ |
| 280 | zClass = "EXTRA"; |
| 281 | } |
| 282 | |
| 283 | /* Only report files for which a change classification was determined. */ |
| 284 | if( zClass ){ |
| 285 | if( flags & C_COMMENT ){ |
| @@ -295,30 +299,34 @@ | |
| 295 | if( flags & C_SIZE ){ |
| 296 | blob_appendf(report, "%7d ", size); |
| 297 | } |
| 298 | if( flags & C_RELPATH ){ |
| 299 | /* If C_RELPATH, display paths relative to current directory. */ |
| 300 | const char *zDisplayName; |
| 301 | file_relative_name(zFullName, &rewrittenPathname, 0); |
| 302 | zDisplayName = blob_str(&rewrittenPathname); |
| 303 | if( zDisplayName[0]=='.' && zDisplayName[1]=='/' ){ |
| 304 | zDisplayName += 2; /* no unnecessary ./ prefix */ |
| 305 | } |
| 306 | if( (flags & (C_FILTER ^ C_RENAMED)) && zOrigName ){ |
| 307 | blob_appendf(report, "%s -> %s", zOrigName, zDisplayName); |
| 308 | }else{ |
| 309 | blob_append(report, zDisplayName, -1); |
| 310 | } |
| 311 | }else{ |
| 312 | /* If not C_RELPATH, display paths relative to project root. */ |
| 313 | blob_append(report, zPathname, -1); |
| 314 | } |
| 315 | blob_append(report, "\n", 1); |
| 316 | } |
| 317 | free(zFullName); |
| 318 | } |
| 319 | blob_reset(&rewrittenPathname); |
| 320 | db_finalize(&q); |
| 321 | |
| 322 | /* If C_MERGE, put merge contributors at the end of the report. */ |
| 323 | skipFiles: |
| 324 | if( flags & C_MERGE ){ |
| 325 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -121,11 +121,11 @@ | |
| 121 | Blob *report, /* Append the status report here */ |
| 122 | unsigned flags /* Filter and other configuration flags */ |
| 123 | ){ |
| 124 | Stmt q; |
| 125 | int nErr = 0; |
| 126 | Blob rewrittenOrigName, rewrittenPathname; |
| 127 | Blob sql = BLOB_INITIALIZER, where = BLOB_INITIALIZER; |
| 128 | const char *zName; |
| 129 | int i; |
| 130 | |
| 131 | /* Skip the file report if no files are requested at all. */ |
| @@ -205,10 +205,11 @@ | |
| 205 | db_bind_int(&q, ":vid", db_lget_int("checkout", 0)); |
| 206 | } |
| 207 | |
| 208 | /* Execute the query and assemble the report. */ |
| 209 | blob_zero(&rewrittenPathname); |
| 210 | blob_zero(&rewrittenOrigName); |
| 211 | while( db_step(&q)==SQLITE_ROW ){ |
| 212 | const char *zPathname = db_column_text(&q, 0); |
| 213 | const char *zClass = 0; |
| 214 | int isManaged = db_column_int(&q, 7); |
| 215 | const char *zMtime = db_column_text(&q, 1); |
| @@ -268,18 +269,21 @@ | |
| 269 | && file_contains_merge_marker(zFullName) ){ |
| 270 | zClass = "CONFLICT"; |
| 271 | }else if( (flags & (C_EDITED | C_CHANGED)) && isChnged |
| 272 | && (isChnged<2 || isChnged>9) ){ |
| 273 | zClass = "EDITED"; |
| 274 | }else if( (flags & C_UNCHANGED) && isManaged && !isNew |
| 275 | && !isChnged && !isRenamed ){ |
| 276 | zClass = "UNCHANGED"; |
| 277 | }else if( (flags & C_EXTRA) && !isManaged ){ |
| 278 | zClass = "EXTRA"; |
| 279 | } |
| 280 | if( (flags & C_RENAMED) && isRenamed ){ |
| 281 | zOrigName = db_column_text(&q,8); |
| 282 | if( zClass==0 ){ |
| 283 | zClass = "RENAMED"; |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | /* Only report files for which a change classification was determined. */ |
| 288 | if( zClass ){ |
| 289 | if( flags & C_COMMENT ){ |
| @@ -295,30 +299,34 @@ | |
| 299 | if( flags & C_SIZE ){ |
| 300 | blob_appendf(report, "%7d ", size); |
| 301 | } |
| 302 | if( flags & C_RELPATH ){ |
| 303 | /* If C_RELPATH, display paths relative to current directory. */ |
| 304 | file_relative_name(zFullName, &rewrittenPathname, 0); |
| 305 | zPathname = blob_str(&rewrittenPathname); |
| 306 | if( zPathname[0]=='.' && zPathname[1]=='/' ){ |
| 307 | zPathname += 2; /* no unnecessary ./ prefix */ |
| 308 | } |
| 309 | if( (flags & (C_FILTER ^ C_RENAMED)) && zOrigName ){ |
| 310 | char *zOrigFullName = mprintf("%s%s", g.zLocalRoot, zOrigName); |
| 311 | file_relative_name(zOrigFullName, &rewrittenOrigName, 0); |
| 312 | zOrigName = blob_str(&rewrittenOrigName); |
| 313 | fossil_free(zOrigFullName); |
| 314 | if( zOrigName[0]=='.' && zOrigName[1]=='/' ){ |
| 315 | zOrigName += 2; /* no unnecessary ./ prefix */ |
| 316 | } |
| 317 | } |
| 318 | } |
| 319 | if( (flags & (C_FILTER ^ C_RENAMED)) && zOrigName ){ |
| 320 | blob_appendf(report, "%s -> ", zOrigName); |
| 321 | } |
| 322 | blob_appendf(report, "%s\n", zPathname); |
| 323 | } |
| 324 | free(zFullName); |
| 325 | } |
| 326 | blob_reset(&rewrittenPathname); |
| 327 | blob_reset(&rewrittenOrigName); |
| 328 | db_finalize(&q); |
| 329 | |
| 330 | /* If C_MERGE, put merge contributors at the end of the report. */ |
| 331 | skipFiles: |
| 332 | if( flags & C_MERGE ){ |
| 333 |