@@ -172,32 +172,30 @@ static int should_write_log(struct ref_store *refs, const char *refname)
172
172
}
173
173
}
174
174
175
- static void fill_reftable_log_record (struct reftable_log_record * log )
175
+ static void fill_reftable_log_record (struct reftable_log_record * log , const struct ident_split * split )
176
176
{
177
- const char * info = git_committer_info (0 );
178
- struct ident_split split = {0 };
177
+ const char * tz_begin ;
179
178
int sign = 1 ;
180
179
181
- if (split_ident_line (& split , info , strlen (info )))
182
- BUG ("failed splitting committer info" );
183
-
184
180
reftable_log_record_release (log );
185
181
log -> value_type = REFTABLE_LOG_UPDATE ;
186
182
log -> value .update .name =
187
- xstrndup (split . name_begin , split . name_end - split . name_begin );
183
+ xstrndup (split -> name_begin , split -> name_end - split -> name_begin );
188
184
log -> value .update .email =
189
- xstrndup (split .mail_begin , split .mail_end - split .mail_begin );
190
- log -> value .update .time = atol (split .date_begin );
191
- if (* split .tz_begin == '-' ) {
185
+ xstrndup (split -> mail_begin , split -> mail_end - split -> mail_begin );
186
+ log -> value .update .time = atol (split -> date_begin );
187
+
188
+ tz_begin = split -> tz_begin ;
189
+ if (* tz_begin == '-' ) {
192
190
sign = -1 ;
193
- split . tz_begin ++ ;
191
+ tz_begin ++ ;
194
192
}
195
- if (* split . tz_begin == '+' ) {
193
+ if (* tz_begin == '+' ) {
196
194
sign = 1 ;
197
- split . tz_begin ++ ;
195
+ tz_begin ++ ;
198
196
}
199
197
200
- log -> value .update .tz_offset = sign * atoi (split . tz_begin );
198
+ log -> value .update .tz_offset = sign * atoi (tz_begin );
201
199
}
202
200
203
201
static int read_ref_without_reload (struct reftable_stack * stack ,
@@ -1021,9 +1019,15 @@ static int write_transaction_table(struct reftable_writer *writer, void *cb_data
1021
1019
reftable_stack_merged_table (arg -> stack );
1022
1020
uint64_t ts = reftable_stack_next_update_index (arg -> stack );
1023
1021
struct reftable_log_record * logs = NULL ;
1022
+ struct ident_split committer_ident = {0 };
1024
1023
size_t logs_nr = 0 , logs_alloc = 0 , i ;
1024
+ const char * committer_info ;
1025
1025
int ret = 0 ;
1026
1026
1027
+ committer_info = git_committer_info (0 );
1028
+ if (split_ident_line (& committer_ident , committer_info , strlen (committer_info )))
1029
+ BUG ("failed splitting committer info" );
1030
+
1027
1031
QSORT (arg -> updates , arg -> updates_nr , transaction_update_cmp );
1028
1032
1029
1033
reftable_writer_set_limits (writer , ts , ts );
@@ -1089,7 +1093,7 @@ static int write_transaction_table(struct reftable_writer *writer, void *cb_data
1089
1093
log = & logs [logs_nr ++ ];
1090
1094
memset (log , 0 , sizeof (* log ));
1091
1095
1092
- fill_reftable_log_record (log );
1096
+ fill_reftable_log_record (log , & committer_ident );
1093
1097
log -> update_index = ts ;
1094
1098
log -> refname = xstrdup (u -> refname );
1095
1099
memcpy (log -> value .update .new_hash , u -> new_oid .hash , GIT_MAX_RAWSZ );
@@ -1227,6 +1231,7 @@ static int reftable_be_pack_refs(struct ref_store *ref_store,
1227
1231
struct write_create_symref_arg {
1228
1232
struct reftable_ref_store * refs ;
1229
1233
struct reftable_stack * stack ;
1234
+ struct strbuf * err ;
1230
1235
const char * refname ;
1231
1236
const char * target ;
1232
1237
const char * logmsg ;
@@ -1242,13 +1247,20 @@ static int write_create_symref_table(struct reftable_writer *writer, void *cb_da
1242
1247
.value .symref = (char * )create -> target ,
1243
1248
.update_index = ts ,
1244
1249
};
1250
+ struct ident_split committer_ident = {0 };
1245
1251
struct reftable_log_record log = {0 };
1246
1252
struct object_id new_oid ;
1247
1253
struct object_id old_oid ;
1254
+ const char * committer_info ;
1248
1255
int ret ;
1249
1256
1250
1257
reftable_writer_set_limits (writer , ts , ts );
1251
1258
1259
+ ret = refs_verify_refname_available (& create -> refs -> base , create -> refname ,
1260
+ NULL , NULL , create -> err );
1261
+ if (ret < 0 )
1262
+ return ret ;
1263
+
1252
1264
ret = reftable_writer_add_ref (writer , & ref );
1253
1265
if (ret )
1254
1266
return ret ;
@@ -1267,7 +1279,11 @@ static int write_create_symref_table(struct reftable_writer *writer, void *cb_da
1267
1279
!should_write_log (& create -> refs -> base , create -> refname ))
1268
1280
return 0 ;
1269
1281
1270
- fill_reftable_log_record (& log );
1282
+ committer_info = git_committer_info (0 );
1283
+ if (split_ident_line (& committer_ident , committer_info , strlen (committer_info )))
1284
+ BUG ("failed splitting committer info" );
1285
+
1286
+ fill_reftable_log_record (& log , & committer_ident );
1271
1287
log .refname = xstrdup (create -> refname );
1272
1288
log .update_index = ts ;
1273
1289
log .value .update .message = xstrndup (create -> logmsg ,
@@ -1290,12 +1306,14 @@ static int reftable_be_create_symref(struct ref_store *ref_store,
1290
1306
struct reftable_ref_store * refs =
1291
1307
reftable_be_downcast (ref_store , REF_STORE_WRITE , "create_symref" );
1292
1308
struct reftable_stack * stack = stack_for (refs , refname , & refname );
1309
+ struct strbuf err = STRBUF_INIT ;
1293
1310
struct write_create_symref_arg arg = {
1294
1311
.refs = refs ,
1295
1312
.stack = stack ,
1296
1313
.refname = refname ,
1297
1314
.target = target ,
1298
1315
.logmsg = logmsg ,
1316
+ .err = & err ,
1299
1317
};
1300
1318
int ret ;
1301
1319
@@ -1311,9 +1329,15 @@ static int reftable_be_create_symref(struct ref_store *ref_store,
1311
1329
1312
1330
done :
1313
1331
assert (ret != REFTABLE_API_ERROR );
1314
- if (ret )
1315
- error ("unable to write symref for %s: %s" , refname ,
1316
- reftable_error_str (ret ));
1332
+ if (ret ) {
1333
+ if (err .len )
1334
+ error ("%s" , err .buf );
1335
+ else
1336
+ error ("unable to write symref for %s: %s" , refname ,
1337
+ reftable_error_str (ret ));
1338
+ }
1339
+
1340
+ strbuf_release (& err );
1317
1341
return ret ;
1318
1342
}
1319
1343
@@ -1335,10 +1359,16 @@ static int write_copy_table(struct reftable_writer *writer, void *cb_data)
1335
1359
struct reftable_log_record old_log = {0 }, * logs = NULL ;
1336
1360
struct reftable_iterator it = {0 };
1337
1361
struct string_list skip = STRING_LIST_INIT_NODUP ;
1362
+ struct ident_split committer_ident = {0 };
1338
1363
struct strbuf errbuf = STRBUF_INIT ;
1339
1364
size_t logs_nr = 0 , logs_alloc = 0 , i ;
1365
+ const char * committer_info ;
1340
1366
int ret ;
1341
1367
1368
+ committer_info = git_committer_info (0 );
1369
+ if (split_ident_line (& committer_ident , committer_info , strlen (committer_info )))
1370
+ BUG ("failed splitting committer info" );
1371
+
1342
1372
if (reftable_stack_read_ref (arg -> stack , arg -> oldname , & old_ref )) {
1343
1373
ret = error (_ ("refname %s not found" ), arg -> oldname );
1344
1374
goto done ;
@@ -1361,7 +1391,8 @@ static int write_copy_table(struct reftable_writer *writer, void *cb_data)
1361
1391
/*
1362
1392
* Verify that the new refname is available.
1363
1393
*/
1364
- string_list_insert (& skip , arg -> oldname );
1394
+ if (arg -> delete_old )
1395
+ string_list_insert (& skip , arg -> oldname );
1365
1396
ret = refs_verify_refname_available (& arg -> refs -> base , arg -> newname ,
1366
1397
NULL , & skip , & errbuf );
1367
1398
if (ret < 0 ) {
@@ -1412,7 +1443,7 @@ static int write_copy_table(struct reftable_writer *writer, void *cb_data)
1412
1443
1413
1444
ALLOC_GROW (logs , logs_nr + 1 , logs_alloc );
1414
1445
memset (& logs [logs_nr ], 0 , sizeof (logs [logs_nr ]));
1415
- fill_reftable_log_record (& logs [logs_nr ]);
1446
+ fill_reftable_log_record (& logs [logs_nr ], & committer_ident );
1416
1447
logs [logs_nr ].refname = (char * )arg -> newname ;
1417
1448
logs [logs_nr ].update_index = deletion_ts ;
1418
1449
logs [logs_nr ].value .update .message =
@@ -1444,7 +1475,7 @@ static int write_copy_table(struct reftable_writer *writer, void *cb_data)
1444
1475
*/
1445
1476
ALLOC_GROW (logs , logs_nr + 1 , logs_alloc );
1446
1477
memset (& logs [logs_nr ], 0 , sizeof (logs [logs_nr ]));
1447
- fill_reftable_log_record (& logs [logs_nr ]);
1478
+ fill_reftable_log_record (& logs [logs_nr ], & committer_ident );
1448
1479
logs [logs_nr ].refname = (char * )arg -> newname ;
1449
1480
logs [logs_nr ].update_index = creation_ts ;
1450
1481
logs [logs_nr ].value .update .message =
0 commit comments