From: Max Kirillov Date: Sun, 13 Sep 2015 22:17:41 +0000 (+0300) Subject: submodule refactor: use strbuf_git_path_submodule() in add_submodule_odb() X-Git-Tag: v2.6.3~23^2~1 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/35fb4d2e3d4a3cd008ec0baa077939f60a64f244 submodule refactor: use strbuf_git_path_submodule() in add_submodule_odb() Functions which directly operate submodule's object database do not handle the case when the submodule is linked worktree (which are introduced in c7b3a3d2fe). Instead of fixing the path calculation use already existing strbuf_git_path_submodule() function without changing overall behaviour. Then it will be possible to modify only that function whenever we need to change real location of submodule's repository content. Helped-by: Jeff King Signed-off-by: Max Kirillov Signed-off-by: Junio C Hamano --- diff --git a/submodule.c b/submodule.c index 245ed4dfbb..5e5a46fe2a 100644 --- a/submodule.c +++ b/submodule.c @@ -122,15 +122,8 @@ static int add_submodule_odb(const char *path) struct strbuf objects_directory = STRBUF_INIT; struct alternate_object_database *alt_odb; int ret = 0; - const char *git_dir; - strbuf_addf(&objects_directory, "%s/.git", path); - git_dir = read_gitfile(objects_directory.buf); - if (git_dir) { - strbuf_reset(&objects_directory); - strbuf_addstr(&objects_directory, git_dir); - } - strbuf_addstr(&objects_directory, "/objects/"); + strbuf_git_path_submodule(&objects_directory, path, "objects/"); if (!is_directory(objects_directory.buf)) { ret = -1; goto done;