1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-04-28 16:55:09 +02:00

Merge branch 'en/header-cleanup'

Code clean-up to clarify the rule that "git-compat-util.h" must be
the first to be included.

* en/header-cleanup:
  diff.h: remove unnecessary include of object.h
  Remove unnecessary includes of builtin.h
  treewide: replace cache.h with more direct headers, where possible
  replace-object.h: move read_replace_refs declaration from cache.h to here
  object-store.h: move struct object_info from cache.h
  dir.h: refactor to no longer need to include cache.h
  object.h: stop depending on cache.h; make cache.h depend on object.h
  ident.h: move ident-related declarations out of cache.h
  pretty.h: move has_non_ascii() declaration from commit.h
  cache.h: remove dependence on hex.h; make other files include it explicitly
  hex.h: move some hex-related declarations from cache.h
  hash.h: move some oid-related declarations from cache.h
  alloc.h: move ALLOC_GROW() functions from cache.h
  treewide: remove unnecessary cache.h includes in source files
  treewide: remove unnecessary cache.h includes
  treewide: remove unnecessary git-compat-util.h includes in headers
  treewide: ensure one of the appropriate headers is sourced first
This commit is contained in:
Junio C Hamano 2023-03-17 14:03:08 -07:00
commit 88cc8ed8bc
322 changed files with 858 additions and 529 deletions

View File

@ -442,8 +442,12 @@ For C programs:
detail. detail.
- The first #include in C files, except in platform specific compat/ - The first #include in C files, except in platform specific compat/
implementations, must be either "git-compat-util.h", "cache.h" or implementations and sha1dc/, must be either "git-compat-util.h" or
"builtin.h". You do not have to include more than one of these. one of the approved headers that includes it first for you. (The
approved headers currently include "cache.h", "builtin.h",
"t/helper/test-tool.h", "xdiff/xinclude.h", or
"reftable/system.h"). You do not have to include more than one of
these.
- A C file must directly include the header files that declare the - A C file must directly include the header files that declare the
functions and the types it uses, except for the functions and types functions and the types it uses, except for the functions and types

View File

@ -3,6 +3,7 @@
#include "color.h" #include "color.h"
#include "config.h" #include "config.h"
#include "diffcore.h" #include "diffcore.h"
#include "hex.h"
#include "revision.h" #include "revision.h"
#include "refs.h" #include "refs.h"
#include "string-list.h" #include "string-list.h"

View File

@ -1,5 +1,6 @@
#include "cache.h" #include "cache.h"
#include "add-interactive.h" #include "add-interactive.h"
#include "alloc.h"
#include "strbuf.h" #include "strbuf.h"
#include "run-command.h" #include "run-command.h"
#include "strvec.h" #include "strvec.h"

View File

@ -1,6 +1,8 @@
#include "cache.h" #include "git-compat-util.h"
#include "advice.h"
#include "config.h" #include "config.h"
#include "color.h" #include "color.h"
#include "gettext.h"
#include "help.h" #include "help.h"
#include "string-list.h" #include "string-list.h"

View File

@ -1,8 +1,6 @@
#ifndef ADVICE_H #ifndef ADVICE_H
#define ADVICE_H #define ADVICE_H
#include "git-compat-util.h"
struct string_list; struct string_list;
/* /*

View File

@ -1,6 +1,8 @@
#include "cache.h" #include "git-compat-util.h"
#include "alias.h" #include "alias.h"
#include "alloc.h"
#include "config.h" #include "config.h"
#include "gettext.h"
#include "string-list.h" #include "string-list.h"
struct config_alias_data { struct config_alias_data {

View File

@ -8,7 +8,7 @@
* up with maximal alignment because it doesn't know what the object alignment * up with maximal alignment because it doesn't know what the object alignment
* for the new allocation is. * for the new allocation is.
*/ */
#include "cache.h" #include "git-compat-util.h"
#include "object.h" #include "object.h"
#include "blob.h" #include "blob.h"
#include "tree.h" #include "tree.h"

75
alloc.h
View File

@ -17,4 +17,79 @@ void *alloc_object_node(struct repository *r);
struct alloc_state *allocate_alloc_state(void); struct alloc_state *allocate_alloc_state(void);
void clear_alloc_state(struct alloc_state *s); void clear_alloc_state(struct alloc_state *s);
#define alloc_nr(x) (((x)+16)*3/2)
/**
* Dynamically growing an array using realloc() is error prone and boring.
*
* Define your array with:
*
* - a pointer (`item`) that points at the array, initialized to `NULL`
* (although please name the variable based on its contents, not on its
* type);
*
* - an integer variable (`alloc`) that keeps track of how big the current
* allocation is, initialized to `0`;
*
* - another integer variable (`nr`) to keep track of how many elements the
* array currently has, initialized to `0`.
*
* Then before adding `n`th element to the item, call `ALLOC_GROW(item, n,
* alloc)`. This ensures that the array can hold at least `n` elements by
* calling `realloc(3)` and adjusting `alloc` variable.
*
* ------------
* sometype *item;
* size_t nr;
* size_t alloc
*
* for (i = 0; i < nr; i++)
* if (we like item[i] already)
* return;
*
* // we did not like any existing one, so add one
* ALLOC_GROW(item, nr + 1, alloc);
* item[nr++] = value you like;
* ------------
*
* You are responsible for updating the `nr` variable.
*
* If you need to specify the number of elements to allocate explicitly
* then use the macro `REALLOC_ARRAY(item, alloc)` instead of `ALLOC_GROW`.
*
* Consider using ALLOC_GROW_BY instead of ALLOC_GROW as it has some
* added niceties.
*
* DO NOT USE any expression with side-effect for 'x', 'nr', or 'alloc'.
*/
#define ALLOC_GROW(x, nr, alloc) \
do { \
if ((nr) > alloc) { \
if (alloc_nr(alloc) < (nr)) \
alloc = (nr); \
else \
alloc = alloc_nr(alloc); \
REALLOC_ARRAY(x, alloc); \
} \
} while (0)
/*
* Similar to ALLOC_GROW but handles updating of the nr value and
* zeroing the bytes of the newly-grown array elements.
*
* DO NOT USE any expression with side-effect for any of the
* arguments.
*/
#define ALLOC_GROW_BY(x, nr, increase, alloc) \
do { \
if (increase) { \
size_t new_nr = nr + (increase); \
if (new_nr < nr) \
BUG("negative growth in ALLOC_GROW_BY"); \
ALLOC_GROW(x, new_nr, alloc); \
memset((x) + nr, 0, sizeof(*(x)) * (increase)); \
nr = new_nr; \
} \
} while (0)
#endif #endif

View File

@ -8,12 +8,14 @@
*/ */
#include "cache.h" #include "cache.h"
#include "alloc.h"
#include "config.h" #include "config.h"
#include "object-store.h" #include "object-store.h"
#include "blob.h" #include "blob.h"
#include "delta.h" #include "delta.h"
#include "diff.h" #include "diff.h"
#include "dir.h" #include "dir.h"
#include "hex.h"
#include "xdiff-interface.h" #include "xdiff-interface.h"
#include "ll-merge.h" #include "ll-merge.h"
#include "lockfile.h" #include "lockfile.h"

