Fossil SCM
Add --sha1sum option to commit command.
Commit
a9ad53ba3abd61dd4b1f131b07f6ee7dfd3abe82
Parent
71aa33cd92f7385…
2 files changed
+9
-2
+4
-4
+9
-2
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -1377,11 +1377,14 @@ | ||
| 1377 | 1377 | ** allowed against a closed leaf. |
| 1378 | 1378 | ** |
| 1379 | 1379 | ** The --private option creates a private check-in that is never synced. |
| 1380 | 1380 | ** Children of private check-ins are automatically private. |
| 1381 | 1381 | ** |
| 1382 | -** the --tag option applies the symbolic tag name to the check-in. | |
| 1382 | +** The --tag option applies the symbolic tag name to the check-in. | |
| 1383 | +** | |
| 1384 | +** The --sha1sum option detects edited files by computing each file's | |
| 1385 | +** SHA1 hash rather than just checking for changes to its size or mtime. | |
| 1383 | 1386 | ** |
| 1384 | 1387 | ** Options: |
| 1385 | 1388 | ** --allow-conflict allow unresolved merge conflicts |
| 1386 | 1389 | ** --allow-empty allow a commit with no changes |
| 1387 | 1390 | ** --allow-fork allow the commit to fork |
| @@ -1397,10 +1400,12 @@ | ||
| 1397 | 1400 | ** --mimetype MIMETYPE mimetype of check-in comment |
| 1398 | 1401 | ** -n|--dry-run If given, display instead of run actions |
| 1399 | 1402 | ** --no-warnings omit all warnings about file contents |
| 1400 | 1403 | ** --nosign do not attempt to sign this commit with gpg |
| 1401 | 1404 | ** --private do not sync changes and their descendants |
| 1405 | +** --sha1sum verify file status using SHA1 hashing rather | |
| 1406 | +** than relying on file mtimes | |
| 1402 | 1407 | ** --tag TAG-NAME assign given tag TAG-NAME to the checkin |
| 1403 | 1408 | ** |
| 1404 | 1409 | ** See also: branch, changes, checkout, extra, sync |
| 1405 | 1410 | */ |
| 1406 | 1411 | void commit_cmd(void){ |
| @@ -1410,10 +1415,11 @@ | ||
| 1410 | 1415 | int nvid; /* Blob-id of the new check-in */ |
| 1411 | 1416 | Blob comment; /* Check-in comment */ |
| 1412 | 1417 | const char *zComment; /* Check-in comment */ |
| 1413 | 1418 | Stmt q; /* Various queries */ |
| 1414 | 1419 | char *zUuid; /* UUID of the new check-in */ |
| 1420 | + int useSha1sum = 0; /* True to verify file status using SHA1 hashing */ | |
| 1415 | 1421 | int noSign = 0; /* True to omit signing the manifest using GPG */ |
| 1416 | 1422 | int isAMerge = 0; /* True if checking in a merge */ |
| 1417 | 1423 | int noWarningFlag = 0; /* True if skipping all warnings */ |
| 1418 | 1424 | int forceFlag = 0; /* Undocumented: Disables all checks */ |
| 1419 | 1425 | int forceDelta = 0; /* Force a delta-manifest */ |
| @@ -1441,10 +1447,11 @@ | ||
| 1441 | 1447 | Blob ans; |
| 1442 | 1448 | char cReply; |
| 1443 | 1449 | |
| 1444 | 1450 | memset(&sCiInfo, 0, sizeof(sCiInfo)); |
| 1445 | 1451 | url_proxy_options(); |
| 1452 | + useSha1sum = find_option("sha1sum", 0, 0)!=0; | |
| 1446 | 1453 | noSign = find_option("nosign",0,0)!=0; |
| 1447 | 1454 | forceDelta = find_option("delta",0,0)!=0; |
| 1448 | 1455 | forceBaseline = find_option("baseline",0,0)!=0; |
| 1449 | 1456 | if( forceDelta && forceBaseline ){ |
| 1450 | 1457 | fossil_fatal("cannot use --delta and --baseline together"); |
| @@ -1586,11 +1593,11 @@ | ||
| 1586 | 1593 | */ |
| 1587 | 1594 | if( !db_exists("SELECT 1 FROM user WHERE login=%Q", g.zLogin) ){ |
| 1588 | 1595 | fossil_fatal("no such user: %s", g.zLogin); |
| 1589 | 1596 | } |
| 1590 | 1597 | |
| 1591 | - hasChanges = unsaved_changes(); | |
| 1598 | + hasChanges = unsaved_changes(useSha1sum ? CKSIG_SHA1 : 0); | |
| 1592 | 1599 | db_begin_transaction(); |
| 1593 | 1600 | db_record_repository_filename(0); |
| 1594 | 1601 | if( hasChanges==0 && !isAMerge && !allowEmpty && !forceFlag ){ |
| 1595 | 1602 | fossil_fatal("nothing has changed; use --allow-empty to override"); |
| 1596 | 1603 | } |
| 1597 | 1604 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -1377,11 +1377,14 @@ | |
| 1377 | ** allowed against a closed leaf. |
| 1378 | ** |
| 1379 | ** The --private option creates a private check-in that is never synced. |
| 1380 | ** Children of private check-ins are automatically private. |
| 1381 | ** |
| 1382 | ** the --tag option applies the symbolic tag name to the check-in. |
| 1383 | ** |
| 1384 | ** Options: |
| 1385 | ** --allow-conflict allow unresolved merge conflicts |
| 1386 | ** --allow-empty allow a commit with no changes |
| 1387 | ** --allow-fork allow the commit to fork |
| @@ -1397,10 +1400,12 @@ | |
| 1397 | ** --mimetype MIMETYPE mimetype of check-in comment |
| 1398 | ** -n|--dry-run If given, display instead of run actions |
| 1399 | ** --no-warnings omit all warnings about file contents |
| 1400 | ** --nosign do not attempt to sign this commit with gpg |
| 1401 | ** --private do not sync changes and their descendants |
| 1402 | ** --tag TAG-NAME assign given tag TAG-NAME to the checkin |
| 1403 | ** |
| 1404 | ** See also: branch, changes, checkout, extra, sync |
| 1405 | */ |
| 1406 | void commit_cmd(void){ |
| @@ -1410,10 +1415,11 @@ | |
| 1410 | int nvid; /* Blob-id of the new check-in */ |
| 1411 | Blob comment; /* Check-in comment */ |
| 1412 | const char *zComment; /* Check-in comment */ |
| 1413 | Stmt q; /* Various queries */ |
| 1414 | char *zUuid; /* UUID of the new check-in */ |
| 1415 | int noSign = 0; /* True to omit signing the manifest using GPG */ |
| 1416 | int isAMerge = 0; /* True if checking in a merge */ |
| 1417 | int noWarningFlag = 0; /* True if skipping all warnings */ |
| 1418 | int forceFlag = 0; /* Undocumented: Disables all checks */ |
| 1419 | int forceDelta = 0; /* Force a delta-manifest */ |
| @@ -1441,10 +1447,11 @@ | |
| 1441 | Blob ans; |
| 1442 | char cReply; |
| 1443 | |
| 1444 | memset(&sCiInfo, 0, sizeof(sCiInfo)); |
| 1445 | url_proxy_options(); |
| 1446 | noSign = find_option("nosign",0,0)!=0; |
| 1447 | forceDelta = find_option("delta",0,0)!=0; |
| 1448 | forceBaseline = find_option("baseline",0,0)!=0; |
| 1449 | if( forceDelta && forceBaseline ){ |
| 1450 | fossil_fatal("cannot use --delta and --baseline together"); |
| @@ -1586,11 +1593,11 @@ | |
| 1586 | */ |
| 1587 | if( !db_exists("SELECT 1 FROM user WHERE login=%Q", g.zLogin) ){ |
| 1588 | fossil_fatal("no such user: %s", g.zLogin); |
| 1589 | } |
| 1590 | |
| 1591 | hasChanges = unsaved_changes(); |
| 1592 | db_begin_transaction(); |
| 1593 | db_record_repository_filename(0); |
| 1594 | if( hasChanges==0 && !isAMerge && !allowEmpty && !forceFlag ){ |
| 1595 | fossil_fatal("nothing has changed; use --allow-empty to override"); |
| 1596 | } |
| 1597 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -1377,11 +1377,14 @@ | |
| 1377 | ** allowed against a closed leaf. |
| 1378 | ** |
| 1379 | ** The --private option creates a private check-in that is never synced. |
| 1380 | ** Children of private check-ins are automatically private. |
| 1381 | ** |
| 1382 | ** The --tag option applies the symbolic tag name to the check-in. |
| 1383 | ** |
| 1384 | ** The --sha1sum option detects edited files by computing each file's |
| 1385 | ** SHA1 hash rather than just checking for changes to its size or mtime. |
| 1386 | ** |
| 1387 | ** Options: |
| 1388 | ** --allow-conflict allow unresolved merge conflicts |
| 1389 | ** --allow-empty allow a commit with no changes |
| 1390 | ** --allow-fork allow the commit to fork |
| @@ -1397,10 +1400,12 @@ | |
| 1400 | ** --mimetype MIMETYPE mimetype of check-in comment |
| 1401 | ** -n|--dry-run If given, display instead of run actions |
| 1402 | ** --no-warnings omit all warnings about file contents |
| 1403 | ** --nosign do not attempt to sign this commit with gpg |
| 1404 | ** --private do not sync changes and their descendants |
| 1405 | ** --sha1sum verify file status using SHA1 hashing rather |
| 1406 | ** than relying on file mtimes |
| 1407 | ** --tag TAG-NAME assign given tag TAG-NAME to the checkin |
| 1408 | ** |
| 1409 | ** See also: branch, changes, checkout, extra, sync |
| 1410 | */ |
| 1411 | void commit_cmd(void){ |
| @@ -1410,10 +1415,11 @@ | |
| 1415 | int nvid; /* Blob-id of the new check-in */ |
| 1416 | Blob comment; /* Check-in comment */ |
| 1417 | const char *zComment; /* Check-in comment */ |
| 1418 | Stmt q; /* Various queries */ |
| 1419 | char *zUuid; /* UUID of the new check-in */ |
| 1420 | int useSha1sum = 0; /* True to verify file status using SHA1 hashing */ |
| 1421 | int noSign = 0; /* True to omit signing the manifest using GPG */ |
| 1422 | int isAMerge = 0; /* True if checking in a merge */ |
| 1423 | int noWarningFlag = 0; /* True if skipping all warnings */ |
| 1424 | int forceFlag = 0; /* Undocumented: Disables all checks */ |
| 1425 | int forceDelta = 0; /* Force a delta-manifest */ |
| @@ -1441,10 +1447,11 @@ | |
| 1447 | Blob ans; |
| 1448 | char cReply; |
| 1449 | |
| 1450 | memset(&sCiInfo, 0, sizeof(sCiInfo)); |
| 1451 | url_proxy_options(); |
| 1452 | useSha1sum = find_option("sha1sum", 0, 0)!=0; |
| 1453 | noSign = find_option("nosign",0,0)!=0; |
| 1454 | forceDelta = find_option("delta",0,0)!=0; |
| 1455 | forceBaseline = find_option("baseline",0,0)!=0; |
| 1456 | if( forceDelta && forceBaseline ){ |
| 1457 | fossil_fatal("cannot use --delta and --baseline together"); |
| @@ -1586,11 +1593,11 @@ | |
| 1593 | */ |
| 1594 | if( !db_exists("SELECT 1 FROM user WHERE login=%Q", g.zLogin) ){ |
| 1595 | fossil_fatal("no such user: %s", g.zLogin); |
| 1596 | } |
| 1597 | |
| 1598 | hasChanges = unsaved_changes(useSha1sum ? CKSIG_SHA1 : 0); |
| 1599 | db_begin_transaction(); |
| 1600 | db_record_repository_filename(0); |
| 1601 | if( hasChanges==0 && !isAMerge && !allowEmpty && !forceFlag ){ |
| 1602 | fossil_fatal("nothing has changed; use --allow-empty to override"); |
| 1603 | } |
| 1604 |
+4
-4
| --- src/checkout.c | ||
| +++ src/checkout.c | ||
| @@ -28,16 +28,16 @@ | ||
| 28 | 28 | ** |
| 29 | 29 | ** 0: There is an existing checkout but it is unmodified |
| 30 | 30 | ** 1: There is a modified checkout - there are unsaved changes |
| 31 | 31 | ** 2: There is no existing checkout |
| 32 | 32 | */ |
| 33 | -int unsaved_changes(void){ | |
| 33 | +int unsaved_changes(unsigned int cksigFlags){ | |
| 34 | 34 | int vid; |
| 35 | 35 | db_must_be_within_tree(); |
| 36 | 36 | vid = db_lget_int("checkout",0); |
| 37 | 37 | if( vid==0 ) return 2; |
| 38 | - vfile_check_signature(vid, CKSIG_ENOTFILE); | |
| 38 | + vfile_check_signature(vid, cksigFlags|CKSIG_ENOTFILE); | |
| 39 | 39 | return db_exists("SELECT 1 FROM vfile WHERE chnged" |
| 40 | 40 | " OR coalesce(origname!=pathname,0)"); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /* |
| @@ -200,11 +200,11 @@ | ||
| 200 | 200 | latestFlag = find_option("latest",0,0)!=0; |
| 201 | 201 | promptFlag = find_option("prompt",0,0)!=0 || forceFlag==0; |
| 202 | 202 | if( (latestFlag!=0 && g.argc!=2) || (latestFlag==0 && g.argc!=3) ){ |
| 203 | 203 | usage("VERSION|--latest ?--force? ?--keep?"); |
| 204 | 204 | } |
| 205 | - if( !forceFlag && unsaved_changes()==1 ){ | |
| 205 | + if( !forceFlag && unsaved_changes(0)==1 ){ | |
| 206 | 206 | fossil_fatal("there are unsaved changes in the current checkout"); |
| 207 | 207 | } |
| 208 | 208 | if( forceFlag ){ |
| 209 | 209 | db_multi_exec("DELETE FROM vfile"); |
| 210 | 210 | prior = 0; |
| @@ -288,11 +288,11 @@ | ||
| 288 | 288 | ** See also: open |
| 289 | 289 | */ |
| 290 | 290 | void close_cmd(void){ |
| 291 | 291 | int forceFlag = find_option("force","f",0)!=0; |
| 292 | 292 | db_must_be_within_tree(); |
| 293 | - if( !forceFlag && unsaved_changes()==1 ){ | |
| 293 | + if( !forceFlag && unsaved_changes(0)==1 ){ | |
| 294 | 294 | fossil_fatal("there are unsaved changes in the current checkout"); |
| 295 | 295 | } |
| 296 | 296 | if( !forceFlag |
| 297 | 297 | && db_exists("SELECT 1 FROM %s.sqlite_master WHERE name='stash'", |
| 298 | 298 | db_name("localdb")) |
| 299 | 299 |
| --- src/checkout.c | |
| +++ src/checkout.c | |
| @@ -28,16 +28,16 @@ | |
| 28 | ** |
| 29 | ** 0: There is an existing checkout but it is unmodified |
| 30 | ** 1: There is a modified checkout - there are unsaved changes |
| 31 | ** 2: There is no existing checkout |
| 32 | */ |
| 33 | int unsaved_changes(void){ |
| 34 | int vid; |
| 35 | db_must_be_within_tree(); |
| 36 | vid = db_lget_int("checkout",0); |
| 37 | if( vid==0 ) return 2; |
| 38 | vfile_check_signature(vid, CKSIG_ENOTFILE); |
| 39 | return db_exists("SELECT 1 FROM vfile WHERE chnged" |
| 40 | " OR coalesce(origname!=pathname,0)"); |
| 41 | } |
| 42 | |
| 43 | /* |
| @@ -200,11 +200,11 @@ | |
| 200 | latestFlag = find_option("latest",0,0)!=0; |
| 201 | promptFlag = find_option("prompt",0,0)!=0 || forceFlag==0; |
| 202 | if( (latestFlag!=0 && g.argc!=2) || (latestFlag==0 && g.argc!=3) ){ |
| 203 | usage("VERSION|--latest ?--force? ?--keep?"); |
| 204 | } |
| 205 | if( !forceFlag && unsaved_changes()==1 ){ |
| 206 | fossil_fatal("there are unsaved changes in the current checkout"); |
| 207 | } |
| 208 | if( forceFlag ){ |
| 209 | db_multi_exec("DELETE FROM vfile"); |
| 210 | prior = 0; |
| @@ -288,11 +288,11 @@ | |
| 288 | ** See also: open |
| 289 | */ |
| 290 | void close_cmd(void){ |
| 291 | int forceFlag = find_option("force","f",0)!=0; |
| 292 | db_must_be_within_tree(); |
| 293 | if( !forceFlag && unsaved_changes()==1 ){ |
| 294 | fossil_fatal("there are unsaved changes in the current checkout"); |
| 295 | } |
| 296 | if( !forceFlag |
| 297 | && db_exists("SELECT 1 FROM %s.sqlite_master WHERE name='stash'", |
| 298 | db_name("localdb")) |
| 299 |
| --- src/checkout.c | |
| +++ src/checkout.c | |
| @@ -28,16 +28,16 @@ | |
| 28 | ** |
| 29 | ** 0: There is an existing checkout but it is unmodified |
| 30 | ** 1: There is a modified checkout - there are unsaved changes |
| 31 | ** 2: There is no existing checkout |
| 32 | */ |
| 33 | int unsaved_changes(unsigned int cksigFlags){ |
| 34 | int vid; |
| 35 | db_must_be_within_tree(); |
| 36 | vid = db_lget_int("checkout",0); |
| 37 | if( vid==0 ) return 2; |
| 38 | vfile_check_signature(vid, cksigFlags|CKSIG_ENOTFILE); |
| 39 | return db_exists("SELECT 1 FROM vfile WHERE chnged" |
| 40 | " OR coalesce(origname!=pathname,0)"); |
| 41 | } |
| 42 | |
| 43 | /* |
| @@ -200,11 +200,11 @@ | |
| 200 | latestFlag = find_option("latest",0,0)!=0; |
| 201 | promptFlag = find_option("prompt",0,0)!=0 || forceFlag==0; |
| 202 | if( (latestFlag!=0 && g.argc!=2) || (latestFlag==0 && g.argc!=3) ){ |
| 203 | usage("VERSION|--latest ?--force? ?--keep?"); |
| 204 | } |
| 205 | if( !forceFlag && unsaved_changes(0)==1 ){ |
| 206 | fossil_fatal("there are unsaved changes in the current checkout"); |
| 207 | } |
| 208 | if( forceFlag ){ |
| 209 | db_multi_exec("DELETE FROM vfile"); |
| 210 | prior = 0; |
| @@ -288,11 +288,11 @@ | |
| 288 | ** See also: open |
| 289 | */ |
| 290 | void close_cmd(void){ |
| 291 | int forceFlag = find_option("force","f",0)!=0; |
| 292 | db_must_be_within_tree(); |
| 293 | if( !forceFlag && unsaved_changes(0)==1 ){ |
| 294 | fossil_fatal("there are unsaved changes in the current checkout"); |
| 295 | } |
| 296 | if( !forceFlag |
| 297 | && db_exists("SELECT 1 FROM %s.sqlite_master WHERE name='stash'", |
| 298 | db_name("localdb")) |
| 299 |