Fossil SCM

Enhance finfo command to print "whatis" information when -r is used without -p.

andybradford 2021-04-09 05:19 trunk
Commit cb68b7dc3efb1ad34f453aa03f5354520e0ab22d6fceda1cdaa67b1b5d68fea7
1 file changed +19 -1
+19 -1
--- src/finfo.c
+++ src/finfo.c
@@ -56,10 +56,12 @@
5656
** more than 22 or else 0 to indicate no limit.
5757
**
5858
** See also: [[artifact]], [[cat]], [[descendants]], [[info]], [[leaves]]
5959
*/
6060
void finfo_cmd(void){
61
+ const char *zRevision = find_option("revision", "r", 1);
62
+
6163
db_must_be_within_tree();
6264
if( find_option("status","s",0) ){
6365
Stmt q;
6466
Blob line;
6567
Blob fname;
@@ -116,11 +118,10 @@
116118
blob_reset(&fname);
117119
blob_reset(&line);
118120
}else if( find_option("print","p",0) ){
119121
Blob record;
120122
Blob fname;
121
- const char *zRevision = find_option("revision", "r", 1);
122123
123124
/* We should be done with options.. */
124125
verify_all_options();
125126
126127
file_tree_name(g.argv[2], &fname, 0, 1);
@@ -134,10 +135,27 @@
134135
}
135136
content_get(rid, &record);
136137
}
137138
blob_write_to_file(&record, "-");
138139
blob_reset(&record);
140
+ blob_reset(&fname);
141
+ }else if( zRevision && zRevision[0] ){
142
+ Blob fname;
143
+
144
+ verify_all_options();
145
+
146
+ if( g.argc!=3 ) usage("-r|--revision REVISION FILENAME");
147
+ file_tree_name(g.argv[2], &fname, 0, 1);
148
+ int rid = db_int(0, "SELECT rid FROM blob WHERE uuid ="
149
+ " (SELECT uuid FROM files_of_checkin(%Q)"
150
+ " WHERE filename=%B %s)",
151
+ zRevision, &fname, filename_collation());
152
+ if( rid==0 ) {
153
+ fossil_fatal("file not found for revision %s: %s",
154
+ zRevision, blob_str(&fname));
155
+ }
156
+ whatis_rid(rid,0);
139157
blob_reset(&fname);
140158
}else{
141159
Blob line;
142160
Stmt q;
143161
Blob fname;
144162
--- src/finfo.c
+++ src/finfo.c
@@ -56,10 +56,12 @@
56 ** more than 22 or else 0 to indicate no limit.
57 **
58 ** See also: [[artifact]], [[cat]], [[descendants]], [[info]], [[leaves]]
59 */
60 void finfo_cmd(void){
 
 
61 db_must_be_within_tree();
62 if( find_option("status","s",0) ){
63 Stmt q;
64 Blob line;
65 Blob fname;
@@ -116,11 +118,10 @@
116 blob_reset(&fname);
117 blob_reset(&line);
118 }else if( find_option("print","p",0) ){
119 Blob record;
120 Blob fname;
121 const char *zRevision = find_option("revision", "r", 1);
122
123 /* We should be done with options.. */
124 verify_all_options();
125
126 file_tree_name(g.argv[2], &fname, 0, 1);
@@ -134,10 +135,27 @@
134 }
135 content_get(rid, &record);
136 }
137 blob_write_to_file(&record, "-");
138 blob_reset(&record);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139 blob_reset(&fname);
140 }else{
141 Blob line;
142 Stmt q;
143 Blob fname;
144
--- src/finfo.c
+++ src/finfo.c
@@ -56,10 +56,12 @@
56 ** more than 22 or else 0 to indicate no limit.
57 **
58 ** See also: [[artifact]], [[cat]], [[descendants]], [[info]], [[leaves]]
59 */
60 void finfo_cmd(void){
61 const char *zRevision = find_option("revision", "r", 1);
62
63 db_must_be_within_tree();
64 if( find_option("status","s",0) ){
65 Stmt q;
66 Blob line;
67 Blob fname;
@@ -116,11 +118,10 @@
118 blob_reset(&fname);
119 blob_reset(&line);
120 }else if( find_option("print","p",0) ){
121 Blob record;
122 Blob fname;
 
123
124 /* We should be done with options.. */
125 verify_all_options();
126
127 file_tree_name(g.argv[2], &fname, 0, 1);
@@ -134,10 +135,27 @@
135 }
136 content_get(rid, &record);
137 }
138 blob_write_to_file(&record, "-");
139 blob_reset(&record);
140 blob_reset(&fname);
141 }else if( zRevision && zRevision[0] ){
142 Blob fname;
143
144 verify_all_options();
145
146 if( g.argc!=3 ) usage("-r|--revision REVISION FILENAME");
147 file_tree_name(g.argv[2], &fname, 0, 1);
148 int rid = db_int(0, "SELECT rid FROM blob WHERE uuid ="
149 " (SELECT uuid FROM files_of_checkin(%Q)"
150 " WHERE filename=%B %s)",
151 zRevision, &fname, filename_collation());
152 if( rid==0 ) {
153 fossil_fatal("file not found for revision %s: %s",
154 zRevision, blob_str(&fname));
155 }
156 whatis_rid(rid,0);
157 blob_reset(&fname);
158 }else{
159 Blob line;
160 Stmt q;
161 Blob fname;
162

Keyboard Shortcuts

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