View File

@ -1,8 +1,10 @@
/* /*
* Copyright (c) 2005, 2006 Rene Scharfe * Copyright (c) 2005, 2006 Rene Scharfe
*/ */
#include "cache.h" #include "git-compat-util.h"
#include "alloc.h"
#include "config.h" #include "config.h"
#include "hex.h"
#include "tar.h" #include "tar.h"
#include "archive.h" #include "archive.h"
#include "object-store.h" #include "object-store.h"

View File

@ -4,6 +4,7 @@
#include "cache.h" #include "cache.h"
#include "config.h" #include "config.h"
#include "archive.h" #include "archive.h"
#include "hex.h"
#include "streaming.h" #include "streaming.h"
#include "utf8.h" #include "utf8.h"
#include "object-store.h" #include "object-store.h"

View File

@ -1,5 +1,7 @@
#include "cache.h" #include "git-compat-util.h"
#include "alloc.h"
#include "config.h" #include "config.h"
#include "hex.h"
#include "refs.h" #include "refs.h"
#include "object-store.h" #include "object-store.h"
#include "commit.h" #include "commit.h"

1
attr.c
View File

@ -7,6 +7,7 @@
*/ */
#include "cache.h" #include "cache.h"
#include "alloc.h"
#include "config.h" #include "config.h"
#include "exec-cmd.h" #include "exec-cmd.h"
#include "attr.h" #include "attr.h"

View File

@ -2,6 +2,7 @@
#include "config.h" #include "config.h"
#include "commit.h" #include "commit.h"
#include "diff.h" #include "diff.h"
#include "hex.h"
#include "revision.h" #include "revision.h"
#include "refs.h" #include "refs.h"
#include "list-objects.h" #include "list-objects.h"

View File

@ -5,6 +5,7 @@
#include "mergesort.h" #include "mergesort.h"
#include "diff.h" #include "diff.h"
#include "diffcore.h" #include "diffcore.h"
#include "hex.h"
#include "tag.h" #include "tag.h"
#include "blame.h" #include "blame.h"
#include "alloc.h" #include "alloc.h"

View File

@ -1,7 +1,6 @@
#ifndef BLAME_H #ifndef BLAME_H
#define BLAME_H #define BLAME_H
#include "cache.h"
#include "commit.h" #include "commit.h"
#include "xdiff-interface.h" #include "xdiff-interface.h"
#include "revision.h" #include "revision.h"

2
blob.c
View File

@ -1,4 +1,4 @@
#include "cache.h" #include "git-compat-util.h"
#include "blob.h" #include "blob.h"
#include "repository.h" #include "repository.h"
#include "alloc.h" #include "alloc.h"

View File

@ -2,6 +2,7 @@
#include "cache.h" #include "cache.h"
#include "config.h" #include "config.h"
#include "branch.h" #include "branch.h"
#include "hex.h"
#include "refs.h" #include "refs.h"
#include "refspec.h" #include "refspec.h"
#include "remote.h" #include "remote.h"

View File

@ -8,6 +8,7 @@
#include "config.h" #include "config.h"
#include "builtin.h" #include "builtin.h"
#include "exec-cmd.h" #include "exec-cmd.h"
#include "hex.h"
#include "parse-options.h" #include "parse-options.h"
#include "dir.h" #include "dir.h"
#include "run-command.h" #include "run-command.h"

View File

@ -1,5 +1,6 @@
#include "builtin.h" #include "builtin.h"
#include "cache.h" #include "cache.h"
#include "hex.h"
#include "parse-options.h" #include "parse-options.h"
#include "bisect.h" #include "bisect.h"
#include "refs.h" #include "refs.h"

View File

@ -5,10 +5,12 @@
* See COPYING for licensing conditions * See COPYING for licensing conditions
*/ */
#include "cache.h" #include "git-compat-util.h"
#include "alloc.h"
#include "config.h" #include "config.h"
#include "color.h" #include "color.h"
#include "builtin.h" #include "builtin.h"
#include "hex.h"
#include "repository.h" #include "repository.h"
#include "commit.h" #include "commit.h"
#include "diff.h" #include "diff.h"

View File

@ -5,9 +5,12 @@
*/ */
#define USE_THE_INDEX_VARIABLE #define USE_THE_INDEX_VARIABLE
#include "cache.h" #include "cache.h"
#include "alloc.h"
#include "config.h" #include "config.h"
#include "builtin.h" #include "builtin.h"
#include "diff.h" #include "diff.h"
#include "hex.h"
#include "ident.h"
#include "parse-options.h" #include "parse-options.h"
#include "userdiff.h" #include "userdiff.h"
#include "streaming.h" #include "streaming.h"
@ -15,6 +18,7 @@
#include "oid-array.h" #include "oid-array.h"
#include "packfile.h" #include "packfile.h"
#include "object-store.h" #include "object-store.h"
#include "replace-object.h"
#include "promisor-remote.h" #include "promisor-remote.h"
#include "mailmap.h" #include "mailmap.h"

View File

@ -1,5 +1,6 @@
#include "builtin.h" #include "builtin.h"
#include "config.h" #include "config.h"
#include "ident.h"
#include "mailmap.h" #include "mailmap.h"
#include "parse-options.h" #include "parse-options.h"
#include "string-list.h" #include "string-list.h"

View File

@ -1,4 +1,5 @@
#include "builtin.h" #include "builtin.h"
#include "alloc.h"
#include "config.h" #include "config.h"
#include "entry.h" #include "entry.h"
#include "parallel-checkout.h" #include "parallel-checkout.h"

View File

@ -9,6 +9,7 @@
#include "config.h" #include "config.h"
#include "diff.h" #include "diff.h"
#include "dir.h" #include "dir.h"
#include "hex.h"
#include "hook.h" #include "hook.h"
#include "ll-merge.h" #include "ll-merge.h"
#include "lockfile.h" #include "lockfile.h"

View File

@ -11,6 +11,7 @@
#define USE_THE_INDEX_VARIABLE #define USE_THE_INDEX_VARIABLE
#include "builtin.h" #include "builtin.h"
#include "config.h" #include "config.h"
#include "hex.h"
#include "lockfile.h" #include "lockfile.h"
#include "parse-options.h" #include "parse-options.h"
#include "fetch-pack.h" #include "fetch-pack.h"

View File

@ -1,12 +1,14 @@
#include "builtin.h" #include "builtin.h"
#include "config.h" #include "config.h"
#include "dir.h" #include "dir.h"
#include "hex.h"
#include "lockfile.h" #include "lockfile.h"
#include "parse-options.h" #include "parse-options.h"
#include "repository.h" #include "repository.h"
#include "commit-graph.h" #include "commit-graph.h"
#include "object-store.h" #include "object-store.h"
#include "progress.h" #include "progress.h"
#include "replace-object.h"
#include "tag.h" #include "tag.h"
#define BUILTIN_COMMIT_GRAPH_VERIFY_USAGE \ #define BUILTIN_COMMIT_GRAPH_VERIFY_USAGE \

