Commit b5ced41e85d4657376d3d6f53d8dc08ed3dcdacc

Vicent Marti 2010-12-18T02:35:45

Merge branch 'timezone'

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
diff --git a/src/commit.c b/src/commit.c
index d39fc54..019cefe 100644
--- a/src/commit.c
+++ b/src/commit.c
@@ -26,11 +26,12 @@
 #include "git2/common.h"
 #include "git2/object.h"
 #include "git2/repository.h"
+#include "git2/signature.h"
 
 #include "common.h"
 #include "commit.h"
 #include "revwalk.h"
-#include "person.h"
+#include "signature.h"
 
 #define COMMIT_BASIC_PARSE 0x0
 #define COMMIT_FULL_PARSE 0x1
@@ -50,8 +51,8 @@ void git_commit__free(git_commit *commit)
 {
 	clear_parents(commit);
 
-	git_person__free(commit->author);
-	git_person__free(commit->committer);
+	git_signature_free(commit->author);
+	git_signature_free(commit->committer);
 
 	free(commit->message);
 	free(commit->message_short);
@@ -82,12 +83,12 @@ int git_commit__writeback(git_commit *commit, git_odb_source *src)
 	if (commit->author == NULL)
 		return GIT_EMISSINGOBJDATA;
 
-	git_person__write(src, "author", commit->author);
+	git_signature__write(src, "author", commit->author);
 
 	if (commit->committer == NULL)
 		return GIT_EMISSINGOBJDATA;
 
-	git_person__write(src, "committer", commit->committer);
+	git_signature__write(src, "committer", commit->committer);
 
 	if (commit->message != NULL)
 		git__source_printf(src, "\n%s", commit->message);
@@ -137,10 +138,10 @@ int commit_parse_buffer(git_commit *commit, void *data, size_t len, unsigned int
 
 	if (parse_flags & COMMIT_FULL_PARSE) {
 		if (commit->author)
-			git_person__free(commit->author);
+			git_signature_free(commit->author);
 
-		commit->author = git__malloc(sizeof(git_person));
-		if ((error = git_person__parse(commit->author, &buffer, buffer_end, "author ")) < GIT_SUCCESS)
+		commit->author = git__malloc(sizeof(git_signature));
+		if ((error = git_signature__parse(commit->author, &buffer, buffer_end, "author ")) < GIT_SUCCESS)
 			return error;
 
 	} else {
@@ -152,14 +153,12 @@ int commit_parse_buffer(git_commit *commit, void *data, size_t len, unsigned int
 
 	/* Always parse the committer; we need the commit time */
 	if (commit->committer)
-		git_person__free(commit->committer);
+		git_signature_free(commit->committer);
 
-	commit->committer = git__malloc(sizeof(git_person));
-	if ((error = git_person__parse(commit->committer, &buffer, buffer_end, "committer ")) < GIT_SUCCESS)
+	commit->committer = git__malloc(sizeof(git_signature));
+	if ((error = git_signature__parse(commit->committer, &buffer, buffer_end, "committer ")) < GIT_SUCCESS)
 		return error;
 
-	commit->commit_time = commit->committer->time;
-
 	/* parse commit message */
 	while (buffer <= buffer_end && *buffer == '\n')
 		buffer++;
@@ -231,22 +230,21 @@ int git_commit__parse_full(git_commit *commit)
 		git_commit__parse_full(commit); 
 
 GIT_COMMIT_GETTER(git_tree *, tree)
-GIT_COMMIT_GETTER(git_person *, author)
-GIT_COMMIT_GETTER(git_person *, committer)
+GIT_COMMIT_GETTER(git_signature *, author)
+GIT_COMMIT_GETTER(git_signature *, committer)
 GIT_COMMIT_GETTER(char *, message)
 GIT_COMMIT_GETTER(char *, message_short)
 
 time_t git_commit_time(git_commit *commit)
 {
-	assert(commit);
-
-	if (commit->commit_time)
-		return commit->commit_time;
-
-	if (!commit->object.in_memory)
-		git_commit__parse_full(commit);
+	assert(commit && commit->committer);
+	return commit->committer->when.time;
+}
 
-	return commit->commit_time;
+int git_commit_time_offset(git_commit *commit)
+{
+	assert(commit && commit->committer);
+	return commit->committer->when.offset;
 }
 
 unsigned int git_commit_parentcount(git_commit *commit)
@@ -269,25 +267,24 @@ void git_commit_set_tree(git_commit *commit, git_tree *tree)
 	commit->tree = tree;
 }
 
-void git_commit_set_author(git_commit *commit, const char *name, const char *email, time_t time)
+void git_commit_set_author(git_commit *commit, const git_signature *author_sig)
 {
-	assert(commit && name && email);
+	assert(commit && author_sig);
 	commit->object.modified = 1;
 	CHECK_FULL_PARSE();
 
-	git_person__free(commit->author);
-	commit->author = git_person__new(name, email, time);
+	git_signature_free(commit->author);
+	commit->author = git_signature_dup(author_sig);
 }
 
-void git_commit_set_committer(git_commit *commit, const char *name, const char *email, time_t time)
+void git_commit_set_committer(git_commit *commit, const git_signature *committer_sig)
 {
-	assert(commit && name && email);
+	assert(commit && committer_sig);
 	commit->object.modified = 1;
 	CHECK_FULL_PARSE();
 
-	git_person__free(commit->committer);
-	commit->committer = git_person__new(name, email, time);
-	commit->commit_time = time;
+	git_signature_free(commit->committer);
+	commit->committer = git_signature_dup(committer_sig);
 }
 
 void git_commit_set_message(git_commit *commit, const char *message)
diff --git a/src/commit.h b/src/commit.h
index eca566d..b53ee9b 100644
--- a/src/commit.h
+++ b/src/commit.h
@@ -11,12 +11,11 @@
 struct git_commit {
 	git_object object;
 
-	time_t commit_time;
 	git_vector parents;
 
 	git_tree *tree;
-	git_person *author;
-	git_person *committer;
+	git_signature *author;
+	git_signature *committer;
 
 	char *message;
 	char *message_short;
diff --git a/src/git2.h b/src/git2.h
index dbf5a99..9eb9294 100644
--- a/src/git2.h
+++ b/src/git2.h
@@ -33,6 +33,7 @@
 #include "git2/types.h"
 
 #include "git2/oid.h"
+#include "git2/signature.h"
 #include "git2/odb.h"
 
 #include "git2/repository.h"
diff --git a/src/git2/commit.h b/src/git2/commit.h
index 7286797..ccffec4 100644
--- a/src/git2/commit.h
+++ b/src/git2/commit.h
@@ -93,18 +93,25 @@ GIT_EXTERN(const char *) git_commit_message(git_commit *commit);
 GIT_EXTERN(time_t) git_commit_time(git_commit *commit);
 
 /**
+ * Get the commit timezone offset (i.e. committer's preferred timezone) of a commit.
+ * @param commit a previously loaded commit.
+ * @return positive or negative timezone offset, in minutes from UTC
+ */
+GIT_EXTERN(int) git_commit_timezone_offset(git_commit *commit);
+
+/**
  * Get the committer of a commit.
  * @param commit a previously loaded commit.
  * @return the committer of a commit
  */
-GIT_EXTERN(const git_person *) git_commit_committer(git_commit *commit);
+GIT_EXTERN(const git_signature *) git_commit_committer(git_commit *commit);
 
 /**
  * Get the author of a commit.
  * @param commit a previously loaded commit.
  * @return the author of a commit
  */
-GIT_EXTERN(const git_person *) git_commit_author(git_commit *commit);
+GIT_EXTERN(const git_signature *) git_commit_author(git_commit *commit);
 
 /**
  * Get the tree pointed to by a commit.
@@ -147,20 +154,16 @@ GIT_EXTERN(void) git_commit_set_message(git_commit *commit, const char *message)
 /**
  * Set the committer of a commit
  * @param commit the commit object
- * @param name name of the new committer
- * @param email email of the new committer
- * @param time time when the committer committed the commit
+ * @param author_sig signature of the committer
  */
-GIT_EXTERN(void) git_commit_set_committer(git_commit *commit, const char *name, const char *email, time_t time);
+GIT_EXTERN(void) git_commit_set_committer(git_commit *commit, const git_signature *committer_sig);
 
 /**
  * Set the author of a commit
  * @param commit the commit object
- * @param name name of the new author
- * @param email email of the new author
- * @param time time when the author created the commit
+ * @param author_sig signature of the author
  */
-GIT_EXTERN(void) git_commit_set_author(git_commit *commit, const char *name, const char *email, time_t time);
+GIT_EXTERN(void) git_commit_set_author(git_commit *commit, const git_signature *author_sig);
 
 /**
  * Set the tree which is pointed to by a commit
diff --git a/src/git2/common.h b/src/git2/common.h
index b819f05..9d014c0 100644
--- a/src/git2/common.h
+++ b/src/git2/common.h
@@ -134,16 +134,7 @@
 /** The index file is not backed up by an existing repository */
 #define GIT_EBAREINDEX (GIT_ERROR -14)
 
-
 GIT_BEGIN_DECL
-
-/** Parsed representation of a person */
-typedef struct git_person git_person;
-
-const char *git_person_name(git_person *person);
-const char *git_person_email(git_person *person);
-time_t git_person_time(git_person *person);
-
 /** @} */
 GIT_END_DECL
 #endif
diff --git a/src/git2/signature.h b/src/git2/signature.h
new file mode 100644
index 0000000..96275aa
--- /dev/null
+++ b/src/git2/signature.h
@@ -0,0 +1,70 @@
+/*
+ * This file is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2,
+ * as published by the Free Software Foundation.
+ *
+ * In addition to the permissions in the GNU General Public License,
+ * the authors give you unlimited permission to link the compiled
+ * version of this file into combinations with other programs,
+ * and to distribute those combinations without any restriction
+ * coming from the use of this file.  (The General Public License
+ * restrictions do apply in other respects; for example, they cover
+ * modification of the file, and distribution when not linked into
+ * a combined executable.)
+ *
+ * This file is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; see the file COPYING.  If not, write to
+ * the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+#ifndef INCLUDE_git_signature_h__
+#define INCLUDE_git_signature_h__
+
+#include "common.h"
+#include "types.h"
+
+/**
+ * @file git2/signature.h
+ * @brief Git signature creation
+ * @defgroup git_signature Git signature creation
+ * @ingroup Git
+ * @{
+ */
+GIT_BEGIN_DECL
+
+/**
+ * Create a new action signature. The signature must be freed
+ * manually or using git_signature_free
+ *
+ * @name name of the person
+ * @email email of the person
+ * @time time when the action happened
+ * @offset timezone offset in minutes for the time
+ * @return the new sig, NULl on out of memory
+ */
+GIT_EXTERN(git_signature *) git_signature_new(const char *name, const char *email, time_t time, int offset);
+
+/**
+ * Create a copy of an existing signature.
+ *
+ * All internal strings are also duplicated.
+ * @sig signature to duplicated
+ * @return a copy of sig, NULL on out of memory
+ */
+GIT_EXTERN(git_signature *) git_signature_dup(const git_signature *sig);
+
+/**
+ * Free an existing signature
+ *
+ * @sig signature to free
+ */
+GIT_EXTERN(void) git_signature_free(git_signature *sig);
+
+/** @} */
+GIT_END_DECL
+#endif
diff --git a/src/git2/tag.h b/src/git2/tag.h
index 39b45ac..8e29bc1 100644
--- a/src/git2/tag.h
+++ b/src/git2/tag.h
@@ -96,7 +96,7 @@ GIT_EXTERN(const char *) git_tag_name(git_tag *t);
  * @param tag a previously loaded tag.
  * @return reference to the tag's author
  */
-GIT_EXTERN(const git_person *) git_tag_tagger(git_tag *t);
+GIT_EXTERN(const git_signature *) git_tag_tagger(git_tag *t);
 
 /**
  * Get the message of a tag
@@ -122,11 +122,9 @@ GIT_EXTERN(void) git_tag_set_name(git_tag *tag, const char *name);
 /**
  * Set the tagger of a tag
  * @param tag The tag to modify
- * @param name the name of the new tagger
- * @param email the email of the new tagger
- * @param time the time when the tag was created
+ * @param tagger_sig signature of the tagging action
  */
-GIT_EXTERN(void) git_tag_set_tagger(git_tag *tag, const char *name, const char *email, time_t time);
+GIT_EXTERN(void) git_tag_set_tagger(git_tag *tag, const git_signature *tagger_sig);
 
 /**
  * Set the message of a tag
diff --git a/src/git2/types.h b/src/git2/types.h
index 22fecef..99de332 100644
--- a/src/git2/types.h
+++ b/src/git2/types.h
@@ -82,6 +82,19 @@ typedef struct git_tree git_tree;
 /** Memory representation of an index file. */
 typedef struct git_index git_index;
 
+/** Time in a signature */
+typedef struct git_time {
+	time_t time; /** time in seconds from epoch */
+	int offset; /** timezone offset, in minutes */
+} git_time;
+
+/** An action signature (e.g. for committers, taggers, etc) */
+typedef struct git_signature {
+	char *name; /** full name of the author */
+	char *email; /** email of the author */
+	git_time when; /** time when the action happened */
+} git_signature;
+
 /** @} */
 GIT_END_DECL
 
diff --git a/src/person.c b/src/person.c
deleted file mode 100644
index e93e1b8..0000000
--- a/src/person.c
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * This file is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2,
- * as published by the Free Software Foundation.
- *
- * In addition to the permissions in the GNU General Public License,
- * the authors give you unlimited permission to link the compiled
- * version of this file into combinations with other programs,
- * and to distribute those combinations without any restriction
- * coming from the use of this file.  (The General Public License
- * restrictions do apply in other respects; for example, they cover
- * modification of the file, and distribution when not linked into
- * a combined executable.)
- *
- * This file is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; see the file COPYING.  If not, write to
- * the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "common.h"
-#include "person.h"
-#include "repository.h"
-#include "git2/common.h"
-
-void git_person__free(git_person *person)
-{
-	if (person == NULL)
-		return;
-
-	free(person->name);
-	free(person->email);
-	free(person);
-}
-
-git_person *git_person__new(const char *name, const char *email, time_t time)
-{
-	git_person *p;
-
-	if ((p = git__malloc(sizeof(git_person))) == NULL)
-		goto cleanup;
-
-	p->name = git__strdup(name);
-	p->email = git__strdup(email);
-	p->time = time;
-
-	if (p->name == NULL || p->email == NULL)
-		goto cleanup;
-
-	return p;
-
-cleanup:
-	git_person__free(p);
-	return NULL;
-}
-
-const char *git_person_name(git_person *person)
-{
-	return person->name;
-}
-
-const char *git_person_email(git_person *person)
-{
-	return person->email;
-}
-
-time_t git_person_time(git_person *person)
-{
-	return person->time;
-}
-
-int git_person__parse(git_person *person, char **buffer_out,
-		const char *buffer_end, const char *header)
-{
-	const size_t header_len = strlen(header);
-
-	int name_length, email_length;
-	char *buffer = *buffer_out;
-	char *line_end, *name_end, *email_end;
-
-	memset(person, 0x0, sizeof(git_person));
-
-	line_end = memchr(buffer, '\n', buffer_end - buffer);
-	if (!line_end)
-		return GIT_EOBJCORRUPTED;
-
-	if (buffer + (header_len + 1) > line_end)
-		return GIT_EOBJCORRUPTED;
-
-	if (memcmp(buffer, header, header_len) != 0)
-		return GIT_EOBJCORRUPTED;
-
-	buffer += header_len;
-
-	/* Parse name */
-	if ((name_end = memchr(buffer, '<', buffer_end - buffer)) == NULL)
-		return GIT_EOBJCORRUPTED;
-
-	name_length = name_end - buffer - 1;
-	person->name = git__malloc(name_length + 1);
-	memcpy(person->name, buffer, name_length);
-	person->name[name_length] = 0;
-	buffer = name_end + 1;
-
-	if (buffer >= line_end)
-		return GIT_EOBJCORRUPTED;
-
-	/* Parse email */
-	if ((email_end = memchr(buffer, '>', buffer_end - buffer)) == NULL)
-		return GIT_EOBJCORRUPTED;
-
-	email_length = email_end - buffer;
-	person->email = git__malloc(email_length + 1);
-	memcpy(person->email, buffer, email_length);
-	person->email[email_length] = 0;
-	buffer = email_end + 1;
-
-	if (buffer >= line_end)
-		return GIT_EOBJCORRUPTED;
-
-	person->time = strtol(buffer, &buffer, 10);
-
-	if (person->time == 0)
-		return GIT_EOBJCORRUPTED;
-
-	*buffer_out = (line_end + 1);
-	return GIT_SUCCESS;
-}
-
-int git_person__write(git_odb_source *src, const char *header, const git_person *person)
-{
-	return git__source_printf(src, "%s %s <%s> %u\n", header, person->name, person->email, person->time);
-}
-
-
diff --git a/src/person.h b/src/person.h
deleted file mode 100644
index 7a9fcb7..0000000
--- a/src/person.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef INCLUDE_person_h__
-#define INCLUDE_person_h__
-
-#include "git2/common.h"
-#include "repository.h"
-#include <time.h>
-
-/** Parsed representation of a person */
-struct git_person {
-	char *name; /**< Full name */
-	char *email; /**< Email address */
-	time_t time; /**< Time when this person committed the change */
-};
-
-void git_person__free(git_person *person);
-git_person *git_person__new(const char *name, const char *email, time_t time);
-int git_person__parse(git_person *person, char **buffer_out, const char *buffer_end, const char *header);
-int git_person__write(git_odb_source *src, const char *header, const git_person *person);
-
-#endif
diff --git a/src/revwalk.c b/src/revwalk.c
index f2eaa71..df8f47a 100644
--- a/src/revwalk.c
+++ b/src/revwalk.c
@@ -400,8 +400,8 @@ void git_revwalk_list_timesort(git_revwalk_list *list)
 					e = q, q = q->next, q_size--;
 
 				else if (q_size == 0 || q == NULL ||
-						p->walk_commit->commit_object->commit_time >= 
-						q->walk_commit->commit_object->commit_time)
+						p->walk_commit->commit_object->committer->when.time >= 
+						q->walk_commit->commit_object->committer->when.time)
 					e = p, p = p->next, p_size--;
 
 				else
diff --git a/src/signature.c b/src/signature.c
new file mode 100644
index 0000000..c5bfda8
--- /dev/null
+++ b/src/signature.c
@@ -0,0 +1,199 @@
+/*
+ * This file is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2,
+ * as published by the Free Software Foundation.
+ *
+ * In addition to the permissions in the GNU General Public License,
+ * the authors give you unlimited permission to link the compiled
+ * version of this file into combinations with other programs,
+ * and to distribute those combinations without any restriction
+ * coming from the use of this file.  (The General Public License
+ * restrictions do apply in other respects; for example, they cover
+ * modification of the file, and distribution when not linked into
+ * a combined executable.)
+ *
+ * This file is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; see the file COPYING.  If not, write to
+ * the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "common.h"
+#include "signature.h"
+#include "repository.h"
+#include "git2/common.h"
+
+void git_signature_free(git_signature *sig)
+{
+	if (sig == NULL)
+		return;
+
+	free(sig->name);
+	free(sig->email);
+	free(sig);
+}
+
+git_signature *git_signature_new(const char *name, const char *email, time_t time, int offset)
+{
+	git_signature *p = NULL;
+
+	if ((p = git__malloc(sizeof(git_signature))) == NULL)
+		goto cleanup;
+
+	p->name = git__strdup(name);
+	if (p->name == NULL)
+		goto cleanup;
+
+	p->email = git__strdup(email);
+	if (p->email == NULL)
+		goto cleanup;
+
+	p->when.time = time;
+	p->when.offset = offset;
+
+	if (p->name == NULL || p->email == NULL)
+		goto cleanup;
+
+	return p;
+
+cleanup:
+	git_signature_free(p);
+	return NULL;
+}
+
+git_signature *git_signature_dup(const git_signature *sig)
+{
+	return git_signature_new(sig->name, sig->email, sig->when.time, sig->when.offset);
+}
+
+
+static int parse_timezone_offset(const char *buffer, int *offset_out)
+{
+	int offset, dec_offset;
+	int mins, hours;
+
+	const char* offset_start;
+	char* offset_end;
+
+	offset_start = buffer + 1;
+
+	if (*offset_start == '\n') {
+		*offset_out = 0;
+		return GIT_SUCCESS;
+	}
+
+	if (offset_start[0] != '-' && offset_start[0] != '+')
+		return GIT_EOBJCORRUPTED;
+
+	dec_offset = strtol(offset_start + 1, &offset_end, 10);
+
+	if (offset_end - offset_start != 5)
+		return GIT_EOBJCORRUPTED;
+
+	hours = dec_offset / 100;
+	mins = dec_offset % 100;
+
+	if (hours > 14)	// see http://www.worldtimezone.com/faq.html 
+		return GIT_EOBJCORRUPTED;
+
+	if (mins > 59)
+		return GIT_EOBJCORRUPTED;
+
+	offset = (hours * 60) + mins;
+
+	if (offset_start[0] == '-')
+		offset *= -1;
+	
+	*offset_out = offset;
+
+	return GIT_SUCCESS;
+}
+
+
+int git_signature__parse(git_signature *sig, char **buffer_out,
+		const char *buffer_end, const char *header)
+{
+	const size_t header_len = strlen(header);
+
+	int name_length, email_length;
+	char *buffer = *buffer_out;
+	char *line_end, *name_end, *email_end;
+	int offset = 0;
+
+	memset(sig, 0x0, sizeof(git_signature));
+
+	line_end = memchr(buffer, '\n', buffer_end - buffer);
+	if (!line_end)
+		return GIT_EOBJCORRUPTED;
+
+	if (buffer + (header_len + 1) > line_end)
+		return GIT_EOBJCORRUPTED;
+
+	if (memcmp(buffer, header, header_len) != 0)
+		return GIT_EOBJCORRUPTED;
+
+	buffer += header_len;
+
+	/* Parse name */
+	if ((name_end = memchr(buffer, '<', buffer_end - buffer)) == NULL)
+		return GIT_EOBJCORRUPTED;
+
+	name_length = name_end - buffer - 1;
+	sig->name = git__malloc(name_length + 1);
+	memcpy(sig->name, buffer, name_length);
+	sig->name[name_length] = 0;
+	buffer = name_end + 1;
+
+	if (buffer >= line_end)
+		return GIT_EOBJCORRUPTED;
+
+	/* Parse email */
+	if ((email_end = memchr(buffer, '>', buffer_end - buffer)) == NULL)
+		return GIT_EOBJCORRUPTED;
+
+	email_length = email_end - buffer;
+	sig->email = git__malloc(email_length + 1);
+	memcpy(sig->email, buffer, email_length);
+	sig->email[email_length] = 0;
+	buffer = email_end + 1;
+
+	if (buffer >= line_end)
+		return GIT_EOBJCORRUPTED;
+
+	sig->when.time = strtol(buffer, &buffer, 10);
+
+	if (sig->when.time == 0)
+		return GIT_EOBJCORRUPTED;
+
+	if (parse_timezone_offset(buffer, &offset) < GIT_SUCCESS)
+		return GIT_EOBJCORRUPTED;
+	
+	sig->when.offset = offset;
+
+	*buffer_out = (line_end + 1);
+	return GIT_SUCCESS;
+}
+
+int git_signature__write(git_odb_source *src, const char *header, const git_signature *sig)
+{
+	char sign;
+	int offset, hours, mins;
+
+	offset = sig->when.offset;
+	sign = (sig->when.offset < 0) ? '-' : '+';
+	
+	if (offset < 0)
+		offset = -offset;
+
+	hours = offset / 60;
+	mins = offset % 60;
+
+	return git__source_printf(src, "%s %s <%s> %u %c%02d%02d\n", header, sig->name, sig->email, sig->when.time, sign, hours, mins);
+}
+
+
diff --git a/src/signature.h b/src/signature.h
new file mode 100644
index 0000000..ee212c2
--- /dev/null
+++ b/src/signature.h
@@ -0,0 +1,12 @@
+#ifndef INCLUDE_signature_h__
+#define INCLUDE_signature_h__
+
+#include "git2/common.h"
+#include "git2/signature.h"
+#include "repository.h"
+#include <time.h>
+
+int git_signature__parse(git_signature *sig, char **buffer_out, const char *buffer_end, const char *header);
+int git_signature__write(git_odb_source *src, const char *header, const git_signature *sig);
+
+#endif
diff --git a/src/tag.c b/src/tag.c
index b5b8b9f..4c6cabf 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -26,14 +26,15 @@
 #include "common.h"
 #include "commit.h"
 #include "tag.h"
-#include "person.h"
+#include "signature.h"
 #include "revwalk.h"
 #include "git2/object.h"
 #include "git2/repository.h"
+#include "git2/signature.h"
 
 void git_tag__free(git_tag *tag)
 {
-	git_person__free(tag->tagger);
+	git_signature_free(tag->tagger);
 	free(tag->message);
 	free(tag->tag_name);
 	free(tag);
@@ -92,18 +93,18 @@ void git_tag_set_name(git_tag *tag, const char *name)
 	tag->tag_name = git__strdup(name);
 }
 
-const git_person *git_tag_tagger(git_tag *t)
+const git_signature *git_tag_tagger(git_tag *t)
 {
 	return t->tagger;
 }
 
-void git_tag_set_tagger(git_tag *tag, const char *name, const char *email, time_t time)
+void git_tag_set_tagger(git_tag *tag, const git_signature *tagger_sig)
 {
-	assert(tag && name && email);
+	assert(tag && tagger_sig);
 	tag->object.modified = 1;
 
-	git_person__free(tag->tagger);
-	tag->tagger = git_person__new(name, email, time);
+	git_signature_free(tag->tagger);
+	tag->tagger = git_signature_dup(tagger_sig);
 }
 
 const char *git_tag_message(git_tag *t)
@@ -190,11 +191,11 @@ static int parse_tag_buffer(git_tag *tag, char *buffer, const char *buffer_end)
 	buffer = search + 1;
 
 	if (tag->tagger != NULL)
-		git_person__free(tag->tagger);
+		git_signature_free(tag->tagger);
 
-	tag->tagger = git__malloc(sizeof(git_person));
+	tag->tagger = git__malloc(sizeof(git_signature));
 
-	if ((error = git_person__parse(tag->tagger, &buffer, buffer_end, "tagger ")) != 0)
+	if ((error = git_signature__parse(tag->tagger, &buffer, buffer_end, "tagger ")) != 0)
 		return error;
 
 	text_len = buffer_end - ++buffer;
@@ -217,7 +218,7 @@ int git_tag__writeback(git_tag *tag, git_odb_source *src)
 	git__write_oid(src, "object", git_object_id(tag->target));
 	git__source_printf(src, "type %s\n", git_object_type2string(tag->type));
 	git__source_printf(src, "tag %s\n", tag->tag_name);
-	git_person__write(src, "tagger", tag->tagger);
+	git_signature__write(src, "tagger", tag->tagger);
 
 	if (tag->message != NULL)
 		git__source_printf(src, "\n%s", tag->message);
diff --git a/src/tag.h b/src/tag.h
index dd84ff6..624fcc6 100644
--- a/src/tag.h
+++ b/src/tag.h
@@ -10,7 +10,7 @@ struct git_tag {
 	git_object *target;
 	git_otype type;
 	char *tag_name;
-	git_person *tagger;
+	git_signature *tagger;
 	char *message;
 };
 
diff --git a/tests/t0401-parse.c b/tests/t0401-parse.c
index b82a9b1..d734e5d 100644
--- a/tests/t0401-parse.c
+++ b/tests/t0401-parse.c
@@ -1,7 +1,7 @@
 #include "test_lib.h"
 #include "test_helpers.h"
 #include "commit.h"
-#include "person.h"
+#include "signature.h"
 #include <git2/odb.h>
 #include <git2/commit.h>
 #include <git2/revwalk.h>
@@ -129,96 +129,134 @@ BEGIN_TEST(parse_oid_test)
 
 END_TEST
 
-BEGIN_TEST(parse_person_test)
+BEGIN_TEST(parse_sig_test)
 
-#define TEST_PERSON_PASS(_string, _header, _name, _email, _time) { \
+#define TEST_SIGNATURE_PASS(_string, _header, _name, _email, _time, _offset) { \
 	char *ptr = _string; \
 	size_t len = strlen(_string);\
-	git_person person = {NULL, NULL, 0}; \
-	must_pass(git_person__parse(&person, &ptr, ptr + len, _header));\
+	git_signature person = {NULL, NULL, {0, 0}}; \
+	must_pass(git_signature__parse(&person, &ptr, ptr + len, _header));\
 	must_be_true(strcmp(_name, person.name) == 0);\
 	must_be_true(strcmp(_email, person.email) == 0);\
-	must_be_true(_time == person.time);\
+	must_be_true(_time == person.when.time);\
+	must_be_true(_offset == person.when.offset);\
 	free(person.name); free(person.email);\
 }
 
-#define TEST_PERSON_FAIL(_string, _header) { \
+#define TEST_SIGNATURE_FAIL(_string, _header) { \
 	char *ptr = _string; \
 	size_t len = strlen(_string);\
-	git_person person = {NULL, NULL, 0}; \
-	must_fail(git_person__parse(&person, &ptr, ptr + len, _header));\
+	git_signature person = {NULL, NULL, {0, 0}}; \
+	must_fail(git_signature__parse(&person, &ptr, ptr + len, _header));\
 	free(person.name); free(person.email);\
 }
 
