Commit 2d9291943c253e9e1520f87b13abb1e81cffdb29

Russell Belfer 2014-02-07T16:14:17

Merge pull request #2099 from libgit2/bs/more-reflog-stuff More reflogness

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
diff --git a/examples/network/fetch.c b/examples/network/fetch.c
index 474b45b..ad16f27 100644
--- a/examples/network/fetch.c
+++ b/examples/network/fetch.c
@@ -156,7 +156,7 @@ int fetch(git_repository *repo, int argc, char **argv)
 	// right commits. This may be needed even if there was no packfile
 	// to download, which can happen e.g. when the branches have been
 	// changed but all the neede objects are available locally.
-	if (git_remote_update_tips(remote) < 0)
+	if (git_remote_update_tips(remote, NULL, NULL) < 0)
 		return -1;
 
 	git_remote_free(remote);
diff --git a/include/git2/push.h b/include/git2/push.h
index 12f0e7f..67702ac 100644
--- a/include/git2/push.h
+++ b/include/git2/push.h
@@ -103,10 +103,16 @@ GIT_EXTERN(int) git_push_add_refspec(git_push *push, const char *refspec);
  * Update remote tips after a push
  *
  * @param push The push object
+ * @param signature The identity to use when updating reflogs
+ * @param reflog_message The message to insert into the reflogs. If NULL, the
+ *                       default is "update by push".
  *
  * @return 0 or an error code
  */
-GIT_EXTERN(int) git_push_update_tips(git_push *push);
+GIT_EXTERN(int) git_push_update_tips(
+		git_push *push,
+		const git_signature *signature,
+		const char *reflog_message);
 
 /**
  * Actually push all given refspecs
diff --git a/include/git2/remote.h b/include/git2/remote.h
index eba6ca7..238b6fd 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -355,9 +355,16 @@ GIT_EXTERN(void) git_remote_free(git_remote *remote);
  * Update the tips to the new state
  *
  * @param remote the remote to update
+ * @param signature The identity to use when updating reflogs
+ * @param reflog_message The message to insert into the reflogs. If NULL, the
+ *                       default is "fetch <name>", where <name> is the name of
+ *                       the remote (or its url, for in-memory remotes).
  * @return 0 or an error code
  */
-GIT_EXTERN(int) git_remote_update_tips(git_remote *remote);
+GIT_EXTERN(int) git_remote_update_tips(
+		git_remote *remote,
+		const git_signature *signature,
+		const char *reflog_message);
 
 /**
  * Download new data and update tips
@@ -366,9 +373,15 @@ GIT_EXTERN(int) git_remote_update_tips(git_remote *remote);
  * disconnect and update the remote-tracking branches.
  *
  * @param remote the remote to fetch from
+ * @param signature The identity to use when updating reflogs
+ * @param reflog_message The message to insert into the reflogs. If NULL, the
+ *								 default is "fetch"
  * @return 0 or an error code
  */
-GIT_EXTERN(int) git_remote_fetch(git_remote *remote);
+GIT_EXTERN(int) git_remote_fetch(
+		git_remote *remote,
+		const git_signature *signature,
+		const char *reflog_message);
 
 /**
  * Return whether a string is a valid remote URL
diff --git a/include/git2/repository.h b/include/git2/repository.h
index 648667c..bf12c7a 100644
--- a/include/git2/repository.h
+++ b/include/git2/repository.h
@@ -615,11 +615,15 @@ GIT_EXTERN(int) git_repository_set_head_detached(
  * Otherwise, the HEAD will be detached and point to the peeled Commit.
  *
  * @param repo Repository pointer
+ * @param signature The identity that will used to populate the reflog entry
+ * @param log_message The one line long message to be appended to the reflog
  * @return 0 on success, GIT_EUNBORNBRANCH when HEAD points to a non existing
  * branch or an error code
  */
 GIT_EXTERN(int) git_repository_detach_head(
-	git_repository* repo);
+	git_repository* repo,
+	const git_signature *signature,
+	const char *reflog_message);
 
 typedef enum {
 	GIT_REPOSITORY_STATE_NONE,
diff --git a/include/git2/reset.h b/include/git2/reset.h
index c367817..1759cc0 100644
--- a/include/git2/reset.h
+++ b/include/git2/reset.h
@@ -48,10 +48,21 @@ typedef enum {
  *
  * @param reset_type Kind of reset operation to perform.
  *
+ * @param signature The identity that will used to populate the reflog entry
+ *
+ * @param log_message The one line long message to be appended to the reflog.
+ * The reflog is only updated if the affected direct reference is actually
+ * changing. If NULL, the default is "reset: moving"; if you want something more
+ * useful, provide a message.
+ *
  * @return 0 on success or an error code
  */
 GIT_EXTERN(int) git_reset(
-	git_repository *repo, git_object *target, git_reset_t reset_type);
+	git_repository *repo,
+	git_object *target,
+	git_reset_t reset_type,
+	git_signature *signature,
+	const char *log_message);
 
 /**
  * Updates some entries in the index from the target commit tree.
diff --git a/script/cibuild.sh b/script/cibuild.sh
index 5c0584a..1f15e85 100755
--- a/script/cibuild.sh
+++ b/script/cibuild.sh
@@ -34,5 +34,5 @@ export GITTEST_REMOTE_SSH_PUBKEY="$HOME/.ssh/id_rsa.pub"
 export GITTEST_REMOTE_SSH_PASSPHRASE=""
 
 if [ -e ./libgit2_clar ]; then
-    ./libgit2_clar -sonline::push
+    ./libgit2_clar -sonline::push -sonline::clone::cred_callback_failure
 fi
diff --git a/src/clone.c b/src/clone.c
index 3443528..bcc3867 100644
--- a/src/clone.c
+++ b/src/clone.c
@@ -360,7 +360,7 @@ int git_clone_into(git_repository *repo, git_remote *remote, const git_checkout_
 	git_remote_set_update_fetchhead(remote, 0);
 	git_buf_printf(&reflog_message, "clone: from %s", git_remote_url(remote));
 
-	if ((error = git_remote_fetch(remote)) != 0)
+	if ((error = git_remote_fetch(remote, signature, git_buf_cstr(&reflog_message))) != 0)
 		goto cleanup;
 
 	if (branch)
diff --git a/src/commit.c b/src/commit.c
index 730fa64..d66cf0c 100644
--- a/src/commit.c
+++ b/src/commit.c
@@ -111,8 +111,27 @@ int git_commit_create_from_ids(
 
 	git_buf_free(&commit);
 
-	if (update_ref != NULL)
-		return git_reference__update_terminal(repo, update_ref, oid, NULL, NULL);
+	if (update_ref != NULL) {
+		int error;
+		git_commit *c;
+		const char *shortmsg;
+		git_buf reflog_msg = GIT_BUF_INIT;
+
+		if (git_commit_lookup(&c, repo, oid) < 0)
+			goto on_error;
+
+		shortmsg = git_commit_summary(c);
+		git_buf_printf(&reflog_msg, "commit%s: %s",
+				git_commit_parentcount(c) == 0 ? " (initial)" : "",
+				shortmsg);
+		git_commit_free(c);
+
+		error = git_reference__update_terminal(repo, update_ref, oid,
+				committer, git_buf_cstr(&reflog_msg));
+
+		git_buf_free(&reflog_msg);
+		return error;
+	}
 
 	return 0;
 
diff --git a/src/push.c b/src/push.c
index d39a271..c294780 100644
--- a/src/push.c
+++ b/src/push.c
@@ -194,7 +194,10 @@ int git_push_add_refspec(git_push *push, const char *refspec)
 	return 0;
 }
 
-int git_push_update_tips(git_push *push)
+int git_push_update_tips(
+		git_push *push,
+		const git_signature *signature,
+		const char *reflog_message)
 {
 	git_buf remote_ref_name = GIT_BUF_INIT;
 	size_t i, j;
@@ -241,7 +244,9 @@ int git_push_update_tips(git_push *push)
 				giterr_clear();
 			else
 				goto on_error;
-		} else if ((error = git_reference_create(NULL, push->remote->repo, git_buf_cstr(&remote_ref_name), &push_spec->loid, 1, NULL, NULL)) < 0)
+		} else if ((error = git_reference_create(NULL, push->remote->repo,
+						git_buf_cstr(&remote_ref_name), &push_spec->loid, 1, signature,
+						reflog_message ? reflog_message : "update by push")) < 0)
 			goto on_error;
 	}
 
diff --git a/src/refs.c b/src/refs.c
index bdf2da3..3ba4b0a 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -1082,8 +1082,10 @@ static int reference__update_terminal(
 			nesting+1, signature, log_message);
 		git_reference_free(ref);
 	} else {
+		/* If we're not moving the target, don't recreate the ref */
+		if (0 != git_oid_cmp(git_reference_target(ref), oid))
+			error = git_reference_create(NULL, repo, ref_name, oid, 1, signature, log_message);
 		git_reference_free(ref);
-		error = git_reference_create(NULL, repo, ref_name, oid, 1, signature, log_message);
 	}
 
 	return error;
diff --git a/src/remote.c b/src/remote.c
index f33f5ef..f320f4a 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -845,9 +845,13 @@ int git_remote_download(git_remote *remote)
 	return git_fetch_download_pack(remote);
 }
 
-int git_remote_fetch(git_remote *remote)
+int git_remote_fetch(
+		git_remote *remote,
+		const git_signature *signature,
+		const char *reflog_message)
 {
 	int error;
+	git_buf reflog_msg_buf = GIT_BUF_INIT;
 
 	/* Connect and download everything */
 	if ((error = git_remote_connect(remote, GIT_DIRECTION_FETCH)) != 0)
@@ -859,8 +863,18 @@ int git_remote_fetch(git_remote *remote)
 	/* We don't need to be connected anymore */
 	git_remote_disconnect(remote);
 
+	/* Default reflog message */
+	if (reflog_message)
+		git_buf_sets(&reflog_msg_buf, reflog_message);
+	else {
+		git_buf_printf(&reflog_msg_buf, "fetch %s",
+				remote->name ? remote->name : remote->url);
+	}
+
 	/* Create "remote/foo" branches for all remote branches */
-	return git_remote_update_tips(remote);
+	error = git_remote_update_tips(remote, signature, git_buf_cstr(&reflog_msg_buf));
+	git_buf_free(&reflog_msg_buf);
+	return error;
 }
 
 static int remote_head_for_fetchspec_src(git_remote_head **out, git_vector *update_heads, const char *fetchspec_src)
