Fossil SCM
Addendum to previous commit: Allow the user to decide whether the "fossil knows nothing about" warning should abort the commit or not.
Commit
c31bbd40846e3ca8b1cf589bf5ade7f50e9790c5
Parent
7a8808b2206630a…
1 file changed
+12
-2
+12
-2
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -616,12 +616,15 @@ | ||
| 616 | 616 | ** of the array. |
| 617 | 617 | ** |
| 618 | 618 | ** If there were no arguments passed to [commit], aCommitFile is not |
| 619 | 619 | ** allocated and remains NULL. Other parts of the code interpret this |
| 620 | 620 | ** to mean "all files". |
| 621 | +** | |
| 622 | +** Returns 1 if there was a warning, 0 otherwise. | |
| 621 | 623 | */ |
| 622 | -void select_commit_files(void){ | |
| 624 | +int select_commit_files(void){ | |
| 625 | + int result = 0; | |
| 623 | 626 | if( g.argc>2 ){ |
| 624 | 627 | int ii, jj=0; |
| 625 | 628 | Blob b; |
| 626 | 629 | blob_zero(&b); |
| 627 | 630 | g.aCommitFile = fossil_malloc(sizeof(int)*(g.argc-1)); |
| @@ -630,17 +633,19 @@ | ||
| 630 | 633 | int iId; |
| 631 | 634 | file_tree_name(g.argv[ii], &b, 1); |
| 632 | 635 | iId = db_int(-1, "SELECT id FROM vfile WHERE pathname=%Q", blob_str(&b)); |
| 633 | 636 | if( iId<0 ){ |
| 634 | 637 | fossil_warning("fossil knows nothing about: %s", g.argv[ii]); |
| 638 | + result = 1; | |
| 635 | 639 | } else { |
| 636 | 640 | g.aCommitFile[jj++] = iId; |
| 637 | 641 | } |
| 638 | 642 | blob_reset(&b); |
| 639 | 643 | } |
| 640 | 644 | g.aCommitFile[jj] = 0; |
| 641 | 645 | } |
| 646 | + return result; | |
| 642 | 647 | } |
| 643 | 648 | |
| 644 | 649 | /* |
| 645 | 650 | ** Make sure the current check-in with timestamp zDate is younger than its |
| 646 | 651 | ** ancestor identified rid and zUuid. Throw a fatal error if not. |
| @@ -1200,11 +1205,16 @@ | ||
| 1200 | 1205 | ** After the following function call has returned, the Global.aCommitFile[] |
| 1201 | 1206 | ** array is allocated to contain the "id" field from the vfile table |
| 1202 | 1207 | ** for each file to be committed. Or, if aCommitFile is NULL, all files |
| 1203 | 1208 | ** should be committed. |
| 1204 | 1209 | */ |
| 1205 | - select_commit_files(); | |
| 1210 | + if ( select_commit_files() ){ | |
| 1211 | + blob_zero(&ans); | |
| 1212 | + prompt_user("continue (y/N)? ", &ans); | |
| 1213 | + cReply = blob_str(&ans)[0]; | |
| 1214 | + if( cReply!='y' && cReply!='Y' ) fossil_exit(1);; | |
| 1215 | + } | |
| 1206 | 1216 | isAMerge = db_exists("SELECT 1 FROM vmerge WHERE id=0"); |
| 1207 | 1217 | if( g.aCommitFile && isAMerge ){ |
| 1208 | 1218 | fossil_fatal("cannot do a partial commit of a merge"); |
| 1209 | 1219 | } |
| 1210 | 1220 | |
| 1211 | 1221 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -616,12 +616,15 @@ | |
| 616 | ** of the array. |
| 617 | ** |
| 618 | ** If there were no arguments passed to [commit], aCommitFile is not |
| 619 | ** allocated and remains NULL. Other parts of the code interpret this |
| 620 | ** to mean "all files". |
| 621 | */ |
| 622 | void select_commit_files(void){ |
| 623 | if( g.argc>2 ){ |
| 624 | int ii, jj=0; |
| 625 | Blob b; |
| 626 | blob_zero(&b); |
| 627 | g.aCommitFile = fossil_malloc(sizeof(int)*(g.argc-1)); |
| @@ -630,17 +633,19 @@ | |
| 630 | int iId; |
| 631 | file_tree_name(g.argv[ii], &b, 1); |
| 632 | iId = db_int(-1, "SELECT id FROM vfile WHERE pathname=%Q", blob_str(&b)); |
| 633 | if( iId<0 ){ |
| 634 | fossil_warning("fossil knows nothing about: %s", g.argv[ii]); |
| 635 | } else { |
| 636 | g.aCommitFile[jj++] = iId; |
| 637 | } |
| 638 | blob_reset(&b); |
| 639 | } |
| 640 | g.aCommitFile[jj] = 0; |
| 641 | } |
| 642 | } |
| 643 | |
| 644 | /* |
| 645 | ** Make sure the current check-in with timestamp zDate is younger than its |
| 646 | ** ancestor identified rid and zUuid. Throw a fatal error if not. |
| @@ -1200,11 +1205,16 @@ | |
| 1200 | ** After the following function call has returned, the Global.aCommitFile[] |
| 1201 | ** array is allocated to contain the "id" field from the vfile table |
| 1202 | ** for each file to be committed. Or, if aCommitFile is NULL, all files |
| 1203 | ** should be committed. |
| 1204 | */ |
| 1205 | select_commit_files(); |
| 1206 | isAMerge = db_exists("SELECT 1 FROM vmerge WHERE id=0"); |
| 1207 | if( g.aCommitFile && isAMerge ){ |
| 1208 | fossil_fatal("cannot do a partial commit of a merge"); |
| 1209 | } |
| 1210 | |
| 1211 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -616,12 +616,15 @@ | |
| 616 | ** of the array. |
| 617 | ** |
| 618 | ** If there were no arguments passed to [commit], aCommitFile is not |
| 619 | ** allocated and remains NULL. Other parts of the code interpret this |
| 620 | ** to mean "all files". |
| 621 | ** |
| 622 | ** Returns 1 if there was a warning, 0 otherwise. |
| 623 | */ |
| 624 | int select_commit_files(void){ |
| 625 | int result = 0; |
| 626 | if( g.argc>2 ){ |
| 627 | int ii, jj=0; |
| 628 | Blob b; |
| 629 | blob_zero(&b); |
| 630 | g.aCommitFile = fossil_malloc(sizeof(int)*(g.argc-1)); |
| @@ -630,17 +633,19 @@ | |
| 633 | int iId; |
| 634 | file_tree_name(g.argv[ii], &b, 1); |
| 635 | iId = db_int(-1, "SELECT id FROM vfile WHERE pathname=%Q", blob_str(&b)); |
| 636 | if( iId<0 ){ |
| 637 | fossil_warning("fossil knows nothing about: %s", g.argv[ii]); |
| 638 | result = 1; |
| 639 | } else { |
| 640 | g.aCommitFile[jj++] = iId; |
| 641 | } |
| 642 | blob_reset(&b); |
| 643 | } |
| 644 | g.aCommitFile[jj] = 0; |
| 645 | } |
| 646 | return result; |
| 647 | } |
| 648 | |
| 649 | /* |
| 650 | ** Make sure the current check-in with timestamp zDate is younger than its |
| 651 | ** ancestor identified rid and zUuid. Throw a fatal error if not. |
| @@ -1200,11 +1205,16 @@ | |
| 1205 | ** After the following function call has returned, the Global.aCommitFile[] |
| 1206 | ** array is allocated to contain the "id" field from the vfile table |
| 1207 | ** for each file to be committed. Or, if aCommitFile is NULL, all files |
| 1208 | ** should be committed. |
| 1209 | */ |
| 1210 | if ( select_commit_files() ){ |
| 1211 | blob_zero(&ans); |
| 1212 | prompt_user("continue (y/N)? ", &ans); |
| 1213 | cReply = blob_str(&ans)[0]; |
| 1214 | if( cReply!='y' && cReply!='Y' ) fossil_exit(1);; |
| 1215 | } |
| 1216 | isAMerge = db_exists("SELECT 1 FROM vmerge WHERE id=0"); |
| 1217 | if( g.aCommitFile && isAMerge ){ |
| 1218 | fossil_fatal("cannot do a partial commit of a merge"); |
| 1219 | } |
| 1220 | |
| 1221 |