Browse Source

cache.h: flip NO_THE_INDEX_COMPATIBILITY_MACROS switch

By default, index compat macros are off from now on, because they
could hide the_index dependency.

Only those in builtin can use it.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Nguyễn Thái Ngọc Duy 6 years ago committed by Junio C Hamano
parent
commit
f8adbec9fe
  1. 1
      attr.c
  2. 1
      builtin/add.c
  3. 1
      builtin/am.c
  4. 3
      builtin/blame.c
  5. 1
      builtin/cat-file.c
  6. 1
      builtin/check-attr.c
  7. 1
      builtin/check-ignore.c
  8. 1
      builtin/checkout-index.c
  9. 1
      builtin/checkout.c
  10. 1
      builtin/clean.c
  11. 1
      builtin/clone.c
  12. 1
      builtin/commit.c
  13. 1
      builtin/describe.c
  14. 1
      builtin/diff-files.c
  15. 1
      builtin/diff-index.c
  16. 1
      builtin/diff-tree.c
  17. 1
      builtin/diff.c
  18. 1
      builtin/difftool.c
  19. 1
      builtin/fsck.c
  20. 1
      builtin/grep.c
  21. 3
      builtin/hash-object.c
  22. 1
      builtin/log.c
  23. 1
      builtin/ls-files.c
  24. 1
      builtin/merge-index.c
  25. 1
      builtin/merge-ours.c
  26. 4
      builtin/merge-tree.c
  27. 1
      builtin/merge.c
  28. 1
      builtin/mv.c
  29. 2
      builtin/pack-objects.c
  30. 1
      builtin/pull.c
  31. 1
      builtin/read-tree.c
  32. 1
      builtin/rebase--interactive.c
  33. 1
      builtin/rebase.c
  34. 2
      builtin/replace.c
  35. 1
      builtin/reset.c
  36. 1
      builtin/rev-parse.c
  37. 1
      builtin/rm.c
  38. 1
      builtin/submodule--helper.c
  39. 1
      builtin/update-index.c
  40. 1
      builtin/write-tree.c
  41. 2
      cache-tree.h
  42. 6
      cache.h
  43. 1
      convert.c
  44. 1
      dir.c
  45. 4
      git.c
  46. 1
      name-hash.c
  47. 1
      pathspec.c
  48. 2
      read-cache.c
  49. 6
      repository.c
  50. 1
      submodule.c
  51. 4
      t/helper/test-dump-fsmonitor.c
  52. 1
      t/helper/test-dump-untracked-cache.c
  53. 1
      t/helper/test-tool.h
  54. 1
      tree.c
  55. 1
      unpack-trees.c

1
attr.c

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
* an insanely large number of attributes.
*/

#define NO_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "exec-cmd.h"

1
builtin/add.c

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
*
* Copyright (C) 2006 Linus Torvalds
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "builtin.h"

1
builtin/am.c

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
*
* Based on git-am.sh by Junio C Hamano.
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "builtin.h"

3
builtin/blame.c