-	TEST_PERSON_PASS(
-			"author Vicent Marti <tanoku@gmail.com> 12345 \n",
-			"author ",
-			"Vicent Marti",
-			"tanoku@gmail.com",
-			12345);
+	TEST_SIGNATURE_PASS(
+		"author Vicent Marti <tanoku@gmail.com> 12345 \n",
+		"author ",
+		"Vicent Marti",
+		"tanoku@gmail.com",
+		12345,
+		0);
 
-	TEST_PERSON_PASS(
+	TEST_SIGNATURE_PASS(
 		"author Vicent Marti <> 12345 \n",
 		"author ",
 		"Vicent Marti",
 		"",
-		12345);
+		12345,
+		0);
 
-	TEST_PERSON_PASS(
-		"author Vicent Marti <tanoku@gmail.com> 231301 +2020\n",
+	TEST_SIGNATURE_PASS(
+		"author Vicent Marti <tanoku@gmail.com> 231301 +1020\n",
 		"author ",
 		"Vicent Marti",
 		"tanoku@gmail.com",
-		231301);
+		231301,
+		620);
 
-	TEST_PERSON_PASS(
+	TEST_SIGNATURE_PASS(
 		"author Vicent Marti with an outrageously long name \
 		which will probably overflow the buffer <tanoku@gmail.com> 12345 \n",
 		"author ",
 		"Vicent Marti with an outrageously long name \
 		which will probably overflow the buffer",
 		"tanoku@gmail.com",
-		12345);
+		12345,
+		0);
 
