Fossil SCM

Merge working directory relative file listings for changes and extras commands into ben-testing.

ben 2011-07-20 08:37 ben-testing merge
Commit 8320393b2fa0f672045e489d0fd72f652fb85088
2 files changed +52 -15 +52 -15
+52 -15
--- src/checkin.c
+++ src/checkin.c
@@ -32,60 +32,72 @@
3232
** are not true files results in a fatal error.
3333
*/
3434
static void status_report(
3535
Blob *report, /* Append the status report here */
3636
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 */
3839
){
3940
Stmt q;
4041
int nPrefix = strlen(zPrefix);
4142
int nErr = 0;
43
+ Blob rewrittenPathname;
4244
db_prepare(&q,
4345
"SELECT pathname, deleted, chnged, rid, coalesce(origname!=pathname,0)"
4446
" FROM vfile "
4547
" WHERE file_is_selected(id)"
4648
" AND (chnged OR deleted OR rid=0 OR pathname!=origname) ORDER BY 1"
4749
);
50
+ blob_zero(&rewrittenPathname);
4851
while( db_step(&q)==SQLITE_ROW ){
4952
const char *zPathname = db_column_text(&q,0);
53
+ const char *zDisplayName = zPathname;
5054
int isDeleted = db_column_int(&q, 1);
5155
int isChnged = db_column_int(&q,2);
5256
int isNew = db_column_int(&q,3)==0;
5357
int isRenamed = db_column_int(&q,4);
5458
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
+ }
5566
blob_append(report, zPrefix, nPrefix);
5667
if( isDeleted ){
57
- blob_appendf(report, "DELETED %s\n", zPathname);
68
+ blob_appendf(report, "DELETED %s\n", zDisplayName);
5869
}else if( !file_isfile(zFullName) ){
5970
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);
6172
if( missingIsFatal ){
62
- fossil_warning("not a file: %s", zPathname);
73
+ fossil_warning("not a file: %s", zDisplayName);
6374
nErr++;
6475
}
6576
}else{
66
- blob_appendf(report, "MISSING %s\n", zPathname);
77
+ blob_appendf(report, "MISSING %s\n", zDisplayName);
6778
if( missingIsFatal ){
68
- fossil_warning("missing file: %s", zPathname);
79
+ fossil_warning("missing file: %s", zDisplayName);
6980
nErr++;
7081
}
7182
}
7283
}else if( isNew ){
73
- blob_appendf(report, "ADDED %s\n", zPathname);
84
+ blob_appendf(report, "ADDED %s\n", zDisplayName);
7485
}else if( isDeleted ){
75
- blob_appendf(report, "DELETED %s\n", zPathname);
86
+ blob_appendf(report, "DELETED %s\n", zDisplayName);
7687
}else if( isChnged==2 ){
77
- blob_appendf(report, "UPDATED_BY_MERGE %s\n", zPathname);
88
+ blob_appendf(report, "UPDATED_BY_MERGE %s\n", zDisplayName);
7889
}else if( isChnged==3 ){
79
- blob_appendf(report, "ADDED_BY_MERGE %s\n", zPathname);
90
+ blob_appendf(report, "ADDED_BY_MERGE %s\n", zDisplayName);
8091
}else if( isChnged==1 ){
81
- blob_appendf(report, "EDITED %s\n", zPathname);
92
+ blob_appendf(report, "EDITED %s\n", zDisplayName);
8293
}else if( isRenamed ){
83
- blob_appendf(report, "RENAMED %s\n", zPathname);
94
+ blob_appendf(report, "RENAMED %s\n", zDisplayName);
8495
}
8596
free(zFullName);
8697
}
98
+ blob_reset(&rewrittenPathname);
8799
db_finalize(&q);
88100
db_prepare(&q, "SELECT uuid FROM vmerge JOIN blob ON merge=rid"
89101
" WHERE id=0");
90102
while( db_step(&q)==SQLITE_ROW ){
91103
blob_append(report, zPrefix, nPrefix);
@@ -107,20 +119,24 @@
107119
**
108120
** Options:
109121
**
110122
** --sha1sum Verify file status using SHA1 hashing rather
111123
** than relying on file mtimes.
124
+**
125
+** --non-relative Don't display filenames relative to the current
126
+** working directory.
112127
*/
113128
void changes_cmd(void){
114129
Blob report;
115130
int vid;
116131
int useSha1sum = find_option("sha1sum", 0, 0)!=0;
132
+ int nonRelative = find_option("non-relative", 0, 0)!=0;
117133
db_must_be_within_tree();
118134
blob_zero(&report);
119135
vid = db_lget_int("checkout", 0);
120136
vfile_check_signature(vid, 0, useSha1sum);
121
- status_report(&report, "", 0);
137
+ status_report(&report, "", 0, !nonRelative);
122138
blob_write_to_file(&report, "-");
123139
}
124140
125141
/*
126142
** COMMAND: status
@@ -131,10 +147,13 @@
131147
**
132148
** Options:
133149
**
134150
** --sha1sum Verify file status using SHA1 hashing rather
135151
** than relying on file mtimes.
152
+**
153
+** --non-relative Don't display filenames relative to the current
154
+** working directory.
136155
*/
137156
void status_cmd(void){
138157
int vid;
139158
db_must_be_within_tree();
140159
/* 012345678901234 */
@@ -212,20 +231,26 @@
212231
** ignored but can be included by adding the --dotfiles option.
213232
**
214233
** The GLOBPATTERN is a comma-separated list of GLOB expressions for
215234
** files that are ignored. The GLOBPATTERN specified by the "ignore-glob"
216235
** 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.
217239
*/
218240
void extra_cmd(void){
219241
Blob path;
220242
Blob repo;
221243
Stmt q;
222244
int n;
223245
const char *zIgnoreFlag = find_option("ignore",0,1);
224246
int allFlag = find_option("dotfiles",0,0)!=0;
247
+ int cwdRelative = !(find_option("non-relative", 0, 0)!=0);
225248
int outputManifest;
226249
Glob *pIgnore;
250
+ Blob rewrittenPathname;
251
+ const char *zPathname, *zDisplayName;
227252
228253
db_must_be_within_tree();
229254
outputManifest = db_get_versionable_setting_boolean("manifest",0);
230255
db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)");
231256
n = strlen(g.zLocalRoot);
@@ -243,13 +268,25 @@
243268
fossil_all_reserved_names()
244269
);
245270
if( file_tree_name(g.zRepositoryName, &repo, 0) ){
246271
db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo);
247272
}
273
+ blob_zero(&rewrittenPathname);
248274
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);
250286
}
287
+ blob_reset(&rewrittenPathname);
251288
db_finalize(&q);
252289
}
253290
254291
/*
255292
** COMMAND: clean
@@ -367,11 +404,11 @@
367404
"# PRIVATE BRANCH: This check-in will be private and will not sync to\n"
368405
"# repositories.\n"
369406
"#\n", -1
370407
);
371408
}
372
- status_report(&text, "# ", 1);
409
+ status_report(&text, "# ", 1, 0);
373410
zEditor = db_get("editor", 0);
374411
if( zEditor==0 ){
375412
zEditor = getenv("VISUAL");
376413
}
377414
if( zEditor==0 ){
378415
--- 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 @@
3232
** are not true files results in a fatal error.
3333
*/
3434
static void status_report(
3535
Blob *report, /* Append the status report here */
3636
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 */
3839
){
3940
Stmt q;
4041
int nPrefix = strlen(zPrefix);
4142
int nErr = 0;
43
+ Blob rewrittenPathname;
4244
db_prepare(&q,
4345
"SELECT pathname, deleted, chnged, rid, coalesce(origname!=pathname,0)"
4446
" FROM vfile "
4547
" WHERE file_is_selected(id)"
4648
" AND (chnged OR deleted OR rid=0 OR pathname!=origname) ORDER BY 1"
4749
);
50
+ blob_zero(&rewrittenPathname);
4851
while( db_step(&q)==SQLITE_ROW ){
4952
const char *zPathname = db_column_text(&q,0);
53
+ const char *zDisplayName = zPathname;
5054
int isDeleted = db_column_int(&q, 1);
5155
int isChnged = db_column_int(&q,2);
5256
int isNew = db_column_int(&q,3)==0;
5357
int isRenamed = db_column_int(&q,4);
5458
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
+ }
5566
blob_append(report, zPrefix, nPrefix);
5667
if( isDeleted ){
57
- blob_appendf(report, "DELETED %s\n", zPathname);
68
+ blob_appendf(report, "DELETED %s\n", zDisplayName);
5869
}else if( !file_isfile(zFullName) ){
5970
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);
6172
if( missingIsFatal ){
62
- fossil_warning("not a file: %s", zPathname);
73
+ fossil_warning("not a file: %s", zDisplayName);
6374
nErr++;
6475
}
6576
}else{
66
- blob_appendf(report, "MISSING %s\n", zPathname);
77
+ blob_appendf(report, "MISSING %s\n", zDisplayName);
6778
if( missingIsFatal ){
68
- fossil_warning("missing file: %s", zPathname);
79
+ fossil_warning("missing file: %s", zDisplayName);
6980
nErr++;
7081
}
7182
}
7283
}else if( isNew ){
73
- blob_appendf(report, "ADDED %s\n", zPathname);
84
+ blob_appendf(report, "ADDED %s\n", zDisplayName);
7485
}else if( isDeleted ){
75
- blob_appendf(report, "DELETED %s\n", zPathname);
86
+ blob_appendf(report, "DELETED %s\n", zDisplayName);
7687
}else if( isChnged==2 ){
77
- blob_appendf(report, "UPDATED_BY_MERGE %s\n", zPathname);
88
+ blob_appendf(report, "UPDATED_BY_MERGE %s\n", zDisplayName);
7889
}else if( isChnged==3 ){
79
- blob_appendf(report, "ADDED_BY_MERGE %s\n", zPathname);
90
+ blob_appendf(report, "ADDED_BY_MERGE %s\n", zDisplayName);
8091
}else if( isChnged==1 ){
81
- blob_appendf(report, "EDITED %s\n", zPathname);
92
+ blob_appendf(report, "EDITED %s\n", zDisplayName);
8293
}else if( isRenamed ){
83
- blob_appendf(report, "RENAMED %s\n", zPathname);
94
+ blob_appendf(report, "RENAMED %s\n", zDisplayName);
8495
}
8596
free(zFullName);
8697
}
98
+ blob_reset(&rewrittenPathname);
8799
db_finalize(&q);
88100
db_prepare(&q, "SELECT uuid FROM vmerge JOIN blob ON merge=rid"
89101
" WHERE id=0");
90102
while( db_step(&q)==SQLITE_ROW ){
91103
blob_append(report, zPrefix, nPrefix);
@@ -107,20 +119,24 @@
107119
**
108120
** Options:
109121
**
110122
** --sha1sum Verify file status using SHA1 hashing rather
111123
** than relying on file mtimes.
124
+**
125
+** --non-relative Don't display filenames relative to the current
126
+** working directory.
112127
*/
113128
void changes_cmd(void){
114129
Blob report;
115130
int vid;
116131
int useSha1sum = find_option("sha1sum", 0, 0)!=0;
132
+ int nonRelative = find_option("non-relative", 0, 0)!=0;
117133
db_must_be_within_tree();
118134
blob_zero(&report);
119135
vid = db_lget_int("checkout", 0);
120136
vfile_check_signature(vid, 0, useSha1sum);
121
- status_report(&report, "", 0);
137
+ status_report(&report, "", 0, !nonRelative);
122138
blob_write_to_file(&report, "-");
123139
}
124140
125141
/*
126142
** COMMAND: status
@@ -131,10 +147,13 @@
131147
**
132148
** Options:
133149
**
134150
** --sha1sum Verify file status using SHA1 hashing rather
135151
** than relying on file mtimes.
152
+**
153
+** --non-relative Don't display filenames relative to the current
154
+** working directory.
136155
*/
137156
void status_cmd(void){
138157
int vid;
139158
db_must_be_within_tree();
140159
/* 012345678901234 */
@@ -212,20 +231,26 @@
212231
** ignored but can be included by adding the --dotfiles option.
213232
**
214233
** The GLOBPATTERN is a comma-separated list of GLOB expressions for
215234
** files that are ignored. The GLOBPATTERN specified by the "ignore-glob"
216235
** 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.
217239
*/
218240
void extra_cmd(void){
219241
Blob path;
220242
Blob repo;
221243
Stmt q;
222244
int n;
223245
const char *zIgnoreFlag = find_option("ignore",0,1);
224246
int allFlag = find_option("dotfiles",0,0)!=0;
247
+ int cwdRelative = !(find_option("non-relative", 0, 0)!=0);
225248
int outputManifest;
226249
Glob *pIgnore;
250
+ Blob rewrittenPathname;
251
+ const char *zPathname, *zDisplayName;
227252
228253
db_must_be_within_tree();
229254
outputManifest = db_get_versionable_setting_boolean("manifest",0);
230255
db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)");
231256
n = strlen(g.zLocalRoot);
@@ -243,13 +268,25 @@
243268
fossil_all_reserved_names()
244269
);
245270
if( file_tree_name(g.zRepositoryName, &repo, 0) ){
246271
db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo);
247272
}
273
+ blob_zero(&rewrittenPathname);
248274
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);
250286
}
287
+ blob_reset(&rewrittenPathname);
251288
db_finalize(&q);
252289
}
253290
254291
/*
255292
** COMMAND: clean
@@ -367,11 +404,11 @@
367404
"# PRIVATE BRANCH: This check-in will be private and will not sync to\n"
368405
"# repositories.\n"
369406
"#\n", -1
370407
);
371408
}
372
- status_report(&text, "# ", 1);
409
+ status_report(&text, "# ", 1, 0);
373410
zEditor = db_get("editor", 0);
374411
if( zEditor==0 ){
375412
zEditor = getenv("VISUAL");
376413
}
377414
if( zEditor==0 ){
378415
--- 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

Keyboard Shortcuts

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