Fossil SCM
Disallow the sequence: "fossil mv A B; fossil add A; fossil commit A;" since doing so requires both the old A and the new A to be in the same check-in. Ticket [0ff64b0a5fc8].
Commit
27298fffc87fe42f238542e94246395a25b6ba07
Parent
19ca7c6c54d685a…
1 file changed
+22
+22
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -1146,10 +1146,32 @@ | ||
| 1146 | 1146 | select_commit_files(); |
| 1147 | 1147 | isAMerge = db_exists("SELECT 1 FROM vmerge WHERE id=0"); |
| 1148 | 1148 | if( g.aCommitFile && isAMerge ){ |
| 1149 | 1149 | fossil_fatal("cannot do a partial commit of a merge"); |
| 1150 | 1150 | } |
| 1151 | + | |
| 1152 | + /* Doing "fossil mv fileA fileB; fossil add fileA; fossil commit fileA" | |
| 1153 | + ** will generate a manifest that has two fileA entries, which is illegal. | |
| 1154 | + ** When you think about it, the sequence above makes no sense. So detect | |
| 1155 | + ** it and disallow it. Ticket [0ff64b0a5fc8]. | |
| 1156 | + */ | |
| 1157 | + if( g.aCommitFile ){ | |
| 1158 | + Stmt qRename; | |
| 1159 | + db_prepare(&qRename, | |
| 1160 | + "SELECT v1.pathname, v2.pathname" | |
| 1161 | + " FROM vfile AS v2 CROSS JOIN vfile AS v1" | |
| 1162 | + " WHERE is_selected(v1.id)" | |
| 1163 | + " AND v2.origname IS NOT NULL" | |
| 1164 | + " AND v2.origname=v1.pathname"); | |
| 1165 | + if( db_step(&qRename)==SQLITE_ROW ){ | |
| 1166 | + const char *zFrom = db_column_text(&qRename, 0); | |
| 1167 | + const char *zTo = db_column_text(&qRename, 1); | |
| 1168 | + fossil_fatal("cannot do a partial commit of '%s' because " | |
| 1169 | + "'%s' was renamed to '%s'", zFrom, zFrom, zTo); | |
| 1170 | + } | |
| 1171 | + db_finalize(&qRename); | |
| 1172 | + } | |
| 1151 | 1173 | |
| 1152 | 1174 | user_select(); |
| 1153 | 1175 | /* |
| 1154 | 1176 | ** Check that the user exists. |
| 1155 | 1177 | */ |
| 1156 | 1178 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -1146,10 +1146,32 @@ | |
| 1146 | select_commit_files(); |
| 1147 | isAMerge = db_exists("SELECT 1 FROM vmerge WHERE id=0"); |
| 1148 | if( g.aCommitFile && isAMerge ){ |
| 1149 | fossil_fatal("cannot do a partial commit of a merge"); |
| 1150 | } |
| 1151 | |
| 1152 | user_select(); |
| 1153 | /* |
| 1154 | ** Check that the user exists. |
| 1155 | */ |
| 1156 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -1146,10 +1146,32 @@ | |
| 1146 | select_commit_files(); |
| 1147 | isAMerge = db_exists("SELECT 1 FROM vmerge WHERE id=0"); |
| 1148 | if( g.aCommitFile && isAMerge ){ |
| 1149 | fossil_fatal("cannot do a partial commit of a merge"); |
| 1150 | } |
| 1151 | |
| 1152 | /* Doing "fossil mv fileA fileB; fossil add fileA; fossil commit fileA" |
| 1153 | ** will generate a manifest that has two fileA entries, which is illegal. |
| 1154 | ** When you think about it, the sequence above makes no sense. So detect |
| 1155 | ** it and disallow it. Ticket [0ff64b0a5fc8]. |
| 1156 | */ |
| 1157 | if( g.aCommitFile ){ |
| 1158 | Stmt qRename; |
| 1159 | db_prepare(&qRename, |
| 1160 | "SELECT v1.pathname, v2.pathname" |
| 1161 | " FROM vfile AS v2 CROSS JOIN vfile AS v1" |
| 1162 | " WHERE is_selected(v1.id)" |
| 1163 | " AND v2.origname IS NOT NULL" |
| 1164 | " AND v2.origname=v1.pathname"); |
| 1165 | if( db_step(&qRename)==SQLITE_ROW ){ |
| 1166 | const char *zFrom = db_column_text(&qRename, 0); |
| 1167 | const char *zTo = db_column_text(&qRename, 1); |
| 1168 | fossil_fatal("cannot do a partial commit of '%s' because " |
| 1169 | "'%s' was renamed to '%s'", zFrom, zFrom, zTo); |
| 1170 | } |
| 1171 | db_finalize(&qRename); |
| 1172 | } |
| 1173 | |
| 1174 | user_select(); |
| 1175 | /* |
| 1176 | ** Check that the user exists. |
| 1177 | */ |
| 1178 |