sha1-name.c: remove the_repo from get_oid_with_context_1()

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Apr 16, 2019 at 16:33 UTC efe461b0811352b539e2cc4721aa5efcf11f0255
1 file changed +10 -1
sha1-name.c
+10 -1
@@ -12,6 +12,7 @@
12 #include "packfile.h"
13 #include "object-store.h"
14 #include "repository.h"
15 +#include "submodule.h"
16 #include "midx.h"
17 #include "commit-reach.h"
18
@@ -1797,7 +1798,7 @@ static enum get_oid_result get_oid_with_context_1(struct repository *repo,
1798 oc->path = xstrdup(cp);
1799
1800 if (!repo->index->cache)
1800 - repo_read_index(the_repository);
1801 + repo_read_index(repo);
1802 pos = index_name_pos(repo->index, cp, namelen);
1803 if (pos < 0)
1804 pos = -pos - 1;
@@ -1842,6 +1843,14 @@ static enum get_oid_result get_oid_with_context_1(struct repository *repo,
1843 new_filename = resolve_relative_path(repo, filename);
1844 if (new_filename)
1845 filename = new_filename;
1846 + /*
1847 + * NEEDSWORK: Eventually get_tree_entry*() should
1848 + * learn to take struct repository directly and we
1849 + * would not need to inject submodule odb to the
1850 + * in-core odb.
1851 + */
1852 + if (repo != the_repository)
1853 + add_to_alternates_memory(repo->objects->odb->path);
1854 if (flags & GET_OID_FOLLOW_SYMLINKS) {
1855 ret = get_tree_entry_follow_symlinks(&tree_oid,
1856 filename, oid, &oc->symlink_path,