@ -1513,7 +1513,7 @@ int strbuf_check_branch_ref(struct strbuf *sb, const char *name)
@@ -1513,7 +1513,7 @@ int strbuf_check_branch_ref(struct strbuf *sb, const char *name)
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);
}
@ -1530,35 +1530,40 @@ int get_oid(const char *name, struct object_id *oid)
@@ -1530,35 +1530,40 @@ int get_oid(const char *name, struct object_id *oid)
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);
}
@ -1597,7 +1602,8 @@ static void diagnose_invalid_oid_path(const char *prefix,
@@ -1597,7 +1602,8 @@ static void diagnose_invalid_oid_path(const char *prefix,
}
/* 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)
{
@ -1610,11 +1616,11 @@ static void diagnose_invalid_index_path(int stage,
@@ -1610,11 +1616,11 @@ static void diagnose_invalid_index_path(int stage,
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"
@ -1626,11 +1632,11 @@ static void diagnose_invalid_index_path(int stage,
@@ -1626,11 +1632,11 @@ static void diagnose_invalid_index_path(int stage,
/* 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"
@ -1664,7 +1670,8 @@ static char *resolve_relative_path(const char *rel)
@@ -1664,7 +1670,8 @@ static char *resolve_relative_path(const char *rel)
rel);
}
static int get_oid_with_context_1(const char *name,
static int get_oid_with_context_1(struct repository *repo,
const char *name,
unsigned flags,
const char *prefix,
struct object_id *oid,
@ -1723,13 +1730,13 @@ static int get_oid_with_context_1(const char *name,
@@ -1723,13 +1730,13 @@ static int get_oid_with_context_1(const char *name,
if (flags & GET_OID_RECORD_PATH)
oc->path = xstrdup(cp);
if (!the_index.cache)
if (!repo->index->cache)
repo_read_index(the_repository);
pos = index_name_pos(&the_index, cp, namelen);
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;
@ -1742,7 +1749,7 @@ static int get_oid_with_context_1(const char *name,
@@ -1742,7 +1749,7 @@ static int get_oid_with_context_1(const char *name,
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;
}
@ -1807,12 +1814,15 @@ void maybe_die_on_misspelt_object_name(const char *name, const char *prefix)
@@ -1807,12 +1814,15 @@ void maybe_die_on_misspelt_object_name(const char *name, const char *prefix)
{
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);
}