Fossil SCM
Enhance finfo command to print "whatis" information when -r is used without -p.
Commit
cb68b7dc3efb1ad34f453aa03f5354520e0ab22d6fceda1cdaa67b1b5d68fea7
Parent
041c3d1fa7e0843…
1 file changed
+19
-1
+19
-1
| --- src/finfo.c | ||
| +++ src/finfo.c | ||
| @@ -56,10 +56,12 @@ | ||
| 56 | 56 | ** more than 22 or else 0 to indicate no limit. |
| 57 | 57 | ** |
| 58 | 58 | ** See also: [[artifact]], [[cat]], [[descendants]], [[info]], [[leaves]] |
| 59 | 59 | */ |
| 60 | 60 | void finfo_cmd(void){ |
| 61 | + const char *zRevision = find_option("revision", "r", 1); | |
| 62 | + | |
| 61 | 63 | db_must_be_within_tree(); |
| 62 | 64 | if( find_option("status","s",0) ){ |
| 63 | 65 | Stmt q; |
| 64 | 66 | Blob line; |
| 65 | 67 | Blob fname; |
| @@ -116,11 +118,10 @@ | ||
| 116 | 118 | blob_reset(&fname); |
| 117 | 119 | blob_reset(&line); |
| 118 | 120 | }else if( find_option("print","p",0) ){ |
| 119 | 121 | Blob record; |
| 120 | 122 | Blob fname; |
| 121 | - const char *zRevision = find_option("revision", "r", 1); | |
| 122 | 123 | |
| 123 | 124 | /* We should be done with options.. */ |
| 124 | 125 | verify_all_options(); |
| 125 | 126 | |
| 126 | 127 | file_tree_name(g.argv[2], &fname, 0, 1); |
| @@ -134,10 +135,27 @@ | ||
| 134 | 135 | } |
| 135 | 136 | content_get(rid, &record); |
| 136 | 137 | } |
| 137 | 138 | blob_write_to_file(&record, "-"); |
| 138 | 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); | |
| 139 | 157 | blob_reset(&fname); |
| 140 | 158 | }else{ |
| 141 | 159 | Blob line; |
| 142 | 160 | Stmt q; |
| 143 | 161 | Blob fname; |
| 144 | 162 |
| --- 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 |