View File

@ -5,6 +5,7 @@
*/ */
#include "cache.h" #include "cache.h"
#include "config.h" #include "config.h"
#include "hex.h"
#include "object-store.h" #include "object-store.h"
#include "repository.h" #include "repository.h"
#include "commit.h" #include "commit.h"

View File

@ -1,7 +1,8 @@
#include "builtin.h" #include "builtin.h"
#include "cache.h" #include "alloc.h"
#include "config.h" #include "config.h"
#include "color.h" #include "color.h"
#include "ident.h"
#include "parse-options.h" #include "parse-options.h"
#include "urlmatch.h" #include "urlmatch.h"
#include "quote.h" #include "quote.h"

View File

@ -1,4 +1,5 @@
#include "builtin.h" #include "builtin.h"
#include "alloc.h"
#include "parse-options.h" #include "parse-options.h"
#ifndef NO_UNIX_SOCKETS #ifndef NO_UNIX_SOCKETS

View File

@ -1,6 +1,7 @@
#define USE_THE_INDEX_VARIABLE #define USE_THE_INDEX_VARIABLE
#include "cache.h" #include "cache.h"
#include "config.h" #include "config.h"
#include "hex.h"
#include "lockfile.h" #include "lockfile.h"
#include "commit.h" #include "commit.h"
#include "tag.h" #include "tag.h"

View File

@ -3,6 +3,7 @@
#include "config.h" #include "config.h"
#include "diff.h" #include "diff.h"
#include "commit.h" #include "commit.h"
#include "hex.h"
#include "log-tree.h" #include "log-tree.h"
#include "builtin.h" #include "builtin.h"
#include "submodule.h" #include "submodule.h"

View File

@ -17,6 +17,7 @@
#include "builtin.h" #include "builtin.h"
#include "run-command.h" #include "run-command.h"
#include "exec-cmd.h" #include "exec-cmd.h"
#include "hex.h"
#include "parse-options.h" #include "parse-options.h"
#include "strvec.h" #include "strvec.h"
#include "strbuf.h" #include "strbuf.h"

View File

@ -6,6 +6,7 @@
#include "builtin.h" #include "builtin.h"
#include "cache.h" #include "cache.h"
#include "config.h" #include "config.h"
#include "hex.h"
#include "refs.h" #include "refs.h"
#include "refspec.h" #include "refspec.h"
#include "object-store.h" #include "object-store.h"

View File

@ -1,5 +1,6 @@
#include "builtin.h" #include "builtin.h"
#include "cache.h" #include "cache.h"
#include "hex.h"
#include "repository.h" #include "repository.h"
#include "config.h" #include "config.h"
#include "lockfile.h" #include "lockfile.h"

View File

@ -1,4 +1,6 @@
#include "builtin.h" #include "builtin.h"
#include "alloc.h"
#include "hex.h"
#include "pkt-line.h" #include "pkt-line.h"
#include "fetch-pack.h" #include "fetch-pack.h"
#include "remote.h" #include "remote.h"

View File

@ -3,6 +3,7 @@
*/ */
#include "cache.h" #include "cache.h"
#include "config.h" #include "config.h"
#include "hex.h"
#include "repository.h" #include "repository.h"
#include "refs.h" #include "refs.h"
#include "refspec.h" #include "refspec.h"

View File

@ -1,5 +1,6 @@
#include "builtin.h" #include "builtin.h"
#include "cache.h" #include "cache.h"
#include "hex.h"
#include "repository.h" #include "repository.h"
#include "config.h" #include "config.h"
#include "commit.h" #include "commit.h"
@ -18,6 +19,7 @@
#include "decorate.h" #include "decorate.h"
#include "packfile.h" #include "packfile.h"
#include "object-store.h" #include "object-store.h"
#include "replace-object.h"
#include "resolve-undo.h" #include "resolve-undo.h"
#include "run-command.h" #include "run-command.h"
#include "worktree.h" #include "worktree.h"

View File

@ -1,4 +1,5 @@
#include "builtin.h" #include "builtin.h"
#include "alloc.h"
#include "config.h" #include "config.h"
#include "parse-options.h" #include "parse-options.h"
#include "fsmonitor.h" #include "fsmonitor.h"

View File

@ -11,6 +11,7 @@
*/ */
#include "builtin.h" #include "builtin.h"
#include "hex.h"
#include "repository.h" #include "repository.h"
#include "config.h" #include "config.h"
#include "tempfile.h" #include "tempfile.h"

View File

@ -4,6 +4,8 @@
* Copyright (c) 2006 Junio C Hamano * Copyright (c) 2006 Junio C Hamano
*/ */
#include "cache.h" #include "cache.h"
#include "alloc.h"
#include "hex.h"
#include "repository.h" #include "repository.h"
#include "config.h" #include "config.h"
#include "blob.h" #include "blob.h"

View File

@ -6,6 +6,7 @@
*/ */
#include "builtin.h" #include "builtin.h"
#include "config.h" #include "config.h"
#include "hex.h"
#include "object-store.h" #include "object-store.h"
#include "blob.h" #include "blob.h"
#include "quote.h" #include "quote.h"

View File

@ -1,6 +1,8 @@
#include "builtin.h" #include "builtin.h"
#include "alloc.h"
#include "config.h" #include "config.h"
#include "delta.h" #include "delta.h"
#include "hex.h"
#include "pack.h" #include "pack.h"
#include "csum-file.h" #include "csum-file.h"
#include "blob.h" #include "blob.h"
@ -14,6 +16,7 @@
#include "thread-utils.h" #include "thread-utils.h"
#include "packfile.h" #include "packfile.h"
#include "object-store.h" #include "object-store.h"
#include "replace-object.h"
#include "promisor-remote.h" #include "promisor-remote.h"
static const char index_pack_usage[] = static const char index_pack_usage[] =

View File

@ -4,8 +4,10 @@
* (C) Copyright 2006 Linus Torvalds * (C) Copyright 2006 Linus Torvalds
* 2006 Junio Hamano * 2006 Junio Hamano
*/ */
#include "cache.h" #include "git-compat-util.h"
#include "alloc.h"
#include "config.h" #include "config.h"
#include "hex.h"
#include "refs.h" #include "refs.h"
#include "object-store.h" #include "object-store.h"
#include "color.h" #include "color.h"

View File

@ -1,5 +1,6 @@
#include "builtin.h" #include "builtin.h"
#include "cache.h" #include "cache.h"
#include "hex.h"
#include "transport.h" #include "transport.h"
#include "ref-filter.h" #include "ref-filter.h"
#include "remote.h" #include "remote.h"

View File

@ -5,6 +5,7 @@
*/ */
#include "cache.h" #include "cache.h"
#include "config.h" #include "config.h"
#include "hex.h"
#include "object-store.h" #include "object-store.h"
#include "blob.h" #include "blob.h"
#include "tree.h" #include "tree.h"

View File

