object-file: get rid of the_repository in index-related functions
Both `index_fd()` and `index_path()` still use `the_repository` even though they have a repository available via `struct index_state`. Adapt them so that they use the index' repository instead to get rid of this global dependency. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
c2b5d1490a
commit
5f2e994e34
@@ -1257,7 +1257,7 @@ int index_fd(struct index_state *istate, struct object_id *oid,
|
|||||||
ret = index_stream_convert_blob(istate, oid, fd, path, flags);
|
ret = index_stream_convert_blob(istate, oid, fd, path, flags);
|
||||||
else if (!S_ISREG(st->st_mode))
|
else if (!S_ISREG(st->st_mode))
|
||||||
ret = index_pipe(istate, oid, fd, type, path, flags);
|
ret = index_pipe(istate, oid, fd, type, path, flags);
|
||||||
else if ((st->st_size >= 0 && (size_t) st->st_size <= repo_settings_get_big_file_threshold(the_repository)) ||
|
else if ((st->st_size >= 0 && (size_t) st->st_size <= repo_settings_get_big_file_threshold(istate->repo)) ||
|
||||||
type != OBJ_BLOB ||
|
type != OBJ_BLOB ||
|
||||||
(path && would_convert_to_git(istate, path)))
|
(path && would_convert_to_git(istate, path)))
|
||||||
ret = index_core(istate, oid, fd, xsize_t(st->st_size),
|
ret = index_core(istate, oid, fd, xsize_t(st->st_size),
|
||||||
@@ -1291,12 +1291,12 @@ int index_path(struct index_state *istate, struct object_id *oid,
|
|||||||
if (!(flags & INDEX_WRITE_OBJECT))
|
if (!(flags & INDEX_WRITE_OBJECT))
|
||||||
hash_object_file(istate->repo->hash_algo, sb.buf, sb.len,
|
hash_object_file(istate->repo->hash_algo, sb.buf, sb.len,
|
||||||
OBJ_BLOB, oid);
|
OBJ_BLOB, oid);
|
||||||
else if (odb_write_object(the_repository->objects, sb.buf, sb.len, OBJ_BLOB, oid))
|
else if (odb_write_object(istate->repo->objects, sb.buf, sb.len, OBJ_BLOB, oid))
|
||||||
rc = error(_("%s: failed to insert into database"), path);
|
rc = error(_("%s: failed to insert into database"), path);
|
||||||
strbuf_release(&sb);
|
strbuf_release(&sb);
|
||||||
break;
|
break;
|
||||||
case S_IFDIR:
|
case S_IFDIR:
|
||||||
return repo_resolve_gitlink_ref(the_repository, path, "HEAD", oid);
|
return repo_resolve_gitlink_ref(istate->repo, path, "HEAD", oid);
|
||||||
default:
|
default:
|
||||||
return error(_("%s: unsupported file type"), path);
|
return error(_("%s: unsupported file type"), path);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user