summaryrefslogtreecommitdiff
path: root/read-cache.c
diff options
context:
space:
mode:
Diffstat (limited to 'read-cache.c')
-rw-r--r--read-cache.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/read-cache.c b/read-cache.c
index c0bb760ad4..990d4ead0d 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -8,7 +8,6 @@
#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
-#include "bulk-checkin.h"
#include "config.h"
#include "date.h"
#include "diff.h"
@@ -20,7 +19,7 @@
#include "refs.h"
#include "dir.h"
#include "object-file.h"
-#include "object-store.h"
+#include "odb.h"
#include "oid-array.h"
#include "tree.h"
#include "commit.h"
@@ -254,7 +253,7 @@ static int ce_compare_link(const struct cache_entry *ce, size_t expected_size)
if (strbuf_readlink(&sb, ce->name, expected_size))
return -1;
- buffer = repo_read_object_file(the_repository, &ce->oid, &type, &size);
+ buffer = odb_read_object(the_repository->objects, &ce->oid, &type, &size);
if (buffer) {
if (size == sb.len)
match = memcmp(buffer, sb.buf, size);
@@ -690,7 +689,7 @@ static struct cache_entry *create_alias_ce(struct index_state *istate,
void set_object_name_for_intent_to_add_entry(struct cache_entry *ce)
{
struct object_id oid;
- if (write_object_file("", 0, OBJ_BLOB, &oid))
+ if (odb_write_object(the_repository->objects, "", 0, OBJ_BLOB, &oid))
die(_("cannot create an empty blob in the object database"));
oidcpy(&ce->oid, &oid);
}
@@ -707,7 +706,6 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
int add_option = (ADD_CACHE_OK_TO_ADD|ADD_CACHE_OK_TO_REPLACE|
(intent_only ? ADD_CACHE_NEW_ONLY : 0));
unsigned hash_flags = pretend ? 0 : INDEX_WRITE_OBJECT;
- struct object_id oid;
if (flags & ADD_CACHE_RENORMALIZE)
hash_flags |= INDEX_RENORMALIZE;
@@ -717,8 +715,6 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
namelen = strlen(path);
if (S_ISDIR(st_mode)) {
- if (repo_resolve_gitlink_ref(the_repository, path, "HEAD", &oid) < 0)
- return error(_("'%s' does not have a commit checked out"), path);
while (namelen && path[namelen-1] == '/')
namelen--;
}
@@ -1456,7 +1452,8 @@ int repo_refresh_and_write_index(struct repository *repo,
struct lock_file lock_file = LOCK_INIT;
int fd, ret = 0;
- fd = repo_hold_locked_index(repo, &lock_file, 0);
+ fd = repo_hold_locked_index(repo, &lock_file,
+ gentle ? 0 : LOCK_REPORT_ON_ERROR);
if (!gentle && fd < 0)
return -1;
if (refresh_index(repo->index, refresh_flags, pathspec, seen, header_msg))
@@ -1806,7 +1803,7 @@ static struct cache_entry *create_from_disk(struct mem_pool *ce_mem_pool,
if (expand_name_field) {
const unsigned char *cp = (const unsigned char *)name;
- size_t strip_len, previous_len;
+ uint64_t strip_len, previous_len;
/* If we're at the beginning of a block, ignore the previous name */
strip_len = decode_varint(&cp);
@@ -2654,8 +2651,10 @@ static int ce_write_entry(struct hashfile *f, struct cache_entry *ce,
hashwrite(f, ce->name, len);
hashwrite(f, padding, align_padding_size(size, len));
} else {
- int common, to_remove, prefix_size;
+ int common, to_remove;
+ uint8_t prefix_size;
unsigned char to_remove_vi[16];
+
for (common = 0;
(common < previous_name->len &&
ce->name[common] &&
@@ -2754,7 +2753,7 @@ static int record_eoie(void)
{
int val;
- if (!git_config_get_bool("index.recordendofindexentries", &val))
+ if (!repo_config_get_bool(the_repository, "index.recordendofindexentries", &val))
return val;
/*
@@ -2769,7 +2768,7 @@ static int record_ieot(void)
{
int val;
- if (!git_config_get_bool("index.recordoffsettable", &val))
+ if (!repo_config_get_bool(the_repository, "index.recordoffsettable", &val))
return val;
/*
@@ -3485,8 +3484,8 @@ void *read_blob_data_from_index(struct index_state *istate,
}
if (pos < 0)
return NULL;
- data = repo_read_object_file(the_repository, &istate->cache[pos]->oid,
- &type, &sz);
+ data = odb_read_object(the_repository->objects, &istate->cache[pos]->oid,
+ &type, &sz);
if (!data || type != OBJ_BLOB) {
free(data);
return NULL;
@@ -3729,9 +3728,9 @@ void prefetch_cache_entries(const struct index_state *istate,
if (S_ISGITLINK(ce->ce_mode) || !must_prefetch(ce))
continue;
- if (!oid_object_info_extended(the_repository, &ce->oid,
- NULL,
- OBJECT_INFO_FOR_PREFETCH))
+ if (!odb_read_object_info_extended(the_repository->objects,
+ &ce->oid, NULL,
+ OBJECT_INFO_FOR_PREFETCH))
continue;
oid_array_append(&to_fetch, &ce->oid);
}
@@ -3946,6 +3945,7 @@ int add_files_to_cache(struct repository *repo, const char *prefix,
const struct pathspec *pathspec, char *ps_matched,
int include_sparse, int flags)
{
+ struct odb_transaction *transaction;
struct update_callback_data data;
struct rev_info rev;
@@ -3971,9 +3971,9 @@ int add_files_to_cache(struct repository *repo, const char *prefix,
* This function is invoked from commands other than 'add', which
* may not have their own transaction active.
*/
- begin_odb_transaction();
+ transaction = odb_transaction_begin(repo->objects);
run_diff_files(&rev, DIFF_RACY_IS_MODIFIED);
- end_odb_transaction();
+ odb_transaction_commit(transaction);
release_revisions(&rev);
return !!data.add_errors;