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].

drh 2012-11-04 00:46 trunk
Commit 27298fffc87fe42f238542e94246395a25b6ba07
1 file changed +22
--- src/checkin.c
+++ src/checkin.c
@@ -1146,10 +1146,32 @@
11461146
select_commit_files();
11471147
isAMerge = db_exists("SELECT 1 FROM vmerge WHERE id=0");
11481148
if( g.aCommitFile && isAMerge ){
11491149
fossil_fatal("cannot do a partial commit of a merge");
11501150
}
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
+ }
11511173
11521174
user_select();
11531175
/*
11541176
** Check that the user exists.
11551177
*/
11561178
--- 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

Keyboard Shortcuts

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