match-trees: compute buffer offset correctly when splicing
Currently, the struct object_id pointer returned from tree_entry_extract lives directly inside the parsed tree buffer. In a future commit, this will change so that it instead points to a dedicated struct member. Since in this code path, we want to modify the buffer directly, compute the buffer offset we want to modify by using the pointer to the path instead. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
0a3faa45b1
commit
36775ab524
@ -199,15 +199,16 @@ static int splice_tree(const struct object_id *oid1, const char *prefix,
|
|||||||
while (desc.size) {
|
while (desc.size) {
|
||||||
const char *name;
|
const char *name;
|
||||||
unsigned mode;
|
unsigned mode;
|
||||||
const struct object_id *oid;
|
|
||||||
|
|
||||||
oid = tree_entry_extract(&desc, &name, &mode);
|
tree_entry_extract(&desc, &name, &mode);
|
||||||
if (strlen(name) == toplen &&
|
if (strlen(name) == toplen &&
|
||||||
!memcmp(name, prefix, toplen)) {
|
!memcmp(name, prefix, toplen)) {
|
||||||
if (!S_ISDIR(mode))
|
if (!S_ISDIR(mode))
|
||||||
die("entry %s in tree %s is not a tree", name,
|
die("entry %s in tree %s is not a tree", name,
|
||||||
oid_to_hex(oid1));
|
oid_to_hex(oid1));
|
||||||
rewrite_here = (struct object_id *)oid;
|
rewrite_here = (struct object_id *)(desc.entry.path +
|
||||||
|
strlen(desc.entry.path) +
|
||||||
|
1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
update_tree_entry(&desc);
|
update_tree_entry(&desc);
|
||||||
|
Loading…
Reference in New Issue
Block a user