@ -2,6 +2,7 @@
#include "cache.h" #include "cache.h"
#include "config.h" #include "config.h"
#include "commit.h" #include "commit.h"
#include "hex.h"
#include "refs.h" #include "refs.h"
#include "diff.h" #include "diff.h"
#include "revision.h" #include "revision.h"

View File

@ -1,5 +1,6 @@
#define USE_THE_INDEX_VARIABLE #define USE_THE_INDEX_VARIABLE
#include "builtin.h" #include "builtin.h"
#include "hex.h"
#include "run-command.h" #include "run-command.h"
static const char *pgm; static const char *pgm;

View File

@ -3,6 +3,7 @@
#include "tree-walk.h" #include "tree-walk.h"
#include "xdiff-interface.h" #include "xdiff-interface.h"
#include "help.h" #include "help.h"
#include "hex.h"
#include "commit.h" #include "commit.h"
#include "commit-reach.h" #include "commit-reach.h"
#include "merge-ort.h" #include "merge-ort.h"

View File

@ -8,7 +8,9 @@
#define USE_THE_INDEX_VARIABLE #define USE_THE_INDEX_VARIABLE
#include "cache.h" #include "cache.h"
#include "alloc.h"
#include "config.h" #include "config.h"
#include "hex.h"
#include "parse-options.h" #include "parse-options.h"
#include "builtin.h" #include "builtin.h"
#include "lockfile.h" #include "lockfile.h"

View File

@ -1,4 +1,5 @@
#include "builtin.h" #include "builtin.h"
#include "hex.h"
#include "parse-options.h" #include "parse-options.h"
#include "tag.h" #include "tag.h"
#include "replace-object.h" #include "replace-object.h"

View File

@ -4,6 +4,8 @@
* Copyright (c) Junio C Hamano, 2006, 2009 * Copyright (c) Junio C Hamano, 2006, 2009
*/ */
#include "builtin.h" #include "builtin.h"
#include "alloc.h"
#include "hex.h"
#include "quote.h" #include "quote.h"
#include "tree.h" #include "tree.h"
#include "parse-options.h" #include "parse-options.h"

View File

@ -5,6 +5,7 @@
*/ */
#define USE_THE_INDEX_VARIABLE #define USE_THE_INDEX_VARIABLE
#include "builtin.h" #include "builtin.h"
#include "alloc.h"
#include "config.h" #include "config.h"
#include "pathspec.h" #include "pathspec.h"
#include "lockfile.h" #include "lockfile.h"

View File

@ -1,5 +1,6 @@
#include "builtin.h" #include "builtin.h"
#include "cache.h" #include "alloc.h"
#include "hex.h"
#include "repository.h" #include "repository.h"
#include "config.h" #include "config.h"
#include "commit.h" #include "commit.h"

View File

@ -10,6 +10,7 @@
#include "cache.h" #include "cache.h"
#include "config.h" #include "config.h"
#include "builtin.h" #include "builtin.h"
#include "hex.h"
#include "notes.h" #include "notes.h"
#include "object-store.h" #include "object-store.h"
#include "repository.h" #include "repository.h"

View File

@ -1,5 +1,6 @@
#include "builtin.h" #include "builtin.h"
#include "cache.h" #include "alloc.h"
#include "hex.h"
#include "repository.h" #include "repository.h"
#include "config.h" #include "config.h"
#include "attr.h" #include "attr.h"
@ -31,6 +32,7 @@
#include "list.h" #include "list.h"
#include "packfile.h" #include "packfile.h"
#include "object-store.h" #include "object-store.h"
#include "replace-object.h"
#include "dir.h" #include "dir.h"
#include "midx.h" #include "midx.h"
#include "trace2.h" #include "trace2.h"

View File

@ -7,6 +7,7 @@
*/ */
#include "builtin.h" #include "builtin.h"
#include "hex.h"
#include "repository.h" #include "repository.h"
#include "packfile.h" #include "packfile.h"
#include "object-store.h" #include "object-store.h"

View File

@ -2,6 +2,7 @@
#include "builtin.h" #include "builtin.h"
#include "config.h" #include "config.h"
#include "diff.h" #include "diff.h"
#include "hex.h"
#include "parse-options.h" #include "parse-options.h"
static void flush_current_id(int patchlen, struct object_id *id, struct object_id *result) static void flush_current_id(int patchlen, struct object_id *id, struct object_id *result)

View File

@ -1,12 +1,14 @@
#include "cache.h" #include "cache.h"
#include "commit.h" #include "commit.h"
#include "diff.h" #include "diff.h"
#include "hex.h"
#include "revision.h" #include "revision.h"
#include "builtin.h" #include "builtin.h"
#include "reachable.h" #include "reachable.h"
#include "parse-options.h" #include "parse-options.h"
#include "progress.h" #include "progress.h"
#include "prune-packed.h" #include "prune-packed.h"
#include "replace-object.h"
#include "object-store.h" #include "object-store.h"
#include "shallow.h" #include "shallow.h"

View File

@ -9,6 +9,7 @@
#include "cache.h" #include "cache.h"
#include "config.h" #include "config.h"
#include "builtin.h" #include "builtin.h"
#include "hex.h"
#include "parse-options.h" #include "parse-options.h"
#include "exec-cmd.h" #include "exec-cmd.h"
#include "run-command.h" #include "run-command.h"

View File

@ -7,6 +7,7 @@
#define USE_THE_INDEX_VARIABLE #define USE_THE_INDEX_VARIABLE
#include "cache.h" #include "cache.h"
#include "config.h" #include "config.h"
#include "hex.h"
#include "lockfile.h" #include "lockfile.h"
#include "object.h" #include "object.h"
#include "tree.h" #include "tree.h"

View File

@ -6,6 +6,7 @@
#define USE_THE_INDEX_VARIABLE #define USE_THE_INDEX_VARIABLE
#include "builtin.h" #include "builtin.h"
#include "hex.h"
#include "run-command.h" #include "run-command.h"
#include "exec-cmd.h" #include "exec-cmd.h"
#include "strvec.h" #include "strvec.h"

View File

@ -1,6 +1,7 @@
#include "builtin.h" #include "builtin.h"
#include "repository.h" #include "repository.h"
#include "config.h" #include "config.h"
#include "hex.h"
#include "lockfile.h" #include "lockfile.h"
#include "pack.h" #include "pack.h"
#include "refs.h" #include "refs.h"

View File

@ -1,7 +1,8 @@
#include "builtin.h" #include "builtin.h"
#include "cache.h" #include "alloc.h"
#include "config.h" #include "config.h"
#include "dir.h" #include "dir.h"
#include "hex.h"
#include "parse-options.h" #include "parse-options.h"
#include "run-command.h" #include "run-command.h"
#include "sigchain.h" #include "sigchain.h"

View File

@ -11,10 +11,12 @@
#include "cache.h" #include "cache.h"
#include "config.h" #include "config.h"
#include "builtin.h" #include "builtin.h"
#include "hex.h"
#include "refs.h" #include "refs.h"
#include "parse-options.h" #include "parse-options.h"
#include "run-command.h" #include "run-command.h"
#include "object-store.h" #include "object-store.h"
#include "replace-object.h"
#include "repository.h" #include "repository.h"
#include "tag.h" #include "tag.h"