@@ -978,7 +992,12 @@ cleanup:
 	return error;
 }
 
-static int update_tips_for_spec(git_remote *remote, git_refspec *spec, git_vector *refs)
+static int update_tips_for_spec(
+		git_remote *remote,
+		git_refspec *spec,
+		git_vector *refs,
+		const git_signature *signature,
+		const char *log_message)
 {
 	int error = 0, autotag;
 	unsigned int i = 0;
@@ -1045,7 +1064,8 @@ static int update_tips_for_spec(git_remote *remote, git_refspec *spec, git_vecto
 			continue;
 
 		/* In autotag mode, don't overwrite any locally-existing tags */
-		error = git_reference_create(&ref, remote->repo, refname.ptr, &head->oid, !autotag, NULL, NULL);
+		error = git_reference_create(&ref, remote->repo, refname.ptr, &head->oid, !autotag, 
+				signature, log_message);
 		if (error < 0 && error != GIT_EEXISTS)
 			goto on_error;
 
@@ -1074,7 +1094,10 @@ on_error:
 
 }
 
-int git_remote_update_tips(git_remote *remote)
+int git_remote_update_tips(
+		git_remote *remote,
+		const git_signature *signature,
+		const char *reflog_message)
 {
 	git_refspec *spec, tagspec;
 	git_vector refs;
@@ -1089,7 +1112,7 @@ int git_remote_update_tips(git_remote *remote)
 		goto out;
 
 	if (remote->download_tags == GIT_REMOTE_DOWNLOAD_TAGS_ALL) {
-		error = update_tips_for_spec(remote, &tagspec, &refs);
+		error = update_tips_for_spec(remote, &tagspec, &refs, signature, reflog_message);
 		goto out;
 	}
 
@@ -1097,7 +1120,7 @@ int git_remote_update_tips(git_remote *remote)
 		if (spec->push)
 			continue;
 
-		if ((error = update_tips_for_spec(remote, spec, &refs)) < 0)
+		if ((error = update_tips_for_spec(remote, spec, &refs, signature, reflog_message)) < 0)
 			goto out;
 	}
 
diff --git a/src/repository.c b/src/repository.c
index 44d0f0b..9f0c2f6 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -1891,7 +1891,9 @@ cleanup:
 }
 
 int git_repository_detach_head(
-	git_repository* repo)
+	git_repository* repo,
+	const git_signature *signature,
+	const char *reflog_message)
 {
 	git_reference *old_head = NULL,
 		*new_head = NULL;
@@ -1906,7 +1908,8 @@ int git_repository_detach_head(
 	if ((error = git_object_lookup(&object, repo, git_reference_target(old_head), GIT_OBJ_COMMIT)) < 0)
 		goto cleanup;
 
-	error = git_reference_create(&new_head, repo, GIT_HEAD_FILE, git_reference_target(old_head), 1, NULL, NULL);
+	error = git_reference_create(&new_head, repo, GIT_HEAD_FILE, git_reference_target(old_head),
+			1, signature, reflog_message);
 
 cleanup:
 	git_object_free(object);
diff --git a/src/reset.c b/src/reset.c
index 15f7fe1..07fd088 100644
--- a/src/reset.c
+++ b/src/reset.c
@@ -94,13 +94,16 @@ cleanup:
 int git_reset(
 	git_repository *repo,
 	git_object *target,
-	git_reset_t reset_type)
+	git_reset_t reset_type,
+	git_signature *signature,
+	const char *log_message)
 {
 	git_object *commit = NULL;
 	git_index *index = NULL;
 	git_tree *tree = NULL;
 	int error = 0;
 	git_checkout_opts opts = GIT_CHECKOUT_OPTS_INIT;
+	git_buf log_message_buf = GIT_BUF_INIT;
 
 	assert(repo && target);
 
@@ -129,9 +132,14 @@ int git_reset(
 		goto cleanup;
 	}
 
+	if (log_message)
+		git_buf_sets(&log_message_buf, log_message);
+	else
+		git_buf_sets(&log_message_buf, "reset: moving");
+
 	/* move HEAD to the new target */
 	if ((error = git_reference__update_terminal(repo, GIT_HEAD_FILE,
-		git_object_id(commit), NULL, NULL)) < 0)
+		git_object_id(commit), signature, git_buf_cstr(&log_message_buf))) < 0)
 		goto cleanup;
 
 	if (reset_type == GIT_RESET_HARD) {
diff --git a/tests/checkout/conflict.c b/tests/checkout/conflict.c
index a8b93b2..2fea511 100644
--- a/tests/checkout/conflict.c
+++ b/tests/checkout/conflict.c
@@ -61,12 +61,19 @@ struct checkout_name_entry {
 
 void test_checkout_conflict__initialize(void)
 {
+	git_config *cfg;
+
 	g_repo = cl_git_sandbox_init(TEST_REPO_PATH);
 	git_repository_index(&g_index, g_repo);
 
 	cl_git_rewritefile(
 		TEST_REPO_PATH "/.gitattributes",
 		"* text eol=lf\n");
+
+	/* Ensure that the user's merge.conflictstyle doesn't interfere */
+	cl_git_pass(git_repository_config(&cfg, g_repo));
+	cl_git_pass(git_config_set_string(cfg, "merge.conflictstyle", "merge"));
+	git_config_free(cfg);
 }
 
 void test_checkout_conflict__cleanup(void)
diff --git a/tests/checkout/tree.c b/tests/checkout/tree.c
index 407908a..f433b26 100644
--- a/tests/checkout/tree.c
+++ b/tests/checkout/tree.c
@@ -571,7 +571,7 @@ void test_checkout_tree__donot_update_deleted_file_by_default(void)
 
 	cl_git_pass(git_oid_fromstr(&old_id, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"));
 	cl_git_pass(git_commit_lookup(&old_commit, g_repo, &old_id));
-	cl_git_pass(git_reset(g_repo, (git_object *)old_commit, GIT_RESET_HARD));
+	cl_git_pass(git_reset(g_repo, (git_object *)old_commit, GIT_RESET_HARD, NULL, NULL));
 
 	cl_git_pass(p_unlink("testrepo/branch_file.txt"));
 	cl_git_pass(git_index_remove_bypath(index ,"branch_file.txt"));
diff --git a/tests/commit/write.c b/tests/commit/write.c
index 8e5b67f..b1cdf44 100644
--- a/tests/commit/write.c
+++ b/tests/commit/write.c
@@ -7,6 +7,8 @@ static const char *commit_message = "This commit has been created in memory\n\
 static const char *tree_oid = "1810dff58d8a660512d4832e740f692884338ccd";
 static const char *root_commit_message = "This is a root commit\n\
    This is a root commit and should be the only one in this branch\n";
+static const char *root_reflog_message = "commit (initial): This is a root commit \
+   This is a root commit and should be the only one in this branch";
 static char *head_old;
 static git_reference *head, *branch;
 static git_commit *commit;
@@ -101,6 +103,8 @@ void test_commit_write__root(void)
 	git_signature *author, *committer;
 	const char *branch_name = "refs/heads/root-commit-branch";
 	git_tree *tree;
+	git_reflog *log;
+	const git_reflog_entry *entry;
 
 	git_oid_fromstr(&tree_id, tree_oid);
 	cl_git_pass(git_tree_lookup(&tree, g_repo, &tree_id));
@@ -130,7 +134,6 @@ void test_commit_write__root(void)
 		0));
 
 	git_object_free((git_object *)tree);
-	git_signature_free(committer);
 	git_signature_free(author);
 
 	/*
@@ -144,4 +147,14 @@ void test_commit_write__root(void)
 	branch_oid = git_reference_target(branch);
 	cl_git_pass(git_oid_cmp(branch_oid, &commit_id));
 	cl_assert_equal_s(root_commit_message, git_commit_message(commit));
+
+	cl_git_pass(git_reflog_read(&log, g_repo, branch_name));
+	cl_assert_equal_i(1, git_reflog_entrycount(log));
+	entry = git_reflog_entry_byindex(log, 0);
+	cl_assert_equal_s(committer->email, git_reflog_entry_committer(entry)->email);
+	cl_assert_equal_s(committer->name, git_reflog_entry_committer(entry)->name);
+	cl_assert_equal_s(root_reflog_message, git_reflog_entry_message(entry));
+
+	git_signature_free(committer);
+	git_reflog_free(log);
 }
diff --git a/tests/index/names.c b/tests/index/names.c
index 9007b1b..4723449 100644
--- a/tests/index/names.c
+++ b/tests/index/names.c
@@ -86,10 +86,10 @@ void test_index_names__cleaned_on_reset_hard(void)
 {
 	git_object *target;
 
-	retrieve_target_from_oid(&target, repo, "3a34580a35add43a4cf361e8e9a30060a905c876");
+	cl_git_pass(git_revparse_single(&target, repo, "3a34580"));
 
 	test_index_names__add();
-	cl_git_pass(git_reset(repo, target, GIT_RESET_HARD));
+	cl_git_pass(git_reset(repo, target, GIT_RESET_HARD, NULL, NULL));
 	cl_assert(git_index_name_entrycount(repo_index) == 0);
 
 	git_object_free(target);
@@ -99,10 +99,10 @@ void test_index_names__cleaned_on_reset_mixed(void)
 {
 	git_object *target;
 
-	retrieve_target_from_oid(&target, repo, "3a34580a35add43a4cf361e8e9a30060a905c876");
+	cl_git_pass(git_revparse_single(&target, repo, "3a34580"));
 
 	test_index_names__add();
-	cl_git_pass(git_reset(repo, target, GIT_RESET_MIXED));
+	cl_git_pass(git_reset(repo, target, GIT_RESET_MIXED, NULL, NULL));
 	cl_assert(git_index_name_entrycount(repo_index) == 0);
 
 	git_object_free(target);
diff --git a/tests/index/reuc.c b/tests/index/reuc.c
index a18d560..bf051c8 100644
--- a/tests/index/reuc.c
+++ b/tests/index/reuc.c
@@ -295,10 +295,10 @@ void test_index_reuc__cleaned_on_reset_hard(void)
 {
 	git_object *target;
 
-	retrieve_target_from_oid(&target, repo, "3a34580a35add43a4cf361e8e9a30060a905c876");
+	cl_git_pass(git_revparse_single(&target, repo, "3a34580"));
 
 	test_index_reuc__add();
-	cl_git_pass(git_reset(repo, target, GIT_RESET_HARD));
+	cl_git_pass(git_reset(repo, target, GIT_RESET_HARD, NULL, NULL));
 	cl_assert(reuc_entry_exists() == false);
 
 	git_object_free(target);
@@ -308,10 +308,10 @@ void test_index_reuc__cleaned_on_reset_mixed(void)
 {
 	git_object *target;
 
-	retrieve_target_from_oid(&target, repo, "3a34580a35add43a4cf361e8e9a30060a905c876");
+	cl_git_pass(git_revparse_single(&target, repo, "3a34580"));
 
 	test_index_reuc__add();
-	cl_git_pass(git_reset(repo, target, GIT_RESET_MIXED));
+	cl_git_pass(git_reset(repo, target, GIT_RESET_MIXED, NULL, NULL));
 	cl_assert(reuc_entry_exists() == false);
 
 	git_object_free(target);
@@ -321,12 +321,12 @@ void test_index_reuc__retained_on_reset_soft(void)
 {
 	git_object *target;
 
-	retrieve_target_from_oid(&target, repo, "3a34580a35add43a4cf361e8e9a30060a905c876");
+	cl_git_pass(git_revparse_single(&target, repo, "3a34580"));
 
-	git_reset(repo, target, GIT_RESET_HARD);
+	git_reset(repo, target, GIT_RESET_HARD, NULL, NULL);
 
 	test_index_reuc__add();
-	cl_git_pass(git_reset(repo, target, GIT_RESET_SOFT));
+	cl_git_pass(git_reset(repo, target, GIT_RESET_SOFT, NULL, NULL));
 	cl_assert(reuc_entry_exists() == true);
 
 	git_object_free(target);
diff --git a/tests/merge/workdir/dirty.c b/tests/merge/workdir/dirty.c
index 625d3d0..a77f9b2 100644
--- a/tests/merge/workdir/dirty.c
+++ b/tests/merge/workdir/dirty.c
@@ -183,7 +183,7 @@ static void stage_content(char *content[])
 
 	cl_git_pass(git_repository_head(&head, repo));
 	cl_git_pass(git_reference_peel(&head_object, head, GIT_OBJ_COMMIT));
-	cl_git_pass(git_reset(repo, head_object, GIT_RESET_HARD));
+	cl_git_pass(git_reset(repo, head_object, GIT_RESET_HARD, NULL, NULL));
 
 	for (i = 0, filename = content[i], text = content[++i];
 		filename && text;
@@ -212,7 +212,7 @@ static int merge_dirty_files(char *dirty_files[])
 
 	cl_git_pass(git_repository_head(&head, repo));
 	cl_git_pass(git_reference_peel(&head_object, head, GIT_OBJ_COMMIT));
-	cl_git_pass(git_reset(repo, head_object, GIT_RESET_HARD));
+	cl_git_pass(git_reset(repo, head_object, GIT_RESET_HARD, NULL, NULL));
 
 	write_files(dirty_files);
 
@@ -234,7 +234,7 @@ static int merge_differently_filtered_files(char *files[])
 
 	cl_git_pass(git_repository_head(&head, repo));
 	cl_git_pass(git_reference_peel(&head_object, head, GIT_OBJ_COMMIT));
-	cl_git_pass(git_reset(repo, head_object, GIT_RESET_HARD));
+	cl_git_pass(git_reset(repo, head_object, GIT_RESET_HARD, NULL, NULL));
 
 	write_files(files);
 	hack_index(files);
diff --git a/tests/merge/workdir/renames.c b/tests/merge/workdir/renames.c
index d383979..2774772 100644
--- a/tests/merge/workdir/renames.c
+++ b/tests/merge/workdir/renames.c
@@ -17,7 +17,14 @@ static git_repository *repo;
 // Fixture setup and teardown
 void test_merge_workdir_renames__initialize(void)
 {
+	git_config *cfg;
+
 	repo = cl_git_sandbox_init(TEST_REPO_PATH);
+
+	/* Ensure that the user's merge.conflictstyle doesn't interfere */
+	cl_git_pass(git_repository_config(&cfg, repo));
+	cl_git_pass(git_config_set_string(cfg, "merge.conflictstyle", "merge"));
+	git_config_free(cfg);
 }
 
 void test_merge_workdir_renames__cleanup(void)
diff --git a/tests/merge/workdir/simple.c b/tests/merge/workdir/simple.c
index 4ff761c..a9a6365 100644
--- a/tests/merge/workdir/simple.c
+++ b/tests/merge/workdir/simple.c
@@ -116,8 +116,15 @@ static git_index *repo_index;
 // Fixture setup and teardown
 void test_merge_workdir_simple__initialize(void)
 {
+	git_config *cfg;
+
 	repo = cl_git_sandbox_init(TEST_REPO_PATH);
 	git_repository_index(&repo_index, repo);
+
+	/* Ensure that the user's merge.conflictstyle doesn't interfere */
+	cl_git_pass(git_repository_config(&cfg, repo));
+	cl_git_pass(git_config_set_string(cfg, "merge.conflictstyle", "merge"));
+	git_config_free(cfg);
 }
 
 void test_merge_workdir_simple__cleanup(void)
@@ -585,7 +592,7 @@ void test_merge_workdir_simple__directory_file(void)
 	cl_git_pass(git_reference_symbolic_create(&head, repo, GIT_HEAD_FILE, GIT_REFS_HEADS_DIR OURS_DIRECTORY_FILE, 1, NULL, NULL));
 	cl_git_pass(git_reference_name_to_id(&head_commit_id, repo, GIT_HEAD_FILE));
 	cl_git_pass(git_commit_lookup(&head_commit, repo, &head_commit_id));
-	cl_git_pass(git_reset(repo, (git_object *)head_commit, GIT_RESET_HARD));
+	cl_git_pass(git_reset(repo, (git_object *)head_commit, GIT_RESET_HARD, NULL, NULL));
 
 	cl_git_pass(git_oid_fromstr(&their_oids[0], THEIRS_DIRECTORY_FILE));
 	cl_git_pass(git_merge_head_from_id(&their_heads[0], repo, &their_oids[0]));
@@ -684,7 +691,7 @@ void test_merge_workdir_simple__binary(void)
 	cl_git_pass(git_oid_fromstr(&their_oid, "ad01aebfdf2ac13145efafe3f9fcf798882f1730"));
 
 	cl_git_pass(git_commit_lookup(&our_commit, repo, &our_oid));
-	cl_git_pass(git_reset(repo, (git_object *)our_commit, GIT_RESET_HARD));
+	cl_git_pass(git_reset(repo, (git_object *)our_commit, GIT_RESET_HARD, NULL, NULL));
 
 	cl_git_pass(git_merge_head_from_id(&their_head, repo, &their_oid));
 
diff --git a/tests/merge/workdir/submodules.c b/tests/merge/workdir/submodules.c
index f01faac..42451bd 100644
--- a/tests/merge/workdir/submodules.c
+++ b/tests/merge/workdir/submodules.c
@@ -46,7 +46,7 @@ void test_merge_workdir_submodules__automerge(void)
 
 	cl_git_pass(git_reference_lookup(&our_ref, repo, "refs/heads/" SUBMODULE_MAIN_BRANCH));
 	cl_git_pass(git_commit_lookup(&our_commit, repo, git_reference_target(our_ref)));
-	cl_git_pass(git_reset(repo, (git_object *)our_commit, GIT_RESET_HARD));
+	cl_git_pass(git_reset(repo, (git_object *)our_commit, GIT_RESET_HARD, NULL, NULL));
 
 	cl_git_pass(git_reference_lookup(&their_ref, repo, "refs/heads/" SUBMODULE_OTHER_BRANCH));
 	cl_git_pass(git_merge_head_from_ref(&their_head, repo, their_ref));
@@ -82,7 +82,7 @@ void test_merge_workdir_submodules__take_changed(void)
 
 	cl_git_pass(git_reference_lookup(&our_ref, repo, "refs/heads/" SUBMODULE_MAIN_BRANCH));
 	cl_git_pass(git_commit_lookup(&our_commit, repo, git_reference_target(our_ref)));
-	cl_git_pass(git_reset(repo, (git_object *)our_commit, GIT_RESET_HARD));
+	cl_git_pass(git_reset(repo, (git_object *)our_commit, GIT_RESET_HARD, NULL, NULL));
 
 	cl_git_pass(git_reference_lookup(&their_ref, repo, "refs/heads/" SUBMODULE_OTHER2_BRANCH));
 	cl_git_pass(git_merge_head_from_ref(&their_head, repo, their_ref));
diff --git a/tests/network/fetchlocal.c b/tests/network/fetchlocal.c
index 28c7115..4c39394 100644
--- a/tests/network/fetchlocal.c
+++ b/tests/network/fetchlocal.c
@@ -37,7 +37,7 @@ void test_network_fetchlocal__complete(void)
 	git_remote_set_callbacks(origin, &callbacks);
 	cl_git_pass(git_remote_connect(origin, GIT_DIRECTION_FETCH));
 	cl_git_pass(git_remote_download(origin));
-	cl_git_pass(git_remote_update_tips(origin));
+	cl_git_pass(git_remote_update_tips(origin, NULL, NULL));
 
 	cl_git_pass(git_reference_list(&refnames, repo));
 	cl_assert_equal_i(19, (int)refnames.count);
@@ -75,7 +75,7 @@ void test_network_fetchlocal__partial(void)
 	git_remote_set_callbacks(origin, &callbacks);
 	cl_git_pass(git_remote_connect(origin, GIT_DIRECTION_FETCH));
 	cl_git_pass(git_remote_download(origin));
-	cl_git_pass(git_remote_update_tips(origin));
+	cl_git_pass(git_remote_update_tips(origin, NULL, NULL));
 
 	git_strarray_free(&refnames);
 
diff --git a/tests/network/remote/local.c b/tests/network/remote/local.c
index 9b9f716..589e6ac 100644
--- a/tests/network/remote/local.c
+++ b/tests/network/remote/local.c
@@ -115,7 +115,7 @@ void test_network_remote_local__shorthand_fetch_refspec0(void)
 	cl_git_pass(git_remote_add_fetch(remote, refspec2));
 
 	cl_git_pass(git_remote_download(remote));
-	cl_git_pass(git_remote_update_tips(remote));
+	cl_git_pass(git_remote_update_tips(remote, NULL, NULL));
 
 	cl_git_pass(git_reference_lookup(&ref, repo, "refs/remotes/sloppy/master"));
 	git_reference_free(ref);
@@ -137,7 +137,7 @@ void test_network_remote_local__shorthand_fetch_refspec1(void)
 	cl_git_pass(git_remote_add_fetch(remote, refspec2));
 
 	cl_git_pass(git_remote_download(remote));
-	cl_git_pass(git_remote_update_tips(remote));
+	cl_git_pass(git_remote_update_tips(remote, NULL, NULL));
 
 	cl_git_fail(git_reference_lookup(&ref, repo, "refs/remotes/master"));
 
@@ -152,7 +152,7 @@ void test_network_remote_local__tagopt(void)
 	git_remote_set_autotag(remote, GIT_REMOTE_DOWNLOAD_TAGS_ALL);
 
 	cl_git_pass(git_remote_download(remote));
-	cl_git_pass(git_remote_update_tips(remote));
+	cl_git_pass(git_remote_update_tips(remote, NULL, NULL));
 
 
 	cl_git_fail(git_reference_lookup(&ref, repo, "refs/remotes/master"));
@@ -171,7 +171,7 @@ void test_network_remote_local__push_to_bare_remote(void)
 	connect_to_local_repository(cl_fixture("testrepo.git"));
 	cl_git_pass(git_remote_add_fetch(remote, "master:master"));
 	cl_git_pass(git_remote_download(remote));
-	cl_git_pass(git_remote_update_tips(remote));
+	cl_git_pass(git_remote_update_tips(remote, NULL, NULL));
 	git_remote_disconnect(remote);
 
 	/* Set up an empty bare repo to push into */
@@ -208,7 +208,7 @@ void test_network_remote_local__push_to_bare_remote_with_file_url(void)
 	connect_to_local_repository(cl_fixture("testrepo.git"));
 	cl_git_pass(git_remote_add_fetch(remote, "master:master"));
 	cl_git_pass(git_remote_download(remote));
-	cl_git_pass(git_remote_update_tips(remote));
+	cl_git_pass(git_remote_update_tips(remote, NULL, NULL));
 	git_remote_disconnect(remote);
 
 	/* Set up an empty bare repo to push into */
@@ -248,7 +248,7 @@ void test_network_remote_local__push_to_non_bare_remote(void)
 	connect_to_local_repository(cl_fixture("testrepo.git"));
 	cl_git_pass(git_remote_add_fetch(remote, "master:master"));
 	cl_git_pass(git_remote_download(remote));
-	cl_git_pass(git_remote_update_tips(remote));
+	cl_git_pass(git_remote_update_tips(remote, NULL, NULL));
 	git_remote_disconnect(remote);
 
 	/* Set up an empty non-bare repo to push into */
@@ -273,3 +273,86 @@ void test_network_remote_local__push_to_non_bare_remote(void)
 	git_remote_free(localremote);
 	cl_fixture_cleanup("localbare.git");
 }
