diff options
-rw-r--r-- | refs.c | 19 |
1 files changed, 13 insertions, 6 deletions
@@ -1301,19 +1301,26 @@ const char *resolve_ref_unsafe(const char *refname, int resolve_flags, int resolve_gitlink_ref(const char *path, const char *refname, unsigned char *sha1) { - int len = strlen(path); - struct strbuf submodule = STRBUF_INIT; + size_t len = strlen(path); struct ref_store *refs; int flags; - while (len && path[len-1] == '/') + while (len && path[len - 1] == '/') len--; + if (!len) return -1; - strbuf_add(&submodule, path, len); - refs = get_ref_store(submodule.buf); - strbuf_release(&submodule); + if (path[len]) { + /* We need to strip off one or more trailing slashes */ + char *stripped = xmemdupz(path, len); + + refs = get_ref_store(stripped); + free(stripped); + } else { + refs = get_ref_store(path); + } + if (!refs) return -1; |