Fossil SCM

Add an "unprotect()" call to /ckout so that it can see that files have changed and update the vfile table appropriately. Updates to diff command-line parser comments to mention all the latest options.

drh 2024-12-10 13:13 trunk
Commit a2a0390cbf7df9a707766d7593d67d68b4a33bbb627cec03612984f96832974b
+9
--- src/diff.c
+++ src/diff.c
@@ -3227,20 +3227,29 @@
32273227
** Initialize the DiffConfig object using command-line options.
32283228
**
32293229
** Process diff-related command-line options and return an appropriate
32303230
** "diffFlags" integer.
32313231
**
3232
+** -b|--browser Show the diff output in a web-browser
32323233
** --brief Show filenames only DIFF_BRIEF
3234
+** --by Shorthand for "--browser -y"
32333235
** -c|--context N N lines of context. nContext
3236
+** --dark Use dark mode for Tcl/Tk and HTML output
32343237
** --html Format for HTML DIFF_HTML
3238
+** -i|--internal Use built-in diff, not an external tool
32353239
** --invert Invert the diff DIFF_INVERT
3240
+** --json Output formatted as JSON
32363241
** -n|--linenum Show line numbers DIFF_LINENO
3242
+** -N|--new-file Alias for --verbose
32373243
** --noopt Disable optimization DIFF_NOOPT
32383244
** --numstat Show change counts DIFF_NUMSTAT
32393245
** --strip-trailing-cr Strip trailing CR DIFF_STRIP_EOLCR
3246
+** --tcl Tcl-formatted output used internally by --tk
32403247
** --unified Unified diff. ~DIFF_SIDEBYSIDE
3248
+** -v|--verbose Show complete text of added or deleted files
32413249
** -w|--ignore-all-space Ignore all whitespaces DIFF_IGNORE_ALLWS
3250
+** --webpage Format output as a stand-alone HTML webpage
32423251
** -W|--width N N character lines. wColumn
32433252
** -y|--side-by-side Side-by-side diff. DIFF_SIDEBYSIDE
32443253
** -Z|--ignore-trailing-space Ignore eol-whitespaces DIFF_IGNORE_EOLWS
32453254
*/
32463255
void diff_options(DiffConfig *pCfg, int isGDiff, int bUnifiedTextOnly){
32473256
--- src/diff.c
+++ src/diff.c
@@ -3227,20 +3227,29 @@
3227 ** Initialize the DiffConfig object using command-line options.
3228 **
3229 ** Process diff-related command-line options and return an appropriate
3230 ** "diffFlags" integer.
3231 **
 
3232 ** --brief Show filenames only DIFF_BRIEF
 
3233 ** -c|--context N N lines of context. nContext
 
3234 ** --html Format for HTML DIFF_HTML
 
3235 ** --invert Invert the diff DIFF_INVERT
 
3236 ** -n|--linenum Show line numbers DIFF_LINENO
 
3237 ** --noopt Disable optimization DIFF_NOOPT
3238 ** --numstat Show change counts DIFF_NUMSTAT
3239 ** --strip-trailing-cr Strip trailing CR DIFF_STRIP_EOLCR
 
3240 ** --unified Unified diff. ~DIFF_SIDEBYSIDE
 
3241 ** -w|--ignore-all-space Ignore all whitespaces DIFF_IGNORE_ALLWS
 
3242 ** -W|--width N N character lines. wColumn
3243 ** -y|--side-by-side Side-by-side diff. DIFF_SIDEBYSIDE
3244 ** -Z|--ignore-trailing-space Ignore eol-whitespaces DIFF_IGNORE_EOLWS
3245 */
3246 void diff_options(DiffConfig *pCfg, int isGDiff, int bUnifiedTextOnly){
3247
--- src/diff.c
+++ src/diff.c
@@ -3227,20 +3227,29 @@
3227 ** Initialize the DiffConfig object using command-line options.
3228 **
3229 ** Process diff-related command-line options and return an appropriate
3230 ** "diffFlags" integer.
3231 **
3232 ** -b|--browser Show the diff output in a web-browser
3233 ** --brief Show filenames only DIFF_BRIEF
3234 ** --by Shorthand for "--browser -y"
3235 ** -c|--context N N lines of context. nContext
3236 ** --dark Use dark mode for Tcl/Tk and HTML output
3237 ** --html Format for HTML DIFF_HTML
3238 ** -i|--internal Use built-in diff, not an external tool
3239 ** --invert Invert the diff DIFF_INVERT
3240 ** --json Output formatted as JSON
3241 ** -n|--linenum Show line numbers DIFF_LINENO
3242 ** -N|--new-file Alias for --verbose
3243 ** --noopt Disable optimization DIFF_NOOPT
3244 ** --numstat Show change counts DIFF_NUMSTAT
3245 ** --strip-trailing-cr Strip trailing CR DIFF_STRIP_EOLCR
3246 ** --tcl Tcl-formatted output used internally by --tk
3247 ** --unified Unified diff. ~DIFF_SIDEBYSIDE
3248 ** -v|--verbose Show complete text of added or deleted files
3249 ** -w|--ignore-all-space Ignore all whitespaces DIFF_IGNORE_ALLWS
3250 ** --webpage Format output as a stand-alone HTML webpage
3251 ** -W|--width N N character lines. wColumn
3252 ** -y|--side-by-side Side-by-side diff. DIFF_SIDEBYSIDE
3253 ** -Z|--ignore-trailing-space Ignore eol-whitespaces DIFF_IGNORE_EOLWS
3254 */
3255 void diff_options(DiffConfig *pCfg, int isGDiff, int bUnifiedTextOnly){
3256
+3 -3
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -1312,11 +1312,12 @@
13121312
zFrom = mprintf("root:%s", zBranch);
13131313
}
13141314
if( zCheckin!=0 && ( zFrom!=0 || zTo!=0 ) ){
13151315
fossil_fatal("cannot use --checkin together with --from or --to");
13161316
}
1317
- g.diffCnt[0] = g.diffCnt[1] = g.diffCnt[2] = 0;
1317
+ diff_options(&DCfg, isGDiff, 0);
1318
+ determine_exec_relative_option(1);
13181319
if( 0==zCheckin ){
13191320
if( zTo==0 || againstUndo ){
13201321
db_must_be_within_tree();
13211322
}else if( zFrom==0 ){
13221323
fossil_fatal("must use --from if --to is present");
@@ -1324,13 +1325,12 @@
13241325
db_find_and_open_repository(0, 0);
13251326
}
13261327
}else{
13271328
db_find_and_open_repository(0, 0);
13281329
}
1329
- diff_options(&DCfg, isGDiff, 0);
1330
- determine_exec_relative_option(1);
13311330
verify_all_options();
1331
+ g.diffCnt[0] = g.diffCnt[1] = g.diffCnt[2] = 0;
13321332
if( g.argc>=3 ){
13331333
int i;
13341334
Blob fname;
13351335
pFileDir = fossil_malloc( sizeof(*pFileDir) * (g.argc-1) );
13361336
memset(pFileDir, 0, sizeof(*pFileDir) * (g.argc-1));
13371337
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -1312,11 +1312,12 @@
1312 zFrom = mprintf("root:%s", zBranch);
1313 }
1314 if( zCheckin!=0 && ( zFrom!=0 || zTo!=0 ) ){
1315 fossil_fatal("cannot use --checkin together with --from or --to");
1316 }
1317 g.diffCnt[0] = g.diffCnt[1] = g.diffCnt[2] = 0;
 
1318 if( 0==zCheckin ){
1319 if( zTo==0 || againstUndo ){
1320 db_must_be_within_tree();
1321 }else if( zFrom==0 ){
1322 fossil_fatal("must use --from if --to is present");
@@ -1324,13 +1325,12 @@
1324 db_find_and_open_repository(0, 0);
1325 }
1326 }else{
1327 db_find_and_open_repository(0, 0);
1328 }
1329 diff_options(&DCfg, isGDiff, 0);
1330 determine_exec_relative_option(1);
1331 verify_all_options();
 
1332 if( g.argc>=3 ){
1333 int i;
1334 Blob fname;
1335 pFileDir = fossil_malloc( sizeof(*pFileDir) * (g.argc-1) );
1336 memset(pFileDir, 0, sizeof(*pFileDir) * (g.argc-1));
1337
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -1312,11 +1312,12 @@
1312 zFrom = mprintf("root:%s", zBranch);
1313 }
1314 if( zCheckin!=0 && ( zFrom!=0 || zTo!=0 ) ){
1315 fossil_fatal("cannot use --checkin together with --from or --to");
1316 }
1317 diff_options(&DCfg, isGDiff, 0);
1318 determine_exec_relative_option(1);
1319 if( 0==zCheckin ){
1320 if( zTo==0 || againstUndo ){
1321 db_must_be_within_tree();
1322 }else if( zFrom==0 ){
1323 fossil_fatal("must use --from if --to is present");
@@ -1324,13 +1325,12 @@
1325 db_find_and_open_repository(0, 0);
1326 }
1327 }else{
1328 db_find_and_open_repository(0, 0);
1329 }
 
 
1330 verify_all_options();
1331 g.diffCnt[0] = g.diffCnt[1] = g.diffCnt[2] = 0;
1332 if( g.argc>=3 ){
1333 int i;
1334 Blob fname;
1335 pFileDir = fossil_malloc( sizeof(*pFileDir) * (g.argc-1) );
1336 memset(pFileDir, 0, sizeof(*pFileDir) * (g.argc-1));
1337
+2
--- src/info.c
+++ src/info.c
@@ -626,11 +626,13 @@
626626
return;
627627
}
628628
diffType = preferred_diff_type();
629629
pCfg = construct_diff_flags(diffType, &DCfg);
630630
vid = db_lget_int("checkout", 0);
631
+ db_unprotect(PROTECT_ALL);
631632
vfile_check_signature(vid, CKSIG_ENOTFILE);
633
+ db_protect_pop();
632634
style_set_current_feature("vinfo");
633635
zHostname = fossil_hostname();
634636
zCwd = file_getcwd(0,0);
635637
if( zHostname ){
636638
style_header("Checkout at %s:%s", zHostname, zCwd);
637639
--- src/info.c
+++ src/info.c
@@ -626,11 +626,13 @@
626 return;
627 }
628 diffType = preferred_diff_type();
629 pCfg = construct_diff_flags(diffType, &DCfg);
630 vid = db_lget_int("checkout", 0);
 
631 vfile_check_signature(vid, CKSIG_ENOTFILE);
 
632 style_set_current_feature("vinfo");
633 zHostname = fossil_hostname();
634 zCwd = file_getcwd(0,0);
635 if( zHostname ){
636 style_header("Checkout at %s:%s", zHostname, zCwd);
637
--- src/info.c
+++ src/info.c
@@ -626,11 +626,13 @@
626 return;
627 }
628 diffType = preferred_diff_type();
629 pCfg = construct_diff_flags(diffType, &DCfg);
630 vid = db_lget_int("checkout", 0);
631 db_unprotect(PROTECT_ALL);
632 vfile_check_signature(vid, CKSIG_ENOTFILE);
633 db_protect_pop();
634 style_set_current_feature("vinfo");
635 zHostname = fossil_hostname();
636 zCwd = file_getcwd(0,0);
637 if( zHostname ){
638 style_header("Checkout at %s:%s", zHostname, zCwd);
639

Keyboard Shortcuts

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