Fossil SCM
Add the --if-changes option to "fossil commit" which causes the command to be a no-op if there have not been any changes to the current checkout.
Commit
f36695adf3f13bbac5ca5ffba1ad10c721508ef906fb537508290e3165fb5333
Parent
57da8e297717a36…
1 file changed
+10
-1
+10
-1
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -2354,10 +2354,12 @@ | ||
| 2354 | 2354 | ** --close Close the branch being committed |
| 2355 | 2355 | ** --date-override DATETIME DATE to use instead of 'now' |
| 2356 | 2356 | ** --delta Use a delta manifest in the commit process |
| 2357 | 2357 | ** --hash Verify file status using hashing rather |
| 2358 | 2358 | ** than relying on file mtimes |
| 2359 | +** --if-changes Make this command a silent no-op if there | |
| 2360 | +** are no changes | |
| 2359 | 2361 | ** --ignore-clock-skew If a clock skew is detected, ignore it and |
| 2360 | 2362 | ** behave as if the user had entered 'yes' to |
| 2361 | 2363 | ** the question of whether to proceed despite |
| 2362 | 2364 | ** the skew. |
| 2363 | 2365 | ** --ignore-oversize Do not warn the user about oversized files |
| @@ -2409,10 +2411,11 @@ | ||
| 2409 | 2411 | int forceFlag = 0; /* Undocumented: Disables all checks */ |
| 2410 | 2412 | int forceDelta = 0; /* Force a delta-manifest */ |
| 2411 | 2413 | int forceBaseline = 0; /* Force a baseline-manifest */ |
| 2412 | 2414 | int allowConflict = 0; /* Allow unresolve merge conflicts */ |
| 2413 | 2415 | int allowEmpty = 0; /* Allow a commit with no changes */ |
| 2416 | + int onlyIfChanges = 0; /* No-op if there are no changes */ | |
| 2414 | 2417 | int allowFork = 0; /* Allow the commit to fork */ |
| 2415 | 2418 | int allowOlder = 0; /* Allow a commit older than its ancestor */ |
| 2416 | 2419 | char *zManifestFile; /* Name of the manifest file */ |
| 2417 | 2420 | int useCksum; /* True if checksums should be computed and verified */ |
| 2418 | 2421 | int outputManifest; /* True to output "manifest" and "manifest.uuid" */ |
| @@ -2466,10 +2469,11 @@ | ||
| 2466 | 2469 | } |
| 2467 | 2470 | zComment = find_option("comment","m",1); |
| 2468 | 2471 | forceFlag = find_option("force", "f", 0)!=0; |
| 2469 | 2472 | allowConflict = find_option("allow-conflict",0,0)!=0; |
| 2470 | 2473 | allowEmpty = find_option("allow-empty",0,0)!=0; |
| 2474 | + onlyIfChanges = find_option("if-changes",0,0)!=0; | |
| 2471 | 2475 | allowFork = find_option("allow-fork",0,0)!=0; |
| 2472 | 2476 | if( find_option("override-lock",0,0)!=0 ) allowFork = 1; |
| 2473 | 2477 | allowOlder = find_option("allow-older",0,0)!=0; |
| 2474 | 2478 | noPrompt = find_option("no-prompt", 0, 0)!=0; |
| 2475 | 2479 | noWarningFlag = find_option("no-warnings", 0, 0)!=0; |
| @@ -2581,10 +2585,16 @@ | ||
| 2581 | 2585 | if( nTag ){ |
| 2582 | 2586 | int i; |
| 2583 | 2587 | for(i=0; i<nTag; i++) sCiInfo.azTag[i] = mprintf("%F", sCiInfo.azTag[i]); |
| 2584 | 2588 | qsort((void*)sCiInfo.azTag, nTag, sizeof(sCiInfo.azTag[0]), tagCmp); |
| 2585 | 2589 | } |
| 2590 | + | |
| 2591 | + hasChanges = unsaved_changes(useHash ? CKSIG_HASH : 0); | |
| 2592 | + if( hasChanges==0 && onlyIfChanges ){ | |
| 2593 | + /* "fossil commit --if-changes" is a no-op if there are no changes. */ | |
| 2594 | + return; | |
| 2595 | + } | |
| 2586 | 2596 | |
| 2587 | 2597 | /* |
| 2588 | 2598 | ** Autosync if autosync is enabled and this is not a private check-in. |
| 2589 | 2599 | */ |
| 2590 | 2600 | if( !g.markPrivate ){ |
| @@ -2686,11 +2696,10 @@ | ||
| 2686 | 2696 | "'%s' was renamed to '%s'", zFrom, zTo, zFrom, zTo); |
| 2687 | 2697 | } |
| 2688 | 2698 | db_finalize(&q); |
| 2689 | 2699 | } |
| 2690 | 2700 | |
| 2691 | - hasChanges = unsaved_changes(useHash ? CKSIG_HASH : 0); | |
| 2692 | 2701 | db_begin_transaction(); |
| 2693 | 2702 | db_record_repository_filename(0); |
| 2694 | 2703 | if( hasChanges==0 && !isAMerge && !allowEmpty && !forceFlag ){ |
| 2695 | 2704 | fossil_fatal("nothing has changed; use --allow-empty to override"); |
| 2696 | 2705 | } |
| 2697 | 2706 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -2354,10 +2354,12 @@ | |
| 2354 | ** --close Close the branch being committed |
| 2355 | ** --date-override DATETIME DATE to use instead of 'now' |
| 2356 | ** --delta Use a delta manifest in the commit process |
| 2357 | ** --hash Verify file status using hashing rather |
| 2358 | ** than relying on file mtimes |
| 2359 | ** --ignore-clock-skew If a clock skew is detected, ignore it and |
| 2360 | ** behave as if the user had entered 'yes' to |
| 2361 | ** the question of whether to proceed despite |
| 2362 | ** the skew. |
| 2363 | ** --ignore-oversize Do not warn the user about oversized files |
| @@ -2409,10 +2411,11 @@ | |
| 2409 | int forceFlag = 0; /* Undocumented: Disables all checks */ |
| 2410 | int forceDelta = 0; /* Force a delta-manifest */ |
| 2411 | int forceBaseline = 0; /* Force a baseline-manifest */ |
| 2412 | int allowConflict = 0; /* Allow unresolve merge conflicts */ |
| 2413 | int allowEmpty = 0; /* Allow a commit with no changes */ |
| 2414 | int allowFork = 0; /* Allow the commit to fork */ |
| 2415 | int allowOlder = 0; /* Allow a commit older than its ancestor */ |
| 2416 | char *zManifestFile; /* Name of the manifest file */ |
| 2417 | int useCksum; /* True if checksums should be computed and verified */ |
| 2418 | int outputManifest; /* True to output "manifest" and "manifest.uuid" */ |
| @@ -2466,10 +2469,11 @@ | |
| 2466 | } |
| 2467 | zComment = find_option("comment","m",1); |
| 2468 | forceFlag = find_option("force", "f", 0)!=0; |
| 2469 | allowConflict = find_option("allow-conflict",0,0)!=0; |
| 2470 | allowEmpty = find_option("allow-empty",0,0)!=0; |
| 2471 | allowFork = find_option("allow-fork",0,0)!=0; |
| 2472 | if( find_option("override-lock",0,0)!=0 ) allowFork = 1; |
| 2473 | allowOlder = find_option("allow-older",0,0)!=0; |
| 2474 | noPrompt = find_option("no-prompt", 0, 0)!=0; |
| 2475 | noWarningFlag = find_option("no-warnings", 0, 0)!=0; |
| @@ -2581,10 +2585,16 @@ | |
| 2581 | if( nTag ){ |
| 2582 | int i; |
| 2583 | for(i=0; i<nTag; i++) sCiInfo.azTag[i] = mprintf("%F", sCiInfo.azTag[i]); |
| 2584 | qsort((void*)sCiInfo.azTag, nTag, sizeof(sCiInfo.azTag[0]), tagCmp); |
| 2585 | } |
| 2586 | |
| 2587 | /* |
| 2588 | ** Autosync if autosync is enabled and this is not a private check-in. |
| 2589 | */ |
| 2590 | if( !g.markPrivate ){ |
| @@ -2686,11 +2696,10 @@ | |
| 2686 | "'%s' was renamed to '%s'", zFrom, zTo, zFrom, zTo); |
| 2687 | } |
| 2688 | db_finalize(&q); |
| 2689 | } |
| 2690 | |
| 2691 | hasChanges = unsaved_changes(useHash ? CKSIG_HASH : 0); |
| 2692 | db_begin_transaction(); |
| 2693 | db_record_repository_filename(0); |
| 2694 | if( hasChanges==0 && !isAMerge && !allowEmpty && !forceFlag ){ |
| 2695 | fossil_fatal("nothing has changed; use --allow-empty to override"); |
| 2696 | } |
| 2697 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -2354,10 +2354,12 @@ | |
| 2354 | ** --close Close the branch being committed |
| 2355 | ** --date-override DATETIME DATE to use instead of 'now' |
| 2356 | ** --delta Use a delta manifest in the commit process |
| 2357 | ** --hash Verify file status using hashing rather |
| 2358 | ** than relying on file mtimes |
| 2359 | ** --if-changes Make this command a silent no-op if there |
| 2360 | ** are no changes |
| 2361 | ** --ignore-clock-skew If a clock skew is detected, ignore it and |
| 2362 | ** behave as if the user had entered 'yes' to |
| 2363 | ** the question of whether to proceed despite |
| 2364 | ** the skew. |
| 2365 | ** --ignore-oversize Do not warn the user about oversized files |
| @@ -2409,10 +2411,11 @@ | |
| 2411 | int forceFlag = 0; /* Undocumented: Disables all checks */ |
| 2412 | int forceDelta = 0; /* Force a delta-manifest */ |
| 2413 | int forceBaseline = 0; /* Force a baseline-manifest */ |
| 2414 | int allowConflict = 0; /* Allow unresolve merge conflicts */ |
| 2415 | int allowEmpty = 0; /* Allow a commit with no changes */ |
| 2416 | int onlyIfChanges = 0; /* No-op if there are no changes */ |
| 2417 | int allowFork = 0; /* Allow the commit to fork */ |
| 2418 | int allowOlder = 0; /* Allow a commit older than its ancestor */ |
| 2419 | char *zManifestFile; /* Name of the manifest file */ |
| 2420 | int useCksum; /* True if checksums should be computed and verified */ |
| 2421 | int outputManifest; /* True to output "manifest" and "manifest.uuid" */ |
| @@ -2466,10 +2469,11 @@ | |
| 2469 | } |
| 2470 | zComment = find_option("comment","m",1); |
| 2471 | forceFlag = find_option("force", "f", 0)!=0; |
| 2472 | allowConflict = find_option("allow-conflict",0,0)!=0; |
| 2473 | allowEmpty = find_option("allow-empty",0,0)!=0; |
| 2474 | onlyIfChanges = find_option("if-changes",0,0)!=0; |
| 2475 | allowFork = find_option("allow-fork",0,0)!=0; |
| 2476 | if( find_option("override-lock",0,0)!=0 ) allowFork = 1; |
| 2477 | allowOlder = find_option("allow-older",0,0)!=0; |
| 2478 | noPrompt = find_option("no-prompt", 0, 0)!=0; |
| 2479 | noWarningFlag = find_option("no-warnings", 0, 0)!=0; |
| @@ -2581,10 +2585,16 @@ | |
| 2585 | if( nTag ){ |
| 2586 | int i; |
| 2587 | for(i=0; i<nTag; i++) sCiInfo.azTag[i] = mprintf("%F", sCiInfo.azTag[i]); |
| 2588 | qsort((void*)sCiInfo.azTag, nTag, sizeof(sCiInfo.azTag[0]), tagCmp); |
| 2589 | } |
| 2590 | |
| 2591 | hasChanges = unsaved_changes(useHash ? CKSIG_HASH : 0); |
| 2592 | if( hasChanges==0 && onlyIfChanges ){ |
| 2593 | /* "fossil commit --if-changes" is a no-op if there are no changes. */ |
| 2594 | return; |
| 2595 | } |
| 2596 | |
| 2597 | /* |
| 2598 | ** Autosync if autosync is enabled and this is not a private check-in. |
| 2599 | */ |
| 2600 | if( !g.markPrivate ){ |
| @@ -2686,11 +2696,10 @@ | |
| 2696 | "'%s' was renamed to '%s'", zFrom, zTo, zFrom, zTo); |
| 2697 | } |
| 2698 | db_finalize(&q); |
| 2699 | } |
| 2700 | |
| 2701 | db_begin_transaction(); |
| 2702 | db_record_repository_filename(0); |
| 2703 | if( hasChanges==0 && !isAMerge && !allowEmpty && !forceFlag ){ |
| 2704 | fossil_fatal("nothing has changed; use --allow-empty to override"); |
| 2705 | } |
| 2706 |