int get_oid(const char *name, struct object_id *oid)
{
struct object_context unused;
- return get_oid_with_context(name, 0, oid, &unused);
+ return get_oid_with_context(the_repository, name, 0, oid, &unused);
}
int get_oid_committish(const char *name, struct object_id *oid)
{
struct object_context unused;
- return get_oid_with_context(name, GET_OID_COMMITTISH,
+ return get_oid_with_context(the_repository,
+ name, GET_OID_COMMITTISH,
oid, &unused);
}
int get_oid_treeish(const char *name, struct object_id *oid)
{
struct object_context unused;
- return get_oid_with_context(name, GET_OID_TREEISH,
+ return get_oid_with_context(the_repository,
+ name, GET_OID_TREEISH,
oid, &unused);
}
int get_oid_commit(const char *name, struct object_id *oid)
{
struct object_context unused;
- return get_oid_with_context(name, GET_OID_COMMIT,
+ return get_oid_with_context(the_repository,
+ name, GET_OID_COMMIT,
oid, &unused);
}
int get_oid_tree(const char *name, struct object_id *oid)
{
struct object_context unused;
- return get_oid_with_context(name, GET_OID_TREE,
+ return get_oid_with_context(the_repository,
+ name, GET_OID_TREE,
oid, &unused);
}
int get_oid_blob(const char *name, struct object_id *oid)
{
struct object_context unused;
- return get_oid_with_context(name, GET_OID_BLOB,
+ return get_oid_with_context(the_repository,
+ name, GET_OID_BLOB,
oid, &unused);
}
}
/* Must be called only when :stage:filename doesn't exist. */
-static void diagnose_invalid_index_path(int stage,
+static void diagnose_invalid_index_path(struct index_state *istate,
+ int stage,
const char *prefix,
const char *filename)
{
prefix = "";
/* Wrong stage number? */
- pos = cache_name_pos(filename, namelen);
+ pos = index_name_pos(istate, filename, namelen);
if (pos < 0)
pos = -pos - 1;
- if (pos < active_nr) {
- ce = active_cache[pos];
+ if (pos < istate->cache_nr) {
+ ce = istate->cache[pos];
if (ce_namelen(ce) == namelen &&
!memcmp(ce->name, filename, namelen))
die("Path '%s' is in the index, but not at stage %d.\n"
/* Confusion between relative and absolute filenames? */
strbuf_addstr(&fullname, prefix);
strbuf_addstr(&fullname, filename);
- pos = cache_name_pos(fullname.buf, fullname.len);
+ pos = index_name_pos(istate, fullname.buf, fullname.len);
if (pos < 0)
pos = -pos - 1;
- if (pos < active_nr) {
- ce = active_cache[pos];
+ if (pos < istate->cache_nr) {
+ ce = istate->cache[pos];
if (ce_namelen(ce) == fullname.len &&
!memcmp(ce->name, fullname.buf, fullname.len))
die("Path '%s' is in the index, but not '%s'.\n"
rel);
}
-static enum get_oid_result get_oid_with_context_1(const char *name,
- unsigned flags,
- const char *prefix,
- struct object_id *oid,
- struct object_context *oc)
+static enum get_oid_result get_oid_with_context_1(struct repository *repo,
+ const char *name,
+ unsigned flags,
+ const char *prefix,
+ struct object_id *oid,
+ struct object_context *oc)
{
int ret, bracket_depth;
int namelen = strlen(name);
if (flags & GET_OID_RECORD_PATH)
oc->path = xstrdup(cp);
- if (!active_cache)
- read_cache();
- pos = cache_name_pos(cp, namelen);
+ if (!repo->index->cache)
+ repo_read_index(the_repository);
+ pos = index_name_pos(repo->index, cp, namelen);
if (pos < 0)
pos = -pos - 1;
- while (pos < active_nr) {
- ce = active_cache[pos];
+ while (pos < repo->index->cache_nr) {
+ ce = repo->index->cache[pos];
if (ce_namelen(ce) != namelen ||
memcmp(ce->name, cp, namelen))
break;
pos++;
}
if (only_to_die && name[1] && name[1] != '/')
- diagnose_invalid_index_path(stage, prefix, cp);
+ diagnose_invalid_index_path(repo->index, stage, prefix, cp);
free(new_path);
return -1;
}
{
struct object_context oc;
struct object_id oid;
- get_oid_with_context_1(name, GET_OID_ONLY_TO_DIE, prefix, &oid, &oc);
+ get_oid_with_context_1(the_repository, name, GET_OID_ONLY_TO_DIE,
+ prefix, &oid, &oc);
}
-int get_oid_with_context(const char *str, unsigned flags, struct object_id *oid, struct object_context *oc)
+int get_oid_with_context(struct repository *repo, const char *str,
+ unsigned flags, struct object_id *oid,
+ struct object_context *oc)
{
if (flags & GET_OID_FOLLOW_SYMLINKS && flags & GET_OID_ONLY_TO_DIE)
BUG("incompatible flags for get_sha1_with_context");
- return get_oid_with_context_1(str, flags, NULL, oid, oc);
+ return get_oid_with_context_1(repo, str, flags, NULL, oid, oc);
}