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.

mark 2023-06-28 12:40 trunk
Commit ca9d0ddf064a7885c4abfaa69dc94398d639667720e16ef4a64816230a5d847d
1 file changed +25 -17
+25 -17
--- src/checkin.c
+++ src/checkin.c
@@ -121,11 +121,11 @@
121121
Blob *report, /* Append the status report here */
122122
unsigned flags /* Filter and other configuration flags */
123123
){
124124
Stmt q;
125125
int nErr = 0;
126
- Blob rewrittenPathname;
126
+ Blob rewrittenOrigName, rewrittenPathname;
127127
Blob sql = BLOB_INITIALIZER, where = BLOB_INITIALIZER;
128128
const char *zName;
129129
int i;
130130
131131
/* Skip the file report if no files are requested at all. */
@@ -205,10 +205,11 @@
205205
db_bind_int(&q, ":vid", db_lget_int("checkout", 0));
206206
}
207207
208208
/* Execute the query and assemble the report. */
209209
blob_zero(&rewrittenPathname);
210
+ blob_zero(&rewrittenOrigName);
210211
while( db_step(&q)==SQLITE_ROW ){
211212
const char *zPathname = db_column_text(&q, 0);
212213
const char *zClass = 0;
213214
int isManaged = db_column_int(&q, 7);
214215
const char *zMtime = db_column_text(&q, 1);
@@ -268,18 +269,21 @@
268269
&& file_contains_merge_marker(zFullName) ){
269270
zClass = "CONFLICT";
270271
}else if( (flags & (C_EDITED | C_CHANGED)) && isChnged
271272
&& (isChnged<2 || isChnged>9) ){
272273
zClass = "EDITED";
273
- }else if( (flags & C_RENAMED) && isRenamed ){
274
- zClass = "RENAMED";
275
- zOrigName = db_column_text(&q,8);
276274
}else if( (flags & C_UNCHANGED) && isManaged && !isNew
277275
&& !isChnged && !isRenamed ){
278276
zClass = "UNCHANGED";
279277
}else if( (flags & C_EXTRA) && !isManaged ){
280278
zClass = "EXTRA";
279
+ }
280
+ if( (flags & C_RENAMED) && isRenamed ){
281
+ zOrigName = db_column_text(&q,8);
282
+ if( zClass==0 ){
283
+ zClass = "RENAMED";
284
+ }
281285
}
282286
283287
/* Only report files for which a change classification was determined. */
284288
if( zClass ){
285289
if( flags & C_COMMENT ){
@@ -295,30 +299,34 @@
295299
if( flags & C_SIZE ){
296300
blob_appendf(report, "%7d ", size);
297301
}
298302
if( flags & C_RELPATH ){
299303
/* If C_RELPATH, display paths relative to current directory. */
300
- const char *zDisplayName;
301304
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 */
305308
}
306309
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);
316323
}
317324
free(zFullName);
318325
}
319326
blob_reset(&rewrittenPathname);
327
+ blob_reset(&rewrittenOrigName);
320328
db_finalize(&q);
321329
322330
/* If C_MERGE, put merge contributors at the end of the report. */
323331
skipFiles:
324332
if( flags & C_MERGE ){
325333
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button