@ -1007,7 +1007,8 @@ parse_done: @@ -1007,7 +1007,8 @@ parse_done:
long bottom, top;
if (parse_range_arg(range_list.items[range_i].string,
nth_line_cb, &sb, lno, anchor,
&bottom, &top, sb.path, &the_index))
&bottom, &top, sb.path,
the_repository->index))
usage(blame_usage);
if ((!lno && (top || bottom)) || lno < bottom)
die(Q_("file %s has only %lu line",

1
builtin/cat-file.c

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
*
* Copyright (C) Linus Torvalds, 2005
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "builtin.h"

1
builtin/check-attr.c

@ -1,3 +1,4 @@ @@ -1,3 +1,4 @@
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "builtin.h"
#include "cache.h"
#include "config.h"

1
builtin/check-ignore.c

@ -1,3 +1,4 @@ @@ -1,3 +1,4 @@
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "builtin.h"
#include "cache.h"
#include "config.h"

1
builtin/checkout-index.c

@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
* Copyright (C) 2005 Linus Torvalds
*
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "builtin.h"
#include "config.h"
#include "lockfile.h"

1
builtin/checkout.c

@ -1,3 +1,4 @@ @@ -1,3 +1,4 @@
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "builtin.h"
#include "config.h"
#include "checkout.h"

1
builtin/clean.c

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
* Based on git-clean.sh by Pavel Roskin
*/

#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "builtin.h"
#include "cache.h"
#include "config.h"

1
builtin/clone.c

@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
* Clone a repository into a different directory that does not yet exist.
*/

#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "builtin.h"
#include "config.h"
#include "lockfile.h"

1
builtin/commit.c

@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
* Based on git-commit.sh by Junio C Hamano and Linus Torvalds
*/

#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "lockfile.h"

1
builtin/describe.c

@ -1,3 +1,4 @@ @@ -1,3 +1,4 @@
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "lockfile.h"

1
builtin/diff-files.c

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
*
* Copyright (C) Linus Torvalds, 2005
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "diff.h"

1
builtin/diff-index.c

@ -1,3 +1,4 @@ @@ -1,3 +1,4 @@
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "diff.h"

1
builtin/diff-tree.c

@ -1,3 +1,4 @@ @@ -1,3 +1,4 @@
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "diff.h"

1
builtin/diff.c

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
*
* Copyright (c) 2006 Junio C Hamano
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "lockfile.h"

1
builtin/difftool.c

@ -11,6 +11,7 @@ @@ -11,6 +11,7 @@
*
* Copyright (C) 2016 Johannes Schindelin
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "builtin.h"

1
builtin/fsck.c

@ -1,3 +1,4 @@ @@ -1,3 +1,4 @@
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "builtin.h"
#include "cache.h"
#include "repository.h"

1
builtin/grep.c

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
*
* Copyright (c) 2006 Junio C Hamano
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "repository.h"
#include "config.h"

3
builtin/hash-object.c

@ -40,7 +40,8 @@ static void hash_fd(int fd, const char *type, const char *path, unsigned flags, @@ -40,7 +40,8 @@ static void hash_fd(int fd, const char *type, const char *path, unsigned flags,
if (fstat(fd, &st) < 0 ||
(literally
? hash_literally(&oid, fd, type, flags)
: index_fd(&the_index, &oid, fd, &st, type_from_string(type), path, flags)))
: index_fd(the_repository->index, &oid, fd, &st,
type_from_string(type), path, flags)))
die((flags & HASH_WRITE_OBJECT)
? "Unable to add %s to database"
: "Unable to hash %s", path);

1
builtin/log.c

@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
* (C) Copyright 2006 Linus Torvalds
* 2006 Junio Hamano
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "refs.h"

1
builtin/ls-files.c

@ -5,7 +5,6 @@ @@ -5,7 +5,6 @@
*
* Copyright (C) Linus Torvalds, 2005
*/
#define NO_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "repository.h"
#include "config.h"

1
builtin/merge-index.c

@ -1,3 +1,4 @@ @@ -1,3 +1,4 @@
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "builtin.h"
#include "run-command.h"


1
builtin/merge-ours.c

@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
*
* Pretend we resolved the heads, but declare our tree trumps everybody else.
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "git-compat-util.h"
#include "builtin.h"
#include "diff.h"

4
builtin/merge-tree.c

@ -1,3 +1,4 @@ @@ -1,3 +1,4 @@
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "builtin.h"
#include "tree-walk.h"
#include "xdiff-interface.h"
@ -76,7 +77,8 @@ static void *result(struct merge_list *entry, unsigned long *size) @@ -76,7 +77,8 @@ static void *result(struct merge_list *entry, unsigned long *size)
their = NULL;
if (entry)
their = entry->blob;
return merge_blobs(&the_index, path, base, our, their, size);
return merge_blobs(the_repository->index, path,
base, our, their, size);
}

static void *origin(struct merge_list *entry, unsigned long *size)

1
builtin/merge.c

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
* Based on git-merge.sh by Junio C Hamano.
*/

#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "parse-options.h"

1
builtin/mv.c

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
*
* Copyright (C) 2006 Johannes Schindelin
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "builtin.h"
#include "config.h"
#include "pathspec.h"

2
builtin/pack-objects.c

@ -970,7 +970,7 @@ static int no_try_delta(const char *path) @@ -970,7 +970,7 @@ static int no_try_delta(const char *path)

if (!check)
check = attr_check_initl("delta", NULL);
git_check_attr(&the_index, path, check);
git_check_attr(the_repository->index, path, check);
if (ATTR_FALSE(check->items[0].value))
return 1;
return 0;

1
builtin/pull.c

@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
*
* Fetch one or more remote refs and merge it/them into the current HEAD.
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "builtin.h"

1
builtin/read-tree.c

@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
* Copyright (C) Linus Torvalds, 2005
*/

#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "lockfile.h"

1
builtin/rebase--interactive.c

@ -1,3 +1,4 @@ @@ -1,3 +1,4 @@
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "builtin.h"
#include "cache.h"
#include "config.h"

1
builtin/rebase.c

@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
* Copyright (c) 2018 Pratik Karki
*/

#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "builtin.h"
#include "run-command.h"
#include "exec-cmd.h"

2
builtin/replace.c

@ -295,7 +295,7 @@ static int import_object(struct object_id *oid, enum object_type type, @@ -295,7 +295,7 @@ static int import_object(struct object_id *oid, enum object_type type,
close(fd);
return -1;
}
if (index_fd(&the_index, oid, fd, &st, type, NULL, flags) < 0)
if (index_fd(the_repository->index, oid, fd, &st, type, NULL, flags) < 0)
return error(_("unable to write object to database"));
/* index_fd close()s fd for us */
}

1
builtin/reset.c

@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
*
* Copyright (c) 2005, 2006 Linus Torvalds and Junio C Hamano
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "builtin.h"
#include "config.h"
#include "lockfile.h"

1
builtin/rev-parse.c

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
*
* Copyright (C) Linus Torvalds, 2005
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "commit.h"

1
builtin/rm.c

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
*
* Copyright (C) Linus Torvalds 2006
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "builtin.h"
#include "config.h"
#include "lockfile.h"

1
builtin/submodule--helper.c

@ -1,3 +1,4 @@ @@ -1,3 +1,4 @@
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "builtin.h"
#include "repository.h"
#include "cache.h"

1
builtin/update-index.c

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
*
* Copyright (C) Linus Torvalds, 2005
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "lockfile.h"

1
builtin/write-tree.c

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
*
* Copyright (C) Linus Torvalds, 2005
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "builtin.h"
#include "cache.h"
#include "config.h"

2
cache-tree.h

@ -51,7 +51,7 @@ void prime_cache_tree(struct repository *, struct index_state *, struct tree *); @@ -51,7 +51,7 @@ void prime_cache_tree(struct repository *, struct index_state *, struct tree *);

int cache_tree_matches_traversal(struct cache_tree *, struct name_entry *ent, struct traverse_info *info);

#ifndef NO_THE_INDEX_COMPATIBILITY_MACROS
#ifdef USE_THE_INDEX_COMPATIBILITY_MACROS
static inline int write_cache_as_tree(struct object_id *oid, int flags, const char *prefix)
{
return write_index_as_tree(oid, &the_index, get_index_file(), flags, prefix);

6
cache.h

@ -338,8 +338,6 @@ struct index_state { @@ -338,8 +338,6 @@ struct index_state {
struct mem_pool *ce_mem_pool;
};

extern struct index_state the_index;

/* Name hashing */
extern int test_lazy_init_name_hash(struct index_state *istate, int try_threaded);
extern void add_name_hash(struct index_state *istate, struct cache_entry *ce);
@ -401,7 +399,9 @@ struct cache_entry *dup_cache_entry(const struct cache_entry *ce, struct index_s @@ -401,7 +399,9 @@ struct cache_entry *dup_cache_entry(const struct cache_entry *ce, struct index_s
*/
void validate_cache_entries(const struct index_state *istate);

#ifndef NO_THE_INDEX_COMPATIBILITY_MACROS
#ifdef USE_THE_INDEX_COMPATIBILITY_MACROS
extern struct index_state the_index;

#define active_cache (the_index.cache)
#define active_nr (the_index.cache_nr)
#define active_alloc (the_index.cache_alloc)

1
convert.c

@ -1,4 +1,3 @@ @@ -1,4 +1,3 @@
#define NO_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "object-store.h"

1
dir.c

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
* Copyright (C) Linus Torvalds, 2005-2006
* Junio Hamano, 2005-2006
*/
#define NO_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "dir.h"

4
git.c

@ -417,9 +417,9 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv) @@ -417,9 +417,9 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)

trace_argv_printf(argv, "trace: built-in: git");

validate_cache_entries(&the_index);
validate_cache_entries(the_repository->index);
status = p->fn(argc, argv, prefix);
validate_cache_entries(&the_index);
validate_cache_entries(the_repository->index);

if (status)
return status;

1
name-hash.c

@ -5,7 +5,6 @@ @@ -5,7 +5,6 @@
*
* Copyright (C) 2008 Linus Torvalds
*/
#define NO_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "thread-utils.h"


1
pathspec.c

@ -1,4 +1,3 @@ @@ -1,4 +1,3 @@
#define NO_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "dir.h"

2
read-cache.c

@ -3,7 +3,6 @@ @@ -3,7 +3,6 @@
*
* Copyright (C) Linus Torvalds, 2005
*/
#define NO_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "diff.h"
@ -95,7 +94,6 @@ static struct mem_pool *find_mem_pool(struct index_state *istate) @@ -95,7 +94,6 @@ static struct mem_pool *find_mem_pool(struct index_state *istate)
return *pool_ptr;
}

struct index_state the_index;
static const char *alternate_index_output;

static void set_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)

6
repository.c

@ -1,3 +1,8 @@ @@ -1,3 +1,8 @@
/*
* not really _using_ the compat macros, just make sure the_index
* declaration matches the definition in this file.
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "repository.h"
#include "object-store.h"
@ -9,6 +14,7 @@ @@ -9,6 +14,7 @@
/* The main repository */
static struct repository the_repo;
struct repository *the_repository;
struct index_state the_index;

void initialize_the_repository(void)
{

1
submodule.c

@ -1,4 +1,3 @@ @@ -1,4 +1,3 @@
#define NO_THE_INDEX_COMPATIBILITY_MACROS

#include "cache.h"
#include "repository.h"

4
t/helper/test-dump-fsmonitor.c

@ -3,11 +3,11 @@ @@ -3,11 +3,11 @@

int cmd__dump_fsmonitor(int ac, const char **av)
{
struct index_state *istate = &the_index;
struct index_state *istate = the_repository->index;
int i;

setup_git_directory();
if (do_read_index(istate, get_index_file(), 0) < 0)
if (do_read_index(istate, the_repository->index_file, 0) < 0)
die("unable to read index file");
if (!istate->fsmonitor_last_update) {
printf("no fsmonitor\n");

1
t/helper/test-dump-untracked-cache.c

@ -1,3 +1,4 @@ @@ -1,3 +1,4 @@
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "test-tool.h"
#include "cache.h"
#include "dir.h"

1
t/helper/test-tool.h

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
#ifndef TEST_TOOL_H
#define TEST_TOOL_H

#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "git-compat-util.h"

int cmd__chmtime(int argc, const char **argv);

1
tree.c

@ -1,4 +1,3 @@ @@ -1,4 +1,3 @@
#define NO_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "cache-tree.h"
#include "tree.h"

1
unpack-trees.c

@ -1,4 +1,3 @@ @@ -1,4 +1,3 @@
#define NO_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "argv-array.h"
#include "repository.h"

Loading…
Cancel
Save