From: Stefan Beller <sbeller@google.com>
To: gitster@pobox.com, git@jeffhostetler.com
Cc: git@vger.kernel.org, Stefan Beller <sbeller@google.com>
Subject: [PATCH 14/24] cache.h: drop cache_name_pos
Date: Tue, 2 May 2017 15:23:12 -0700 [thread overview]
Message-ID: <20170502222322.21055-15-sbeller@google.com> (raw)
In-Reply-To: <20170502222322.21055-1-sbeller@google.com>
coccinelle patch:
@@ expression name, namelen; @@
-cache_name_pos(name, namelen)
+index_name_pos(&the_index, name, namelen)
Additionally manual editing:
* drop the define from cache.h.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
apply.c | 9 +++++----
builtin/blame.c | 4 ++--
builtin/checkout-index.c | 2 +-
builtin/checkout.c | 2 +-
builtin/ls-files.c | 7 ++++---
builtin/merge-index.c | 2 +-
builtin/mv.c | 8 ++++----
builtin/rm.c | 4 ++--
builtin/update-index.c | 10 +++++-----
cache.h | 1 -
diff.c | 2 +-
dir.c | 8 ++++----
merge-recursive.c | 4 ++--
pathspec.c | 2 +-
rerere.c | 2 +-
sha1_name.c | 6 +++---
submodule.c | 2 +-
wt-status.c | 4 ++--
18 files changed, 40 insertions(+), 39 deletions(-)
diff --git a/apply.c b/apply.c
index eb8eaeabec..bb1cd77c66 100644
--- a/apply.c
+++ b/apply.c
@@ -3496,7 +3496,7 @@ static int load_current(struct apply_state *state,
if (!patch->is_new)
die("BUG: patch to %s is not a creation", patch->old_name);
- pos = cache_name_pos(name, strlen(name));
+ pos = index_name_pos(&the_index, name, strlen(name));
if (pos < 0)
return error(_("%s: does not exist in index"), name);
ce = the_index.cache[pos];
@@ -3665,7 +3665,8 @@ static int check_preimage(struct apply_state *state,
}
if (state->check_index && !previous) {
- int pos = cache_name_pos(old_name, strlen(old_name));
+ int pos = index_name_pos(&the_index, old_name,
+ strlen(old_name));
if (pos < 0) {
if (patch->is_new < 0)
goto is_new;
@@ -3721,7 +3722,7 @@ static int check_to_create(struct apply_state *state,
struct stat nst;
if (state->check_index &&
- cache_name_pos(new_name, strlen(new_name)) >= 0 &&
+ index_name_pos(&the_index, new_name, strlen(new_name)) >= 0 &&
!ok_if_exists)
return EXISTS_IN_INDEX;
if (state->cached)
@@ -3998,7 +3999,7 @@ static int get_current_oid(struct apply_state *state, const char *path,
if (read_apply_cache(state) < 0)
return -1;
- pos = cache_name_pos(path, strlen(path));
+ pos = index_name_pos(&the_index, path, strlen(path));
if (pos < 0)
return -1;
oidcpy(oid, &the_index.cache[pos]->oid);
diff --git a/builtin/blame.c b/builtin/blame.c
index b47aae25d4..c71d9a3340 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -2239,7 +2239,7 @@ static void verify_working_tree_path(struct commit *work_tree, const char *path)
return;
}
- pos = cache_name_pos(path, strlen(path));
+ pos = index_name_pos(&the_index, path, strlen(path));
if (pos >= 0)
; /* path is in the index */
else if (-1 - pos < the_index.cache_nr &&
@@ -2399,7 +2399,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
len = strlen(path);
if (!mode) {
- int pos = cache_name_pos(path, len);
+ int pos = index_name_pos(&the_index, path, len);
if (0 <= pos)
mode = the_index.cache[pos]->ce_mode;
else
diff --git a/builtin/checkout-index.c b/builtin/checkout-index.c
index 1c3dcc1a8b..e8fc24b2ce 100644
--- a/builtin/checkout-index.c
+++ b/builtin/checkout-index.c
@@ -46,7 +46,7 @@ static void write_tempfile_record(const char *name, const char *prefix)
static int checkout_file(const char *name, const char *prefix)
{
int namelen = strlen(name);
- int pos = cache_name_pos(name, namelen);
+ int pos = index_name_pos(&the_index, name, namelen);
int has_same_name = 0;
int did_checkout = 0;
int errs = 0;
diff --git a/builtin/checkout.c b/builtin/checkout.c
index a6cd8c0f37..039d3d296b 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -107,7 +107,7 @@ static int update_some(const unsigned char *sha1, struct strbuf *base,
* entry in place. Whether it is UPTODATE or not, checkout_entry will
* do the right thing.
*/
- pos = cache_name_pos(ce->name, ce->ce_namelen);
+ pos = index_name_pos(&the_index, ce->name, ce->ce_namelen);
if (pos >= 0) {
struct cache_entry *old = the_index.cache[pos];
if (ce->ce_mode == old->ce_mode &&
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index 6f7ecec1b0..3507490d3e 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -134,7 +134,8 @@ static void show_killed_files(struct dir_struct *dir)
/* If ent->name is prefix of an entry in the
* cache, it will be killed.
*/
- pos = cache_name_pos(ent->name, ent->len);
+ pos = index_name_pos(&the_index, ent->name,
+ ent->len);
if (0 <= pos)
die("BUG: killed-file %.*s not found",
ent->len, ent->name);
@@ -156,7 +157,7 @@ static void show_killed_files(struct dir_struct *dir)
killed = 1;
break;
}
- if (0 <= cache_name_pos(ent->name, sp - ent->name)) {
+ if (0 <= index_name_pos(&the_index, ent->name, sp - ent->name)) {
/* If any of the leading directories in
* ent->name is registered in the cache,
* ent->name will be killed.
@@ -384,7 +385,7 @@ static void prune_cache(const char *prefix, size_t prefixlen)
if (!prefix)
return;
- pos = cache_name_pos(prefix, prefixlen);
+ pos = index_name_pos(&the_index, prefix, prefixlen);
if (pos < 0)
pos = -pos-1;
first = pos;
diff --git a/builtin/merge-index.c b/builtin/merge-index.c
index d867ee73f0..ec7104614c 100644
--- a/builtin/merge-index.c
+++ b/builtin/merge-index.c
@@ -44,7 +44,7 @@ static int merge_entry(int pos, const char *path)
static void merge_one_path(const char *path)
{
- int pos = cache_name_pos(path, strlen(path));
+ int pos = index_name_pos(&the_index, path, strlen(path));
/*
* If it already exists in the cache as stage0, it's
diff --git a/builtin/mv.c b/builtin/mv.c
index 3b887a9490..40e40bb098 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -97,7 +97,7 @@ static int index_range_of_same_dir(const char *src, int length,
const char *src_w_slash = add_slash(src);
int first, last, len_w_slash = length + 1;
- first = cache_name_pos(src_w_slash, len_w_slash);
+ first = index_name_pos(&the_index, src_w_slash, len_w_slash);
if (first >= 0)
die(_("%.*s is in index"), len_w_slash, src_w_slash);
@@ -187,7 +187,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
&& lstat(dst, &st) == 0)
bad = _("cannot move directory over file");
else if (src_is_dir) {
- int first = cache_name_pos(src, length), last;
+ int first = index_name_pos(&the_index, src, length), last;
if (first >= 0)
prepare_move_submodule(src, first,
@@ -218,7 +218,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
}
argc += last - first;
}
- } else if (cache_name_pos(src, length) < 0)
+ } else if (index_name_pos(&the_index, src, length) < 0)
bad = _("not under version control");
else if (lstat(dst, &st) == 0 &&
(!ignore_case || strcasecmp(src, dst))) {
@@ -284,7 +284,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
if (mode == WORKING_DIRECTORY)
continue;
- pos = cache_name_pos(src, strlen(src));
+ pos = index_name_pos(&the_index, src, strlen(src));
assert(pos >= 0);
if (!show_only)
rename_cache_entry_at(pos, dst);
diff --git a/builtin/rm.c b/builtin/rm.c
index 0813d0a853..c77c941ef0 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -67,7 +67,7 @@ static void submodules_absorb_gitdir_if_needed(const char *prefix)
int pos;
const struct cache_entry *ce;
- pos = cache_name_pos(name, strlen(name));
+ pos = index_name_pos(&the_index, name, strlen(name));
if (pos < 0) {
pos = get_ours_cache_pos(name, pos);
if (pos < 0)
@@ -112,7 +112,7 @@ static int check_local_mod(struct object_id *head, int index_only)
int local_changes = 0;
int staged_changes = 0;
- pos = cache_name_pos(name, strlen(name));
+ pos = index_name_pos(&the_index, name, strlen(name));
if (pos < 0) {
/*
* Skip unmerged entries except for populated submodules
diff --git a/builtin/update-index.c b/builtin/update-index.c
index c9f06169c0..d7a117c674 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -225,7 +225,7 @@ static int test_if_untracked_cache_is_supported(void)
static int mark_ce_flags(const char *path, int flag, int mark)
{
int namelen = strlen(path);
- int pos = cache_name_pos(path, namelen);
+ int pos = index_name_pos(&the_index, path, namelen);
if (0 <= pos) {
if (mark)
the_index.cache[pos]->ce_flags |= flag;
@@ -317,7 +317,7 @@ static int add_one_path(const struct cache_entry *old, const char *path, int len
static int process_directory(const char *path, int len, struct stat *st)
{
struct object_id oid;
- int pos = cache_name_pos(path, len);
+ int pos = index_name_pos(&the_index, path, len);
/* Exact match: file or existing gitlink */
if (pos >= 0) {
@@ -368,7 +368,7 @@ static int process_path(const char *path)
if (has_symlink_leading_path(path, len))
return error("'%s' is beyond a symbolic link", path);
- pos = cache_name_pos(path, len);
+ pos = index_name_pos(&the_index, path, len);
ce = pos < 0 ? NULL : the_index.cache[pos];
if (ce && ce_skip_worktree(ce)) {
/*
@@ -428,7 +428,7 @@ static void chmod_path(char flip, const char *path)
int pos;
struct cache_entry *ce;
- pos = cache_name_pos(path, strlen(path));
+ pos = index_name_pos(&the_index, path, strlen(path));
if (pos < 0)
goto fail;
ce = the_index.cache[pos];
@@ -610,7 +610,7 @@ static int unresolve_one(const char *path)
struct cache_entry *ce_2 = NULL, *ce_3 = NULL;
/* See if there is such entry in the index. */
- pos = cache_name_pos(path, namelen);
+ pos = index_name_pos(&the_index, path, namelen);
if (0 <= pos) {
/* already merged */
pos = unmerge_index_entry_at(&the_index, pos);
diff --git a/cache.h b/cache.h
index a021d6e988..a18ebf263a 100644
--- a/cache.h
+++ b/cache.h
@@ -354,7 +354,6 @@ extern void free_name_hash(struct index_state *istate);
#ifndef NO_THE_INDEX_COMPATIBILITY_MACROS
-#define cache_name_pos(name, namelen) index_name_pos(&the_index,(name),(namelen))
#define add_cache_entry(ce, option) add_index_entry(&the_index, (ce), (option))
#define rename_cache_entry_at(pos, new_name) rename_index_entry_at(&the_index, (pos), (new_name))
#define remove_cache_entry_at(pos) remove_index_entry_at(&the_index, (pos))
diff --git a/diff.c b/diff.c
index 37083914c5..f2ee40fe21 100644
--- a/diff.c
+++ b/diff.c
@@ -2759,7 +2759,7 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int
return 0;
len = strlen(name);
- pos = cache_name_pos(name, len);
+ pos = index_name_pos(&the_index, name, len);
if (pos < 0)
return 0;
ce = the_index.cache[pos];
diff --git a/dir.c b/dir.c
index 63edaec2ef..47890b3d3b 100644
--- a/dir.c
+++ b/dir.c
@@ -596,7 +596,7 @@ static void *read_skip_worktree_file_from_index(const char *path, size_t *size,
void *data;
len = strlen(path);
- pos = cache_name_pos(path, len);
+ pos = index_name_pos(&the_index, path, len);
if (pos < 0)
return NULL;
if (!ce_skip_worktree(the_index.cache[pos]))
@@ -785,7 +785,7 @@ static int add_excludes(const char *fname, const char *base, int baselen,
!match_stat_data_racy(&the_index, &sha1_stat->stat, &st))
; /* no content change, ss->sha1 still good */
else if (check_index &&
- (pos = cache_name_pos(fname, strlen(fname))) >= 0 &&
+ (pos = index_name_pos(&the_index, fname, strlen(fname))) >= 0 &&
!ce_stage(the_index.cache[pos]) &&
ce_uptodate(the_index.cache[pos]) &&
!would_convert_to_git(fname))
@@ -1290,7 +1290,7 @@ static enum exist_status directory_exists_in_index(const char *dirname, int len)
if (ignore_case)
return directory_exists_in_index_icase(dirname, len);
- pos = cache_name_pos(dirname, len);
+ pos = index_name_pos(&the_index, dirname, len);
if (pos < 0)
pos = -pos-1;
while (pos < the_index.cache_nr) {
@@ -1474,7 +1474,7 @@ static int get_index_dtype(const char *path, int len)
}
/* Try to look it up as a directory */
- pos = cache_name_pos(path, len);
+ pos = index_name_pos(&the_index, path, len);
if (pos >= 0)
return DT_UNKNOWN;
pos = -pos-1;
diff --git a/merge-recursive.c b/merge-recursive.c
index eb0f0c6960..163d37866e 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -680,7 +680,7 @@ static int dir_in_way(const char *path, int check_working_copy, int empty_ok)
strbuf_addstr(&dirpath, path);
strbuf_addch(&dirpath, '/');
- pos = cache_name_pos(dirpath.buf, dirpath.len);
+ pos = index_name_pos(&the_index, dirpath.buf, dirpath.len);
if (pos < 0)
pos = -1 - pos;
@@ -697,7 +697,7 @@ static int dir_in_way(const char *path, int check_working_copy, int empty_ok)
static int was_tracked(const char *path)
{
- int pos = cache_name_pos(path, strlen(path));
+ int pos = index_name_pos(&the_index, path, strlen(path));
if (0 <= pos)
/* we have been tracking this path */
diff --git a/pathspec.c b/pathspec.c
index 25c2afef30..28b5f8b606 100644
--- a/pathspec.c
+++ b/pathspec.c
@@ -389,7 +389,7 @@ static const char *parse_element_magic(unsigned *magic, int *prefix_len,
static void strip_submodule_slash_cheap(struct pathspec_item *item)
{
if (item->len >= 1 && item->match[item->len - 1] == '/') {
- int i = cache_name_pos(item->match, item->len - 1);
+ int i = index_name_pos(&the_index, item->match, item->len - 1);
if (i >= 0 && S_ISGITLINK(the_index.cache[i]->ce_mode)) {
item->len--;
diff --git a/rerere.c b/rerere.c
index 03218166ab..b6d84b8461 100644
--- a/rerere.c
+++ b/rerere.c
@@ -966,7 +966,7 @@ static int handle_cache(const char *path, unsigned char *sha1, const char *outpu
* Reproduce the conflicted merge in-core
*/
len = strlen(path);
- pos = cache_name_pos(path, len);
+ pos = index_name_pos(&the_index, path, len);
if (0 <= pos)
return -1;
pos = -pos - 1;
diff --git a/sha1_name.c b/sha1_name.c
index b73e261498..41ab9d9f1a 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -1441,7 +1441,7 @@ static void diagnose_invalid_index_path(int stage,
prefix = "";
/* Wrong stage number? */
- pos = cache_name_pos(filename, namelen);
+ pos = index_name_pos(&the_index, filename, namelen);
if (pos < 0)
pos = -pos - 1;
if (pos < the_index.cache_nr) {
@@ -1457,7 +1457,7 @@ 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(&the_index, fullname.buf, fullname.len);
if (pos < 0)
pos = -pos - 1;
if (pos < the_index.cache_nr) {
@@ -1553,7 +1553,7 @@ static int get_sha1_with_context_1(const char *name,
if (!the_index.cache)
read_index(&the_index);
- pos = cache_name_pos(cp, namelen);
+ pos = index_name_pos(&the_index, cp, namelen);
if (pos < 0)
pos = -pos - 1;
while (pos < the_index.cache_nr) {
diff --git a/submodule.c b/submodule.c
index b225ff6d1f..148194831d 100644
--- a/submodule.c
+++ b/submodule.c
@@ -179,7 +179,7 @@ void gitmodules_config(void)
strbuf_addstr(&gitmodules_path, "/.gitmodules");
if (read_index(&the_index) < 0)
die("index file corrupt");
- pos = cache_name_pos(".gitmodules", 11);
+ pos = index_name_pos(&the_index, ".gitmodules", 11);
if (pos < 0) { /* .gitmodules not found or isn't merged */
pos = -1 - pos;
if (the_index.cache_nr > pos) { /* there is a .gitmodules */
diff --git a/wt-status.c b/wt-status.c
index d17d4cb6ca..59cdf09a07 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -481,7 +481,7 @@ static int unmerged_mask(const char *path)
int pos, mask;
const struct cache_entry *ce;
- pos = cache_name_pos(path, strlen(path));
+ pos = index_name_pos(&the_index, path, strlen(path));
if (0 <= pos)
return 0;
@@ -2096,7 +2096,7 @@ static void wt_porcelain_v2_print_unmerged_entry(
*/
memset(stages, 0, sizeof(stages));
sum = 0;
- pos = cache_name_pos(it->string, strlen(it->string));
+ pos = index_name_pos(&the_index, it->string, strlen(it->string));
assert(pos < 0);
pos = -pos-1;
while (pos < the_index.cache_nr) {
--
2.13.0.rc1.39.ga6db8bfa24
next prev parent reply other threads:[~2017-05-02 22:24 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-02 22:22 [PATCH 00/24] Retire NO_THE_INDEX_COMPATIBILITY_MACROS Stefan Beller
2017-05-02 22:22 ` [PATCH 01/24] cache.h: drop read_cache() Stefan Beller
2017-05-02 22:23 ` [PATCH 02/24] cache.h: drop active_* macros Stefan Beller
2017-05-02 22:23 ` [PATCH 03/24] cache.h: drop read_cache_from Stefan Beller
2017-05-02 22:23 ` [PATCH 04/24] cache.h: drop read_cache_preload(pathspec) Stefan Beller
2017-05-02 22:23 ` [PATCH 05/24] cache.h: drop read_cache_unmerged() Stefan Beller
2017-05-02 22:23 ` [PATCH 06/24] unpack-trees.c: rename parameter 'the_index' Stefan Beller
2017-05-02 22:23 ` [PATCH 07/24] cache.h: drop read_blob_data_from_cache Stefan Beller
2017-05-02 22:23 ` [PATCH 08/24] cache.h: drop unmerge_cache[_entry_at] Stefan Beller
2017-05-02 22:23 ` [PATCH 09/24] cache.h: drop resolve_undo_clear Stefan Beller
2017-05-02 22:23 ` [PATCH 10/24] cache.h: drop cache_name_is_other Stefan Beller
2017-05-02 22:23 ` [PATCH 11/24] cache.h: drop cache_file_exists Stefan Beller
2017-05-02 22:23 ` [PATCH 12/24] cache.h: drop cache_dir_exists Stefan Beller
2017-05-02 22:23 ` [PATCH 13/24] cache.h: drop is_cache_unborn(), discard_cache(), unmerged_cache() Stefan Beller
2017-05-02 22:23 ` Stefan Beller [this message]
2017-05-02 22:23 ` [PATCH 15/24] cache.h: drop add_cache_entry Stefan Beller
2017-05-02 22:23 ` [PATCH 16/24] cache.h: drop rename_cache_entry_at Stefan Beller
2017-05-02 22:23 ` [PATCH 17/24] cache.h: drop remove_file_from_cache Stefan Beller
2017-05-02 22:23 ` [PATCH 18/24] cache.h: drop add_to_cache Stefan Beller
2017-05-02 22:23 ` [PATCH 19/24] cache.h: drop add_file_to_cache Stefan Beller
2017-05-02 22:23 ` [PATCH 20/24] cache.h: drop chmod_cache_entry Stefan Beller
2017-05-02 22:23 ` [PATCH 21/24] cache.h: drop refresh_cache Stefan Beller
2017-05-02 22:23 ` [PATCH 22/24] cache.h: drop ce_modified Stefan Beller
2017-05-02 22:23 ` [PATCH 23/24] cache.h: drop ce_match_stat Stefan Beller
2017-05-02 22:23 ` [PATCH 24/24] cache.h: retire NO_THE_INDEX_COMPATIBILITY_MACROS Stefan Beller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170502222322.21055-15-sbeller@google.com \
--to=sbeller@google.com \
--cc=git@jeffhostetler.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).