+
+void test_network_remote_local__fetch(void)
+{
+	const char *refspec = "master:remotes/sloppy/master";
+
+	git_reflog *log;
+	const git_reflog_entry *entry;
+	git_signature *sig;
+	git_reference *ref;
+
+	cl_git_pass(git_signature_now(&sig, "Foo Bar", "foo@example.com"));
+
+	connect_to_local_repository(cl_fixture("testrepo.git"));
+	cl_git_pass(git_remote_add_fetch(remote, refspec));
+
+	cl_git_pass(git_remote_fetch(remote, sig, "UPDAAAAAATE!!"));
+
+	cl_git_pass(git_reference_lookup(&ref, repo, "refs/remotes/sloppy/master"));
+	git_reference_free(ref);
+
+	cl_git_pass(git_reflog_read(&log, repo, "refs/remotes/sloppy/master"));
+	cl_assert_equal_i(1, git_reflog_entrycount(log));
+	entry = git_reflog_entry_byindex(log, 0);
+	cl_assert_equal_s("foo@example.com", git_reflog_entry_committer(entry)->email);
+	cl_assert_equal_s("UPDAAAAAATE!!", git_reflog_entry_message(entry));
+
+	git_reflog_free(log);
+	git_signature_free(sig);
+}
+
+void test_network_remote_local__reflog(void)
+{
+	const char *refspec = "master:remotes/sloppy/master";
+
+	git_reflog *log;
+	const git_reflog_entry *entry;
+	git_signature *sig;
+
+	cl_git_pass(git_signature_now(&sig, "Foo Bar", "foo@example.com"));
+
+	connect_to_local_repository(cl_fixture("testrepo.git"));
+	cl_git_pass(git_remote_add_fetch(remote, refspec));
+
+	cl_git_pass(git_remote_download(remote));
+	cl_git_pass(git_remote_update_tips(remote, sig, "UPDAAAAAATE!!"));
+
+	cl_git_pass(git_reflog_read(&log, repo, "refs/remotes/sloppy/master"));
+	cl_assert_equal_i(1, git_reflog_entrycount(log));
+	entry = git_reflog_entry_byindex(log, 0);
+	cl_assert_equal_s("foo@example.com", git_reflog_entry_committer(entry)->email);
+	cl_assert_equal_s("UPDAAAAAATE!!", git_reflog_entry_message(entry));
+
+	git_reflog_free(log);
+	git_signature_free(sig);
+}
+
+void test_network_remote_local__fetch_default_reflog_message(void)
+{
+	const char *refspec = "master:remotes/sloppy/master";
+
+	git_reflog *log;
+	const git_reflog_entry *entry;
+	git_signature *sig;
+	char expected_reflog_msg[1024];
+
+	cl_git_pass(git_signature_now(&sig, "Foo Bar", "foo@example.com"));
+
+	connect_to_local_repository(cl_fixture("testrepo.git"));
+	cl_git_pass(git_remote_add_fetch(remote, refspec));
+
+	cl_git_pass(git_remote_fetch(remote, sig, NULL));
+
+	cl_git_pass(git_reflog_read(&log, repo, "refs/remotes/sloppy/master"));
+	cl_assert_equal_i(1, git_reflog_entrycount(log));
+	entry = git_reflog_entry_byindex(log, 0);
+	cl_assert_equal_s("foo@example.com", git_reflog_entry_committer(entry)->email);
+
+	sprintf(expected_reflog_msg, "fetch %s", git_remote_url(remote));
+	cl_assert_equal_s(expected_reflog_msg, git_reflog_entry_message(entry));
+
+	git_reflog_free(log);
+	git_signature_free(sig);
+}
diff --git a/tests/online/clone.c b/tests/online/clone.c
index 1222d17..fa2408a 100644
--- a/tests/online/clone.c
+++ b/tests/online/clone.c
@@ -192,30 +192,28 @@ static int cred_failure_cb(
 {
 	GIT_UNUSED(cred); GIT_UNUSED(url); GIT_UNUSED(username_from_url);
 	GIT_UNUSED(allowed_types); GIT_UNUSED(data);
-	return -1;
+	return -172;
 }
 
-void test_online_clone__cred_callback_failure_is_euser(void)
+void test_online_clone__cred_callback_failure_return_code_is_tunnelled(void)
 {
 	const char *remote_url = cl_getenv("GITTEST_REMOTE_URL");
 	const char *remote_user = cl_getenv("GITTEST_REMOTE_USER");
-	const char *remote_default = cl_getenv("GITTEST_REMOTE_DEFAULT");
-	int error;
 
 	if (!remote_url) {
 		printf("GITTEST_REMOTE_URL unset; skipping clone test\n");
 		return;
 	}
 
-	if (!remote_user && !remote_default) {
-		printf("GITTEST_REMOTE_USER and GITTEST_REMOTE_DEFAULT unset; skipping clone test\n");
+	if (!remote_user) {
+		printf("GITTEST_REMOTE_USER unset; skipping clone test\n");
 		return;
 	}
 
 	g_options.remote_callbacks.credentials = cred_failure_cb;
 
-	cl_git_fail(error = git_clone(&g_repo, remote_url, "./foo", &g_options));
-	cl_assert_equal_i(error, GIT_EUSER);
+	/* TODO: this should expect -172. */
+	cl_git_fail_with(git_clone(&g_repo, remote_url, "./foo", &g_options), -1);
 }
 
 void test_online_clone__credentials(void)
diff --git a/tests/online/fetch.c b/tests/online/fetch.c
index 8f71cf3..cb84e84 100644
--- a/tests/online/fetch.c
+++ b/tests/online/fetch.c
@@ -48,7 +48,7 @@ static void do_fetch(const char *url, git_remote_autotag_option_t flag, int n)
 	git_remote_set_autotag(remote, flag);
 	cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH));
 	cl_git_pass(git_remote_download(remote));
