diff --git a/hook.c b/hook.c index 0ae935d9ad8bab..a56a202391d278 100644 --- a/hook.c +++ b/hook.c @@ -130,20 +130,14 @@ static char *get_post_index_change_sentinel_name(struct repository *r) { struct strbuf path = STRBUF_INIT; const char *sid = tr2_sid_get(); - char *slash = strchr(sid, '/'); - - /* - * Name is based on top-level SID, so children can indicate that - * the top-level process should run the post-command hook. - */ - if (slash) - *slash = 0; + const char *slash = strchrnul(sid, '/'); /* * Do not write to hooks directory, as it could be redirected * somewhere like the source tree. */ - repo_git_path_replace(r, &path, "info/index-change-%s.snt", sid); + repo_git_path_replace(r, &path, "info/index-change-%.*s.snt", + (int)(slash - sid), sid); return strbuf_detach(&path, NULL); } diff --git a/virtualfilesystem.c b/virtualfilesystem.c index 5be16010ffa103..5c75501285562c 100644 --- a/virtualfilesystem.c +++ b/virtualfilesystem.c @@ -148,7 +148,7 @@ int is_included_in_virtualfilesystem(const char *pathname, int pathlen) static void parent_directory_hashmap_add(struct hashmap *map, const char *pattern, const int patternlen) { - char *slash; + const char *slash; struct virtualfilesystem *vfs; /*