View File

@ -10,6 +10,7 @@
#define USE_THE_INDEX_VARIABLE #define USE_THE_INDEX_VARIABLE
#include "builtin.h" #include "builtin.h"
#include "config.h" #include "config.h"
#include "hex.h"
#include "lockfile.h" #include "lockfile.h"
#include "tag.h" #include "tag.h"
#include "object.h" #include "object.h"

View File

@ -2,6 +2,7 @@
#include "config.h" #include "config.h"
#include "commit.h" #include "commit.h"
#include "diff.h" #include "diff.h"
#include "hex.h"
#include "revision.h" #include "revision.h"
#include "list-objects.h" #include "list-objects.h"
#include "list-objects-filter.h" #include "list-objects-filter.h"

View File

@ -5,8 +5,10 @@
*/ */
#define USE_THE_INDEX_VARIABLE #define USE_THE_INDEX_VARIABLE
#include "cache.h" #include "cache.h"
#include "alloc.h"
#include "config.h" #include "config.h"
#include "commit.h" #include "commit.h"
#include "hex.h"
#include "refs.h" #include "refs.h"
#include "quote.h" #include "quote.h"
#include "builtin.h" #include "builtin.h"

View File

@ -1,4 +1,5 @@
#include "cache.h" #include "git-compat-util.h"
#include "alloc.h"
#include "config.h" #include "config.h"
#include "builtin.h" #include "builtin.h"
#include "parse-options.h" #include "parse-options.h"

View File

@ -5,6 +5,7 @@
*/ */
#define USE_THE_INDEX_VARIABLE #define USE_THE_INDEX_VARIABLE
#include "builtin.h" #include "builtin.h"
#include "alloc.h"
#include "advice.h" #include "advice.h"
#include "config.h" #include "config.h"
#include "lockfile.h" #include "lockfile.h"

View File

@ -1,6 +1,7 @@
#include "builtin.h" #include "builtin.h"
#include "config.h" #include "config.h"
#include "commit.h" #include "commit.h"
#include "hex.h"
#include "refs.h" #include "refs.h"
#include "pkt-line.h" #include "pkt-line.h"
#include "sideband.h" #include "sideband.h"

View File

@ -1,5 +1,6 @@
#include "cache.h" #include "cache.h"
#include "config.h" #include "config.h"
#include "hex.h"
#include "pretty.h" #include "pretty.h"
#include "refs.h" #include "refs.h"
#include "builtin.h" #include "builtin.h"

View File

@ -1,5 +1,6 @@
#include "builtin.h" #include "builtin.h"
#include "cache.h" #include "cache.h"
#include "hex.h"
#include "pack.h" #include "pack.h"
#include "parse-options.h" #include "parse-options.h"

View File

@ -1,6 +1,7 @@
#include "builtin.h" #include "builtin.h"
#include "cache.h" #include "cache.h"
#include "config.h" #include "config.h"
#include "hex.h"
#include "refs.h" #include "refs.h"
#include "object-store.h" #include "object-store.h"
#include "object.h" #include "object.h"

View File

@ -1,6 +1,7 @@
#define USE_THE_INDEX_VARIABLE #define USE_THE_INDEX_VARIABLE
#include "builtin.h" #include "builtin.h"
#include "config.h" #include "config.h"
#include "hex.h"
#include "parse-options.h" #include "parse-options.h"
#include "refs.h" #include "refs.h"
#include "lockfile.h" #include "lockfile.h"

View File

@ -1,5 +1,7 @@
#define USE_THE_INDEX_VARIABLE #define USE_THE_INDEX_VARIABLE
#include "builtin.h" #include "builtin.h"
#include "alloc.h"
#include "hex.h"
#include "repository.h" #include "repository.h"
#include "cache.h" #include "cache.h"
#include "config.h" #include "config.h"

View File

@ -9,6 +9,7 @@
#include "cache.h" #include "cache.h"
#include "config.h" #include "config.h"
#include "builtin.h" #include "builtin.h"
#include "hex.h"
#include "refs.h" #include "refs.h"
#include "object-store.h" #include "object-store.h"
#include "tag.h" #include "tag.h"

View File

@ -1,5 +1,6 @@
#include "builtin.h" #include "builtin.h"
#include "config.h" #include "config.h"
#include "hex.h"
#include "object-store.h" #include "object-store.h"
static char *create_temp_file(struct object_id *oid) static char *create_temp_file(struct object_id *oid)

View File

@ -2,12 +2,14 @@
#include "cache.h" #include "cache.h"
#include "bulk-checkin.h" #include "bulk-checkin.h"
#include "config.h" #include "config.h"
#include "hex.h"
#include "object-store.h" #include "object-store.h"
#include "object.h" #include "object.h"
#include "delta.h" #include "delta.h"
#include "pack.h" #include "pack.h"
#include "blob.h" #include "blob.h"
#include "commit.h" #include "commit.h"
#include "replace-object.h"
#include "tag.h" #include "tag.h"
#include "tree.h" #include "tree.h"
#include "tree-walk.h" #include "tree-walk.h"

View File

@ -7,6 +7,7 @@
#include "cache.h" #include "cache.h"
#include "bulk-checkin.h" #include "bulk-checkin.h"
#include "config.h" #include "config.h"
#include "hex.h"
#include "lockfile.h" #include "lockfile.h"
#include "quote.h" #include "quote.h"
#include "cache-tree.h" #include "cache-tree.h"

View File

@ -4,6 +4,7 @@
#include "pkt-line.h" #include "pkt-line.h"
#include "parse-options.h" #include "parse-options.h"
#include "protocol.h" #include "protocol.h"
#include "replace-object.h"
#include "upload-pack.h" #include "upload-pack.h"
#include "serve.h" #include "serve.h"

View File

@ -5,6 +5,7 @@
*/ */
#include "builtin.h" #include "builtin.h"
#include "config.h" #include "config.h"
#include "ident.h"
#include "refs.h" #include "refs.h"
static const char var_usage[] = "git var (-l | <variable>)"; static const char var_usage[] = "git var (-l | <variable>)";

View File

@ -3,6 +3,7 @@
#include "config.h" #include "config.h"
#include "builtin.h" #include "builtin.h"
#include "dir.h" #include "dir.h"
#include "hex.h"
#include "parse-options.h" #include "parse-options.h"
#include "strvec.h" #include "strvec.h"
#include "branch.h" #include "branch.h"

View File

@ -7,6 +7,7 @@
#include "builtin.h" #include "builtin.h"
#include "cache.h" #include "cache.h"
#include "config.h" #include "config.h"
#include "hex.h"
#include "tree.h" #include "tree.h"
#include "cache-tree.h" #include "cache-tree.h"
#include "parse-options.h" #include "parse-options.h"

View File