-	cl_git_pass(git_remote_update_tips(remote));
+	cl_git_pass(git_remote_update_tips(remote, NULL, NULL));
 	git_remote_disconnect(remote);
 	cl_assert_equal_i(counter, n);
 	cl_assert(bytes_received > 0);
@@ -117,7 +117,7 @@ void test_online_fetch__doesnt_retrieve_a_pack_when_the_repository_is_up_to_date
 
 	cl_assert_equal_i(false, invoked);
 
-	cl_git_pass(git_remote_update_tips(remote));
+	cl_git_pass(git_remote_update_tips(remote, NULL, NULL));
 	git_remote_disconnect(remote);
 
 	git_remote_free(remote);
diff --git a/tests/online/fetchhead.c b/tests/online/fetchhead.c
index 57b183f..0b3f20d 100644
--- a/tests/online/fetchhead.c
+++ b/tests/online/fetchhead.c
@@ -51,7 +51,7 @@ static void fetchhead_test_fetch(const char *fetchspec, const char *expected_fet
 
 	cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH));
 	cl_git_pass(git_remote_download(remote));
-	cl_git_pass(git_remote_update_tips(remote));
+	cl_git_pass(git_remote_update_tips(remote, NULL, NULL));
 	git_remote_disconnect(remote);
 	git_remote_free(remote);
 
