Browse Source

Merge branch 'en/header-split-cache-h-part-2'

More header clean-up.

* en/header-split-cache-h-part-2: (22 commits)
  reftable: ensure git-compat-util.h is the first (indirect) include
  diff.h: reduce unnecessary includes
  object-store.h: reduce unnecessary includes
  commit.h: reduce unnecessary includes
  fsmonitor: reduce includes of cache.h
  cache.h: remove unnecessary headers
  treewide: remove cache.h inclusion due to previous changes
  cache,tree: move basic name compare functions from read-cache to tree
  cache,tree: move cmp_cache_name_compare from tree.[ch] to read-cache.c
  hash-ll.h: split out of hash.h to remove dependency on repository.h
  tree-diff.c: move S_DIFFTREE_IFXMIN_NEQ define from cache.h
  dir.h: move DTYPE defines from cache.h
  versioncmp.h: move declarations for versioncmp.c functions from cache.h
  ws.h: move declarations for ws.c functions from cache.h
  match-trees.h: move declarations for match-trees.c functions from cache.h
  pkt-line.h: move declarations for pkt-line.c functions from cache.h
  base85.h: move declarations for base85.c functions from cache.h
  copy.h: move declarations for copy.c functions from cache.h
  server-info.h: move declarations for server-info.c functions from cache.h
  packfile.h: move pack_window and pack_entry from cache.h
  ...
main
Junio C Hamano 1 year ago
parent
commit
ccd12a3d6c
  1. 1
      add-interactive.c
  2. 1
      alloc.c
  3. 3
      apply.c
  4. 2
      apply.h
  5. 2
      archive-zip.c
  6. 2
      archive.c
  7. 1
      attr.c
  8. 3
      base85.c
  9. 7
      base85.h
  10. 1
      bloom.c
  11. 1
      branch.c
  12. 1
      builtin/apply.c
  13. 1
      builtin/archive.c
  14. 1
      builtin/bisect.c
  15. 2
      builtin/bundle.c
  16. 1
      builtin/check-attr.c
  17. 1
      builtin/check-ignore.c
  18. 1
      builtin/checkout-index.c
  19. 1
      builtin/checkout.c
  20. 1
      builtin/clean.c
  21. 2
      builtin/clone.c
  22. 1
      builtin/config.c
  23. 1
      builtin/credential-cache.c
  24. 1
      builtin/credential-store.c
  25. 1
      builtin/diff-tree.c
  26. 1
      builtin/diff.c
  27. 1
      builtin/difftool.c
  28. 1
      builtin/fetch.c
  29. 2
      builtin/for-each-repo.c
  30. 1
      builtin/gc.c
  31. 1
      builtin/help.c
  32. 2
      builtin/init-db.c
  33. 1
      builtin/log.c
  34. 1
      builtin/ls-remote.c
  35. 1
      builtin/merge-index.c
  36. 2
      builtin/merge-recursive.c
  37. 1
      builtin/merge-tree.c
  38. 1
      builtin/mv.c
  39. 2
      builtin/push.c
  40. 1
      builtin/read-tree.c
  41. 1
      builtin/receive-pack.c
  42. 1
      builtin/repack.c
  43. 1
      builtin/rerere.c
  44. 2
      builtin/rm.c
  45. 2
      builtin/show-branch.c
  46. 2
      builtin/show-index.c
  47. 3
      builtin/update-index.c
  48. 2
      builtin/update-ref.c
  49. 1
      builtin/update-server-info.c
  50. 1
      builtin/upload-archive.c
  51. 2
      builtin/worktree.c
  52. 1
      builtin/write-tree.c
  53. 3
      bundle-uri.c
  54. 122
      cache.h
  55. 1
      checkout.c
  56. 2
      checkout.h
  57. 1
      chunk-format.c
  58. 2
      chunk-format.h
  59. 3
      color.c
  60. 3
      combine-diff.c
  61. 1
      commit-graph.c
  62. 1
      commit.c
  63. 11
      commit.h
  64. 4
      common-main.c
  65. 2
      compat/fsmonitor/fsm-health-darwin.c
  66. 4
      compat/fsmonitor/fsm-ipc-darwin.c
  67. 1
      compat/fsmonitor/fsm-ipc-win32.c
  68. 3
      compat/fsmonitor/fsm-listen-darwin.c
  69. 1
      compat/mingw.c
  70. 1
      compat/precompose_utf8.c
  71. 1
      compat/win32/trace2_win32_process_info.c
  72. 3
      config.c
  73. 1
      convert.c
  74. 2
      convert.h
  75. 4
      copy.c
  76. 10
      copy.h
  77. 3
      credential.c
  78. 1
      csum-file.c
  79. 2
      csum-file.h
  80. 3
      daemon.c
  81. 3
      date.c
  82. 2
      diagnose.c
  83. 1
      diff-lib.c
  84. 2
      diff.c
  85. 1
      diff.h
  86. 2
      diffcore.h
  87. 2
      dir.c
  88. 15
      dir.h
  89. 1
      editor.c
  90. 1
      entry.c
  91. 3
      environment.c
  92. 1
      exec-cmd.c
  93. 1
      fetch-pack.c
  94. 1
      fsck.c
  95. 1
      fsmonitor--daemon.h
  96. 1
      fsmonitor-ipc.c
  97. 2
      gpg-interface.c
  98. 1
      grep.c
  99. 276
      hash-ll.h
  100. 1
      hash-lookup.c
  101. Some files were not shown because too many files have changed in this diff Show More

1
add-interactive.c

@ -12,6 +12,7 @@ @@ -12,6 +12,7 @@
#include "dir.h"
#include "run-command.h"
#include "prompt.h"
#include "tree.h"

