@@ -38,6 +38,7 @@ static int show_dangling = 1;
38
38
#define ERROR_OBJECT 01
39
39
#define ERROR_REACHABLE 02
40
40
#define ERROR_PACK 04
41
+ #define ERROR_REFS 010
41
42
42
43
#ifdef NO_D_INO_IN_DIRENT
43
44
#define SORT_DIRENT 0
@@ -521,8 +522,10 @@ static int fsck_handle_ref(const char *refname, const struct object_id *oid,
521
522
/* We'll continue with the rest despite the error.. */
522
523
return 0 ;
523
524
}
524
- if (obj -> type != OBJ_COMMIT && is_branch (refname ))
525
+ if (obj -> type != OBJ_COMMIT && is_branch (refname )) {
525
526
error ("%s: not a commit" , refname );
527
+ errors_found |= ERROR_REFS ;
528
+ }
526
529
default_refs ++ ;
527
530
obj -> used = 1 ;
528
531
mark_object_reachable (obj );
@@ -585,17 +588,23 @@ static int fsck_head_link(void)
585
588
fprintf (stderr , "Checking HEAD link\n" );
586
589
587
590
head_points_at = resolve_ref_unsafe ("HEAD" , 0 , head_oid .hash , & flag );
588
- if (!head_points_at )
591
+ if (!head_points_at ) {
592
+ errors_found |= ERROR_REFS ;
589
593
return error ("Invalid HEAD" );
594
+ }
590
595
if (!strcmp (head_points_at , "HEAD" ))
591
596
/* detached HEAD */
592
597
null_is_error = 1 ;
593
- else if (!starts_with (head_points_at , "refs/heads/" ))
598
+ else if (!starts_with (head_points_at , "refs/heads/" )) {
599
+ errors_found |= ERROR_REFS ;
594
600
return error ("HEAD points to something strange (%s)" ,
595
601
head_points_at );
602
+ }
596
603
if (is_null_oid (& head_oid )) {
597
- if (null_is_error )
604
+ if (null_is_error ) {
605
+ errors_found |= ERROR_REFS ;
598
606
return error ("HEAD: detached HEAD points at nothing" );
607
+ }
599
608
fprintf (stderr , "notice: HEAD points to an unborn branch (%s)\n" ,
600
609
head_points_at + 11 );
601
610
}
@@ -615,6 +624,7 @@ static int fsck_cache_tree(struct cache_tree *it)
615
624
if (!obj ) {
616
625
error ("%s: invalid sha1 pointer in cache-tree" ,
617
626
sha1_to_hex (it -> sha1 ));
627
+ errors_found |= ERROR_REFS ;
618
628
return 1 ;
619
629
}
620
630
obj -> used = 1 ;
0 commit comments