-	TEST_PERSON_PASS(
+	TEST_SIGNATURE_PASS(
 		"author Vicent Marti <tanokuwithaveryveryverylongemail\
 		whichwillprobablyvoverflowtheemailbuffer@gmail.com> 12345 \n",
 		"author ",
 		"Vicent Marti",
 		"tanokuwithaveryveryverylongemail\
 		whichwillprobablyvoverflowtheemailbuffer@gmail.com",
-		12345);
+		12345,
+		0);
+
+	TEST_SIGNATURE_PASS(
+		"committer Vicent Marti <tanoku@gmail.com> 123456 +0000 \n",
+		"committer ",
+		"Vicent Marti",
+		"tanoku@gmail.com",
+		123456,
+		0);
+
+	TEST_SIGNATURE_PASS(
+		"committer Vicent Marti <tanoku@gmail.com> 123456 +0100 \n",
+		"committer ",
+		"Vicent Marti",
+		"tanoku@gmail.com",
+		123456,
+		60);
+
+	TEST_SIGNATURE_PASS(
+		"committer Vicent Marti <tanoku@gmail.com> 123456 -0100 \n",
+		"committer ",
+		"Vicent Marti",
+		"tanoku@gmail.com",
+		123456,
+		-60);
+
+	TEST_SIGNATURE_FAIL(
+		"committer Vicent Marti <tanoku@gmail.com> 123456 -1500 \n",
+		"committer ");
+
+	TEST_SIGNATURE_FAIL(
+		"committer Vicent Marti <tanoku@gmail.com> 123456 +0163 \n",
+		"committer ");
 