@ -1,8 +1,10 @@
/* /*
* Copyright (c) 2011, Google Inc. * Copyright (c) 2011, Google Inc.
*/ */
#include "cache.h" #include "git-compat-util.h"
#include "alloc.h"
#include "bulk-checkin.h" #include "bulk-checkin.h"
#include "hex.h"
#include "lockfile.h" #include "lockfile.h"
#include "repository.h" #include "repository.h"
#include "csum-file.h" #include "csum-file.h"

View File

@ -1,6 +1,7 @@
#include "cache.h" #include "cache.h"
#include "lockfile.h" #include "lockfile.h"
#include "bundle.h" #include "bundle.h"
#include "hex.h"
#include "object-store.h" #include "object-store.h"
#include "repository.h" #include "repository.h"
#include "object.h" #include "object.h"

View File

@ -1,4 +1,6 @@
#include "cache.h" #include "git-compat-util.h"
#include "alloc.h"
#include "hex.h"
#include "lockfile.h" #include "lockfile.h"
#include "tree.h" #include "tree.h"
#include "tree-walk.h" #include "tree-walk.h"

View File

@ -1,7 +1,6 @@
#ifndef CACHE_TREE_H #ifndef CACHE_TREE_H
#define CACHE_TREE_H #define CACHE_TREE_H
#include "cache.h"
#include "tree.h" #include "tree.h"
#include "tree-walk.h" #include "tree-walk.h"

305
cache.h
View File

