sha1-name.c: remove the_repo from get_oid_basic()
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
49281cf54433c68ce488d41675681116b6b31b47
1 file changed
+12
-13
sha1-name.c
+12
-13
@@ -773,8 +773,8 @@ static inline int push_mark(const char *string, int len)
773
static enum get_oid_result get_oid_1(const char *name, int len, struct object_id *oid, unsigned lookup_flags);
774
static int interpret_nth_prior_checkout(struct repository *r, const char *name, int namelen, struct strbuf *buf);
775
776
-static int get_oid_basic(const char *str, int len, struct object_id *oid,
777
- unsigned int flags)
776
+static int get_oid_basic(struct repository *r, const char *str, int len,
777
+ struct object_id *oid, unsigned int flags)
778
{
779
static const char *warn_msg = "refname '%.*s' is ambiguous.";
780
static const char *object_name_msg = N_(
@@ -792,9 +792,9 @@ static int get_oid_basic(const char *str, int len, struct object_id *oid,
792
int refs_found = 0;
793
int at, reflog_len, nth_prior = 0;
794
795
- if (len == the_hash_algo->hexsz && !get_oid_hex(str, oid)) {
795
+ if (len == r->hash_algo->hexsz && !get_oid_hex(str, oid)) {
796
if (warn_ambiguous_refs && warn_on_object_refname_ambiguity) {
797
- refs_found = dwim_ref(str, len, &tmp_oid, &real_ref);
797
+ refs_found = repo_dwim_ref(r, str, len, &tmp_oid, &real_ref);
798
if (refs_found > 0) {
799
warning(warn_msg, len, str);
800
if (advice_object_name_warning)
@@ -835,8 +835,8 @@ static int get_oid_basic(const char *str, int len, struct object_id *oid,
835
struct strbuf buf = STRBUF_INIT;
836
int detached;
837
838
- if (interpret_nth_prior_checkout(the_repository, str, len, &buf) > 0) {
839
- detached = (buf.len == the_hash_algo->hexsz && !get_oid_hex(buf.buf, oid));
838
+ if (interpret_nth_prior_checkout(r, str, len, &buf) > 0) {
839
+ detached = (buf.len == r->hash_algo->hexsz && !get_oid_hex(buf.buf, oid));
840
strbuf_release(&buf);
841
if (detached)
842
return 0;
@@ -845,19 +845,18 @@ static int get_oid_basic(const char *str, int len, struct object_id *oid,
845
846
if (!len && reflog_len)
847
/* allow "@{...}" to mean the current branch reflog */
848
- refs_found = dwim_ref("HEAD", 4, oid, &real_ref);
848
+ refs_found = repo_dwim_ref(r, "HEAD", 4, oid, &real_ref);
849
else if (reflog_len)
850
- refs_found = dwim_log(str, len, oid, &real_ref);
850
+ refs_found = repo_dwim_log(r, str, len, oid, &real_ref);
851
else
852
- refs_found = dwim_ref(str, len, oid, &real_ref);
852
+ refs_found = repo_dwim_ref(r, str, len, oid, &real_ref);
853
854
if (!refs_found)
855
return -1;
856
857
if (warn_ambiguous_refs && !(flags & GET_OID_QUIETLY) &&
858
(refs_found > 1 ||
859
- !get_short_oid(the_repository,
860
- str, len, &tmp_oid, GET_OID_QUIETLY)))
859
+ !get_short_oid(r, str, len, &tmp_oid, GET_OID_QUIETLY)))
860
warning(warn_msg, len, str);
861
862
if (reflog_len) {
@@ -889,7 +888,7 @@ static int get_oid_basic(const char *str, int len, struct object_id *oid,
888
return -1;
889
}
890
}
892
- if (read_ref_at(get_main_ref_store(the_repository),
891
+ if (read_ref_at(get_main_ref_store(r),
892
real_ref, flags, at_time, nth, oid, NULL,
893
&co_time, &co_tz, &co_cnt)) {
894
if (!len) {
@@ -1159,7 +1158,7 @@ static enum get_oid_result get_oid_1(const char *name, int len,
1158
if (!ret)
1159
return FOUND;
1160
1162
- ret = get_oid_basic(name, len, oid, lookup_flags);
1161
+ ret = get_oid_basic(the_repository, name, len, oid, lookup_flags);
1162
if (!ret)
1163
return FOUND;
1164