Skip to content

Commit 35fb4d2

Browse files
max630gitster
authored andcommitted
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 c7b3a3d). 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 <[email protected]> Signed-off-by: Max Kirillov <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 16ffa64 commit 35fb4d2

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

submodule.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,8 @@ static int add_submodule_odb(const char *path)
122122
struct strbuf objects_directory = STRBUF_INIT;
123123
struct alternate_object_database *alt_odb;
124124
int ret = 0;
125-
const char *git_dir;
126125

127-
strbuf_addf(&objects_directory, "%s/.git", path);
128-
git_dir = read_gitfile(objects_directory.buf);
129-
if (git_dir) {
130-
strbuf_reset(&objects_directory);
131-
strbuf_addstr(&objects_directory, git_dir);
132-
}
133-
strbuf_addstr(&objects_directory, "/objects/");
126+
strbuf_git_path_submodule(&objects_directory, path, "objects/");
134127
if (!is_directory(objects_directory.buf)) {
135128
ret = -1;
136129
goto done;

0 commit comments

Comments
 (0)