| | @@ -323,23 +323,30 @@ |
| 323 | 323 | Stmt q; |
| 324 | 324 | Stmt q2; |
| 325 | 325 | char *zUuid, *zDate; |
| 326 | 326 | int noSign = 0; /* True to omit signing the manifest using GPG */ |
| 327 | 327 | int isAMerge = 0; /* True if checking in a merge */ |
| 328 | + int forceFlag = 0; /* Force a fork */ |
| 328 | 329 | char *zManifestFile; /* Name of the manifest file */ |
| 329 | 330 | Blob manifest; |
| 330 | 331 | Blob muuid; /* Manifest uuid */ |
| 331 | 332 | Blob mcksum; /* Self-checksum on the manifest */ |
| 332 | 333 | Blob cksum1, cksum2; /* Before and after commit checksums */ |
| 333 | 334 | Blob cksum1b; /* Checksum recorded in the manifest */ |
| 334 | 335 | |
| 335 | 336 | noSign = find_option("nosign","",0)!=0; |
| 336 | 337 | zComment = find_option("comment","m",1); |
| 338 | + forceFlag = find_option("force", "r", 0)!=0; |
| 337 | 339 | db_must_be_within_tree(); |
| 338 | 340 | noSign = db_get_int("omit-ci-sig", 0)|noSign; |
| 339 | 341 | verify_all_options(); |
| 340 | | - |
| 342 | + |
| 343 | + /* |
| 344 | + ** Autosync if requested. |
| 345 | + */ |
| 346 | + autosync(1); |
| 347 | + |
| 341 | 348 | /* There are two ways this command may be executed. If there are |
| 342 | 349 | ** no arguments following the word "commit", then all modified files |
| 343 | 350 | ** in the checked out directory are committed. If one or more arguments |
| 344 | 351 | ** follows "commit", then only those files are committed. |
| 345 | 352 | ** |
| | @@ -355,11 +362,11 @@ |
| 355 | 362 | } |
| 356 | 363 | |
| 357 | 364 | user_select(); |
| 358 | 365 | db_begin_transaction(); |
| 359 | 366 | rc = unsaved_changes(); |
| 360 | | - if( rc==0 && !isAMerge ){ |
| 367 | + if( rc==0 && !isAMerge && !forceFlag ){ |
| 361 | 368 | fossil_panic("nothing has changed"); |
| 362 | 369 | } |
| 363 | 370 | |
| 364 | 371 | /* If one or more files that were named on the command line have not |
| 365 | 372 | ** been modified, bail out now. |
| | @@ -375,10 +382,13 @@ |
| 375 | 382 | fossil_panic("file %s has not changed", blob_str(&unmodified)); |
| 376 | 383 | } |
| 377 | 384 | } |
| 378 | 385 | |
| 379 | 386 | vid = db_lget_int("checkout", 0); |
| 387 | + if( !forceFlag && db_exists("SELECT 1 FROM plink WHERE pid=%d", vid) ){ |
| 388 | + fossil_fatal("would fork. use -f or --force"); |
| 389 | + } |
| 380 | 390 | vfile_aggregate_checksum_disk(vid, &cksum1); |
| 381 | 391 | if( zComment ){ |
| 382 | 392 | blob_zero(&comment); |
| 383 | 393 | blob_append(&comment, zComment, -1); |
| 384 | 394 | }else{ |
| | @@ -524,12 +534,8 @@ |
| 524 | 534 | undo_reset(); |
| 525 | 535 | |
| 526 | 536 | /* Commit */ |
| 527 | 537 | db_end_transaction(0); |
| 528 | 538 | |
| 529 | | - /* Autosync and do a push? */ |
| 530 | | - if( do_autosync() ){ |
| 531 | | - g.argc=2; |
| 532 | | - g.argv[1]="push"; |
| 533 | | - push_cmd(); |
| 534 | | - } |
| 539 | + /* Do an autosync push if requested */ |
| 540 | + autosync(0); |
| 535 | 541 | } |
| 536 | 542 | |