Fossil SCM
Add the "fossil cat" command, which is an alias for "fossil finfo -p"
Commit
607ff0855c203c7c32dd469e538e6398d58225db
Parent
f1ef22136f6e842…
1 file changed
+44
-8
+44
-8
| --- src/finfo.c | ||
| +++ src/finfo.c | ||
| @@ -24,23 +24,23 @@ | ||
| 24 | 24 | ** COMMAND: finfo |
| 25 | 25 | ** |
| 26 | 26 | ** Usage: %fossil finfo ?OPTIONS? FILENAME |
| 27 | 27 | ** |
| 28 | 28 | ** Print the complete change history for a single file going backwards |
| 29 | -** in time. The default is -l. | |
| 29 | +** in time. The default mode is -l. | |
| 30 | 30 | ** |
| 31 | -** For the -l|--log option: If "-b|--brief" is specified one line per revision | |
| 31 | +** For the -l|--log mode: If "-b|--brief" is specified one line per revision | |
| 32 | 32 | ** is printed, otherwise the full comment is printed. The "--limit N" |
| 33 | 33 | ** and "--offset P" options limits the output to the first N changes |
| 34 | 34 | ** after skipping P changes. |
| 35 | 35 | ** |
| 36 | -** In the -s form prints the status as <status> <revision>. This is | |
| 36 | +** In the -s mode prints the status as <status> <revision>. This is | |
| 37 | 37 | ** a quick status and does not check for up-to-date-ness of the file. |
| 38 | 38 | ** |
| 39 | -** In the -p form, there's an optional flag "-r|--revision REVISION". | |
| 39 | +** In the -p mode, there's an optional flag "-r|--revision REVISION". | |
| 40 | 40 | ** The specified version (or the latest checked out version) is printed |
| 41 | -** to stdout. | |
| 41 | +** to stdout. The -p mode is another form of the "cat" command. | |
| 42 | 42 | ** |
| 43 | 43 | ** Options: |
| 44 | 44 | ** --brief|-b display a brief (one line / revision) summary |
| 45 | 45 | ** --limit N display the first N changes |
| 46 | 46 | ** --log|-l select log mode (the default) |
| @@ -50,11 +50,11 @@ | ||
| 50 | 50 | ** to stdout (only in print mode) |
| 51 | 51 | ** -s select status mode (print a status indicator for FILE) |
| 52 | 52 | ** --case-sensitive B Enable or disable case-sensitive filenames. B is a |
| 53 | 53 | ** boolean: "yes", "no", "true", "false", etc. |
| 54 | 54 | ** |
| 55 | -** See also: artifact, descendants, info, leaves | |
| 55 | +** See also: artifact, cat, descendants, info, leaves | |
| 56 | 56 | */ |
| 57 | 57 | void finfo_cmd(void){ |
| 58 | 58 | capture_case_sensitive_option(); |
| 59 | 59 | db_must_be_within_tree(); |
| 60 | 60 | if (find_option("status","s",0)) { |
| @@ -185,12 +185,13 @@ | ||
| 185 | 185 | const char *zBr = db_column_text(&q, 5); |
| 186 | 186 | char *zOut; |
| 187 | 187 | if( zBr==0 ) zBr = "trunk"; |
| 188 | 188 | if( iBrief ){ |
| 189 | 189 | fossil_print("%s ", zDate); |
| 190 | - zOut = sqlite3_mprintf("[%.10s] %s (user: %s, artifact: [%.10s], branch: %s)", | |
| 191 | - zCiUuid, zCom, zUser, zFileUuid, zBr); | |
| 190 | + zOut = sqlite3_mprintf( | |
| 191 | + "[%.10s] %s (user: %s, artifact: [%.10s], branch: %s)", | |
| 192 | + zCiUuid, zCom, zUser, zFileUuid, zBr); | |
| 192 | 193 | comment_print(zOut, 11, 79); |
| 193 | 194 | sqlite3_free(zOut); |
| 194 | 195 | }else{ |
| 195 | 196 | blob_reset(&line); |
| 196 | 197 | blob_appendf(&line, "%.10s ", zCiUuid); |
| @@ -203,10 +204,45 @@ | ||
| 203 | 204 | } |
| 204 | 205 | db_finalize(&q); |
| 205 | 206 | blob_reset(&fname); |
| 206 | 207 | } |
| 207 | 208 | } |
| 209 | + | |
| 210 | +/* | |
| 211 | +** COMMAND: cat | |
| 212 | +** | |
| 213 | +** Usage: %fossil cat FILENAME ... ?OPTIONS? | |
| 214 | +** | |
| 215 | +** Print on standard output the content of one or more files as they exist | |
| 216 | +** in the repository. The version currently checked out is shown by default. | |
| 217 | +** Other versions may be specified using the -r option. | |
| 218 | +** | |
| 219 | +** Options: | |
| 220 | +** -R|--repository FILE Extract artifacts from repository FILE | |
| 221 | +** -r VERSION The specific check-in containing the file | |
| 222 | +** | |
| 223 | +** See also: finfo | |
| 224 | +*/ | |
| 225 | +void cat_cmd(void){ | |
| 226 | + int i; | |
| 227 | + int rc; | |
| 228 | + Blob content, fname; | |
| 229 | + const char *zRev; | |
| 230 | + db_find_and_open_repository(0, 0); | |
| 231 | + zRev = find_option("r","r",1); | |
| 232 | + for(i=2; i<g.argc; i++){ | |
| 233 | + file_tree_name(g.argv[i], &fname, 1); | |
| 234 | + blob_zero(&content); | |
| 235 | + rc = historical_version_of_file(zRev, blob_str(&fname), &content, 0,0,0,0); | |
| 236 | + if( rc==0 ){ | |
| 237 | + fossil_fatal("no such file: %s", g.argv[i]); | |
| 238 | + } | |
| 239 | + blob_write_to_file(&content, "-"); | |
| 240 | + blob_reset(&fname); | |
| 241 | + blob_reset(&content); | |
| 242 | + } | |
| 243 | +} | |
| 208 | 244 | |
| 209 | 245 | /* Values for the debug= query parameter to finfo */ |
| 210 | 246 | #define FINFO_DEBUG_MLINK 0x01 |
| 211 | 247 | |
| 212 | 248 | /* |
| 213 | 249 |
| --- src/finfo.c | |
| +++ src/finfo.c | |
| @@ -24,23 +24,23 @@ | |
| 24 | ** COMMAND: finfo |
| 25 | ** |
| 26 | ** Usage: %fossil finfo ?OPTIONS? FILENAME |
| 27 | ** |
| 28 | ** Print the complete change history for a single file going backwards |
| 29 | ** in time. The default is -l. |
| 30 | ** |
| 31 | ** For the -l|--log option: If "-b|--brief" is specified one line per revision |
| 32 | ** is printed, otherwise the full comment is printed. The "--limit N" |
| 33 | ** and "--offset P" options limits the output to the first N changes |
| 34 | ** after skipping P changes. |
| 35 | ** |
| 36 | ** In the -s form prints the status as <status> <revision>. This is |
| 37 | ** a quick status and does not check for up-to-date-ness of the file. |
| 38 | ** |
| 39 | ** In the -p form, there's an optional flag "-r|--revision REVISION". |
| 40 | ** The specified version (or the latest checked out version) is printed |
| 41 | ** to stdout. |
| 42 | ** |
| 43 | ** Options: |
| 44 | ** --brief|-b display a brief (one line / revision) summary |
| 45 | ** --limit N display the first N changes |
| 46 | ** --log|-l select log mode (the default) |
| @@ -50,11 +50,11 @@ | |
| 50 | ** to stdout (only in print mode) |
| 51 | ** -s select status mode (print a status indicator for FILE) |
| 52 | ** --case-sensitive B Enable or disable case-sensitive filenames. B is a |
| 53 | ** boolean: "yes", "no", "true", "false", etc. |
| 54 | ** |
| 55 | ** See also: artifact, descendants, info, leaves |
| 56 | */ |
| 57 | void finfo_cmd(void){ |
| 58 | capture_case_sensitive_option(); |
| 59 | db_must_be_within_tree(); |
| 60 | if (find_option("status","s",0)) { |
| @@ -185,12 +185,13 @@ | |
| 185 | const char *zBr = db_column_text(&q, 5); |
| 186 | char *zOut; |
| 187 | if( zBr==0 ) zBr = "trunk"; |
| 188 | if( iBrief ){ |
| 189 | fossil_print("%s ", zDate); |
| 190 | zOut = sqlite3_mprintf("[%.10s] %s (user: %s, artifact: [%.10s], branch: %s)", |
| 191 | zCiUuid, zCom, zUser, zFileUuid, zBr); |
| 192 | comment_print(zOut, 11, 79); |
| 193 | sqlite3_free(zOut); |
| 194 | }else{ |
| 195 | blob_reset(&line); |
| 196 | blob_appendf(&line, "%.10s ", zCiUuid); |
| @@ -203,10 +204,45 @@ | |
| 203 | } |
| 204 | db_finalize(&q); |
| 205 | blob_reset(&fname); |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | /* Values for the debug= query parameter to finfo */ |
| 210 | #define FINFO_DEBUG_MLINK 0x01 |
| 211 | |
| 212 | /* |
| 213 |
| --- src/finfo.c | |
| +++ src/finfo.c | |
| @@ -24,23 +24,23 @@ | |
| 24 | ** COMMAND: finfo |
| 25 | ** |
| 26 | ** Usage: %fossil finfo ?OPTIONS? FILENAME |
| 27 | ** |
| 28 | ** Print the complete change history for a single file going backwards |
| 29 | ** in time. The default mode is -l. |
| 30 | ** |
| 31 | ** For the -l|--log mode: If "-b|--brief" is specified one line per revision |
| 32 | ** is printed, otherwise the full comment is printed. The "--limit N" |
| 33 | ** and "--offset P" options limits the output to the first N changes |
| 34 | ** after skipping P changes. |
| 35 | ** |
| 36 | ** In the -s mode prints the status as <status> <revision>. This is |
| 37 | ** a quick status and does not check for up-to-date-ness of the file. |
| 38 | ** |
| 39 | ** In the -p mode, there's an optional flag "-r|--revision REVISION". |
| 40 | ** The specified version (or the latest checked out version) is printed |
| 41 | ** to stdout. The -p mode is another form of the "cat" command. |
| 42 | ** |
| 43 | ** Options: |
| 44 | ** --brief|-b display a brief (one line / revision) summary |
| 45 | ** --limit N display the first N changes |
| 46 | ** --log|-l select log mode (the default) |
| @@ -50,11 +50,11 @@ | |
| 50 | ** to stdout (only in print mode) |
| 51 | ** -s select status mode (print a status indicator for FILE) |
| 52 | ** --case-sensitive B Enable or disable case-sensitive filenames. B is a |
| 53 | ** boolean: "yes", "no", "true", "false", etc. |
| 54 | ** |
| 55 | ** See also: artifact, cat, descendants, info, leaves |
| 56 | */ |
| 57 | void finfo_cmd(void){ |
| 58 | capture_case_sensitive_option(); |
| 59 | db_must_be_within_tree(); |
| 60 | if (find_option("status","s",0)) { |
| @@ -185,12 +185,13 @@ | |
| 185 | const char *zBr = db_column_text(&q, 5); |
| 186 | char *zOut; |
| 187 | if( zBr==0 ) zBr = "trunk"; |
| 188 | if( iBrief ){ |
| 189 | fossil_print("%s ", zDate); |
| 190 | zOut = sqlite3_mprintf( |
| 191 | "[%.10s] %s (user: %s, artifact: [%.10s], branch: %s)", |
| 192 | zCiUuid, zCom, zUser, zFileUuid, zBr); |
| 193 | comment_print(zOut, 11, 79); |
| 194 | sqlite3_free(zOut); |
| 195 | }else{ |
| 196 | blob_reset(&line); |
| 197 | blob_appendf(&line, "%.10s ", zCiUuid); |
| @@ -203,10 +204,45 @@ | |
| 204 | } |
| 205 | db_finalize(&q); |
| 206 | blob_reset(&fname); |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | /* |
| 211 | ** COMMAND: cat |
| 212 | ** |
| 213 | ** Usage: %fossil cat FILENAME ... ?OPTIONS? |
| 214 | ** |
| 215 | ** Print on standard output the content of one or more files as they exist |
| 216 | ** in the repository. The version currently checked out is shown by default. |
| 217 | ** Other versions may be specified using the -r option. |
| 218 | ** |
| 219 | ** Options: |
| 220 | ** -R|--repository FILE Extract artifacts from repository FILE |
| 221 | ** -r VERSION The specific check-in containing the file |
| 222 | ** |
| 223 | ** See also: finfo |
| 224 | */ |
| 225 | void cat_cmd(void){ |
| 226 | int i; |
| 227 | int rc; |
| 228 | Blob content, fname; |
| 229 | const char *zRev; |
| 230 | db_find_and_open_repository(0, 0); |
| 231 | zRev = find_option("r","r",1); |
| 232 | for(i=2; i<g.argc; i++){ |
| 233 | file_tree_name(g.argv[i], &fname, 1); |
| 234 | blob_zero(&content); |
| 235 | rc = historical_version_of_file(zRev, blob_str(&fname), &content, 0,0,0,0); |
| 236 | if( rc==0 ){ |
| 237 | fossil_fatal("no such file: %s", g.argv[i]); |
| 238 | } |
| 239 | blob_write_to_file(&content, "-"); |
| 240 | blob_reset(&fname); |
| 241 | blob_reset(&content); |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | /* Values for the debug= query parameter to finfo */ |
| 246 | #define FINFO_DEBUG_MLINK 0x01 |
| 247 | |
| 248 | /* |
| 249 |