Skip to content

Commit 2d40cad

Browse files
committed
Merge branch 'jc/maint-allow-uninteresting-missing'
* jc/maint-allow-uninteresting-missing: revision traversal: allow UNINTERESTING objects to be missing
2 parents b37f26d + aeeae1b commit 2d40cad

File tree

2 files changed

+44
-3
lines changed

2 files changed

+44
-3
lines changed

revision.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,11 @@ static struct commit *handle_commit(struct rev_info *revs, struct object *object
183183
if (!tag->tagged)
184184
die("bad tag");
185185
object = parse_object(tag->tagged->sha1);
186-
if (!object)
186+
if (!object) {
187+
if (flags & UNINTERESTING)
188+
return NULL;
187189
die("bad object %s", sha1_to_hex(tag->tagged->sha1));
190+
}
188191
}
189192

190193
/*
@@ -479,9 +482,10 @@ static int add_parents_to_list(struct rev_info *revs, struct commit *commit,
479482
while (parent) {
480483
struct commit *p = parent->item;
481484
parent = parent->next;
485+
if (p)
486+
p->object.flags |= UNINTERESTING;
482487
if (parse_commit(p) < 0)
483-
return -1;
484-
p->object.flags |= UNINTERESTING;
488+
continue;
485489
if (p->parents)
486490
mark_parents_uninteresting(p);
487491
if (p->object.flags & SEEN)

t/t5519-push-alternates.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,41 @@ test_expect_success 'bob works and pushes' '
103103
)
104104
'
105105

106+
test_expect_success 'alice works and pushes yet again' '
107+
(
108+
# Alice does not care what Bob does. She does not
109+
# even have to be aware of his existence. She just
110+
# keeps working and pushing
111+
cd alice-work &&
112+
echo more and more alice >file &&
113+
git commit -a -m sixth.1 &&
114+
echo more and more alice >>file &&
115+
git commit -a -m sixth.2 &&
116+
echo more and more alice >>file &&
117+
git commit -a -m sixth.3 &&
118+
git push ../alice-pub
119+
)
120+
'
121+
122+
test_expect_success 'bob works and pushes again' '
123+
(
124+
cd alice-pub &&
125+
git cat-file commit master >../bob-work/commit
126+
)
127+
(
128+
# This time Bob does not pull from Alice, and
129+
# the master branch at her public repository points
130+
# at a commit Bob does not fully know about, but
131+
# he happens to have the commit object (but not the
132+
# necessary tree) in his repository from Alice.
133+
# This should not prevent the push by Bob from
134+
# succeeding.
135+
cd bob-work &&
136+
git hash-object -t commit -w commit &&
137+
echo even more bob >file &&
138+
git commit -a -m seventh &&
139+
git push ../bob-pub
140+
)
141+
'
142+
106143
test_done

0 commit comments

Comments
 (0)