summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2014-07-31 21:16:40 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2014-07-31 21:16:40 +0200
commitb69256816f2ea27cfa99d906363fc292517b43a4 (patch)
tree8d2432dd34d2201286baeb194c6d3bb328ee25ba /src
parent28f087c8642ff9c8dd6964e101e6d8539db6281a (diff)
downloadlibgit2-cmn/treebuilder-set-attribute.tar.gz
treebuilder: set the attributes before sorting and insertingcmn/treebuilder-set-attribute
We need to set the attributes before we try to insert it into the vector, as the comparison function needs to know whether the entry is a tree or not.
Diffstat (limited to 'src')
-rw-r--r--src/tree.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/tree.c b/src/tree.c
index b64efe460..4ddb26b2d 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -667,10 +667,16 @@ int git_treebuilder_insert(
entry->removed = 0;
bld->entrycount++;
}
+
+ entry->attr = filemode;
+ git_oid_cpy(&entry->oid, id);
} else {
entry = alloc_entry(filename);
GITERR_CHECK_ALLOC(entry);
+ entry->attr = filemode;
+ git_oid_cpy(&entry->oid, id);
+
if (git_vector_insert_sorted(&bld->entries, entry, NULL) < 0) {
git__free(entry);
return -1;
@@ -679,9 +685,6 @@ int git_treebuilder_insert(
bld->entrycount++;
}
- git_oid_cpy(&entry->oid, id);
- entry->attr = filemode;
-
if (entry_out)
*entry_out = entry;