summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2016-09-05 20:07:52 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-09-07 19:59:42 (GMT)
commit99d1a9861ae88595e7386c453b6b38573a8a570c (patch)
tree670664666d85bb83d7d80b83904c25adb5b7029a /builtin
parent6ebdac1bab966b720d776aa43ca188fe378b1f4b (diff)
downloadgit-99d1a9861ae88595e7386c453b6b38573a8a570c.zip
git-99d1a9861ae88595e7386c453b6b38573a8a570c.tar.gz
git-99d1a9861ae88595e7386c453b6b38573a8a570c.tar.bz2
cache: convert struct cache_entry to use struct object_id
Convert struct cache_entry to use struct object_id by applying the following semantic patch and the object_id transforms from contrib, plus the actual change to the struct: @@ struct cache_entry E1; @@ - E1.sha1 + E1.oid.hash @@ struct cache_entry *E1; @@ - E1->sha1 + E1->oid.hash Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/apply.c10
-rw-r--r--builtin/blame.c2
-rw-r--r--builtin/checkout.c6
-rw-r--r--builtin/fsck.c2
-rw-r--r--builtin/grep.c3
-rw-r--r--builtin/ls-files.c2
-rw-r--r--builtin/merge-index.c2
-rw-r--r--builtin/read-tree.c2
-rw-r--r--builtin/rm.c2
-rw-r--r--builtin/submodule--helper.c5
-rw-r--r--builtin/update-index.c10
11 files changed, 24 insertions, 22 deletions
diff --git a/builtin/apply.c b/builtin/apply.c
index 1a488f9..ba0e75b 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -3220,7 +3220,7 @@ static int read_file_or_gitlink(const struct cache_entry *ce, struct strbuf *buf
{
if (!ce)
return 0;
- return read_blob_object(buf, ce->sha1, ce->ce_mode);
+ return read_blob_object(buf, ce->oid.hash, ce->ce_mode);
}
static struct patch *in_fn_table(struct apply_state *state, const char *name)
@@ -3959,7 +3959,7 @@ static int get_current_sha1(const char *path, unsigned char *sha1)
pos = cache_name_pos(path, strlen(path));
if (pos < 0)
return -1;
- hashcpy(sha1, active_cache[pos]->sha1);
+ hashcpy(sha1, active_cache[pos]->oid.hash);
return 0;
}
@@ -4211,7 +4211,7 @@ static void add_index_file(struct apply_state *state,
const char *s;
if (!skip_prefix(buf, "Subproject commit ", &s) ||
- get_sha1_hex(s, ce->sha1))
+ get_sha1_hex(s, ce->oid.hash))
die(_("corrupt patch for submodule %s"), path);
} else {
if (!state->cached) {
@@ -4220,7 +4220,7 @@ static void add_index_file(struct apply_state *state,
path);
fill_stat_cache_info(ce, &st);
}
- if (write_sha1_file(buf, size, blob_type, ce->sha1) < 0)
+ if (write_sha1_file(buf, size, blob_type, ce->oid.hash) < 0)
die(_("unable to create backing store for newly created file %s"), path);
}
if (add_cache_entry(ce, ADD_CACHE_OK_TO_ADD) < 0)
@@ -4335,7 +4335,7 @@ static void add_conflicted_stages_file(struct apply_state *state,
ce->ce_mode = create_ce_mode(mode);
ce->ce_flags = create_ce_flags(stage);
ce->ce_namelen = namelen;
- hashcpy(ce->sha1, patch->threeway_stage[stage - 1].hash);
+ oidcpy(&ce->oid, &patch->threeway_stage[stage - 1]);
if (add_cache_entry(ce, ADD_CACHE_OK_TO_ADD) < 0)
die(_("unable to add cache entry for %s"), patch->new_name);
}
diff --git a/builtin/blame.c b/builtin/blame.c
index a5bbf91..5eb3725 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -2410,7 +2410,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
}
size = cache_entry_size(len);
ce = xcalloc(1, size);
- hashcpy(ce->sha1, origin->blob_sha1);
+ hashcpy(ce->oid.hash, origin->blob_sha1);
memcpy(ce->name, path, len);
ce->ce_flags = create_ce_flags(0);
ce->ce_namelen = len;
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 8672d07..a9523ff 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -76,7 +76,7 @@ static int update_some(const unsigned char *sha1, struct strbuf *base,
len = base->len + strlen(pathname);
ce = xcalloc(1, cache_entry_size(len));
- hashcpy(ce->sha1, sha1);
+ hashcpy(ce->oid.hash, sha1);
memcpy(ce->name, base->buf, base->len);
memcpy(ce->name + base->len, pathname, len - base->len);
ce->ce_flags = create_ce_flags(0) | CE_UPDATE;
@@ -92,7 +92,7 @@ static int update_some(const unsigned char *sha1, struct strbuf *base,
if (pos >= 0) {
struct cache_entry *old = active_cache[pos];
if (ce->ce_mode == old->ce_mode &&
- !hashcmp(ce->sha1, old->sha1)) {
+ !oidcmp(&ce->oid, &old->oid)) {
old->ce_flags |= CE_UPDATE;
free(ce);
return 0;
@@ -186,7 +186,7 @@ static int checkout_merged(int pos, struct checkout *state)
stage = ce_stage(ce);
if (!stage || strcmp(path, ce->name))
break;
- hashcpy(threeway[stage - 1], ce->sha1);
+ hashcpy(threeway[stage - 1], ce->oid.hash);
if (stage == 2)
mode = create_ce_mode(ce->ce_mode);
pos++;
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 2de272e..f604adf 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -722,7 +722,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
mode = active_cache[i]->ce_mode;
if (S_ISGITLINK(mode))
continue;
- blob = lookup_blob(active_cache[i]->sha1);
+ blob = lookup_blob(active_cache[i]->oid.hash);
if (!blob)
continue;
obj = &blob->object;
diff --git a/builtin/grep.c b/builtin/grep.c
index ae73831..8887b6a 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -398,7 +398,8 @@ static int grep_cache(struct grep_opt *opt, const struct pathspec *pathspec, int
if (cached || (ce->ce_flags & CE_VALID) || ce_skip_worktree(ce)) {
if (ce_stage(ce) || ce_intent_to_add(ce))
continue;
- hit |= grep_sha1(opt, ce->sha1, ce->name, 0, ce->name);
+ hit |= grep_sha1(opt, ce->oid.hash, ce->name, 0,
+ ce->name);
}
else
hit |= grep_file(opt, ce->name);
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index 00ea91a..197f153 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -187,7 +187,7 @@ static void show_ce_entry(const char *tag, const struct cache_entry *ce)
printf("%s%06o %s %d\t",
tag,
ce->ce_mode,
- find_unique_abbrev(ce->sha1,abbrev),
+ find_unique_abbrev(ce->oid.hash,abbrev),
ce_stage(ce));
}
write_eolinfo(ce, ce->name);
diff --git a/builtin/merge-index.c b/builtin/merge-index.c
index 1c3427c..ce356b1 100644
--- a/builtin/merge-index.c
+++ b/builtin/merge-index.c
@@ -22,7 +22,7 @@ static int merge_entry(int pos, const char *path)
if (strcmp(ce->name, path))
break;
found++;
- sha1_to_hex_r(hexbuf[stage], ce->sha1);
+ sha1_to_hex_r(hexbuf[stage], ce->oid.hash);
xsnprintf(ownbuf[stage], sizeof(ownbuf[stage]), "%o", ce->ce_mode);
arguments[stage] = hexbuf[stage];
arguments[stage + 4] = ownbuf[stage];
diff --git a/builtin/read-tree.c b/builtin/read-tree.c
index 8c693e7..9bd1fd7 100644
--- a/builtin/read-tree.c
+++ b/builtin/read-tree.c
@@ -78,7 +78,7 @@ static void debug_stage(const char *label, const struct cache_entry *ce,
else
printf("%06o #%d %s %.8s\n",
ce->ce_mode, ce_stage(ce), ce->name,
- sha1_to_hex(ce->sha1));
+ oid_to_hex(&ce->oid));
}
static int debug_merge(const struct cache_entry * const *stages,
diff --git a/builtin/rm.c b/builtin/rm.c
index b2fee3e..109969d 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -199,7 +199,7 @@ static int check_local_mod(unsigned char *head, int index_only)
if (no_head
|| get_tree_entry(head, name, sha1, &mode)
|| ce->ce_mode != create_ce_mode(mode)
- || hashcmp(ce->sha1, sha1))
+ || hashcmp(ce->oid.hash, sha1))
staged_changes = 1;
/*
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index e79790f..566cfdd 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -296,7 +296,8 @@ static int module_list(int argc, const char **argv, const char *prefix)
if (ce_stage(ce))
printf("%06o %s U\t", ce->ce_mode, sha1_to_hex(null_sha1));
else
- printf("%06o %s %d\t", ce->ce_mode, sha1_to_hex(ce->sha1), ce_stage(ce));
+ printf("%06o %s %d\t", ce->ce_mode,
+ oid_to_hex(&ce->oid), ce_stage(ce));
utf8_fprintf(stdout, "%s\n", ce->name);
}
@@ -683,7 +684,7 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,
strbuf_reset(&sb);
strbuf_addf(&sb, "%06o %s %d %d\t%s\n", ce->ce_mode,
- sha1_to_hex(ce->sha1), ce_stage(ce),
+ oid_to_hex(&ce->oid), ce_stage(ce),
needs_cloning, ce->name);
string_list_append(&suc->projectlines, sb.buf);
diff --git a/builtin/update-index.c b/builtin/update-index.c
index ba04b19..a60a30a 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -275,7 +275,7 @@ static int add_one_path(const struct cache_entry *old, const char *path, int len
fill_stat_cache_info(ce, st);
ce->ce_mode = ce_mode_from_stat(old, st->st_mode);
- if (index_path(ce->sha1, path, st,
+ if (index_path(ce->oid.hash, path, st,
info_only ? 0 : HASH_WRITE_OBJECT)) {
free(ce);
return -1;
@@ -403,7 +403,7 @@ static int add_cacheinfo(unsigned int mode, const unsigned char *sha1,
size = cache_entry_size(len);
ce = xcalloc(1, size);
- hashcpy(ce->sha1, sha1);
+ hashcpy(ce->oid.hash, sha1);
memcpy(ce->name, path, len);
ce->ce_flags = create_ce_flags(stage);
ce->ce_namelen = len;
@@ -601,7 +601,7 @@ static struct cache_entry *read_one_ent(const char *which,
size = cache_entry_size(namelen);
ce = xcalloc(1, size);
- hashcpy(ce->sha1, sha1);
+ hashcpy(ce->oid.hash, sha1);
memcpy(ce->name, path, namelen);
ce->ce_flags = create_ce_flags(stage);
ce->ce_namelen = namelen;
@@ -658,7 +658,7 @@ static int unresolve_one(const char *path)
ret = -1;
goto free_return;
}
- if (!hashcmp(ce_2->sha1, ce_3->sha1) &&
+ if (!oidcmp(&ce_2->oid, &ce_3->oid) &&
ce_2->ce_mode == ce_3->ce_mode) {
fprintf(stderr, "%s: identical in both, skipping.\n",
path);
@@ -743,7 +743,7 @@ static int do_reupdate(int ac, const char **av,
old = read_one_ent(NULL, head_sha1,
ce->name, ce_namelen(ce), 0);
if (old && ce->ce_mode == old->ce_mode &&
- !hashcmp(ce->sha1, old->sha1)) {
+ !oidcmp(&ce->oid, &old->oid)) {
free(old);
continue; /* unchanged */
}