@@ -98,12 +98,38 @@ static int process_tag(struct tag *tag)
98
98
static struct object_list * process_queue = NULL ;
99
99
static struct object_list * * process_queue_end = & process_queue ;
100
100
101
- static int process ( unsigned char * sha1 , const char * type )
101
+ static int process_object ( struct object * obj )
102
102
{
103
- struct object * obj ;
104
- if (has_sha1_file (sha1 ))
103
+ if (obj -> type == commit_type ) {
104
+ if (process_commit ((struct commit * )obj ))
105
+ return -1 ;
106
+ return 0 ;
107
+ }
108
+ if (obj -> type == tree_type ) {
109
+ if (process_tree ((struct tree * )obj ))
110
+ return -1 ;
111
+ return 0 ;
112
+ }
113
+ if (obj -> type == blob_type ) {
114
+ return 0 ;
115
+ }
116
+ if (obj -> type == tag_type ) {
117
+ if (process_tag ((struct tag * )obj ))
118
+ return -1 ;
105
119
return 0 ;
106
- obj = lookup_object_type (sha1 , type );
120
+ }
121
+ return error ("Unable to determine requirements "
122
+ "of type %s for %s" ,
123
+ obj -> type , sha1_to_hex (obj -> sha1 ));
124
+ }
125
+
126
+ static int process (unsigned char * sha1 , const char * type )
127
+ {
128
+ struct object * obj = lookup_object_type (sha1 , type );
129
+ if (has_sha1_file (sha1 )) {
130
+ /* We already have it, so we should scan it now. */
131
+ return process_object (obj );
132
+ }
107
133
if (object_list_contains (process_queue , obj ))
108
134
return 0 ;
109
135
object_list_insert (obj , process_queue_end );
@@ -134,27 +160,8 @@ static int loop(void)
134
160
return -1 ;
135
161
if (!obj -> type )
136
162
parse_object (obj -> sha1 );
137
- if (obj -> type == commit_type ) {
138
- if (process_commit ((struct commit * )obj ))
139
- return -1 ;
140
- continue ;
141
- }
142
- if (obj -> type == tree_type ) {
143
- if (process_tree ((struct tree * )obj ))
144
- return -1 ;
145
- continue ;
146
- }
147
- if (obj -> type == blob_type ) {
148
- continue ;
149
- }
150
- if (obj -> type == tag_type ) {
151
- if (process_tag ((struct tag * )obj ))
152
- return -1 ;
153
- continue ;
154
- }
155
- return error ("Unable to determine requirements "
156
- "of type %s for %s" ,
157
- obj -> type , sha1_to_hex (obj -> sha1 ));
163
+ if (process_object (obj ))
164
+ return -1 ;
158
165
}
159
166
return 0 ;
160
167
}
0 commit comments