-	TEST_PERSON_FAIL(
+	TEST_SIGNATURE_FAIL(
 		"author Vicent Marti <tanoku@gmail.com> 12345 \n",
 		"author  ");
 
-	TEST_PERSON_FAIL(
+	TEST_SIGNATURE_FAIL(
 		"author Vicent Marti <tanoku@gmail.com> 12345 \n",
 		"committer ");
 
-	TEST_PERSON_FAIL(
+	TEST_SIGNATURE_FAIL(
 		"author Vicent Marti 12345 \n",
 		"author ");
 
-	TEST_PERSON_FAIL(
+	TEST_SIGNATURE_FAIL(
 		"author Vicent Marti <broken@email 12345 \n",
 		"author ");
 
-	TEST_PERSON_FAIL(
+	TEST_SIGNATURE_FAIL(
 		"author Vicent Marti <tanoku@gmail.com> notime \n",
 		"author ");
 
-	TEST_PERSON_FAIL(
+	TEST_SIGNATURE_FAIL(
 		"author Vicent Marti <tanoku@gmail.com>\n",
 		"author ");
 
-	TEST_PERSON_FAIL(
+	TEST_SIGNATURE_FAIL(
 		"author ",
 		"author ");
 
-#undef TEST_PERSON_PASS
-#undef TEST_PERSON_FAIL
+#undef TEST_SIGNATURE_PASS
+#undef TEST_SIGNATURE_FAIL
 
 END_TEST
 
diff --git a/tests/t0402-details.c b/tests/t0402-details.c
index 489b3ff..0b2fe22 100644
--- a/tests/t0402-details.c
+++ b/tests/t0402-details.c
@@ -1,7 +1,7 @@
 #include "test_lib.h"
 #include "test_helpers.h"
 #include "commit.h"
-#include "person.h"
+#include "signature.h"
 
 #include <git2/odb.h>
 #include <git2/commit.h>
@@ -28,7 +28,7 @@ BEGIN_TEST(query_details_test)
 		git_oid id;
 		git_commit *commit;
 
-		const git_person *author, *committer;
+		const git_signature *author, *committer;
 		const char *message, *message_short;
 		time_t commit_time;
 		unsigned int parents, p;
diff --git a/tests/t0403-write.c b/tests/t0403-write.c
index 8b29b05..c8e72da 100644
--- a/tests/t0403-write.c
+++ b/tests/t0403-write.c
@@ -1,11 +1,12 @@
 #include "test_lib.h"
 #include "test_helpers.h"
 #include "commit.h"
-#include "person.h"
+#include "signature.h"
 
 #include <git2/odb.h>
 #include <git2/commit.h>
 #include <git2/revwalk.h>
+#include <git2/signature.h>
 
 static const char *commit_ids[] = {
 	"a4a7dce85cf63874e984719f4fdd239f5145052f", /* 0 */
@@ -27,7 +28,7 @@ BEGIN_TEST(writenew_test)
 	git_commit *commit, *parent;
 	git_tree *tree;
 	git_oid id;
-	const git_person *author, *committer;
+	const git_signature *author, *committer;
 	/* char hex_oid[41]; */
 
 	must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
@@ -42,23 +43,33 @@ BEGIN_TEST(writenew_test)
 	git_commit_add_parent(commit, parent);
 
 	/* Set other attributes */
-	git_commit_set_committer(commit, COMMITTER_NAME, COMMITTER_EMAIL, 123456789);
-	git_commit_set_author(commit, COMMITTER_NAME, COMMITTER_EMAIL, 987654321);
+	committer = git_signature_new(COMMITTER_NAME, COMMITTER_EMAIL, 123456789, 60);
+	must_be_true(committer != NULL);
+
+	author = git_signature_new(COMMITTER_NAME, COMMITTER_EMAIL, 987654321, 90);
+	must_be_true(author != NULL);
+
+	git_commit_set_committer(commit, committer);
+	git_commit_set_author(commit, author);
 	git_commit_set_message(commit, COMMIT_MESSAGE);
 
+	git_signature_free((git_signature *)committer);
+	git_signature_free((git_signature *)author);
+
 	/* Check attributes were set correctly */
 	author = git_commit_author(commit);
 	must_be_true(author != NULL);
 	must_be_true(strcmp(author->name, COMMITTER_NAME) == 0);
 	must_be_true(strcmp(author->email, COMMITTER_EMAIL) == 0);
-	must_be_true(author->time == 987654321);
+	must_be_true(author->when.time == 987654321);
+	must_be_true(author->when.offset == 90);
 
 	committer = git_commit_committer(commit);
 	must_be_true(committer != NULL);
 	must_be_true(strcmp(committer->name, COMMITTER_NAME) == 0);
 	must_be_true(strcmp(committer->email, COMMITTER_EMAIL) == 0);
-	must_be_true(committer->time == 123456789);
-	must_be_true(git_commit_time(commit) == 123456789);
+	must_be_true(committer->when.time == 123456789);
+	must_be_true(committer->when.offset == 60);
 
 	must_be_true(strcmp(git_commit_message(commit), COMMIT_MESSAGE) == 0);
 
@@ -74,18 +85,8 @@ BEGIN_TEST(writenew_test)
 	/* Write to disk */
 	must_pass(git_object_write((git_object *)commit));
 
-	/* Show new SHA1 */
-/*
-	git_oid_fmt(hex_oid, git_commit_id(commit));
-	hex_oid[40] = 0;
-	printf("Written new commit, SHA1: %s\n", hex_oid);
-*/
-
 	must_pass(remove_loose_object(REPOSITORY_FOLDER, (git_object *)commit));
 
-	//git_person_free(&author);
-	//git_person_free(&committer);
-
 	git_repository_free(repo);
 END_TEST
 
@@ -104,12 +105,6 @@ BEGIN_TEST(writeback_test)
 
 	message = git_commit_message(commit);
 
-/*
-	git_oid_fmt(hex_oid, git_commit_id(commit));
-	hex_oid[40] = 0;
-	printf("Old SHA1: %s\n", hex_oid);
-*/
-
 	git_commit_set_message(commit, "This is a new test message. Cool!\n");
 
 	git_oid_mkstr(&id, commit_ids[4]);
@@ -119,12 +114,6 @@ BEGIN_TEST(writeback_test)
 
 	must_pass(git_object_write((git_object *)commit));
 
-/*
-	git_oid_fmt(hex_oid, git_commit_id(commit));
-	hex_oid[40] = 0;
-	printf("New SHA1: %s\n", hex_oid);
-*/
-
 	must_pass(remove_loose_object(REPOSITORY_FOLDER, (git_object *)commit));
 
 	git_repository_free(repo);
diff --git a/tests/t0502-list.c b/tests/t0502-list.c
index 04427f5..119f15f 100644
--- a/tests/t0502-list.c
+++ b/tests/t0502-list.c
@@ -4,6 +4,7 @@
 #include "revwalk.h"
 #include <git2/odb.h>
 #include <git2/commit.h>
+#include <git2/signature.h>
 
 BEGIN_TEST(list_timesort_test)
 
@@ -15,12 +16,13 @@ BEGIN_TEST(list_timesort_test)
 #define TEST_SORTED() \
 		previous_time = INT_MAX;\
 	for (n = list.head; n != NULL; n = n->next) {\
-		must_be_true(n->walk_commit->commit_object->commit_time <= previous_time);\
-		previous_time = n->walk_commit->commit_object->commit_time;\
+		must_be_true(n->walk_commit->commit_object->committer->when.time <= previous_time);\
+		previous_time = n->walk_commit->commit_object->committer->when.time;\
 	}
 
 #define CLEAR_LIST() \
 	for (n = list.head; n != NULL; n = n->next) {\
+		git_signature_free(n->walk_commit->commit_object->committer);\
 		free(n->walk_commit->commit_object);\
 		free(n->walk_commit);\
 	}\
@@ -37,7 +39,7 @@ BEGIN_TEST(list_timesort_test)
 			git_commit *c = git__malloc(sizeof(git_commit));
 			git_revwalk_commit *rc = git__malloc(sizeof(git_revwalk_commit));
 
-			c->commit_time = (time_t)rand();
+			c->committer = git_signature_new("", "", (time_t)rand(), 0);
 			rc->commit_object = c;
 
 			git_revwalk_list_push_back(&list, rc);
@@ -53,7 +55,7 @@ BEGIN_TEST(list_timesort_test)
 		git_commit *c = git__malloc(sizeof(git_commit));
 		git_revwalk_commit *rc = git__malloc(sizeof(git_revwalk_commit));
 
-		c->commit_time = 0;
+		c->committer = git_signature_new("", "", 0, 0);
 		rc->commit_object = c;
 
 		git_revwalk_list_push_back(&list, rc);