diff --git a/tests/online/push.c b/tests/online/push.c
index 8efe21e..55b97b2 100644
--- a/tests/online/push.c
+++ b/tests/online/push.c
@@ -351,7 +351,7 @@ void test_online_push__initialize(void)
 		/* Now that we've deleted everything, fetch from the remote */
 		cl_git_pass(git_remote_connect(_remote, GIT_DIRECTION_FETCH));
 		cl_git_pass(git_remote_download(_remote));
-		cl_git_pass(git_remote_update_tips(_remote));
+		cl_git_pass(git_remote_update_tips(_remote, NULL, NULL));
 		git_remote_disconnect(_remote);
 	} else
 		printf("GITTEST_REMOTE_URL unset; skipping push test\n");
@@ -414,11 +414,13 @@ static void do_push(
 	git_push_options opts = GIT_PUSH_OPTIONS_INIT;
 	size_t i;
 	int pack_progress_calls = 0, transfer_progress_calls = 0;
+	git_signature *pusher;
 
 	if (_remote) {
 		/* Auto-detect the number of threads to use */
 		opts.pb_parallelism = 0;
 
+		cl_git_pass(git_signature_now(&pusher, "Foo Bar", "foo@example.com"));
 		cl_git_pass(git_remote_connect(_remote, GIT_DIRECTION_PUSH));
 
 		cl_git_pass(git_push_new(&push, _remote));
@@ -455,13 +457,15 @@ static void do_push(
 
 		verify_refs(_remote, expected_refs, expected_refs_len);
 
-		cl_git_pass(git_push_update_tips(push));
+		cl_git_pass(git_push_update_tips(push, pusher, "test push"));
 		verify_tracking_branches(_remote, expected_refs, expected_refs_len);
 
 		git_push_free(push);
 
 		git_remote_disconnect(_remote);
+		git_signature_free(pusher);
 	}
+
 }
 
 /* Call push_finish() without ever calling git_push_add_refspec() */
@@ -528,6 +532,9 @@ void test_online_push__b5_cancel(void)
 
 void test_online_push__multi(void)
 {
+	git_reflog *log;
+	const git_reflog_entry *entry;
+
 	const char *specs[] = {
 		"refs/heads/b1:refs/heads/b1",
 		"refs/heads/b2:refs/heads/b2",
@@ -552,6 +559,15 @@ void test_online_push__multi(void)
 	do_push(specs, ARRAY_SIZE(specs),
 		exp_stats, ARRAY_SIZE(exp_stats),
 		exp_refs, ARRAY_SIZE(exp_refs), 0, 1);
+
+	cl_git_pass(git_reflog_read(&log, _repo, "refs/remotes/test/b1"));
+	entry = git_reflog_entry_byindex(log, 0);
+	if (entry) {
+		cl_assert_equal_s("test push", git_reflog_entry_message(entry));
+		cl_assert_equal_s("foo@example.com", git_reflog_entry_committer(entry)->email);
+	}
+
+	git_reflog_free(log);
 }
 
 void test_online_push__implicit_tgt(void)
diff --git a/tests/refs/branches/create.c b/tests/refs/branches/create.c
index abe5f59..94ecc0b 100644
--- a/tests/refs/branches/create.c
+++ b/tests/refs/branches/create.c
@@ -29,15 +29,16 @@ void test_refs_branches_create__cleanup(void)
 
 static void retrieve_target_from_oid(git_commit **out, git_repository *repo, const char *sha)
 {
-	git_oid oid;
+	git_object *obj;
 
-	cl_git_pass(git_oid_fromstr(&oid, sha));
-	cl_git_pass(git_commit_lookup(out, repo, &oid));
+	cl_git_pass(git_revparse_single(&obj, repo, sha));
+	cl_git_pass(git_commit_lookup(out, repo, git_object_id(obj)));
+	git_object_free(obj);
 }
 
 static void retrieve_known_commit(git_commit **commit, git_repository *repo)
 {
-	retrieve_target_from_oid(commit, repo, "e90810b8df3e80c413d903f631643c716887138d");
+	retrieve_target_from_oid(commit, repo, "e90810b8df3");
 }
 
 #define NEW_BRANCH_NAME "new-branch-on-the-block"
diff --git a/tests/refs/branches/delete.c b/tests/refs/branches/delete.c
index 7d1d400..ed5f162 100644
--- a/tests/refs/branches/delete.c
+++ b/tests/refs/branches/delete.c
@@ -78,7 +78,7 @@ void test_refs_branches_delete__can_delete_a_branch_pointed_at_by_detached_HEAD(
 	git_reference_free(head);
 
 	/* Detach HEAD and make it target the commit that "master" points to */
-	git_repository_detach_head(repo);
+	git_repository_detach_head(repo, NULL, NULL);
 
 	cl_git_pass(git_branch_lookup(&branch, repo, "master", GIT_BRANCH_LOCAL));
 	cl_git_pass(git_branch_delete(branch));
diff --git a/tests/repo/head.c b/tests/repo/head.c
index 127176d..c5965fa 100644
--- a/tests/repo/head.c
+++ b/tests/repo/head.c
@@ -15,21 +15,42 @@ void test_repo_head__cleanup(void)
 	cl_git_sandbox_cleanup();
 }
 
+static void check_last_reflog_entry(const char *email, const char *message)
+{
+	git_reflog *log;
+	const git_reflog_entry *entry;
+
+	cl_git_pass(git_reflog_read(&log, repo, GIT_HEAD_FILE));
+	cl_assert(git_reflog_entrycount(log) > 0);
+	entry = git_reflog_entry_byindex(log, 0);
+	if (email)
+		cl_assert_equal_s(email, git_reflog_entry_committer(entry)->email);
+	if (message)
+		cl_assert_equal_s(message, git_reflog_entry_message(entry));
+	git_reflog_free(log);
+}
+
 void test_repo_head__head_detached(void)
 {
 	git_reference *ref;
+	git_signature *sig;
 
-	cl_git_pass(git_repository_head_detached(repo));
+	cl_git_pass(git_signature_now(&sig, "Foo Bar", "foo@example.com"));
 
-	cl_git_pass(git_repository_detach_head(repo));
+	cl_assert_equal_i(false, git_repository_head_detached(repo));
 
+	cl_git_pass(git_repository_detach_head(repo, sig, "CABLE DETACHED"));
+	check_last_reflog_entry(sig->email, "CABLE DETACHED");
 	cl_assert_equal_i(true, git_repository_head_detached(repo));
 
-	/* take the reop back to it's original state */
-	cl_git_pass(git_reference_symbolic_create(&ref, repo, "HEAD", "refs/heads/master", 1, NULL, NULL));
+	/* take the repo back to it's original state */
+	cl_git_pass(git_reference_symbolic_create(&ref, repo, "HEAD", "refs/heads/master",
+				true, sig, "REATTACH"));
 	git_reference_free(ref);
 
+	check_last_reflog_entry(sig->email, "REATTACH");
 	cl_assert_equal_i(false, git_repository_head_detached(repo));
+	git_signature_free(sig);
 }
 
 void test_repo_head__unborn_head(void)
@@ -147,7 +168,7 @@ void test_repo_head__detach_head_Detaches_HEAD_and_make_it_point_to_the_peeled_c
 {
 	cl_assert_equal_i(false, git_repository_head_detached(repo));
 
-	cl_git_pass(git_repository_detach_head(repo));
+	cl_git_pass(git_repository_detach_head(repo, NULL, NULL));
 
 	assert_head_is_correctly_detached();
 }
@@ -158,7 +179,7 @@ void test_repo_head__detach_head_Fails_if_HEAD_and_point_to_a_non_commitish(void
 
 	cl_git_pass(git_reference_symbolic_create(&head, repo, GIT_HEAD_FILE, "refs/tags/point_to_blob", 1, NULL, NULL));
 
-	cl_git_fail(git_repository_detach_head(repo));
+	cl_git_fail(git_repository_detach_head(repo, NULL, NULL));
 
 	git_reference_free(head);
 }
@@ -167,7 +188,7 @@ void test_repo_head__detaching_an_unborn_branch_returns_GIT_EUNBORNBRANCH(void)
 {
 	make_head_unborn(repo, NON_EXISTING_HEAD);
 
-	cl_assert_equal_i(GIT_EUNBORNBRANCH, git_repository_detach_head(repo));
+	cl_assert_equal_i(GIT_EUNBORNBRANCH, git_repository_detach_head(repo, NULL, NULL));
 }
 
 void test_repo_head__retrieving_an_unborn_branch_returns_GIT_EUNBORNBRANCH(void)
diff --git a/tests/repo/headtree.c b/tests/repo/headtree.c
index e899ac3..79d88c0 100644
--- a/tests/repo/headtree.c
+++ b/tests/repo/headtree.c
@@ -20,7 +20,7 @@ void test_repo_headtree__cleanup(void)
 
 void test_repo_headtree__can_retrieve_the_root_tree_from_a_detached_head(void)
 {
-	cl_git_pass(git_repository_detach_head(repo));
+	cl_git_pass(git_repository_detach_head(repo, NULL, NULL));
 
 	cl_git_pass(git_repository_head_tree(&tree, repo));
 
diff --git a/tests/repo/state.c b/tests/repo/state.c
index 5a0a5f3..5e72272 100644
--- a/tests/repo/state.c
+++ b/tests/repo/state.c
@@ -37,7 +37,7 @@ void test_repo_state__none_with_HEAD_attached(void)
 
 void test_repo_state__none_with_HEAD_detached(void)
 {
-	cl_git_pass(git_repository_detach_head(_repo));
+	cl_git_pass(git_repository_detach_head(_repo, NULL, NULL));
 	assert_repo_state(GIT_REPOSITORY_STATE_NONE);
 }
 
diff --git a/tests/reset/hard.c b/tests/reset/hard.c
index 0f80d32..d4c7db4 100644
--- a/tests/reset/hard.c
+++ b/tests/reset/hard.c
@@ -69,10 +69,9 @@ void test_reset_hard__resetting_reverts_modified_files(void)
 		cl_assert_equal_s(before[i], content.ptr);
 	}
 
-	retrieve_target_from_oid(
-		&target, repo, "26a125ee1bfc5df1e1b2e9441bbe63c8a7ae989f");
+	cl_git_pass(git_revparse_single(&target, repo, "26a125e"));
 
-	cl_git_pass(git_reset(repo, target, GIT_RESET_HARD));
+	cl_git_pass(git_reset(repo, target, GIT_RESET_HARD, NULL, NULL));
 
 	for (i = 0; i < 4; ++i) {
 		cl_git_pass(git_buf_joinpath(&path, wd, files[i]));
@@ -95,9 +94,9 @@ void test_reset_hard__cannot_reset_in_a_bare_repository(void)
 	cl_git_pass(git_repository_open(&bare, cl_fixture("testrepo.git")));
 	cl_assert(git_repository_is_bare(bare) == true);
 
-	retrieve_target_from_oid(&target, bare, KNOWN_COMMIT_IN_BARE_REPO);
+	cl_git_pass(git_revparse_single(&target, bare, KNOWN_COMMIT_IN_BARE_REPO));
 
-	cl_assert_equal_i(GIT_EBAREREPO, git_reset(bare, target, GIT_RESET_HARD));
+	cl_assert_equal_i(GIT_EBAREREPO, git_reset(bare, target, GIT_RESET_HARD, NULL, NULL));
 
 	git_repository_free(bare);
 }
@@ -152,8 +151,8 @@ void test_reset_hard__resetting_reverts_unmerged(void)
 		unmerged_index_init(index, entries);
 		cl_git_pass(git_index_write(index));
 
-		retrieve_target_from_oid(&target, repo, "26a125ee1bfc5df1e1b2e9441bbe63c8a7ae989f");
-		cl_git_pass(git_reset(repo, target, GIT_RESET_HARD));
+		cl_git_pass(git_revparse_single(&target, repo, "26a125e"));
+		cl_git_pass(git_reset(repo, target, GIT_RESET_HARD, NULL, NULL));
 
 		cl_assert(git_path_exists("status/conflicting_file") == 0);
 
@@ -183,8 +182,8 @@ void test_reset_hard__cleans_up_merge(void)
 	cl_git_pass(git_buf_joinpath(&orig_head_path, git_repository_path(repo), "ORIG_HEAD"));
 	cl_git_mkfile(git_buf_cstr(&orig_head_path), "0017bd4ab1ec30440b17bae1680cff124ab5f1f6");
 
-	retrieve_target_from_oid(&target, repo, "0017bd4ab1ec30440b17bae1680cff124ab5f1f6");
-	cl_git_pass(git_reset(repo, target, GIT_RESET_HARD));
+	cl_git_pass(git_revparse_single(&target, repo, "0017bd4"));
+	cl_git_pass(git_reset(repo, target, GIT_RESET_HARD, NULL, NULL));
 
 	cl_assert(!git_path_exists(git_buf_cstr(&merge_head_path)));
 	cl_assert(!git_path_exists(git_buf_cstr(&merge_msg_path)));
@@ -198,3 +197,30 @@ void test_reset_hard__cleans_up_merge(void)
 	git_buf_free(&merge_mode_path);
 	git_buf_free(&orig_head_path);
 }
+
+void test_reset_hard__reflog_is_correct(void)
+{
+	const char *exp_msg = "commit: Add a file which name should appear before the "
+		"\"subdir/\" folder while being dealt with by the treewalker";
+
+	reflog_check(repo, "HEAD", 3, "emeric.fermas@gmail.com", exp_msg);
+	reflog_check(repo, "refs/heads/master", 3, "emeric.fermas@gmail.com", exp_msg);
+
+	/* Branch not moving, no reflog entry */
+	cl_git_pass(git_revparse_single(&target, repo, "HEAD^{commit}"));
+	cl_git_pass(git_reset(repo, target, GIT_RESET_HARD, NULL, NULL));
+	reflog_check(repo, "HEAD", 3, "emeric.fermas@gmail.com", exp_msg);
+	reflog_check(repo, "refs/heads/master", 3, "emeric.fermas@gmail.com", exp_msg);
+
+	/* Moved branch, expect default message */
+	cl_git_pass(git_revparse_single(&target, repo, "HEAD~^{commit}"));
+	cl_git_pass(git_reset(repo, target, GIT_RESET_HARD, NULL, NULL));
+	reflog_check(repo, "HEAD", 3, "emeric.fermas@gmail.com", exp_msg);
+	reflog_check(repo, "refs/heads/master", 4, NULL, "reset: moving");
+
+	/* Moved branch, expect custom message */
+	cl_git_pass(git_revparse_single(&target, repo, "HEAD~^{commit}"));
+	cl_git_pass(git_reset(repo, target, GIT_RESET_HARD, NULL, "message1"));
+	reflog_check(repo, "HEAD", 3, "emeric.fermas@gmail.com", exp_msg);
+	reflog_check(repo, "refs/heads/master", 5, NULL, "message1");
+}
diff --git a/tests/reset/mixed.c b/tests/reset/mixed.c
index 7b90c23..25272a7 100644
--- a/tests/reset/mixed.c
+++ b/tests/reset/mixed.c
@@ -27,9 +27,9 @@ void test_reset_mixed__cannot_reset_in_a_bare_repository(void)
 	cl_git_pass(git_repository_open(&bare, cl_fixture("testrepo.git")));
 	cl_assert(git_repository_is_bare(bare) == true);
 
-	retrieve_target_from_oid(&target, bare, KNOWN_COMMIT_IN_BARE_REPO);
+	cl_git_pass(git_revparse_single(&target, bare, KNOWN_COMMIT_IN_BARE_REPO));
 
-	cl_assert_equal_i(GIT_EBAREREPO, git_reset(bare, target, GIT_RESET_MIXED));
+	cl_assert_equal_i(GIT_EBAREREPO, git_reset(bare, target, GIT_RESET_MIXED, NULL, NULL));
 
 	git_repository_free(bare);
 }