@ -14,8 +14,11 @@
#include "pack-revindex.h" #include "pack-revindex.h"
#include "hash.h" #include "hash.h"
#include "path.h" #include "path.h"
#include "pathspec.h"
#include "object.h"
#include "oid-array.h" #include "oid-array.h"
#include "repository.h" #include "repository.h"
#include "statinfo.h"
#include "mem-pool.h" #include "mem-pool.h"
typedef struct git_zstream { typedef struct git_zstream {
@ -118,26 +121,6 @@ struct cache_header {
#define INDEX_FORMAT_LB 2 #define INDEX_FORMAT_LB 2
#define INDEX_FORMAT_UB 4 #define INDEX_FORMAT_UB 4
/*
* The "cache_time" is just the low 32 bits of the
* time. It doesn't matter if it overflows - we only
* check it for equality in the 32 bits we save.
*/
struct cache_time {
uint32_t sec;
uint32_t nsec;
};
struct stat_data {
struct cache_time sd_ctime;
struct cache_time sd_mtime;
unsigned int sd_dev;
unsigned int sd_ino;
unsigned int sd_uid;
unsigned int sd_gid;
unsigned int sd_size;
};
struct cache_entry { struct cache_entry {
struct hashmap_entry ent; struct hashmap_entry ent;
struct stat_data ce_stat_data; struct stat_data ce_stat_data;
@ -293,6 +276,15 @@ static inline unsigned int canon_mode(unsigned int mode)
return S_IFGITLINK; return S_IFGITLINK;
} }
static inline int ce_path_match(struct index_state *istate,
const struct cache_entry *ce,
const struct pathspec *pathspec,
char *seen)
{
return match_pathspec(istate, pathspec, ce->name, ce_namelen(ce), 0, seen,
S_ISDIR(ce->ce_mode) || S_ISGITLINK(ce->ce_mode));
}
#define cache_entry_size(len) (offsetof(struct cache_entry,name) + (len) + 1) #define cache_entry_size(len) (offsetof(struct cache_entry,name) + (len) + 1)
#define SOMETHING_CHANGED (1 << 0) /* unclassified changes go here */ #define SOMETHING_CHANGED (1 << 0) /* unclassified changes go here */
@ -453,26 +445,6 @@ void prefetch_cache_entries(const struct index_state *istate,
extern struct index_state the_index; extern struct index_state the_index;
#endif #endif
#define TYPE_BITS 3
/*
* Values in this enum (except those outside the 3 bit range) are part
* of pack file format. See gitformat-pack(5) for more information.
*/
enum object_type {
OBJ_BAD = -1,
OBJ_NONE = 0,
OBJ_COMMIT = 1,
OBJ_TREE = 2,
OBJ_BLOB = 3,
OBJ_TAG = 4,
/* 5 for future expansion */
OBJ_OFS_DELTA = 6,
OBJ_REF_DELTA = 7,
OBJ_ANY,
OBJ_MAX
};
static inline enum object_type object_type(unsigned int mode) static inline enum object_type object_type(unsigned int mode)
{ {
return S_ISDIR(mode) ? OBJ_TREE : return S_ISDIR(mode) ? OBJ_TREE :
@ -656,81 +628,6 @@ void initialize_repository_version(int hash_algo, int reinit);
void sanitize_stdfds(void); void sanitize_stdfds(void);
int daemonize(void); int daemonize(void);
#define alloc_nr(x) (((x)+16)*3/2)
/**
* Dynamically growing an array using realloc() is error prone and boring.
*
* Define your array with:
*
* - a pointer (`item`) that points at the array, initialized to `NULL`
* (although please name the variable based on its contents, not on its
* type);
*
* - an integer variable (`alloc`) that keeps track of how big the current
* allocation is, initialized to `0`;
*
* - another integer variable (`nr`) to keep track of how many elements the
* array currently has, initialized to `0`.
*
* Then before adding `n`th element to the item, call `ALLOC_GROW(item, n,
* alloc)`. This ensures that the array can hold at least `n` elements by
* calling `realloc(3)` and adjusting `alloc` variable.
*
* ------------
* sometype *item;
* size_t nr;
* size_t alloc
*
* for (i = 0; i < nr; i++)
* if (we like item[i] already)
* return;
*
* // we did not like any existing one, so add one
* ALLOC_GROW(item, nr + 1, alloc);
* item[nr++] = value you like;
* ------------
*
* You are responsible for updating the `nr` variable.
*
* If you need to specify the number of elements to allocate explicitly
* then use the macro `REALLOC_ARRAY(item, alloc)` instead of `ALLOC_GROW`.
*
* Consider using ALLOC_GROW_BY instead of ALLOC_GROW as it has some
* added niceties.
*
* DO NOT USE any expression with side-effect for 'x', 'nr', or 'alloc'.
*/
#define ALLOC_GROW(x, nr, alloc) \
do { \
if ((nr) > alloc) { \
if (alloc_nr(alloc) < (nr)) \
alloc = (nr); \
else \
alloc = alloc_nr(alloc); \
REALLOC_ARRAY(x, alloc); \
} \
} while (0)
/*
* Similar to ALLOC_GROW but handles updating of the nr value and
* zeroing the bytes of the newly-grown array elements.
*
* DO NOT USE any expression with side-effect for any of the
* arguments.
*/
#define ALLOC_GROW_BY(x, nr, increase, alloc) \
do { \
if (increase) { \
size_t new_nr = nr + (increase); \
if (new_nr < nr) \
BUG("negative growth in ALLOC_GROW_BY"); \
ALLOC_GROW(x, new_nr, alloc); \
memset((x) + nr, 0, sizeof(*(x)) * (increase)); \
nr = new_nr; \
} \
} while (0)
/* Initialize and use the cache information */ /* Initialize and use the cache information */
struct lock_file; struct lock_file;
void preload_index(struct index_state *index, void preload_index(struct index_state *index,
@ -989,14 +886,6 @@ void set_shared_repository(int value);
int get_shared_repository(void); int get_shared_repository(void);
void reset_shared_repository(void); void reset_shared_repository(void);
/*
* Do replace refs need to be checked this run? This variable is
* initialized to true unless --no-replace-object is used or
* $GIT_NO_REPLACE_OBJECTS is set, but is set to false by some
* commands that do not want replace references to be active.
*/
extern int read_replace_refs;
/* /*
* These values are used to help identify parts of a repository to fsync. * These values are used to help identify parts of a repository to fsync.
* FSYNC_COMPONENT_NONE identifies data that will not be a persistent part of the * FSYNC_COMPONENT_NONE identifies data that will not be a persistent part of the
@ -1400,22 +1289,6 @@ int finalize_object_file(const char *tmpfile, const char *filename);
/* Helper to check and "touch" a file */ /* Helper to check and "touch" a file */
int check_and_freshen_file(const char *fn, int freshen); int check_and_freshen_file(const char *fn, int freshen);
extern const signed char hexval_table[256];
static inline unsigned int hexval(unsigned char c)
{
return hexval_table[c];
}
/*
* Convert two consecutive hexadecimal digits into a char. Return a
* negative value on error. Don't run over the end of short strings.
*/
static inline int hex2chr(const char *s)
{
unsigned int val = hexval(s[0]);
return (val & ~0xf) ? val : (val << 4) | hexval(s[1]);
}
/* Convert to/from hex/sha1 representation */ /* Convert to/from hex/sha1 representation */
#define MINIMUM_ABBREV minimum_abbrev #define MINIMUM_ABBREV minimum_abbrev
#define DEFAULT_ABBREV default_abbrev #define DEFAULT_ABBREV default_abbrev
@ -1438,40 +1311,6 @@ struct object_context {
char *path; char *path;
}; };
#define GET_OID_QUIETLY 01
#define GET_OID_COMMIT 02
#define GET_OID_COMMITTISH 04
#define GET_OID_TREE 010
#define GET_OID_TREEISH 020
#define GET_OID_BLOB 040
#define GET_OID_FOLLOW_SYMLINKS 0100
#define GET_OID_RECORD_PATH 0200
#define GET_OID_ONLY_TO_DIE 04000
#define GET_OID_REQUIRE_PATH 010000
#define GET_OID_DISAMBIGUATORS \
(GET_OID_COMMIT | GET_OID_COMMITTISH | \
GET_OID_TREE | GET_OID_TREEISH | \
GET_OID_BLOB)
enum get_oid_result {
FOUND = 0,
MISSING_OBJECT = -1, /* The requested object is missing */
SHORT_NAME_AMBIGUOUS = -2,
/* The following only apply when symlinks are followed */
DANGLING_SYMLINK = -4, /*
* The initial symlink is there, but
* (transitively) points to a missing
* in-tree file
*/
SYMLINK_LOOP = -5,
NOT_DIR = -6, /*
* Somewhere along the symlink chain, a path is
* requested which contains a file as a
* non-final element.
*/
};
int repo_get_oid(struct repository *r, const char *str, struct object_id *oid); int repo_get_oid(struct repository *r, const char *str, struct object_id *oid);
__attribute__((format (printf, 2, 3))) __attribute__((format (printf, 2, 3)))
int get_oidf(struct object_id *oid, const char *fmt, ...); int get_oidf(struct object_id *oid, const char *fmt, ...);
@ -1502,68 +1341,6 @@ int repo_for_each_abbrev(struct repository *r, const char *prefix, each_abbrev_f
int set_disambiguate_hint_config(const char *var, const char *value); int set_disambiguate_hint_config(const char *var, const char *value);
/*
* Try to read a SHA1 in hexadecimal format from the 40 characters
* starting at hex. Write the 20-byte result to sha1 in binary form.
* Return 0 on success. Reading stops if a NUL is encountered in the
* input, so it is safe to pass this function an arbitrary
* null-terminated string.
*/
int get_sha1_hex(const char *hex, unsigned char *sha1);
int get_oid_hex(const char *hex, struct object_id *sha1);
/* Like get_oid_hex, but for an arbitrary hash algorithm. */
int get_oid_hex_algop(const char *hex, struct object_id *oid, const struct git_hash_algo *algop);
/*
* Read `len` pairs of hexadecimal digits from `hex` and write the
* values to `binary` as `len` bytes. Return 0 on success, or -1 if
* the input does not consist of hex digits).
*/
int hex_to_bytes(unsigned char *binary, const char *hex, size_t len);
/*
* Convert a binary hash in "unsigned char []" or an object name in
* "struct object_id *" to its hex equivalent. The `_r` variant is reentrant,
* and writes the NUL-terminated output to the buffer `out`, which must be at
* least `GIT_MAX_HEXSZ + 1` bytes, and returns a pointer to out for
* convenience.
*
* The non-`_r` variant returns a static buffer, but uses a ring of 4
* buffers, making it safe to make multiple calls for a single statement, like:
*
* printf("%s -> %s", hash_to_hex(one), hash_to_hex(two));
* printf("%s -> %s", oid_to_hex(one), oid_to_hex(two));
*/
char *hash_to_hex_algop_r(char *buffer, const unsigned char *hash, const struct git_hash_algo *);
char *oid_to_hex_r(char *out, const struct object_id *oid);
char *hash_to_hex_algop(const unsigned char *hash, const struct git_hash_algo *); /* static buffer result! */
char *hash_to_hex(const unsigned char *hash); /* same static buffer */
char *oid_to_hex(const struct object_id *oid); /* same static buffer */
/*
* Parse a 40-character hexadecimal object ID starting from hex, updating the
* pointer specified by end when parsing stops. The resulting object ID is
* stored in oid. Returns 0 on success. Parsing will stop on the first NUL or
* other invalid character. end is only updated on success; otherwise, it is
* unmodified.
*/
int parse_oid_hex(const char *hex, struct object_id *oid, const char **end);
/* Like parse_oid_hex, but for an arbitrary hash algorithm. */
int parse_oid_hex_algop(const char *hex, struct object_id *oid, const char **end,
const struct git_hash_algo *algo);
/*
* These functions work like get_oid_hex and parse_oid_hex, but they will parse
* a hex value for any algorithm. The algorithm is detected based on the length
* and the algorithm in use is returned. If this is not a hex object ID in any
* algorithm, returns GIT_HASH_UNKNOWN.
*/
int get_oid_hex_any(const char *hex, struct object_id *oid);
int parse_oid_hex_any(const char *hex, struct object_id *oid, const char **end);
/* /*
* This reads short-hand syntax that not only evaluates to a commit * This reads short-hand syntax that not only evaluates to a commit
* object name, but also can act as if the end user spelled the name * object name, but also can act as if the end user spelled the name
@ -1632,65 +1409,10 @@ struct object *repo_peel_to_type(struct repository *r,
#define peel_to_type(name, namelen, obj, type) \ #define peel_to_type(name, namelen, obj, type) \
repo_peel_to_type(the_repository, name, namelen, obj, type) repo_peel_to_type(the_repository, name, namelen, obj, type)
#define IDENT_STRICT 1
#define IDENT_NO_DATE 2
#define IDENT_NO_NAME 4
enum want_ident {
WANT_BLANK_IDENT,
WANT_AUTHOR_IDENT,
WANT_COMMITTER_IDENT
};
const char *git_author_info(int);
const char *git_committer_info(int);
const char *fmt_ident(const char *name, const char *email,
enum want_ident whose_ident,
const char *date_str, int);
const char *fmt_name(enum want_ident);
const char *ident_default_name(void);
const char *ident_default_email(void);
const char *git_editor(void); const char *git_editor(void);
const char *git_sequence_editor(void); const char *git_sequence_editor(void);
const char *git_pager(int stdout_is_tty); const char *git_pager(int stdout_is_tty);
int is_terminal_dumb(void); int is_terminal_dumb(void);
int git_ident_config(const char *, const char *, void *);
/*
* Prepare an ident to fall back on if the user didn't configure it.
*/
void prepare_fallback_ident(const char *name, const char *email);
void reset_ident_date(void);
struct ident_split {
const char *name_begin;
const char *name_end;
const char *mail_begin;
const char *mail_end;
const char *date_begin;
const char *date_end;
const char *tz_begin;
const char *tz_end;
};
/*
* Signals an success with 0, but time part of the result may be NULL
* if the input lacks timestamp and zone
*/
int split_ident_line(struct ident_split *, const char *, int);
/*
* Given a commit or tag object buffer and the commit or tag headers, replaces
* the idents in the headers with their canonical versions using the mailmap mechanism.
*/
void apply_mailmap_to_header(struct strbuf *, const char **, struct string_list *);
/*
* Compare split idents for equality or strict ordering. Note that we
* compare only the ident part of the line, ignoring any timestamp.
*
* Because there are two fields, we must choose one as the primary key; we
* currently arbitrarily pick the email.
*/
int ident_cmp(const struct ident_split *, const struct ident_split *);
struct cache_def { struct cache_def {
struct strbuf path; struct strbuf path;
@ -1757,9 +1479,6 @@ int update_server_info(int);
const char *get_log_output_encoding(void); const char *get_log_output_encoding(void);
const char *get_commit_output_encoding(void); const char *get_commit_output_encoding(void);
int committer_ident_sufficiently_given(void);
int author_ident_sufficiently_given(void);
extern const char *git_commit_encoding; extern const char *git_commit_encoding;
extern const char *git_log_output_encoding; extern const char *git_log_output_encoding;
extern const char *git_mailmap_file; extern const char *git_mailmap_file;

View File

@ -4,6 +4,7 @@
* Based on Adam Langley's adaptation of Dan Bernstein's public domain code * Based on Adam Langley's adaptation of Dan Bernstein's public domain code
* git clone https://github.com/agl/critbit.git * git clone https://github.com/agl/critbit.git
*/ */
#include "git-compat-util.h"
#include "cbtree.h" #include "cbtree.h"
static struct cb_node *cb_node_of(const void *p) static struct cb_node *cb_node_of(const void *p)

View File

@ -14,8 +14,6 @@
#ifndef CBTREE_H #ifndef CBTREE_H
#define CBTREE_H #define CBTREE_H
#include "git-compat-util.h"
struct cb_node; struct cb_node;
struct cb_node { struct cb_node {
struct cb_node *child[2]; struct cb_node *child[2];

View File

@ -1,7 +1,7 @@
#ifndef CHECKOUT_H #ifndef CHECKOUT_H
#define CHECKOUT_H #define CHECKOUT_H
#include "cache.h" #include "hash.h"
/* /*
* Check if the branch name uniquely matches a branch name on a remote * Check if the branch name uniquely matches a branch name on a remote

View File

@ -1,4 +1,5 @@
#include "cache.h" #include "git-compat-util.h"
#include "alloc.h"
#include "chunk-format.h" #include "chunk-format.h"
#include "csum-file.h" #include "csum-file.h"

View File

@ -1,7 +1,6 @@
#ifndef CHUNK_FORMAT_H #ifndef CHUNK_FORMAT_H
#define CHUNK_FORMAT_H #define CHUNK_FORMAT_H
#include "git-compat-util.h"
#include "hash.h" #include "hash.h"
struct hashfile; struct hashfile;

View File

@ -1,6 +1,7 @@
#include "cache.h" #include "cache.h"
#include "config.h" #include "config.h"
#include "color.h" #include "color.h"
#include "hex.h"
static int git_use_color_default = GIT_COLOR_AUTO; static int git_use_color_default = GIT_COLOR_AUTO;
int color_stdout_is_tty = -1; int color_stdout_is_tty = -1;

View File

@ -4,6 +4,7 @@
#include "blob.h" #include "blob.h"
#include "diff.h" #include "diff.h"
#include "diffcore.h" #include "diffcore.h"
#include "hex.h"
#include "quote.h" #include "quote.h"
#include "xdiff-interface.h" #include "xdiff-interface.h"
#include "xdiff/xmacros.h" #include "xdiff/xmacros.h"

View File

@ -1,5 +1,6 @@
#include "git-compat-util.h" #include "git-compat-util.h"
#include "config.h" #include "config.h"
#include "hex.h"
#include "lockfile.h" #include "lockfile.h"
#include "pack.h" #include "pack.h"
#include "packfile.h" #include "packfile.h"

View File

@ -1,7 +1,6 @@
#ifndef COMMIT_GRAPH_H #ifndef COMMIT_GRAPH_H
#define COMMIT_GRAPH_H #define COMMIT_GRAPH_H
#include "git-compat-util.h"
#include "object-store.h" #include "object-store.h"
#include "oidset.h" #include "oidset.h"

View File

@ -1,7 +1,9 @@
#include "cache.h" #include "git-compat-util.h"
#include "alloc.h"
#include "commit.h" #include "commit.h"
#include "commit-graph.h" #include "commit-graph.h"
#include "decorate.h" #include "decorate.h"
#include "hex.h"
#include "prio-queue.h" #include "prio-queue.h"
#include "tree.h" #include "tree.h"
#include "ref-filter.h" #include "ref-filter.h"

View File

@ -1,8 +1,6 @@
#ifndef COMMIT_SLAB_IMPL_H #ifndef COMMIT_SLAB_IMPL_H
#define COMMIT_SLAB_IMPL_H #define COMMIT_SLAB_IMPL_H
#include "git-compat-util.h"
#define implement_static_commit_slab(slabname, elemtype) \ #define implement_static_commit_slab(slabname, elemtype) \
implement_commit_slab(slabname, elemtype, MAYBE_UNUSED static) implement_commit_slab(slabname, elemtype, MAYBE_UNUSED static)

Some files were not shown because too many files have changed in this diff Show More