Skip to content

Commit af4f640

Browse files
committed
Merge branch 'jc/maint-unpack-objects-strict' into maint
* jc/maint-unpack-objects-strict: Fix "unpack-objects --strict" Conflicts: builtin-unpack-objects.c
2 parents 6674d31 + 9a21739 commit af4f640

File tree

2 files changed

+44
-7
lines changed

2 files changed

+44
-7
lines changed

builtin-unpack-objects.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,10 @@ static void write_cached_object(struct object *obj)
181181
static int check_object(struct object *obj, int type, void *data)
182182
{
183183
if (!obj)
184-
return 0;
184+
return 1;
185185

186186
if (obj->flags & FLAG_WRITTEN)
187-
return 1;
187+
return 0;
188188

189189
if (type != OBJ_ANY && obj->type != type)
190190
die("object type mismatch");
@@ -195,22 +195,24 @@ static int check_object(struct object *obj, int type, void *data)
195195
if (type != obj->type || type <= 0)
196196
die("object of unexpected type");
197197
obj->flags |= FLAG_WRITTEN;
198-
return 1;
198+
return 0;
199199
}
200200

201201
if (fsck_object(obj, 1, fsck_error_function))
202202
die("Error in object");
203-
if (!fsck_walk(obj, check_object, NULL))
203+
if (fsck_walk(obj, check_object, NULL))
204204
die("Error on reachable objects of %s", sha1_to_hex(obj->sha1));
205205
write_cached_object(obj);
206-
return 1;
206+
return 0;
207207
}
208208

209209
static void write_rest(void)
210210
{
211211
unsigned i;
212-
for (i = 0; i < nr_objects; i++)
213-
check_object(obj_list[i].obj, OBJ_ANY, NULL);
212+
for (i = 0; i < nr_objects; i++) {
213+
if (obj_list[i].obj)
214+
check_object(obj_list[i].obj, OBJ_ANY, NULL);
215+
}
214216
}
215217

216218
static void added_object(unsigned nr, enum object_type type,

t/t5531-deep-submodule-push.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/sh
2+
3+
test_description='unpack-objects'
4+
5+
. ./test-lib.sh
6+
7+
test_expect_success setup '
8+
mkdir pub.git &&
9+
GIT_DIR=pub.git git init --bare
10+
GIT_DIR=pub.git git config receive.fsckobjects true &&
11+
mkdir work &&
12+
(
13+
cd work &&
14+
git init &&
15+
mkdir -p gar/bage &&
16+
(
17+
cd gar/bage &&
18+
git init &&
19+
>junk &&
20+
git add junk &&
21+
git commit -m "Initial junk"
22+
) &&
23+
git add gar/bage &&
24+
git commit -m "Initial superproject"
25+
)
26+
'
27+
28+
test_expect_success push '
29+
(
30+
cd work &&
31+
git push ../pub.git master
32+
)
33+
'
34+
35+
test_done

0 commit comments

Comments
 (0)