Fossil SCM

Add --sha1sum option to commit command.

joel 2013-12-26 00:07 trunk
Commit a9ad53ba3abd61dd4b1f131b07f6ee7dfd3abe82
2 files changed +9 -2 +4 -4
+9 -2
--- src/checkin.c
+++ src/checkin.c
@@ -1377,11 +1377,14 @@
13771377
** allowed against a closed leaf.
13781378
**
13791379
** The --private option creates a private check-in that is never synced.
13801380
** Children of private check-ins are automatically private.
13811381
**
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.
13831386
**
13841387
** Options:
13851388
** --allow-conflict allow unresolved merge conflicts
13861389
** --allow-empty allow a commit with no changes
13871390
** --allow-fork allow the commit to fork
@@ -1397,10 +1400,12 @@
13971400
** --mimetype MIMETYPE mimetype of check-in comment
13981401
** -n|--dry-run If given, display instead of run actions
13991402
** --no-warnings omit all warnings about file contents
14001403
** --nosign do not attempt to sign this commit with gpg
14011404
** --private do not sync changes and their descendants
1405
+** --sha1sum verify file status using SHA1 hashing rather
1406
+** than relying on file mtimes
14021407
** --tag TAG-NAME assign given tag TAG-NAME to the checkin
14031408
**
14041409
** See also: branch, changes, checkout, extra, sync
14051410
*/
14061411
void commit_cmd(void){
@@ -1410,10 +1415,11 @@
14101415
int nvid; /* Blob-id of the new check-in */
14111416
Blob comment; /* Check-in comment */
14121417
const char *zComment; /* Check-in comment */
14131418
Stmt q; /* Various queries */
14141419
char *zUuid; /* UUID of the new check-in */
1420
+ int useSha1sum = 0; /* True to verify file status using SHA1 hashing */
14151421
int noSign = 0; /* True to omit signing the manifest using GPG */
14161422
int isAMerge = 0; /* True if checking in a merge */
14171423
int noWarningFlag = 0; /* True if skipping all warnings */
14181424
int forceFlag = 0; /* Undocumented: Disables all checks */
14191425
int forceDelta = 0; /* Force a delta-manifest */
@@ -1441,10 +1447,11 @@
14411447
Blob ans;
14421448
char cReply;
14431449
14441450
memset(&sCiInfo, 0, sizeof(sCiInfo));
14451451
url_proxy_options();
1452
+ useSha1sum = find_option("sha1sum", 0, 0)!=0;
14461453
noSign = find_option("nosign",0,0)!=0;
14471454
forceDelta = find_option("delta",0,0)!=0;
14481455
forceBaseline = find_option("baseline",0,0)!=0;
14491456
if( forceDelta && forceBaseline ){
14501457
fossil_fatal("cannot use --delta and --baseline together");
@@ -1586,11 +1593,11 @@
15861593
*/
15871594
if( !db_exists("SELECT 1 FROM user WHERE login=%Q", g.zLogin) ){
15881595
fossil_fatal("no such user: %s", g.zLogin);
15891596
}
15901597
1591
- hasChanges = unsaved_changes();
1598
+ hasChanges = unsaved_changes(useSha1sum ? CKSIG_SHA1 : 0);
15921599
db_begin_transaction();
15931600
db_record_repository_filename(0);
15941601
if( hasChanges==0 && !isAMerge && !allowEmpty && !forceFlag ){
15951602
fossil_fatal("nothing has changed; use --allow-empty to override");
15961603
}
15971604
--- 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 @@
2828
**
2929
** 0: There is an existing checkout but it is unmodified
3030
** 1: There is a modified checkout - there are unsaved changes
3131
** 2: There is no existing checkout
3232
*/
33
-int unsaved_changes(void){
33
+int unsaved_changes(unsigned int cksigFlags){
3434
int vid;
3535
db_must_be_within_tree();
3636
vid = db_lget_int("checkout",0);
3737
if( vid==0 ) return 2;
38
- vfile_check_signature(vid, CKSIG_ENOTFILE);
38
+ vfile_check_signature(vid, cksigFlags|CKSIG_ENOTFILE);
3939
return db_exists("SELECT 1 FROM vfile WHERE chnged"
4040
" OR coalesce(origname!=pathname,0)");
4141
}
4242
4343
/*
@@ -200,11 +200,11 @@
200200
latestFlag = find_option("latest",0,0)!=0;
201201
promptFlag = find_option("prompt",0,0)!=0 || forceFlag==0;
202202
if( (latestFlag!=0 && g.argc!=2) || (latestFlag==0 && g.argc!=3) ){
203203
usage("VERSION|--latest ?--force? ?--keep?");
204204
}
205
- if( !forceFlag && unsaved_changes()==1 ){
205
+ if( !forceFlag && unsaved_changes(0)==1 ){
206206
fossil_fatal("there are unsaved changes in the current checkout");
207207
}
208208
if( forceFlag ){
209209
db_multi_exec("DELETE FROM vfile");
210210
prior = 0;
@@ -288,11 +288,11 @@
288288
** See also: open
289289
*/
290290
void close_cmd(void){
291291
int forceFlag = find_option("force","f",0)!=0;
292292
db_must_be_within_tree();
293
- if( !forceFlag && unsaved_changes()==1 ){
293
+ if( !forceFlag && unsaved_changes(0)==1 ){
294294
fossil_fatal("there are unsaved changes in the current checkout");
295295
}
296296
if( !forceFlag
297297
&& db_exists("SELECT 1 FROM %s.sqlite_master WHERE name='stash'",
298298
db_name("localdb"))
299299
--- 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

Keyboard Shortcuts

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