Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'object-name.c')
-rw-r--r--object-name.c68
1 files changed, 47 insertions, 21 deletions
diff --git a/object-name.c b/object-name.c
index 2dd1a0f56e..3a2ef5d680 100644
--- a/object-name.c
+++ b/object-name.c
@@ -1,18 +1,25 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "object-name.h"
+#include "advice.h"
#include "config.h"
+#include "environment.h"
+#include "gettext.h"
+#include "hex.h"
#include "tag.h"
#include "commit.h"
#include "tree.h"
-#include "blob.h"
#include "tree-walk.h"
#include "refs.h"
#include "remote.h"
#include "dir.h"
#include "oid-array.h"
+#include "oidtree.h"
#include "packfile.h"
-#include "object-store.h"
+#include "pretty.h"
+#include "object-store-ll.h"
+#include "read-cache-ll.h"
#include "repository.h"
-#include "submodule.h"
+#include "setup.h"
#include "midx.h"
#include "commit-reach.h"
#include "date.h"
@@ -223,7 +230,7 @@ static int finish_object_disambiguation(struct disambiguate_state *ds,
static int disambiguate_commit_only(struct repository *r,
const struct object_id *oid,
- void *cb_data_unused)
+ void *cb_data UNUSED)
{
int kind = oid_object_info(r, oid, NULL);
return kind == OBJ_COMMIT;
@@ -231,7 +238,7 @@ static int disambiguate_commit_only(struct repository *r,
static int disambiguate_committish_only(struct repository *r,
const struct object_id *oid,
- void *cb_data_unused)
+ void *cb_data UNUSED)
{
struct object *obj;
int kind;
@@ -251,7 +258,7 @@ static int disambiguate_committish_only(struct repository *r,
static int disambiguate_tree_only(struct repository *r,
const struct object_id *oid,
- void *cb_data_unused)
+ void *cb_data UNUSED)
{
int kind = oid_object_info(r, oid, NULL);
return kind == OBJ_TREE;
@@ -259,7 +266,7 @@ static int disambiguate_tree_only(struct repository *r,
static int disambiguate_treeish_only(struct repository *r,
const struct object_id *oid,
- void *cb_data_unused)
+ void *cb_data UNUSED)
{
struct object *obj;
int kind;
@@ -279,7 +286,7 @@ static int disambiguate_treeish_only(struct repository *r,
static int disambiguate_blob_only(struct repository *r,
const struct object_id *oid,
- void *cb_data_unused)
+ void *cb_data UNUSED)
{
int kind = oid_object_info(r, oid, NULL);
return kind == OBJ_BLOB;
@@ -394,8 +401,10 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)
if (commit) {
struct pretty_print_context pp = {0};
pp.date_mode.type = DATE_SHORT;
- format_commit_message(commit, "%ad", &date, &pp);
- format_commit_message(commit, "%s", &msg, &pp);
+ repo_format_commit_message(the_repository, commit,
+ "%ad", &date, &pp);
+ repo_format_commit_message(the_repository, commit,
+ "%s", &msg, &pp);
}
/*
@@ -473,7 +482,7 @@ static int collect_ambiguous(const struct object_id *oid, void *data)
return 0;
}
-static int repo_collect_ambiguous(struct repository *r,
+static int repo_collect_ambiguous(struct repository *r UNUSED,
const struct object_id *oid,
void *data)
{
@@ -665,7 +674,7 @@ static int extend_abbrev_len(const struct object_id *oid, void *cb_data)
return 0;
}
-static int repo_extend_abbrev_len(struct repository *r,
+static int repo_extend_abbrev_len(struct repository *r UNUSED,
const struct object_id *oid,
void *cb_data)
{
@@ -758,6 +767,21 @@ static void find_abbrev_len_packed(struct min_abbrev_data *mad)
find_abbrev_len_for_pack(p, mad);
}
+void strbuf_repo_add_unique_abbrev(struct strbuf *sb, struct repository *repo,
+ const struct object_id *oid, int abbrev_len)
+{
+ int r;
+ strbuf_grow(sb, GIT_MAX_HEXSZ + 1);
+ r = repo_find_unique_abbrev_r(repo, sb->buf + sb->len, oid, abbrev_len);
+ strbuf_setlen(sb, sb->len + r);
+}
+
+void strbuf_add_unique_abbrev(struct strbuf *sb, const struct object_id *oid,
+ int abbrev_len)
+{
+ strbuf_repo_add_unique_abbrev(sb, the_repository, oid, abbrev_len);
+}
+
int repo_find_unique_abbrev_r(struct repository *r, char *hex,
const struct object_id *oid, int len)
{
@@ -898,6 +922,7 @@ static int get_oid_basic(struct repository *r, const char *str, int len,
char *real_ref = NULL;
int refs_found = 0;
int at, reflog_len, nth_prior = 0;
+ int fatal = !(flags & GET_OID_QUIETLY);
if (len == r->hash_algo->hexsz && !get_oid_hex(str, oid)) {
if (warn_ambiguous_refs && warn_on_object_refname_ambiguity) {
@@ -952,11 +977,11 @@ static int get_oid_basic(struct repository *r, const char *str, int len,
if (!len && reflog_len)
/* allow "@{...}" to mean the current branch reflog */
- refs_found = repo_dwim_ref(r, "HEAD", 4, oid, &real_ref, 0);
+ refs_found = repo_dwim_ref(r, "HEAD", 4, oid, &real_ref, !fatal);
else if (reflog_len)
refs_found = repo_dwim_log(r, str, len, oid, &real_ref);
else
- refs_found = repo_dwim_ref(r, str, len, oid, &real_ref, 0);
+ refs_found = repo_dwim_ref(r, str, len, oid, &real_ref, !fatal);
if (!refs_found)
return -1;
@@ -1036,7 +1061,7 @@ static enum get_oid_result get_parent(struct repository *r,
if (ret)
return ret;
commit = lookup_commit_reference(r, &oid);
- if (parse_commit(commit))
+ if (repo_parse_commit(r, commit))
return MISSING_OBJECT;
if (!idx) {
oidcpy(result, &commit->object.oid);
@@ -1070,7 +1095,7 @@ static enum get_oid_result get_nth_ancestor(struct repository *r,
return MISSING_OBJECT;
while (generation--) {
- if (parse_commit(commit) || !commit->parents)
+ if (repo_parse_commit(r, commit) || !commit->parents)
return MISSING_OBJECT;
commit = commit->parents->item;
}
@@ -1361,10 +1386,10 @@ static int get_oid_oneline(struct repository *r,
commit = pop_most_recent_commit(&list, ONELINE_SEEN);
if (!parse_object(r, &commit->object.oid))
continue;
- buf = get_commit_buffer(commit, NULL);
+ buf = repo_get_commit_buffer(r, commit, NULL);
p = strstr(buf, "\n\n");
matches = negative ^ (p && !regexec(&regex, p + 2, 0, NULL, 0));
- unuse_commit_buffer(commit, buf);
+ repo_unuse_commit_buffer(r, commit, buf);
if (matches) {
oidcpy(oid, &commit->object.oid);
@@ -1666,7 +1691,8 @@ void strbuf_branchname(struct strbuf *sb, const char *name, unsigned allowed)
struct interpret_branch_name_options options = {
.allowed = allowed
};
- int used = interpret_branch_name(name, len, sb, &options);
+ int used = repo_interpret_branch_name(the_repository, name, len, sb,
+ &options);
if (used < 0)
used = 0;
@@ -1719,7 +1745,7 @@ int get_oidf(struct object_id *oid, const char *fmt, ...)
strbuf_vaddf(&sb, fmt, ap);
va_end(ap);
- ret = get_oid(sb.buf, oid);
+ ret = repo_get_oid(the_repository, sb.buf, oid);
strbuf_release(&sb);
return ret;