@@ -40,10 +40,36 @@ void test_reset_mixed__resetting_refreshes_the_index_to_the_commit_tree(void)
 
 	cl_git_pass(git_status_file(&status, repo, "macro_bad"));
 	cl_assert(status == GIT_STATUS_CURRENT);
-	retrieve_target_from_oid(&target, repo, "605812ab7fe421fdd325a935d35cb06a9234a7d7");
+	cl_git_pass(git_revparse_single(&target, repo, "605812a"));
 
-	cl_git_pass(git_reset(repo, target, GIT_RESET_MIXED));
+	cl_git_pass(git_reset(repo, target, GIT_RESET_MIXED, NULL, NULL));
 
 	cl_git_pass(git_status_file(&status, repo, "macro_bad"));
 	cl_assert(status == GIT_STATUS_WT_NEW);
 }
+
+void test_reset_mixed__reflog_is_correct(void)
+{
+	const char *exp_msg = "commit: Updating test data so we can test inter-hunk-context";
+
+	reflog_check(repo, "HEAD", 9, "yoram.harmelin@gmail.com", exp_msg);
+	reflog_check(repo, "refs/heads/master", 9, "yoram.harmelin@gmail.com", exp_msg);
+
+	/* Branch not moving, no reflog entry */
+	cl_git_pass(git_revparse_single(&target, repo, "HEAD^{commit}"));
+	cl_git_pass(git_reset(repo, target, GIT_RESET_MIXED, NULL, NULL));
+	reflog_check(repo, "HEAD", 9, "yoram.harmelin@gmail.com", exp_msg);
+	reflog_check(repo, "refs/heads/master", 9, "yoram.harmelin@gmail.com", exp_msg);
+
+	/* Moved branch, expect default message */
+	cl_git_pass(git_revparse_single(&target, repo, "HEAD~^{commit}"));
+	cl_git_pass(git_reset(repo, target, GIT_RESET_MIXED, NULL, NULL));
+	reflog_check(repo, "HEAD", 9, "yoram.harmelin@gmail.com", exp_msg);
+	reflog_check(repo, "refs/heads/master", 10, NULL, "reset: moving");
+
+	/* Moved branch, expect custom message */
+	cl_git_pass(git_revparse_single(&target, repo, "HEAD~^{commit}"));
+	cl_git_pass(git_reset(repo, target, GIT_RESET_MIXED, NULL, "message1"));
+	reflog_check(repo, "HEAD", 9, "yoram.harmelin@gmail.com", exp_msg);
+	reflog_check(repo, "refs/heads/master", 11, NULL, "message1");
+}
diff --git a/tests/reset/reset_helpers.c b/tests/reset/reset_helpers.c
index 17edca4..7a335a6 100644
--- a/tests/reset/reset_helpers.c
+++ b/tests/reset/reset_helpers.c
@@ -1,10 +1,20 @@
 #include "clar_libgit2.h"
 #include "reset_helpers.h"
 
