mirror of
https://git.proxmox.com/git/libgit2
synced 2025-06-21 16:56:53 +00:00
Convert enqueue_object to a function
This commit is contained in:
parent
799f9a04e3
commit
bef2a12cc0
40
src/push.c
40
src/push.c
@ -347,6 +347,20 @@ on_error:
|
|||||||
return error == GIT_ITEROVER ? 0 : error;
|
return error == GIT_ITEROVER ? 0 : error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int enqueue_object(
|
||||||
|
const git_tree_entry *entry,
|
||||||
|
git_packbuilder *pb)
|
||||||
|
{
|
||||||
|
switch (git_tree_entry_type(entry)) {
|
||||||
|
case GIT_OBJ_COMMIT:
|
||||||
|
return 0;
|
||||||
|
case GIT_OBJ_TREE:
|
||||||
|
return git_packbuilder_insert_tree(pb, &entry->oid);
|
||||||
|
default:
|
||||||
|
return git_packbuilder_insert(pb, &entry->oid, entry->filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int queue_differences(
|
static int queue_differences(
|
||||||
git_tree *base,
|
git_tree *base,
|
||||||
git_tree *delta,
|
git_tree *delta,
|
||||||
@ -358,22 +372,6 @@ static int queue_differences(
|
|||||||
size_t i = 0, j = 0;
|
size_t i = 0, j = 0;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
#define _enqueue_object(ENTRY) do { \
|
|
||||||
switch (git_tree_entry_type((ENTRY))) { \
|
|
||||||
case GIT_OBJ_COMMIT: \
|
|
||||||
break; \
|
|
||||||
case GIT_OBJ_TREE: \
|
|
||||||
if ((error = git_packbuilder_insert_tree(pb, &(ENTRY)->oid)) < 0) \
|
|
||||||
goto on_error; \
|
|
||||||
break; \
|
|
||||||
default: \
|
|
||||||
if ((error = git_packbuilder_insert(pb, &(ENTRY)->oid, \
|
|
||||||
(ENTRY)->filename)) < 0) \
|
|
||||||
goto on_error; \
|
|
||||||
break; \
|
|
||||||
} \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
while (i < b_length && j < d_length) {
|
while (i < b_length && j < d_length) {
|
||||||
const git_tree_entry *b_entry = git_tree_entry_byindex(base, i);
|
const git_tree_entry *b_entry = git_tree_entry_byindex(base, i);
|
||||||
const git_tree_entry *d_entry = git_tree_entry_byindex(delta, j);
|
const git_tree_entry *d_entry = git_tree_entry_byindex(delta, j);
|
||||||
@ -409,8 +407,9 @@ static int queue_differences(
|
|||||||
}
|
}
|
||||||
/* If the object is new or different in the right-hand tree,
|
/* If the object is new or different in the right-hand tree,
|
||||||
* then enumerate it */
|
* then enumerate it */
|
||||||
else if (cmp >= 0)
|
else if (cmp >= 0 &&
|
||||||
_enqueue_object(d_entry);
|
(error = enqueue_object(d_entry, pb)) < 0)
|
||||||
|
goto on_error;
|
||||||
|
|
||||||
loop:
|
loop:
|
||||||
if (cmp <= 0) i++;
|
if (cmp <= 0) i++;
|
||||||
@ -419,9 +418,8 @@ static int queue_differences(
|
|||||||
|
|
||||||
/* Drain the right-hand tree of entries */
|
/* Drain the right-hand tree of entries */
|
||||||
for (; j < d_length; j++)
|
for (; j < d_length; j++)
|
||||||
_enqueue_object(git_tree_entry_byindex(delta, j));
|
if ((error = enqueue_object(git_tree_entry_byindex(delta, j), pb)) < 0)
|
||||||
|
goto on_error;
|
||||||
#undef _enqueue_object
|
|
||||||
|
|
||||||
error = 0;
|
error = 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user