Skip to content

Commit

Permalink
submodule refactor: use strbuf_git_path_submodule() in add_submodule_…
Browse files Browse the repository at this point in the history
…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 <peff@peff.net>
Signed-off-by: Max Kirillov <max@max630.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Max Kirillov authored and Junio C Hamano committed Sep 14, 2015
1 parent 16ffa64 commit 35fb4d2
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions submodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 35fb4d2

Please sign in to comment.