Fossil SCM
Fix multiple problems with check-in [9360b66a67086d64] that can lead to crashes in Fossil itself, and in git-fast-import, when attempt to export Fossil itself to Git.
Commit
b001a1c3def573886d579138a11fdd1c0310ad71cc924ddc113f721086c03d59
Parent
7e961919a0b0597…
1 file changed
+17
-8
+17
-8
| --- src/export.c | ||
| +++ src/export.c | ||
| @@ -1170,34 +1170,43 @@ | ||
| 1170 | 1170 | fprintf(xCmd, "mark %s\n", zMark); |
| 1171 | 1171 | fossil_free(zMark); |
| 1172 | 1172 | sqlite3_snprintf(sizeof(buf), buf, "%lld", |
| 1173 | 1173 | (sqlite3_int64)((pMan->rDate-2440587.5)*86400.0) |
| 1174 | 1174 | ); |
| 1175 | + | |
| 1175 | 1176 | /* |
| 1176 | 1177 | ** Check for 'fx_' table from previous Git import, otherwise take contact info |
| 1177 | 1178 | ** from user table for <emailaddr> in committer field. If no emailaddr, check |
| 1178 | 1179 | ** if username is in email form, otherwise use generic '[email protected]'. |
| 1179 | 1180 | */ |
| 1180 | - char *zTmp; | |
| 1181 | 1181 | if (db_table_exists("repository", "fx_git")) { |
| 1182 | 1182 | zEmail = db_text(0, "SELECT email FROM fx_git WHERE user=%Q", pMan->zUser); |
| 1183 | 1183 | } else { |
| 1184 | 1184 | zEmail = db_text(0, "SELECT info FROM user WHERE login=%Q", pMan->zUser); |
| 1185 | 1185 | } |
| 1186 | + | |
| 1186 | 1187 | /* Some repo 'info' fields return an empty string hence the second check */ |
| 1187 | - if (zEmail == NULL || zEmail[0] == '\0') { | |
| 1188 | + if( zEmail==0 ){ | |
| 1188 | 1189 | /* If username is in emailaddr form, don't append '@noemail.net' */ |
| 1189 | - if (strchr(pMan->zUser, '@') == NULL) { | |
| 1190 | + if( pMan->zUser==0 || strchr(pMan->zUser, '@')==0 ){ | |
| 1190 | 1191 | zEmail = mprintf("%[email protected]", pMan->zUser); |
| 1191 | 1192 | } else { |
| 1192 | 1193 | zEmail = fossil_strdup(pMan->zUser); |
| 1193 | 1194 | } |
| 1194 | - } else if ((zTmp = strchr(zEmail, '<')) != NULL) { | |
| 1195 | - ++zTmp; | |
| 1196 | - char *zTmpEnd = strchr(zTmp, '>'); | |
| 1197 | - *(zTmpEnd) = '\0'; | |
| 1198 | - zEmail = fossil_strdup(zTmp); | |
| 1195 | + }else{ | |
| 1196 | + char *zTmp = strchr(zEmail, '<'); | |
| 1197 | + if( zTmp ){ | |
| 1198 | + char *zTmpEnd = strchr(zTmp+1, '>'); | |
| 1199 | + char *zNew; | |
| 1200 | + int i; | |
| 1201 | + if( zTmpEnd ) *(zTmpEnd) = 0; | |
| 1202 | + zNew = fossil_strdup(zTmp+1); | |
| 1203 | + fossil_free(zEmail); | |
| 1204 | + zEmail = zNew; | |
| 1205 | + for(i=0; zEmail[i] && !fossil_isspace(zEmail[i]); i++){} | |
| 1206 | + zEmail[i] = 0; | |
| 1207 | + } | |
| 1199 | 1208 | } |
| 1200 | 1209 | fprintf(xCmd, "# rid=%d\n", rid); |
| 1201 | 1210 | fprintf(xCmd, "committer %s <%s> %s +0000\n", pMan->zUser, zEmail, buf); |
| 1202 | 1211 | fossil_free(zEmail); |
| 1203 | 1212 | blob_init(&comment, pMan->zComment, -1); |
| 1204 | 1213 |
| --- src/export.c | |
| +++ src/export.c | |
| @@ -1170,34 +1170,43 @@ | |
| 1170 | fprintf(xCmd, "mark %s\n", zMark); |
| 1171 | fossil_free(zMark); |
| 1172 | sqlite3_snprintf(sizeof(buf), buf, "%lld", |
| 1173 | (sqlite3_int64)((pMan->rDate-2440587.5)*86400.0) |
| 1174 | ); |
| 1175 | /* |
| 1176 | ** Check for 'fx_' table from previous Git import, otherwise take contact info |
| 1177 | ** from user table for <emailaddr> in committer field. If no emailaddr, check |
| 1178 | ** if username is in email form, otherwise use generic '[email protected]'. |
| 1179 | */ |
| 1180 | char *zTmp; |
| 1181 | if (db_table_exists("repository", "fx_git")) { |
| 1182 | zEmail = db_text(0, "SELECT email FROM fx_git WHERE user=%Q", pMan->zUser); |
| 1183 | } else { |
| 1184 | zEmail = db_text(0, "SELECT info FROM user WHERE login=%Q", pMan->zUser); |
| 1185 | } |
| 1186 | /* Some repo 'info' fields return an empty string hence the second check */ |
| 1187 | if (zEmail == NULL || zEmail[0] == '\0') { |
| 1188 | /* If username is in emailaddr form, don't append '@noemail.net' */ |
| 1189 | if (strchr(pMan->zUser, '@') == NULL) { |
| 1190 | zEmail = mprintf("%[email protected]", pMan->zUser); |
| 1191 | } else { |
| 1192 | zEmail = fossil_strdup(pMan->zUser); |
| 1193 | } |
| 1194 | } else if ((zTmp = strchr(zEmail, '<')) != NULL) { |
| 1195 | ++zTmp; |
| 1196 | char *zTmpEnd = strchr(zTmp, '>'); |
| 1197 | *(zTmpEnd) = '\0'; |
| 1198 | zEmail = fossil_strdup(zTmp); |
| 1199 | } |
| 1200 | fprintf(xCmd, "# rid=%d\n", rid); |
| 1201 | fprintf(xCmd, "committer %s <%s> %s +0000\n", pMan->zUser, zEmail, buf); |
| 1202 | fossil_free(zEmail); |
| 1203 | blob_init(&comment, pMan->zComment, -1); |
| 1204 |
| --- src/export.c | |
| +++ src/export.c | |
| @@ -1170,34 +1170,43 @@ | |
| 1170 | fprintf(xCmd, "mark %s\n", zMark); |
| 1171 | fossil_free(zMark); |
| 1172 | sqlite3_snprintf(sizeof(buf), buf, "%lld", |
| 1173 | (sqlite3_int64)((pMan->rDate-2440587.5)*86400.0) |
| 1174 | ); |
| 1175 | |
| 1176 | /* |
| 1177 | ** Check for 'fx_' table from previous Git import, otherwise take contact info |
| 1178 | ** from user table for <emailaddr> in committer field. If no emailaddr, check |
| 1179 | ** if username is in email form, otherwise use generic '[email protected]'. |
| 1180 | */ |
| 1181 | if (db_table_exists("repository", "fx_git")) { |
| 1182 | zEmail = db_text(0, "SELECT email FROM fx_git WHERE user=%Q", pMan->zUser); |
| 1183 | } else { |
| 1184 | zEmail = db_text(0, "SELECT info FROM user WHERE login=%Q", pMan->zUser); |
| 1185 | } |
| 1186 | |
| 1187 | /* Some repo 'info' fields return an empty string hence the second check */ |
| 1188 | if( zEmail==0 ){ |
| 1189 | /* If username is in emailaddr form, don't append '@noemail.net' */ |
| 1190 | if( pMan->zUser==0 || strchr(pMan->zUser, '@')==0 ){ |
| 1191 | zEmail = mprintf("%[email protected]", pMan->zUser); |
| 1192 | } else { |
| 1193 | zEmail = fossil_strdup(pMan->zUser); |
| 1194 | } |
| 1195 | }else{ |
| 1196 | char *zTmp = strchr(zEmail, '<'); |
| 1197 | if( zTmp ){ |
| 1198 | char *zTmpEnd = strchr(zTmp+1, '>'); |
| 1199 | char *zNew; |
| 1200 | int i; |
| 1201 | if( zTmpEnd ) *(zTmpEnd) = 0; |
| 1202 | zNew = fossil_strdup(zTmp+1); |
| 1203 | fossil_free(zEmail); |
| 1204 | zEmail = zNew; |
| 1205 | for(i=0; zEmail[i] && !fossil_isspace(zEmail[i]); i++){} |
| 1206 | zEmail[i] = 0; |
| 1207 | } |
| 1208 | } |
| 1209 | fprintf(xCmd, "# rid=%d\n", rid); |
| 1210 | fprintf(xCmd, "committer %s <%s> %s +0000\n", pMan->zUser, zEmail, buf); |
| 1211 | fossil_free(zEmail); |
| 1212 | blob_init(&comment, pMan->zComment, -1); |
| 1213 |