Fossil

Check-in [8975472d26]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add the --out option to the "cat" command to specify an output file - only if a single historical file is requested.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 8975472d2651b49bb629ba23248b54488a265701a13518f5919208335664d6b4
User & Date: danield 2023-03-14 17:18:12.949
Context
2023-03-15
10:35
Forum listing CSS tweaks prompted by [forum:3d350d67b6e836]. check-in: 0aae0ef506 user: stephan tags: trunk
2023-03-14
17:18
Add the --out option to the "cat" command to specify an output file - only if a single historical file is requested. check-in: 8975472d26 user: danield tags: trunk
14:16
Slight CSS tweak to the darkmode skin's forum listing, based on [forum:9a6f4c039d82|forum post 9a6f4c039d82], intended to make the have-been-visited links stand out a bit better. check-in: d2c93a417e user: stephan tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/finfo.c.
270
271
272
273
274
275
276

277
278
279
280
281
282
283
284
285

286
287

288
289
290




291
292
293
294
295



296

297
298
299
300
301
302
303
** Usage: %fossil cat FILENAME ... ?OPTIONS?
**
** Print on standard output the content of one or more files as they exist
** in the repository.  The version currently checked out is shown by default.
** Other versions may be specified using the -r option.
**
** Options:

**    -R|--repository REPO       Extract artifacts from repository REPO
**    -r VERSION                 The specific check-in containing the file
**
** See also: [[finfo]]
*/
void cat_cmd(void){
  int i;
  Blob content, fname;
  const char *zRev;

  db_find_and_open_repository(0, 0);
  zRev = find_option("r","r",1);


  /* We should be done with options.. */
  verify_all_options();





  for(i=2; i<g.argc; i++){
    file_tree_name(g.argv[i], &fname, 0, 1);
    blob_zero(&content);
    historical_blob(zRev, blob_str(&fname), &content, 1);



    blob_write_to_file(&content, "-");

    blob_reset(&fname);
    blob_reset(&content);
  }
}

/* Values for the debug= query parameter to finfo */
#define FINFO_DEBUG_MLINK  0x01







>
|
|







>


>



>
>
>
>





>
>
>
|
>







270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
** Usage: %fossil cat FILENAME ... ?OPTIONS?
**
** Print on standard output the content of one or more files as they exist
** in the repository.  The version currently checked out is shown by default.
** Other versions may be specified using the -r option.
**
** Options:
**    -o|--out OUTFILE         For exactly one given FILENAME, write to OUTFILE
**    -R|--repository REPO     Extract artifacts from repository REPO
**    -r VERSION               The specific check-in containing the file
**
** See also: [[finfo]]
*/
void cat_cmd(void){
  int i;
  Blob content, fname;
  const char *zRev;
  const char *zFileName;
  db_find_and_open_repository(0, 0);
  zRev = find_option("r","r",1);
  zFileName = find_option("out","o",1);

  /* We should be done with options.. */
  verify_all_options();

  if ( zFileName && g.argc>3 ){
    fossil_fatal("output file can only be given when retrieving a single file");
  }

  for(i=2; i<g.argc; i++){
    file_tree_name(g.argv[i], &fname, 0, 1);
    blob_zero(&content);
    historical_blob(zRev, blob_str(&fname), &content, 1);
    if ( g.argc==3 && zFileName ){
      blob_write_to_file(&content, zFileName);
    }else{
      blob_write_to_file(&content, "-");
    }
    blob_reset(&fname);
    blob_reset(&content);
  }
}

/* Values for the debug= query parameter to finfo */
#define FINFO_DEBUG_MLINK  0x01