summaryrefslogtreecommitdiff
path: root/match-trees.c
diff options
context:
space:
mode:
Diffstat (limited to 'match-trees.c')
-rw-r--r--match-trees.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/match-trees.c b/match-trees.c
index 7873cde..e80b4af 100644
--- a/match-trees.c
+++ b/match-trees.c
@@ -182,13 +182,10 @@ static int splice_tree(const unsigned char *hash1,
enum object_type type;
int status;
- subpath = strchr(prefix, '/');
- if (!subpath)
- toplen = strlen(prefix);
- else {
- toplen = subpath - prefix;
+ subpath = strchrnul(prefix, '/');
+ toplen = subpath - prefix;
+ if (*subpath)
subpath++;
- }
buf = read_sha1_file(hash1, &type, &sz);
if (!buf)
@@ -215,7 +212,7 @@ static int splice_tree(const unsigned char *hash1,
if (!rewrite_here)
die("entry %.*s not found in tree %s",
toplen, prefix, sha1_to_hex(hash1));
- if (subpath) {
+ if (*subpath) {
status = splice_tree(rewrite_here, subpath, hash2, subtree);
if (status)
return status;