-void retrieve_target_from_oid(git_object **object_out, git_repository *repo, const char *sha)
+void reflog_check(git_repository *repo, const char *refname,
+		size_t exp_count, const char *exp_email, const char *exp_msg)
 {
-	git_oid oid;
+	git_reflog *log;
+	const git_reflog_entry *entry;
 
-	cl_git_pass(git_oid_fromstr(&oid, sha));
-	cl_git_pass(git_object_lookup(object_out, repo, &oid, GIT_OBJ_ANY));
+	cl_git_pass(git_reflog_read(&log, repo, refname));
+	cl_assert_equal_i(exp_count, git_reflog_entrycount(log));
+	entry = git_reflog_entry_byindex(log, 0);
+
+	if (exp_email)
+		cl_assert_equal_s(exp_email, git_reflog_entry_committer(entry)->email);
+	if (exp_msg)
+		cl_assert_equal_s(exp_msg, git_reflog_entry_message(entry));
+
+	git_reflog_free(log);
 }
diff --git a/tests/reset/reset_helpers.h b/tests/reset/reset_helpers.h
index 5dbe9d2..e7e0485 100644
--- a/tests/reset/reset_helpers.h
+++ b/tests/reset/reset_helpers.h
@@ -3,4 +3,5 @@
 #define KNOWN_COMMIT_IN_BARE_REPO "e90810b8df3e80c413d903f631643c716887138d"
 #define KNOWN_COMMIT_IN_ATTR_REPO "217878ab49e1314388ea2e32dc6fdb58a1b969e0"
 
-extern void retrieve_target_from_oid(git_object **object_out, git_repository *repo, const char *sha);
+void reflog_check(git_repository *repo, const char *refname,
+		size_t exp_count, const char *exp_email, const char *exp_msg);
diff --git a/tests/reset/soft.c b/tests/reset/soft.c
index bd6fcc2..c889c03 100644
--- a/tests/reset/soft.c
+++ b/tests/reset/soft.c
@@ -26,12 +26,11 @@ static void assert_reset_soft(bool should_be_detached)
 
 	cl_git_pass(git_reference_name_to_id(&oid, repo, "HEAD"));
 	cl_git_fail(git_oid_streq(&oid, KNOWN_COMMIT_IN_BARE_REPO));
-
-	retrieve_target_from_oid(&target, repo, KNOWN_COMMIT_IN_BARE_REPO);
+	cl_git_pass(git_revparse_single(&target, repo, KNOWN_COMMIT_IN_BARE_REPO));
 
 	cl_assert(git_repository_head_detached(repo) == should_be_detached);
 
-	cl_git_pass(git_reset(repo, target, GIT_RESET_SOFT));
+	cl_git_pass(git_reset(repo, target, GIT_RESET_SOFT, NULL, NULL));
 
 	cl_assert(git_repository_head_detached(repo) == should_be_detached);
 
@@ -46,7 +45,7 @@ void test_reset_soft__can_reset_the_non_detached_Head_to_the_specified_commit(vo
 
 void test_reset_soft__can_reset_the_detached_Head_to_the_specified_commit(void)
 {
-	git_repository_detach_head(repo);
+	git_repository_detach_head(repo, NULL, NULL);
 
 	assert_reset_soft(true);
 }
@@ -60,9 +59,9 @@ void test_reset_soft__resetting_to_the_commit_pointed_at_by_the_Head_does_not_ch
 	git_oid_fmt(raw_head_oid, &oid);
 	raw_head_oid[GIT_OID_HEXSZ] = '\0';
 
-	retrieve_target_from_oid(&target, repo, raw_head_oid);
+	cl_git_pass(git_revparse_single(&target, repo, raw_head_oid));
 
-	cl_git_pass(git_reset(repo, target, GIT_RESET_SOFT));
+	cl_git_pass(git_reset(repo, target, GIT_RESET_SOFT, NULL, NULL));
 
 	cl_git_pass(git_reference_name_to_id(&oid, repo, "HEAD"));
 	cl_git_pass(git_oid_streq(&oid, raw_head_oid));
@@ -73,9 +72,9 @@ void test_reset_soft__resetting_to_a_tag_sets_the_Head_to_the_peeled_commit(void
 	git_oid oid;
 
 	/* b25fa35 is a tag, pointing to another tag which points to commit e90810b */
-	retrieve_target_from_oid(&target, repo, "b25fa35b38051e4ae45d4222e795f9df2e43f1d1");
+	cl_git_pass(git_revparse_single(&target, repo, "b25fa35"));
 
-	cl_git_pass(git_reset(repo, target, GIT_RESET_SOFT));
+	cl_git_pass(git_reset(repo, target, GIT_RESET_SOFT, NULL, NULL));
 
 	cl_assert(git_repository_head_detached(repo) == false);
 	cl_git_pass(git_reference_name_to_id(&oid, repo, "HEAD"));
@@ -85,27 +84,27 @@ void test_reset_soft__resetting_to_a_tag_sets_the_Head_to_the_peeled_commit(void
 void test_reset_soft__cannot_reset_to_a_tag_not_pointing_at_a_commit(void)
 {
 	/* 53fc32d is the tree of commit e90810b */
-	retrieve_target_from_oid(&target, repo, "53fc32d17276939fc79ed05badaef2db09990016");
+	cl_git_pass(git_revparse_single(&target, repo, "53fc32d"));
 
-	cl_git_fail(git_reset(repo, target, GIT_RESET_SOFT));
+	cl_git_fail(git_reset(repo, target, GIT_RESET_SOFT, NULL, NULL));
 	git_object_free(target);
 
 	/* 521d87c is an annotated tag pointing to a blob */
-	retrieve_target_from_oid(&target, repo, "521d87c1ec3aef9824daf6d96cc0ae3710766d91");
-	cl_git_fail(git_reset(repo, target, GIT_RESET_SOFT));
+	cl_git_pass(git_revparse_single(&target, repo, "521d87c"));
+	cl_git_fail(git_reset(repo, target, GIT_RESET_SOFT, NULL, NULL));
 }
 
 void test_reset_soft__resetting_against_an_unborn_head_repo_makes_the_head_no_longer_unborn(void)
 {
 	git_reference *head;
 
-	retrieve_target_from_oid(&target, repo, KNOWN_COMMIT_IN_BARE_REPO);
+	cl_git_pass(git_revparse_single(&target, repo, KNOWN_COMMIT_IN_BARE_REPO));
 
 	make_head_unborn(repo, NON_EXISTING_HEAD);
 
 	cl_assert_equal_i(true, git_repository_head_unborn(repo));
 
-	cl_git_pass(git_reset(repo, target, GIT_RESET_SOFT));
+	cl_git_pass(git_reset(repo, target, GIT_RESET_SOFT, NULL, NULL));
 
 	cl_assert_equal_i(false, git_repository_head_unborn(repo));
 
@@ -119,13 +118,13 @@ void test_reset_soft__fails_when_merging(void)
 {
 	git_buf merge_head_path = GIT_BUF_INIT;
 
-	cl_git_pass(git_repository_detach_head(repo));
+	cl_git_pass(git_repository_detach_head(repo, NULL, NULL));
 	cl_git_pass(git_buf_joinpath(&merge_head_path, git_repository_path(repo), "MERGE_HEAD"));
 	cl_git_mkfile(git_buf_cstr(&merge_head_path), "beefbeefbeefbeefbeefbeefbeefbeefbeefbeef\n");
 
-	retrieve_target_from_oid(&target, repo, KNOWN_COMMIT_IN_BARE_REPO);
+	cl_git_pass(git_revparse_single(&target, repo, KNOWN_COMMIT_IN_BARE_REPO));
 
-	cl_assert_equal_i(GIT_EUNMERGED, git_reset(repo, target, GIT_RESET_SOFT));
+	cl_assert_equal_i(GIT_EUNMERGED, git_reset(repo, target, GIT_RESET_SOFT, NULL, NULL));
 	cl_git_pass(p_unlink(git_buf_cstr(&merge_head_path)));
 
 	git_buf_free(&merge_head_path);
@@ -153,5 +152,31 @@ void test_reset_soft__fails_when_index_contains_conflicts_independently_of_MERGE
 	cl_git_pass(git_reference_peel(&target, head, GIT_OBJ_COMMIT));
 	git_reference_free(head);
 
-	cl_assert_equal_i(GIT_EUNMERGED, git_reset(repo, target, GIT_RESET_SOFT));
+	cl_assert_equal_i(GIT_EUNMERGED, git_reset(repo, target, GIT_RESET_SOFT, NULL, NULL));
+}
+
+void test_reset_soft_reflog_is_correct(void)
+{
+	const char *exp_msg = "commit: Updating test data so we can test inter-hunk-context";
+
+	reflog_check(repo, "HEAD", 9, "yoram.harmelin@gmail.com", exp_msg);
+	reflog_check(repo, "refs/heads/master", 9, "yoram.harmelin@gmail.com", exp_msg);
+
+	/* Branch not moving, no reflog entry */
+	cl_git_pass(git_revparse_single(&target, repo, "HEAD^{commit}"));
+	cl_git_pass(git_reset(repo, target, GIT_RESET_SOFT, NULL, NULL));
+	reflog_check(repo, "HEAD", 9, "yoram.harmelin@gmail.com", exp_msg);
+	reflog_check(repo, "refs/heads/master", 9, "yoram.harmelin@gmail.com", exp_msg);
+
+	/* Moved branch, expect default message */
+	cl_git_pass(git_revparse_single(&target, repo, "HEAD~^{commit}"));
+	cl_git_pass(git_reset(repo, target, GIT_RESET_SOFT, NULL, NULL));
+	reflog_check(repo, "HEAD", 9, "yoram.harmelin@gmail.com", exp_msg);
+	reflog_check(repo, "refs/heads/master", 10, NULL, "reset: moving");
+
+	/* Moved branch, expect custom message */
+	cl_git_pass(git_revparse_single(&target, repo, "HEAD~^{commit}"));
+	cl_git_pass(git_reset(repo, target, GIT_RESET_SOFT, NULL, "message1"));
+	reflog_check(repo, "HEAD", 9, "yoram.harmelin@gmail.com", exp_msg);
+	reflog_check(repo, "refs/heads/master", 11, NULL, "message1");
 }
diff --git a/tests/revert/workdir.c b/tests/revert/workdir.c
index 5be397c..47abeb8 100644
--- a/tests/revert/workdir.c
+++ b/tests/revert/workdir.c
@@ -15,8 +15,15 @@ static git_index *repo_index;
 // Fixture setup and teardown
 void test_revert_workdir__initialize(void)
 {
+	git_config *cfg;
+
 	repo = cl_git_sandbox_init(TEST_REPO_PATH);
 	git_repository_index(&repo_index, repo);
+
+	/* Ensure that the user's merge.conflictstyle doesn't interfere */
+	cl_git_pass(git_repository_config(&cfg, repo));
+	cl_git_pass(git_config_set_string(cfg, "merge.conflictstyle", "merge"));
+	git_config_free(cfg);
 }
 
 void test_revert_workdir__cleanup(void)
@@ -41,7 +48,7 @@ void test_revert_workdir__automerge(void)
 
 	git_oid_fromstr(&head_oid, "72333f47d4e83616630ff3b0ffe4c0faebcc3c45");
 	cl_git_pass(git_commit_lookup(&head, repo, &head_oid));
-	cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD));
+	cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL));
 
 	git_oid_fromstr(&revert_oid, "d1d403d22cbe24592d725f442835cf46fe60c8ac");
 	cl_git_pass(git_commit_lookup(&commit, repo, &revert_oid));
