@@ -764,30 +764,30 @@ static int fsck_ident(const char **ident,
764
764
return 0 ;
765
765
}
766
766
767
- static int fsck_commit (struct commit * commit , const char * buffer ,
768
- unsigned long size , struct fsck_options * options )
767
+ static int fsck_commit (const struct object_id * oid ,
768
+ const char * buffer , unsigned long size ,
769
+ struct fsck_options * options )
769
770
{
770
771
struct object_id tree_oid , parent_oid ;
771
772
unsigned author_count ;
772
773
int err ;
773
774
const char * buffer_begin = buffer ;
774
775
const char * p ;
775
776
776
- if (verify_headers (buffer , size , & commit -> object .oid ,
777
- commit -> object .type , options ))
777
+ if (verify_headers (buffer , size , oid , OBJ_COMMIT , options ))
778
778
return -1 ;
779
779
780
780
if (!skip_prefix (buffer , "tree " , & buffer ))
781
- return report (options , & commit -> object . oid , commit -> object . type , FSCK_MSG_MISSING_TREE , "invalid format - expected 'tree' line" );
781
+ return report (options , oid , OBJ_COMMIT , FSCK_MSG_MISSING_TREE , "invalid format - expected 'tree' line" );
782
782
if (parse_oid_hex (buffer , & tree_oid , & p ) || * p != '\n' ) {
783
- err = report (options , & commit -> object . oid , commit -> object . type , FSCK_MSG_BAD_TREE_SHA1 , "invalid 'tree' line format - bad sha1" );
783
+ err = report (options , oid , OBJ_COMMIT , FSCK_MSG_BAD_TREE_SHA1 , "invalid 'tree' line format - bad sha1" );
784
784
if (err )
785
785
return err ;
786
786
}
787
787
buffer = p + 1 ;
788
788
while (skip_prefix (buffer , "parent " , & buffer )) {
789
789
if (parse_oid_hex (buffer , & parent_oid , & p ) || * p != '\n' ) {
790
- err = report (options , & commit -> object . oid , commit -> object . type , FSCK_MSG_BAD_PARENT_SHA1 , "invalid 'parent' line format - bad sha1" );
790
+ err = report (options , oid , OBJ_COMMIT , FSCK_MSG_BAD_PARENT_SHA1 , "invalid 'parent' line format - bad sha1" );
791
791
if (err )
792
792
return err ;
793
793
}
@@ -796,23 +796,23 @@ static int fsck_commit(struct commit *commit, const char *buffer,
796
796
author_count = 0 ;
797
797
while (skip_prefix (buffer , "author " , & buffer )) {
798
798
author_count ++ ;
799
- err = fsck_ident (& buffer , & commit -> object . oid , commit -> object . type , options );
799
+ err = fsck_ident (& buffer , oid , OBJ_COMMIT , options );
800
800
if (err )
801
801
return err ;
802
802
}
803
803
if (author_count < 1 )
804
- err = report (options , & commit -> object . oid , commit -> object . type , FSCK_MSG_MISSING_AUTHOR , "invalid format - expected 'author' line" );
804
+ err = report (options , oid , OBJ_COMMIT , FSCK_MSG_MISSING_AUTHOR , "invalid format - expected 'author' line" );
805
805
else if (author_count > 1 )
806
- err = report (options , & commit -> object . oid , commit -> object . type , FSCK_MSG_MULTIPLE_AUTHORS , "invalid format - multiple 'author' lines" );
806
+ err = report (options , oid , OBJ_COMMIT , FSCK_MSG_MULTIPLE_AUTHORS , "invalid format - multiple 'author' lines" );
807
807
if (err )
808
808
return err ;
809
809
if (!skip_prefix (buffer , "committer " , & buffer ))
810
- return report (options , & commit -> object . oid , commit -> object . type , FSCK_MSG_MISSING_COMMITTER , "invalid format - expected 'committer' line" );
811
- err = fsck_ident (& buffer , & commit -> object . oid , commit -> object . type , options );
810
+ return report (options , oid , OBJ_COMMIT , FSCK_MSG_MISSING_COMMITTER , "invalid format - expected 'committer' line" );
811
+ err = fsck_ident (& buffer , oid , OBJ_COMMIT , options );
812
812
if (err )
813
813
return err ;
814
814
if (memchr (buffer_begin , '\0' , size )) {
815
- err = report (options , & commit -> object . oid , commit -> object . type , FSCK_MSG_NUL_IN_COMMIT ,
815
+ err = report (options , oid , OBJ_COMMIT , FSCK_MSG_NUL_IN_COMMIT ,
816
816
"NUL byte in the commit object body" );
817
817
if (err )
818
818
return err ;
@@ -984,8 +984,7 @@ int fsck_object(struct object *obj, void *data, unsigned long size,
984
984
if (obj -> type == OBJ_TREE )
985
985
return fsck_tree ((struct tree * ) obj , data , size , options );
986
986
if (obj -> type == OBJ_COMMIT )
987
- return fsck_commit ((struct commit * ) obj , (const char * ) data ,
988
- size , options );
987
+ return fsck_commit (& obj -> oid , data , size , options );
989
988
if (obj -> type == OBJ_TAG )
990
989
return fsck_tag (& obj -> oid , data , size , options );
991
990
0 commit comments