Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2019-01-15 03:39:42 +0300
committerJunio C Hamano <gitster@pobox.com>2019-01-15 20:57:41 +0300
commit36775ab524a1d180aaaac089e25b5aeb87793a17 (patch)
tree7edeb9206226bfeac21298e834a7f9e30656b8ad /match-trees.c
parent0a3faa45b1d35b227182166769357e0878da8f92 (diff)
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>
Diffstat (limited to 'match-trees.c')
-rw-r--r--match-trees.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/match-trees.c b/match-trees.c
index 2b6d31ef9d..feca48a5fd 100644
--- a/match-trees.c
+++ b/match-trees.c
@@ -199,15 +199,16 @@ static int splice_tree(const struct object_id *oid1, const char *prefix,
while (desc.size) {
const char *name;
unsigned mode;
- const struct object_id *oid;
- oid = tree_entry_extract(&desc, &name, &mode);
+ tree_entry_extract(&desc, &name, &mode);
if (strlen(name) == toplen &&
!memcmp(name, prefix, toplen)) {
if (!S_ISDIR(mode))
die("entry %s in tree %s is not a tree", name,
oid_to_hex(oid1));
- rewrite_here = (struct object_id *)oid;
+ rewrite_here = (struct object_id *)(desc.entry.path +
+ strlen(desc.entry.path) +
+ 1);
break;
}
update_tree_entry(&desc);