@@ -74,7 +81,7 @@ void test_revert_workdir__conflicts(void)
 
 	cl_git_pass(git_repository_head(&head_ref, repo));
 	cl_git_pass(git_reference_peel((git_object **)&head, head_ref, GIT_OBJ_COMMIT));
-	cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD));
+	cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL));
 
 	cl_git_pass(git_commit_lookup(&commit, repo, &revert_oid));
 	cl_git_pass(git_revert(repo, commit, NULL));
@@ -125,7 +132,7 @@ void test_revert_workdir__orphan(void)
 
 	git_oid_fromstr(&head_oid, "39467716290f6df775a91cdb9a4eb39295018145");
 	cl_git_pass(git_commit_lookup(&head, repo, &head_oid));
-	cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD));
+	cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL));
 
 	git_oid_fromstr(&revert_oid, "ebb03002cee5d66c7732dd06241119fe72ab96a5");
 	cl_git_pass(git_commit_lookup(&commit, repo, &revert_oid));
@@ -160,7 +167,7 @@ void test_revert_workdir__again(void)
 
 	cl_git_pass(git_repository_head(&head_ref, repo));
 	cl_git_pass(git_reference_peel((git_object **)&orig_head, head_ref, GIT_OBJ_COMMIT));
-	cl_git_pass(git_reset(repo, (git_object *)orig_head, GIT_RESET_HARD));
+	cl_git_pass(git_reset(repo, (git_object *)orig_head, GIT_RESET_HARD, NULL, NULL));
 
 	cl_git_pass(git_revert(repo, orig_head, NULL));
 
@@ -208,7 +215,7 @@ void test_revert_workdir__again_after_automerge(void)
 
 	git_oid_fromstr(&head_oid, "72333f47d4e83616630ff3b0ffe4c0faebcc3c45");
 	cl_git_pass(git_commit_lookup(&head, repo, &head_oid));
-	cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD));
+	cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL));
 
 	git_oid_fromstr(&revert_oid, "d1d403d22cbe24592d725f442835cf46fe60c8ac");
 	cl_git_pass(git_commit_lookup(&commit, repo, &revert_oid));
@@ -256,7 +263,7 @@ void test_revert_workdir__again_after_edit(void)
 
 	cl_git_pass(git_oid_fromstr(&orig_head_oid, "399fb3aba3d9d13f7d40a9254ce4402067ef3149"));
 	cl_git_pass(git_commit_lookup(&orig_head, repo, &orig_head_oid));
-	cl_git_pass(git_reset(repo, (git_object *)orig_head, GIT_RESET_HARD));
+	cl_git_pass(git_reset(repo, (git_object *)orig_head, GIT_RESET_HARD, NULL, NULL));
 
 	cl_git_pass(git_oid_fromstr(&revert_oid, "2d440f2b3147d3dc7ad1085813478d6d869d5a4d"));
 	cl_git_pass(git_commit_lookup(&commit, repo, &revert_oid));
@@ -307,7 +314,7 @@ void test_revert_workdir__again_after_edit_two(void)
 
 	cl_git_pass(git_oid_fromstr(&head_commit_oid, "e34ef1afe54eb526fd92eec66084125f340f1d65"));
 	cl_git_pass(git_commit_lookup(&head_commit, repo, &head_commit_oid));
-	cl_git_pass(git_reset(repo, (git_object *)head_commit, GIT_RESET_HARD));
+	cl_git_pass(git_reset(repo, (git_object *)head_commit, GIT_RESET_HARD, NULL, NULL));
 
 	cl_git_pass(git_oid_fromstr(&revert_commit_oid, "71eb9c2b53dbbf3c45fb28b27c850db4b7fb8011"));
 	cl_git_pass(git_commit_lookup(&revert_commit, repo, &revert_commit_oid));
@@ -360,7 +367,7 @@ void test_revert_workdir__conflict_use_ours(void)
 
 	git_oid_fromstr(&head_oid, "72333f47d4e83616630ff3b0ffe4c0faebcc3c45");
 	cl_git_pass(git_commit_lookup(&head, repo, &head_oid));
-	cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD));
+	cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL));
 
 	git_oid_fromstr(&revert_oid, "d1d403d22cbe24592d725f442835cf46fe60c8ac");
 	cl_git_pass(git_commit_lookup(&commit, repo, &revert_oid));
@@ -396,7 +403,7 @@ void test_revert_workdir__rename_1_of_2(void)
 
 	git_oid_fromstr(&head_oid, "cef56612d71a6af8d8015691e4865f7fece905b5");
 	cl_git_pass(git_commit_lookup(&head, repo, &head_oid));
-	cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD));
+	cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL));
 
 	git_oid_fromstr(&revert_oid, "55568c8de5322ff9a95d72747a239cdb64a19965");
 	cl_git_pass(git_commit_lookup(&commit, repo, &revert_oid));
@@ -430,7 +437,7 @@ void test_revert_workdir__rename(void)
 
 	git_oid_fromstr(&head_oid, "55568c8de5322ff9a95d72747a239cdb64a19965");
 	cl_git_pass(git_commit_lookup(&head, repo, &head_oid));
-	cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD));
+	cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL));
 
 	git_oid_fromstr(&revert_oid, "0aa8c7e40d342fff78d60b29a4ba8e993ed79c51");
 	cl_git_pass(git_commit_lookup(&commit, repo, &revert_oid));
@@ -459,7 +466,7 @@ void test_revert_workdir__head(void)
 	/* HEAD is 2d440f2b3147d3dc7ad1085813478d6d869d5a4d */
 	cl_git_pass(git_repository_head(&head, repo));
 	cl_git_pass(git_reference_peel((git_object **)&commit, head, GIT_OBJ_COMMIT));
-	cl_git_pass(git_reset(repo, (git_object *)commit, GIT_RESET_HARD));
+	cl_git_pass(git_reset(repo, (git_object *)commit, GIT_RESET_HARD, NULL, NULL));
 	cl_git_pass(git_revert(repo, commit, NULL));
 
 	cl_assert(merge_test_index(repo_index, merge_index_entries, 4));
@@ -496,7 +503,7 @@ void test_revert_workdir__merge_fails_without_mainline_specified(void)
 
 	git_oid_fromstr(&head_oid, "5acdc74af27172ec491d213ee36cea7eb9ef2579");
 	cl_git_pass(git_commit_lookup(&head, repo, &head_oid));
-	cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD));
+	cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL));
 
 	cl_must_fail(git_revert(repo, head, NULL));
 	cl_assert(!git_path_exists(TEST_REPO_PATH "/.git/MERGE_MSG"));
@@ -523,7 +530,7 @@ void test_revert_workdir__merge_first_parent(void)
 
 	git_oid_fromstr(&head_oid, "5acdc74af27172ec491d213ee36cea7eb9ef2579");
 	cl_git_pass(git_commit_lookup(&head, repo, &head_oid));
-	cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD));
+	cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL));
 
 	cl_git_pass(git_revert(repo, head, &opts));
 
@@ -548,7 +555,7 @@ void test_revert_workdir__merge_second_parent(void)
 
 	git_oid_fromstr(&head_oid, "5acdc74af27172ec491d213ee36cea7eb9ef2579");
 	cl_git_pass(git_commit_lookup(&head, repo, &head_oid));
-	cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD));
+	cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL));
 
 	cl_git_pass(git_revert(repo, head, &opts));
 
diff --git a/tests/stash/save.c b/tests/stash/save.c
index 293a89a..b5a793e 100644
--- a/tests/stash/save.c
+++ b/tests/stash/save.c
@@ -196,7 +196,7 @@ void test_stash_save__cannot_stash_against_a_bare_repository(void)
 
 void test_stash_save__can_stash_against_a_detached_head(void)
 {
-	git_repository_detach_head(repo);
+	git_repository_detach_head(repo, NULL, NULL);
 
 	cl_git_pass(git_stash_save(&stash_tip_oid, repo, signature, NULL, GIT_STASH_DEFAULT));