static void init_color(struct repository *r, struct add_i_state *s,
const char *section_and_slot, char *dst,

1
alloc.c

@ -13,6 +13,7 @@ @@ -13,6 +13,7 @@
#include "blob.h"
#include "tree.h"
#include "commit.h"
#include "repository.h"
#include "tag.h"
#include "alloc.h"


3
apply.c

@ -10,6 +10,7 @@ @@ -10,6 +10,7 @@
#include "cache.h"
#include "abspath.h"
#include "alloc.h"
#include "base85.h"
#include "config.h"
#include "object-store.h"
#include "blob.h"
@ -30,6 +31,8 @@ @@ -30,6 +31,8 @@
#include "apply.h"
#include "entry.h"
#include "setup.h"
#include "symlinks.h"
#include "ws.h"
#include "wrapper.h"

struct gitdiff_data {

2
apply.h

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
#ifndef APPLY_H
#define APPLY_H

#include "hash.h"
#include "hash-ll.h"
#include "lockfile.h"
#include "string-list.h"
#include "strmap.h"

2
archive-zip.c

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
/*
* Copyright (c) 2006 Rene Scharfe
*/
#include "cache.h"
#include "git-compat-util.h"
#include "config.h"
#include "archive.h"
#include "gettext.h"

2
archive.c

@ -6,10 +6,12 @@ @@ -6,10 +6,12 @@
#include "environment.h"
#include "gettext.h"
#include "hex.h"
#include "pretty.h"
#include "setup.h"
#include "refs.h"
#include "object-store.h"
#include "commit.h"
#include "tree.h"
#include "tree-walk.h"
#include "attr.h"
#include "archive.h"

1
attr.c

@ -20,6 +20,7 @@ @@ -20,6 +20,7 @@
#include "object-store.h"
#include "setup.h"
#include "thread-utils.h"
#include "tree-walk.h"

const char git_attr__true[] = "(builtin)true";
const char git_attr__false[] = "\0(builtin)false";

3
base85.c

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "cache.h"
#include "git-compat-util.h"
#include "base85.h"

#undef DEBUG_85


7
base85.h

@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
#ifndef BASE85_H
#define BASE85_H

int decode_85(char *dst, const char *line, int linelen);
void encode_85(char *buf, const unsigned char *data, int bytes);

#endif /* BASE85_H */

1
bloom.c

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
#include "hashmap.h"
#include "commit-graph.h"
#include "commit.h"
#include "commit-slab.h"

define_commit_slab(bloom_filter_slab, struct bloom_filter);


1
branch.c

@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
#include "refs.h"
#include "refspec.h"
#include "remote.h"
#include "repository.h"
#include "sequencer.h"
#include "commit.h"
#include "worktree.h"

1
builtin/apply.c

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
#include "builtin.h"
#include "gettext.h"
#include "parse-options.h"
#include "repository.h"
#include "apply.h"

static const char * const apply_usage[] = {

1
builtin/archive.c

@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
#include "transport.h"
#include "parse-options.h"
#include "pkt-line.h"
#include "repository.h"
#include "sideband.h"

static void create_output_file(const char *output_file)

1
builtin/bisect.c

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
#include "builtin.h"
#include "cache.h"
#include "copy.h"
#include "environment.h"
#include "gettext.h"
#include "hex.h"

2
builtin/bundle.c

@ -4,6 +4,8 @@ @@ -4,6 +4,8 @@
#include "setup.h"
#include "strvec.h"
#include "parse-options.h"
#include "pkt-line.h"
#include "repository.h"
#include "cache.h"
#include "bundle.h"


1
builtin/check-attr.c

@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
#include "gettext.h"
#include "object-name.h"
#include "quote.h"
#include "repository.h"
#include "setup.h"
#include "parse-options.h"
#include "write-or-die.h"

1
builtin/check-ignore.c

@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
#include "quote.h"
#include "pathspec.h"
#include "parse-options.h"
#include "repository.h"
#include "submodule.h"
#include "write-or-die.h"


1
builtin/checkout-index.c

@ -11,6 +11,7 @@ @@ -11,6 +11,7 @@
#include "gettext.h"
#include "lockfile.h"
#include "quote.h"
#include "repository.h"
#include "cache-tree.h"
#include "parse-options.h"
#include "entry.h"

1
builtin/checkout.c

@ -28,6 +28,7 @@ @@ -28,6 +28,7 @@
#include "setup.h"
#include "submodule.h"
#include "submodule-config.h"
#include "symlinks.h"
#include "trace2.h"
#include "tree.h"
#include "tree-walk.h"

1
builtin/clean.c

@ -14,6 +14,7 @@ @@ -14,6 +14,7 @@
#include "dir.h"
#include "gettext.h"
#include "parse-options.h"
#include "repository.h"
#include "setup.h"
#include "string-list.h"
#include "quote.h"

2
builtin/clone.c

@ -13,6 +13,7 @@ @@ -13,6 +13,7 @@
#include "abspath.h"
#include "advice.h"
#include "config.h"
#include "copy.h"
#include "environment.h"
#include "gettext.h"
#include "hex.h"
@ -38,6 +39,7 @@ @@ -38,6 +39,7 @@
#include "setup.h"
#include "connected.h"
#include "packfile.h"
#include "pkt-line.h"
#include "list-objects-filter-options.h"
#include "hook.h"
#include "bundle.h"

1
builtin/config.c

@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
#include "ident.h"
#include "parse-options.h"
#include "urlmatch.h"
#include "path.h"
#include "quote.h"
#include "setup.h"
#include "worktree.h"

1
builtin/credential-cache.c

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
#include "builtin.h"
#include "gettext.h"
#include "parse-options.h"
#include "path.h"
#include "wrapper.h"
#include "write-or-die.h"


1
builtin/credential-store.c

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
#include "gettext.h"
#include "lockfile.h"
#include "credential.h"
#include "path.h"
#include "string-list.h"
#include "parse-options.h"
#include "write-or-die.h"

1
builtin/diff-tree.c

@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
#include "builtin.h"
#include "submodule.h"
#include "repository.h"
#include "tree.h"

static struct rev_info log_tree_opt;


1
builtin/diff.c

@ -22,6 +22,7 @@ @@ -22,6 +22,7 @@
#include "setup.h"
#include "submodule.h"
#include "oid-array.h"
#include "tree.h"

#define DIFF_NO_INDEX_EXPLICIT 1
#define DIFF_NO_INDEX_IMPLICIT 2

1
builtin/difftool.c

@ -15,6 +15,7 @@ @@ -15,6 +15,7 @@
#include "cache.h"
#include "abspath.h"
#include "config.h"
#include "copy.h"
#include "builtin.h"
#include "run-command.h"
#include "environment.h"

1
builtin/fetch.c

@ -29,6 +29,7 @@ @@ -29,6 +29,7 @@
#include "utf8.h"
#include "packfile.h"
#include "pager.h"
#include "pkt-line.h"
#include "list-objects-filter-options.h"
#include "commit-reach.h"
#include "branch.h"

2
builtin/for-each-repo.c

@ -3,6 +3,8 @@ @@ -3,6 +3,8 @@
#include "builtin.h"
#include "gettext.h"
#include "parse-options.h"
#include "path.h"
#include "repository.h"
#include "run-command.h"
#include "string-list.h"


1
builtin/gc.c

@ -12,6 +12,7 @@ @@ -12,6 +12,7 @@

#include "builtin.h"
#include "abspath.h"
#include "date.h"
#include "environment.h"
#include "hex.h"
#include "repository.h"

1
builtin/help.c

@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
#include "gettext.h"
#include "pager.h"
#include "parse-options.h"
#include "path.h"
#include "run-command.h"
#include "config-list.h"
#include "help.h"

2
builtin/init-db.c

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
#include "cache.h"
#include "abspath.h"
#include "config.h"
#include "copy.h"
#include "environment.h"
#include "gettext.h"
#include "refs.h"
@ -13,6 +14,7 @@ @@ -13,6 +14,7 @@
#include "exec-cmd.h"
#include "object-file.h"
#include "parse-options.h"
#include "path.h"
#include "setup.h"
#include "worktree.h"
#include "wrapper.h"

1
builtin/log.c

@ -44,6 +44,7 @@ @@ -44,6 +44,7 @@
#include "commit-reach.h"
#include "range-diff.h"
#include "tmp-objdir.h"
#include "tree.h"
#include "write-or-die.h"

#define MAIL_DEFAULT_WRAP 72

1
builtin/ls-remote.c

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
#include "gettext.h"
#include "hex.h"
#include "transport.h"
#include "pkt-line.h"
#include "ref-filter.h"
#include "remote.h"
#include "refs.h"

1
builtin/merge-index.c

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
#define USE_THE_INDEX_VARIABLE
#include "builtin.h"
#include "hex.h"
#include "repository.h"
#include "run-command.h"

static const char *pgm;

2
builtin/merge-recursive.c

@ -3,9 +3,11 @@ @@ -3,9 +3,11 @@
#include "advice.h"
#include "commit.h"
#include "gettext.h"
#include "hash.h"
#include "tag.h"
#include "merge-recursive.h"
#include "object-name.h"
#include "repository.h"
#include "xdiff-interface.h"

static const char builtin_merge_recursive_usage[] =

1
builtin/merge-tree.c

@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
#include "exec-cmd.h"
#include "merge-blobs.h"
#include "quote.h"
#include "tree.h"

static int line_termination = '\n';


1
builtin/mv.c

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
#include "cache-tree.h"
#include "string-list.h"
#include "parse-options.h"
#include "repository.h"
#include "setup.h"
#include "submodule.h"
#include "entry.h"

2
builtin/push.c

@ -14,6 +14,8 @@ @@ -14,6 +14,8 @@
#include "remote.h"
#include "transport.h"
#include "parse-options.h"
#include "pkt-line.h"
#include "repository.h"
#include "submodule.h"
#include "submodule-config.h"
#include "send-pack.h"

1
builtin/read-tree.c

@ -19,6 +19,7 @@ @@ -19,6 +19,7 @@
#include "dir.h"
#include "builtin.h"
#include "parse-options.h"
#include "repository.h"
#include "resolve-undo.h"
#include "setup.h"
#include "submodule.h"

1
builtin/receive-pack.c

@ -33,6 +33,7 @@ @@ -33,6 +33,7 @@
#include "object-store.h"
#include "protocol.h"
#include "commit-reach.h"
#include "server-info.h"
#include "trace.h"
#include "trace2.h"
#include "worktree.h"

1
builtin/repack.c

@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
#include "hex.h"
#include "parse-options.h"
#include "run-command.h"
#include "server-info.h"
#include "sigchain.h"
#include "strbuf.h"
#include "string-list.h"

1
builtin/rerere.c

@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
#include "dir.h"
#include "gettext.h"
#include "parse-options.h"
#include "repository.h"
#include "string-list.h"
#include "rerere.h"
#include "wrapper.h"

2
builtin/rm.c

@ -12,9 +12,11 @@ @@ -12,9 +12,11 @@
#include "dir.h"
#include "cache-tree.h"
#include "gettext.h"
#include "hash.h"
#include "tree-walk.h"
#include "object-name.h"
#include "parse-options.h"
#include "repository.h"
#include "string-list.h"
#include "setup.h"
#include "submodule.h"

2
builtin/show-branch.c

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
#include "config.h"
#include "environment.h"
#include "gettext.h"
#include "hash.h"
#include "hex.h"
#include "pretty.h"
#include "refs.h"
@ -10,6 +11,7 @@ @@ -10,6 +11,7 @@
#include "strvec.h"
#include "object-name.h"
#include "parse-options.h"
#include "repository.h"
#include "dir.h"
#include "commit-slab.h"
#include "date.h"

2
builtin/show-index.c

@ -1,9 +1,11 @@ @@ -1,9 +1,11 @@
#include "builtin.h"
#include "cache.h"
#include "gettext.h"
#include "hash.h"
#include "hex.h"
#include "pack.h"
#include "parse-options.h"
#include "repository.h"

static const char *const show_index_usage[] = {
"git show-index [--object-format=<hash-algorithm>]",

3
builtin/update-index.c

@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
#include "config.h"
#include "environment.h"
#include "gettext.h"
#include "hash.h"
#include "hex.h"
#include "lockfile.h"
#include "quote.h"
@ -21,8 +22,10 @@ @@ -21,8 +22,10 @@
#include "parse-options.h"
#include "pathspec.h"
#include "dir.h"
#include "repository.h"
#include "setup.h"
#include "split-index.h"
#include "symlinks.h"
#include "fsmonitor.h"
#include "write-or-die.h"


2
builtin/update-ref.c

@ -1,11 +1,13 @@ @@ -1,11 +1,13 @@
#include "cache.h"
#include "config.h"
#include "gettext.h"
#include "hash.h"
#include "refs.h"
#include "builtin.h"
#include "object-name.h"
#include "parse-options.h"
#include "quote.h"
#include "repository.h"
#include "strvec.h"

static const char * const git_update_ref_usage[] = {

1
builtin/update-server-info.c

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
#include "builtin.h"
#include "gettext.h"
#include "parse-options.h"
#include "server-info.h"

static const char * const update_server_info_usage[] = {
"git update-server-info [-f | --force]",

1
builtin/upload-archive.c

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
#include "archive.h"
#include "pkt-line.h"
#include "sideband.h"
#include "repository.h"
#include "run-command.h"
#include "strvec.h"


2
builtin/worktree.c

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
#include "abspath.h"
#include "checkout.h"
#include "config.h"
#include "copy.h"
#include "builtin.h"
#include "dir.h"
#include "environment.h"
@ -13,6 +14,7 @@ @@ -13,6 +14,7 @@
#include "strvec.h"
#include "branch.h"
#include "refs.h"
#include "repository.h"
#include "run-command.h"
#include "hook.h"
#include "sigchain.h"

1
builtin/write-tree.c

@ -13,6 +13,7 @@ @@ -13,6 +13,7 @@
#include "tree.h"
#include "cache-tree.h"
#include "parse-options.h"
#include "repository.h"

static const char * const write_tree_usage[] = {
N_("git write-tree [--missing-ok] [--prefix=<prefix>/]"),

3
bundle-uri.c

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
#include "cache.h"
#include "git-compat-util.h"
#include "bundle-uri.h"
#include "bundle.h"
#include "copy.h"
#include "environment.h"
#include "gettext.h"
#include "object-store.h"

122
cache.h

@ -4,41 +4,10 @@ @@ -4,41 +4,10 @@
#include "git-compat-util.h"
#include "strbuf.h"
#include "hashmap.h"
#include "gettext.h"
#include "string-list.h"
#include "pathspec.h"
#include "object.h"
#include "statinfo.h"

#if defined(DT_UNKNOWN) && !defined(NO_D_TYPE_IN_DIRENT)
#define DTYPE(de) ((de)->d_type)
#else
#undef DT_UNKNOWN
#undef DT_DIR
#undef DT_REG
#undef DT_LNK
#define DT_UNKNOWN 0
#define DT_DIR 1
#define DT_REG 2
#define DT_LNK 3
#define DTYPE(de) DT_UNKNOWN
#endif

/*
* Some mode bits are also used internally for computations.
*
* They *must* not overlap with any valid modes, and they *must* not be emitted
* to outside world - i.e. appear on disk or network. In other words, it's just
* temporary fields, which we internally use, but they have to stay in-house.
*
* ( such approach is valid, as standard S_IF* fits into 16 bits, and in Git
* codebase mode is `unsigned int` which is assumed to be at least 32 bits )
*/

/* used internally in tree-diff */
#define S_DIFFTREE_IFXMIN_NEQ 0x80000000


/*
* Basic data structures for the directory cache
*/
@ -586,64 +555,7 @@ extern int verify_ce_order; @@ -586,64 +555,7 @@ extern int verify_ce_order;
#define DATA_CHANGED 0x0020
#define TYPE_CHANGED 0x0040

int base_name_compare(const char *name1, size_t len1, int mode1,
const char *name2, size_t len2, int mode2);
int df_name_compare(const char *name1, size_t len1, int mode1,
const char *name2, size_t len2, int mode2);
int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);
int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);

struct cache_def {
struct strbuf path;
int flags;
int track_flags;
int prefix_len_stat_func;
};
#define CACHE_DEF_INIT { \
.path = STRBUF_INIT, \
}
static inline void cache_def_clear(struct cache_def *cache)
{
strbuf_release(&cache->path);
}

int has_symlink_leading_path(const char *name, int len);
int threaded_has_symlink_leading_path(struct cache_def *, const char *, int);
int check_leading_path(const char *name, int len, int warn_on_lstat_err);
int has_dirs_only_path(const char *name, int len, int prefix_len);
void invalidate_lstat_cache(void);
void schedule_dir_for_removal(const char *name, int len);
void remove_scheduled_dirs(void);

struct pack_window {
struct pack_window *next;
unsigned char *base;
off_t offset;
size_t len;
unsigned int last_used;
unsigned int inuse_cnt;
};

struct pack_entry {
off_t offset;
struct packed_git *p;
};

/* Dumb servers support */
int update_server_info(int);

#define COPY_READ_ERROR (-2)
#define COPY_WRITE_ERROR (-3)
int copy_fd(int ifd, int ofd);
int copy_file(const char *dst, const char *src, int mode);
int copy_file_with_time(const char *dst, const char *src, int mode);

/* base85 */
int decode_85(char *dst, const char *line, int linelen);
void encode_85(char *buf, const unsigned char *data, int bytes);

/* pkt-line.c */
void packet_trace_identity(const char *prog);
int cmp_cache_name_compare(const void *a_, const void *b_);

/* add */
/*
@ -655,36 +567,6 @@ int add_files_to_cache(const char *prefix, const struct pathspec *pathspec, int @@ -655,36 +567,6 @@ int add_files_to_cache(const char *prefix, const struct pathspec *pathspec, int
/* diff.c */
extern int diff_auto_refresh_index;

/* match-trees.c */
void shift_tree(struct repository *, const struct object_id *, const struct object_id *, struct object_id *, int);
void shift_tree_by(struct repository *, const struct object_id *, const struct object_id *, struct object_id *, const char *);

/*
* whitespace rules.
* used by both diff and apply
* last two digits are tab width
*/
#define WS_BLANK_AT_EOL 0100
#define WS_SPACE_BEFORE_TAB 0200
#define WS_INDENT_WITH_NON_TAB 0400
#define WS_CR_AT_EOL 01000
#define WS_BLANK_AT_EOF 02000
#define WS_TAB_IN_INDENT 04000
#define WS_TRAILING_SPACE (WS_BLANK_AT_EOL|WS_BLANK_AT_EOF)
#define WS_DEFAULT_RULE (WS_TRAILING_SPACE|WS_SPACE_BEFORE_TAB|8)
#define WS_TAB_WIDTH_MASK 077
/* All WS_* -- when extended, adapt diff.c emit_symbol */
#define WS_RULE_MASK 07777
extern unsigned whitespace_rule_cfg;
unsigned whitespace_rule(struct index_state *, const char *);
unsigned parse_whitespace_rule(const char *);
unsigned ws_check(const char *line, int len, unsigned ws_rule);
void ws_check_emit(const char *line, int len, unsigned ws_rule, FILE *stream, const char *set, const char *reset, const char *ws);
char *whitespace_error_string(unsigned ws);
void ws_fix_copy(struct strbuf *, const char *, int, unsigned, int *);
int ws_blank_line(const char *line, int len);
#define ws_tab_width(rule) ((rule) & WS_TAB_WIDTH_MASK)

/* ls-files */
void overlay_tree_on_index(struct index_state *istate,
const char *tree_name, const char *prefix);
@ -730,6 +612,4 @@ int stat_validity_check(struct stat_validity *sv, const char *path); @@ -730,6 +612,4 @@ int stat_validity_check(struct stat_validity *sv, const char *path);
*/
void stat_validity_update(struct stat_validity *sv, int fd);

int versioncmp(const char *s1, const char *s2);

#endif /* CACHE_H */

1
checkout.c

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
#include "object-name.h"
#include "remote.h"
#include "refspec.h"
#include "repository.h"
#include "checkout.h"
#include "config.h"
#include "strbuf.h"

2
checkout.h

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
#ifndef CHECKOUT_H
#define CHECKOUT_H

#include "hash.h"
#include "hash-ll.h"

/*
* Check if the branch name uniquely matches a branch name on a remote

1
chunk-format.c

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
#include "chunk-format.h"
#include "csum-file.h"
#include "gettext.h"
#include "hash.h"
#include "trace2.h"

/*

2
chunk-format.h

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
#ifndef CHUNK_FORMAT_H
#define CHUNK_FORMAT_H

#include "hash.h"
#include "hash-ll.h"

struct hashfile;
struct chunkfile;

3
color.c

@ -1,10 +1,11 @@ @@ -1,10 +1,11 @@
#include "cache.h"
#include "git-compat-util.h"
#include "config.h"
#include "color.h"
#include "editor.h"
#include "gettext.h"
#include "hex.h"
#include "pager.h"
#include "strbuf.h"

static int git_use_color_default = GIT_COLOR_AUTO;
int color_stdout_is_tty = -1;

3
combine-diff.c

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
#include "cache.h"
#include "git-compat-util.h"
#include "object-store.h"
#include "commit.h"
#include "convert.h"
@ -13,6 +13,7 @@ @@ -13,6 +13,7 @@
#include "xdiff/xmacros.h"
#include "log-tree.h"
#include "refs.h"
#include "tree.h"
#include "userdiff.h"
#include "oid-array.h"
#include "revision.h"

1
commit-graph.c

@ -23,6 +23,7 @@ @@ -23,6 +23,7 @@
#include "shallow.h"
#include "json-writer.h"
#include "trace2.h"
#include "tree.h"
#include "chunk-format.h"
#include "wrapper.h"


1
commit.c

@ -26,6 +26,7 @@ @@ -26,6 +26,7 @@
#include "run-command.h"
#include "setup.h"
#include "shallow.h"
#include "tree.h"
#include "hook.h"

static struct commit_extra_header *read_commit_extra_header_lines(const char *buf, size_t len, const char **);

11
commit.h

@ -2,13 +2,10 @@ @@ -2,13 +2,10 @@
#define COMMIT_H

#include "object.h"
#include "tree.h"
#include "strbuf.h"
#include "decorate.h"
#include "gpg-interface.h"
#include "string-list.h"
#include "pretty.h"
#include "commit-slab.h"

struct signature_check;
struct strbuf;
struct tree;

#define COMMIT_NOT_FROM_GRAPH 0xFFFFFFFF
#define GENERATION_NUMBER_INFINITY ((1ULL << 63) - 1)

4
common-main.c

@ -1,8 +1,10 @@ @@ -1,8 +1,10 @@
#include "cache.h"
#include "git-compat-util.h"
#include "exec-cmd.h"
#include "gettext.h"
#include "attr.h"
#include "repository.h"
#include "setup.h"
#include "strbuf.h"
#include "trace2.h"

/*

2
compat/fsmonitor/fsm-health-darwin.c

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
#include "cache.h"
#include "git-compat-util.h"
#include "config.h"
#include "fsmonitor.h"
#include "fsm-health.h"

4
compat/fsmonitor/fsm-ipc-darwin.c

@ -1,6 +1,8 @@ @@ -1,6 +1,8 @@
#include "cache.h"
#include "git-compat-util.h"
#include "config.h"
#include "gettext.h"
#include "hex.h"
#include "repository.h"
#include "strbuf.h"
#include "fsmonitor.h"
#include "fsmonitor-ipc.h"

1
compat/fsmonitor/fsm-ipc-win32.c

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
#include "git-compat-util.h"
#include "config.h"
#include "fsmonitor-ipc.h"
#include "path.h"

const char *fsmonitor_ipc__get_path(struct repository *r) {
static char *ret;

3
compat/fsmonitor/fsm-listen-darwin.c

@ -23,12 +23,13 @@ @@ -23,12 +23,13 @@
#endif
#endif

#include "cache.h"
#include "git-compat-util.h"
#include "fsmonitor.h"
#include "fsm-listen.h"
#include "fsmonitor--daemon.h"
#include "fsmonitor-path-utils.h"
#include "gettext.h"
#include "string-list.h"

struct fsm_listen_data
{

1
compat/mingw.c

@ -13,6 +13,7 @@ @@ -13,6 +13,7 @@
#include "../config.h"
#include "../environment.h"
#include "../trace2.h"
#include "../symlinks.h"
#include "../wrapper.h"
#include "dir.h"
#include "gettext.h"

1
compat/precompose_utf8.c

@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
#include "config.h"
#include "environment.h"
#include "gettext.h"
#include "path.h"
#include "utf8.h"
#include "precompose_utf8.h"


1
compat/win32/trace2_win32_process_info.c

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
#include "../../cache.h"
#include "../../json-writer.h"
#include "../../repository.h"
#include "../../trace2.h"
#include "lazyload.h"
#include <Psapi.h>

3
config.c

@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
* Copyright (C) Johannes Schindelin, 2005
*
*/
#include "cache.h"
#include "git-compat-util.h"
#include "abspath.h"
#include "advice.h"
#include "alloc.h"
@ -35,6 +35,7 @@ @@ -35,6 +35,7 @@
#include "setup.h"
#include "trace2.h"
#include "worktree.h"
#include "ws.h"
#include "wrapper.h"
#include "write-or-die.h"


1
convert.c

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
#include "advice.h"
#include "config.h"
#include "convert.h"
#include "copy.h"
#include "gettext.h"
#include "hex.h"
#include "object-store.h"

2
convert.h

@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
#ifndef CONVERT_H
#define CONVERT_H

#include "hash.h"
#include "hash-ll.h"
#include "string-list.h"

struct index_state;

4
copy.c

@ -1,4 +1,6 @@ @@ -1,4 +1,6 @@
#include "cache.h"
#include "git-compat-util.h"
#include "copy.h"
#include "path.h"
#include "wrapper.h"

int copy_fd(int ifd, int ofd)

10
copy.h

@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
#ifndef COPY_H
#define COPY_H

#define COPY_READ_ERROR (-2)
#define COPY_WRITE_ERROR (-3)
int copy_fd(int ifd, int ofd);
int copy_file(const char *dst, const char *src, int mode);
int copy_file_with_time(const char *dst, const char *src, int mode);

#endif /* COPY_H */

3
credential.c

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
#include "cache.h"
#include "git-compat-util.h"
#include "abspath.h"
#include "config.h"
#include "credential.h"
@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
#include "url.h"
#include "prompt.h"
#include "sigchain.h"
#include "strbuf.h"
#include "urlmatch.h"
#include "git-compat-util.h"


1
csum-file.c

@ -10,6 +10,7 @@ @@ -10,6 +10,7 @@
#include "git-compat-util.h"
#include "progress.h"
#include "csum-file.h"
#include "hash.h"
#include "wrapper.h"

static void verify_buffer_or_die(struct hashfile *f,

2
csum-file.h

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
#ifndef CSUM_FILE_H
#define CSUM_FILE_H

#include "hash.h"
#include "hash-ll.h"
#include "write-or-die.h"

struct progress;

3
daemon.c

@ -1,8 +1,9 @@ @@ -1,8 +1,9 @@
#include "cache.h"
#include "git-compat-util.h"
#include "abspath.h"
#include "alloc.h"
#include "config.h"
#include "environment.h"
#include "path.h"
#include "pkt-line.h"
#include "protocol.h"
#include "run-command.h"

3
date.c

@ -4,10 +4,11 @@ @@ -4,10 +4,11 @@
* Copyright (C) Linus Torvalds, 2005
*/

#include "cache.h"
#include "git-compat-util.h"
#include "date.h"
#include "gettext.h"
#include "pager.h"
#include "strbuf.h"

/*
* This is like mktime, but without normalization of tm_wday and tm_yday.

2
diagnose.c

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
#include "cache.h"
#include "git-compat-util.h"
#include "diagnose.h"
#include "compat/disk.h"
#include "archive.h"

1
diff-lib.c

@ -14,6 +14,7 @@ @@ -14,6 +14,7 @@
#include "unpack-trees.h"
#include "refs.h"
#include "submodule.h"
#include "symlinks.h"
#include "trace.h"
#include "dir.h"
#include "fsmonitor.h"

2
diff.c

@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
#include "cache.h"
#include "abspath.h"
#include "alloc.h"
#include "base85.h"
#include "config.h"
#include "convert.h"
#include "environment.h"
@ -40,6 +41,7 @@ @@ -40,6 +41,7 @@
#include "object-name.h"
#include "setup.h"
#include "strmap.h"
#include "ws.h"
#include "wrapper.h"

#ifdef NO_FAST_WORKING_DIRECTORY

1
diff.h

@ -4,7 +4,6 @@ @@ -4,7 +4,6 @@
#ifndef DIFF_H
#define DIFF_H

#include "tree-walk.h"
#include "pathspec.h"
#include "oidset.h"
#include "strbuf.h"

2
diffcore.h

@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
#ifndef DIFFCORE_H
#define DIFFCORE_H

#include "hash.h"
#include "hash-ll.h"

struct diff_options;
struct mem_pool;

2
dir.c

@ -25,7 +25,9 @@ @@ -25,7 +25,9 @@
#include "fsmonitor.h"
#include "setup.h"
#include "submodule-config.h"
#include "symlinks.h"
#include "trace2.h"
#include "tree.h"
#include "wrapper.h"

/*

15
dir.h

@ -640,4 +640,19 @@ static inline int starts_with_dot_dot_slash_native(const char *const path) @@ -640,4 +640,19 @@ static inline int starts_with_dot_dot_slash_native(const char *const path)

return path_match_flags(path, what | PATH_MATCH_NATIVE);
}

#if defined(DT_UNKNOWN) && !defined(NO_D_TYPE_IN_DIRENT)
#define DTYPE(de) ((de)->d_type)
#else
#undef DT_UNKNOWN
#undef DT_DIR
#undef DT_REG
#undef DT_LNK
#define DT_UNKNOWN 0
#define DT_DIR 1
#define DT_REG 2
#define DT_LNK 3
#define DTYPE(de) DT_UNKNOWN
#endif

#endif

1
editor.c

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
#include "environment.h"
#include "gettext.h"
#include "pager.h"
#include "path.h"
#include "strbuf.h"
#include "strvec.h"
#include "run-command.h"

1
entry.c

@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
#include "hex.h"
#include "streaming.h"
#include "submodule.h"
#include "symlinks.h"
#include "progress.h"
#include "fsmonitor.h"
#include "entry.h"

3
environment.c

@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
* even if you might want to know where the git directory etc
* are.
*/
#include "cache.h"
#include "git-compat-util.h"
#include "abspath.h"
#include "branch.h"
#include "convert.h"
@ -67,7 +67,6 @@ int read_replace_refs = 1; @@ -67,7 +67,6 @@ int read_replace_refs = 1;
enum eol core_eol = EOL_UNSET;
int global_conv_flags_eol = CONV_EOL_RNDTRP_WARN;
char *check_roundtrip_encoding = "SHIFT-JIS";
unsigned whitespace_rule_cfg = WS_DEFAULT_RULE;
enum branch_track git_branch_track = BRANCH_TRACK_REMOTE;
enum rebase_setup_type autorebase = AUTOREBASE_NEVER;
enum push_default_type push_default = PUSH_DEFAULT_UNSPECIFIED;

1
exec-cmd.c

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
#include "environment.h"
#include "exec-cmd.h"
#include "gettext.h"
#include "path.h"
#include "quote.h"
#include "strvec.h"
#include "trace.h"

1
fetch-pack.c

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
#include "alloc.h"
#include "repository.h"
#include "config.h"
#include "date.h"
#include "environment.h"
#include "gettext.h"
#include "hex.h"

1
fsck.c

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
#include "git-compat-util.h"
#include "alloc.h"
#include "date.h"
#include "hex.h"
#include "object-store.h"
#include "repository.h"

1
fsmonitor--daemon.h

@ -3,7 +3,6 @@ @@ -3,7 +3,6 @@

#ifdef HAVE_FSMONITOR_DAEMON_BACKEND

#include "cache.h"
#include "dir.h"
#include "run-command.h"
#include "simple-ipc.h"

1
fsmonitor-ipc.c

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
#include "gettext.h"
#include "simple-ipc.h"
#include "fsmonitor-ipc.h"
#include "repository.h"
#include "run-command.h"
#include "strbuf.h"
#include "trace2.h"

2
gpg-interface.c

@ -1,12 +1,14 @@ @@ -1,12 +1,14 @@
#include "git-compat-util.h"
#include "commit.h"
#include "config.h"
#include "date.h"
#include "gettext.h"
#include "run-command.h"
#include "strbuf.h"
#include "dir.h"
#include "ident.h"
#include "gpg-interface.h"
#include "path.h"
#include "sigchain.h"
#include "tempfile.h"
#include "alias.h"

1
grep.c

@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
#include "grep.h"
#include "hex.h"
#include "object-store.h"
#include "pretty.h"
#include "userdiff.h"
#include "xdiff-interface.h"
#include "diff.h"

276
hash-ll.h

@ -0,0 +1,276 @@ @@ -0,0 +1,276 @@
#ifndef HASH_LL_H
#define HASH_LL_H

#if defined(SHA1_APPLE)
#include <CommonCrypto/CommonDigest.h>
#elif defined(SHA1_OPENSSL)
#include <openssl/sha.h>
#elif defined(SHA1_DC)
#include "sha1dc_git.h"
#else /* SHA1_BLK */
#include "block-sha1/sha1.h"
#endif

#if defined(SHA256_NETTLE)
#include "sha256/nettle.h"
#elif defined(SHA256_GCRYPT)
#define SHA256_NEEDS_CLONE_HELPER
#include "sha256/gcrypt.h"
#elif defined(SHA256_OPENSSL)
#include <openssl/sha.h>
#else
#include "sha256/block/sha256.h"
#endif

#ifndef platform_SHA_CTX
/*
* platform's underlying implementation of SHA-1; could be OpenSSL,
* blk_SHA, Apple CommonCrypto, etc... Note that the relevant
* SHA-1 header may have already defined platform_SHA_CTX for our
* own implementations like block-sha1, so we list
* the default for OpenSSL compatible SHA-1 implementations here.
*/
#define platform_SHA_CTX SHA_CTX
#define platform_SHA1_Init SHA1_Init
#define platform_SHA1_Update SHA1_Update
#define platform_SHA1_Final SHA1_Final
#endif

#define git_SHA_CTX platform_SHA_CTX
#define git_SHA1_Init platform_SHA1_Init
#define git_SHA1_Update platform_SHA1_Update
#define git_SHA1_Final platform_SHA1_Final

#ifndef platform_SHA256_CTX
#define platform_SHA256_CTX SHA256_CTX
#define platform_SHA256_Init SHA256_Init
#define platform_SHA256_Update SHA256_Update
#define platform_SHA256_Final SHA256_Final
#endif

#define git_SHA256_CTX platform_SHA256_CTX
#define git_SHA256_Init platform_SHA256_Init
#define git_SHA256_Update platform_SHA256_Update
#define git_SHA256_Final platform_SHA256_Final

#ifdef platform_SHA256_Clone
#define git_SHA256_Clone platform_SHA256_Clone
#endif

#ifdef SHA1_MAX_BLOCK_SIZE
#include "compat/sha1-chunked.h"
#undef git_SHA1_Update
#define git_SHA1_Update git_SHA1_Update_Chunked
#endif

static inline void git_SHA1_Clone(git_SHA_CTX *dst, const git_SHA_CTX *src)
{
memcpy(dst, src, sizeof(*dst));
}

#ifndef SHA256_NEEDS_CLONE_HELPER
static inline void git_SHA256_Clone(git_SHA256_CTX *dst, const git_SHA256_CTX *src)
{
memcpy(dst, src, sizeof(*dst));
}
#endif

/*
* Note that these constants are suitable for indexing the hash_algos array and
* comparing against each other, but are otherwise arbitrary, so they should not
* be exposed to the user or serialized to disk. To know whether a
* git_hash_algo struct points to some usable hash function, test the format_id
* field for being non-zero. Use the name field for user-visible situations and
* the format_id field for fixed-length fields on disk.
*/
/* An unknown hash function. */
#define GIT_HASH_UNKNOWN 0
/* SHA-1 */
#define GIT_HASH_SHA1 1
/* SHA-256 */
#define GIT_HASH_SHA256 2
/* Number of algorithms supported (including unknown). */
#define GIT_HASH_NALGOS (GIT_HASH_SHA256 + 1)

/* "sha1", big-endian */
#define GIT_SHA1_FORMAT_ID 0x73686131

/* The length in bytes and in hex digits of an object name (SHA-1 value). */
#define GIT_SHA1_RAWSZ 20
#define GIT_SHA1_HEXSZ (2 * GIT_SHA1_RAWSZ)
/* The block size of SHA-1. */
#define GIT_SHA1_BLKSZ 64

/* "s256", big-endian */
#define GIT_SHA256_FORMAT_ID 0x73323536

/* The length in bytes and in hex digits of an object name (SHA-256 value). */
#define GIT_SHA256_RAWSZ 32
#define GIT_SHA256_HEXSZ (2 * GIT_SHA256_RAWSZ)
/* The block size of SHA-256. */
#define GIT_SHA256_BLKSZ 64

/* The length in byte and in hex digits of the largest possible hash value. */
#define GIT_MAX_RAWSZ GIT_SHA256_RAWSZ
#define GIT_MAX_HEXSZ GIT_SHA256_HEXSZ
/* The largest possible block size for any supported hash. */
#define GIT_MAX_BLKSZ GIT_SHA256_BLKSZ

struct object_id {
unsigned char hash[GIT_MAX_RAWSZ];
int algo; /* XXX requires 4-byte alignment */
};

#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.
*/
};

/* A suitably aligned type for stack allocations of hash contexts. */
union git_hash_ctx {
git_SHA_CTX sha1;
git_SHA256_CTX sha256;
};
typedef union git_hash_ctx git_hash_ctx;

typedef void (*git_hash_init_fn)(git_hash_ctx *ctx);
typedef void (*git_hash_clone_fn)(git_hash_ctx *dst, const git_hash_ctx *src);
typedef void (*git_hash_update_fn)(git_hash_ctx *ctx, const void *in, size_t len);
typedef void (*git_hash_final_fn)(unsigned char *hash, git_hash_ctx *ctx);
typedef void (*git_hash_final_oid_fn)(struct object_id *oid, git_hash_ctx *ctx);

struct git_hash_algo {
/*
* The name of the algorithm, as appears in the config file and in
* messages.
*/
const char *name;

/* A four-byte version identifier, used in pack indices. */
uint32_t format_id;

/* The length of the hash in binary. */
size_t rawsz;

/* The length of the hash in hex characters. */
size_t hexsz;

/* The block size of the hash. */
size_t blksz;

/* The hash initialization function. */
git_hash_init_fn init_fn;

/* The hash context cloning function. */
git_hash_clone_fn clone_fn;

/* The hash update function. */
git_hash_update_fn update_fn;

/* The hash finalization function. */
git_hash_final_fn final_fn;

/* The hash finalization function for object IDs. */
git_hash_final_oid_fn final_oid_fn;

/* The OID of the empty tree. */
const struct object_id *empty_tree;

/* The OID of the empty blob. */
const struct object_id *empty_blob;

/* The all-zeros OID. */
const struct object_id *null_oid;
};
extern const struct git_hash_algo hash_algos[GIT_HASH_NALGOS];

/*
* Return a GIT_HASH_* constant based on the name. Returns GIT_HASH_UNKNOWN if
* the name doesn't match a known algorithm.
*/
int hash_algo_by_name(const char *name);
/* Identical, except based on the format ID. */
int hash_algo_by_id(uint32_t format_id);
/* Identical, except based on the length. */
int hash_algo_by_length(int len);
/* Identical, except for a pointer to struct git_hash_algo. */
static inline int hash_algo_by_ptr(const struct git_hash_algo *p)
{
return p - hash_algos;
}

const struct object_id *null_oid(void);

static inline int hashcmp_algop(const unsigned char *sha1, const unsigned char *sha2, const struct git_hash_algo *algop)
{
/*
* Teach the compiler that there are only two possibilities of hash size
* here, so that it can optimize for this case as much as possible.
*/
if (algop->rawsz == GIT_MAX_RAWSZ)
return memcmp(sha1, sha2, GIT_MAX_RAWSZ);
return memcmp(sha1, sha2, GIT_SHA1_RAWSZ);
}

static inline int hasheq_algop(const unsigned char *sha1, const unsigned char *sha2, const struct git_hash_algo *algop)
{
/*
* We write this here instead of deferring to hashcmp so that the
* compiler can properly inline it and avoid calling memcmp.
*/
if (algop->rawsz == GIT_MAX_RAWSZ)
return !memcmp(sha1, sha2, GIT_MAX_RAWSZ);
return !memcmp(sha1, sha2, GIT_SHA1_RAWSZ);
}

static inline void oidcpy(struct object_id *dst, const struct object_id *src)
{
memcpy(dst->hash, src->hash, GIT_MAX_RAWSZ);
dst->algo = src->algo;
}

static inline struct object_id *oiddup(const struct object_id *src)
{
struct object_id *dst = xmalloc(sizeof(struct object_id));
oidcpy(dst, src);
return dst;
}

static inline void oid_set_algo(struct object_id *oid, const struct git_hash_algo *algop)
{
oid->algo = hash_algo_by_ptr(algop);
}

const char *empty_tree_oid_hex(void);
const char *empty_blob_oid_hex(void);

#endif

1
hash-lookup.c

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "cache.h"
#include "hash.h"
#include "hash-lookup.h"

static uint32_t take2(const struct object_id *oid, size_t ofs)

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

Loading…
Cancel
Save