Merge branch 'en/incl-forward-decl'
authorJunio C Hamano <gitster@pobox.com>
Mon, 20 Aug 2018 19:41:32 +0000 (12:41 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 20 Aug 2018 19:41:32 +0000 (12:41 -0700)
Code hygiene improvement for the header files.

* en/incl-forward-decl:
Remove forward declaration of an enum
compat/precompose_utf8.h: use more common include guard style
urlmatch.h: fix include guard
Move definition of enum branch_track from cache.h to branch.h
alloc: make allocate_alloc_state and clear_alloc_state more consistent
Add missing includes and forward declarations

15 files changed:
1  2 
apply.h
archive.h
attr.h
cache.h
config.c
config.h
convert.h
diffcore.h
environment.c
object-store.h
repository.h
revision.h
submodule.h
unpack-trees.h
utf8.h
diff --combined apply.h
index 78c8bcfc3c4afe5ebd583f58c76eb3ca0e19a702,0b70e1f3f5c283f3f2ef778c84443cc57febc717..59483481330c61033d56e363f70dff08f4d689af
+++ b/apply.h
@@@ -1,8 -1,9 +1,11 @@@
  #ifndef APPLY_H
  #define APPLY_H
  
+ #include "lockfile.h"
+ #include "string-list.h"
 +struct repository;
 +
  enum apply_ws_error_action {
        nowarn_ws_error,
        warn_on_ws_error,
@@@ -64,7 -65,6 +67,7 @@@ struct apply_state 
        int unsafe_paths;
  
        /* Other non boolean parameters */
 +      struct repository *repo;
        const char *index_file;
        enum apply_verbosity apply_verbosity;
        const char *fake_ancestor;
        int applied_after_fixing_ws;
  };
  
 -extern int apply_parse_options(int argc, const char **argv,
 -                             struct apply_state *state,
 -                             int *force_apply, int *options,
 -                             const char * const *apply_usage);
 -extern int init_apply_state(struct apply_state *state,
 -                          const char *prefix);
 -extern void clear_apply_state(struct apply_state *state);
 -extern int check_apply_state(struct apply_state *state, int force_apply);
 +int apply_parse_options(int argc, const char **argv,
 +                      struct apply_state *state,
 +                      int *force_apply, int *options,
 +                      const char * const *apply_usage);
 +int init_apply_state(struct apply_state *state,
 +                   struct repository *repo,
 +                   const char *prefix);
 +void clear_apply_state(struct apply_state *state);
 +int check_apply_state(struct apply_state *state, int force_apply);
  
  /*
   * Some aspects of the apply behavior are controlled by the following
  #define APPLY_OPT_INACCURATE_EOF      (1<<0) /* accept inaccurate eof */
  #define APPLY_OPT_RECOUNT             (1<<1) /* accept inaccurate line count */
  
 -extern int apply_all_patches(struct apply_state *state,
 -                           int argc,
 -                           const char **argv,
 -                           int options);
 +int apply_all_patches(struct apply_state *state,
 +                    int argc, const char **argv,
 +                    int options);
  
  #endif
diff --combined archive.h
index 75b9a86066b5f4e2977c9525b222c6595cef8b25,7aba1336352c127e6b7791facd5247532e3668f8..d4f97a00f541c66b694ff00340ead218752bf37e
+++ b/archive.h
@@@ -1,12 -1,10 +1,13 @@@
  #ifndef ARCHIVE_H
  #define ARCHIVE_H
  
+ #include "cache.h"
  #include "pathspec.h"
  
 +struct repository;
 +
  struct archiver_args {
 +      struct repository *repo;
        const char *base;
        size_t baselen;
        struct tree *tree;
        int compression_level;
  };
  
 +/* main api */
 +
 +extern int write_archive(int argc, const char **argv, const char *prefix,
 +                       struct repository *repo,
 +                       const char *name_hint, int remote);
 +
 +const char *archive_format_from_filename(const char *filename);
 +
 +/* archive backend stuff */
 +
  #define ARCHIVER_WANT_COMPRESSION_LEVELS 1
  #define ARCHIVER_REMOTE 2
  struct archiver {
@@@ -49,6 -37,9 +50,6 @@@ typedef int (*write_archive_entry_fn_t)
                                        unsigned int mode);
  
  extern int write_archive_entries(struct archiver_args *args, write_archive_entry_fn_t write_entry);
 -extern int write_archive(int argc, const char **argv, const char *prefix, const char *name_hint, int remote);
 -
 -const char *archive_format_from_filename(const char *filename);
  extern void *object_file_to_archive(const struct archiver_args *args,
                                    const char *path, const struct object_id *oid,
                                    unsigned int mode, enum object_type *type,
diff --combined attr.h
index 01dab4a1262bc5aefadca627012cbf59c7c9df16,3185538bda31cadeefe2ffcd87a831148760843b..2be86db36e730938777066f1951360396ddc9676
--- 1/attr.h
--- 2/attr.h
+++ b/attr.h
@@@ -1,14 -1,13 +1,15 @@@
  #ifndef ATTR_H
  #define ATTR_H
  
 +struct index_state;
 +
  /* An attribute is a pointer to this opaque structure */
  struct git_attr;
  
  /* opaque structures used internally for attribute collection */
  struct all_attrs_item;
  struct attr_stack;
+ struct index_state;
  
  /*
   * Given a string, return the gitattribute object that
@@@ -44,41 -43,40 +45,41 @@@ struct attr_check 
        struct attr_stack *stack;
  };
  
 -extern struct attr_check *attr_check_alloc(void);
 -extern struct attr_check *attr_check_initl(const char *, ...);
 -extern struct attr_check *attr_check_dup(const struct attr_check *check);
 +struct attr_check *attr_check_alloc(void);
 +struct attr_check *attr_check_initl(const char *, ...);
 +struct attr_check *attr_check_dup(const struct attr_check *check);
  
 -extern struct attr_check_item *attr_check_append(struct attr_check *check,
 -                                               const struct git_attr *attr);
 +struct attr_check_item *attr_check_append(struct attr_check *check,
 +                                        const struct git_attr *attr);
  
 -extern void attr_check_reset(struct attr_check *check);
 -extern void attr_check_clear(struct attr_check *check);
 -extern void attr_check_free(struct attr_check *check);
 +void attr_check_reset(struct attr_check *check);
 +void attr_check_clear(struct attr_check *check);
 +void attr_check_free(struct attr_check *check);
  
  /*
   * Return the name of the attribute represented by the argument.  The
   * return value is a pointer to a null-delimited string that is part
   * of the internal data structure; it should not be modified or freed.
   */
 -extern const char *git_attr_name(const struct git_attr *);
 +const char *git_attr_name(const struct git_attr *);
  
 -extern int git_check_attr(const char *path, struct attr_check *check);
 +int git_check_attr(const struct index_state *istate,
 +                 const char *path, struct attr_check *check);
  
  /*
   * Retrieve all attributes that apply to the specified path.
   * check holds the attributes and their values.
   */
 -extern void git_all_attrs(const char *path, struct attr_check *check);
 +void git_all_attrs(const struct index_state *istate,
 +                 const char *path, struct attr_check *check);
  
  enum git_attr_direction {
        GIT_ATTR_CHECKIN,
        GIT_ATTR_CHECKOUT,
        GIT_ATTR_INDEX
  };
 -void git_attr_set_direction(enum git_attr_direction new_direction,
 -                          struct index_state *istate);
 +void git_attr_set_direction(enum git_attr_direction new_direction);
  
 -extern void attr_start(void);
 +void attr_start(void);
  
  #endif /* ATTR_H */
diff --combined cache.h
index 66d3b91cdb1d14bbe2499f90a0e1f6d9785b4b37,a1c0c594fb7ca6900f2602df4fc7f7cae8c14610..b1fd3d58ab20b6fd4460c6475c0eb0390c3ab9ac
+++ b/cache.h
@@@ -868,9 -868,11 +868,9 @@@ 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.  As an
 - * optimization it is also set to false if replace references have
 - * been sought but there were none.
 + * commands that do not want replace references to be active.
   */
 -extern int check_replace_refs;
 +extern int read_replace_refs;
  extern char *git_replace_ref_base;
  
  extern int fsync_object_files;
@@@ -917,15 -919,6 +917,6 @@@ enum log_refs_config 
  };
  extern enum log_refs_config log_all_ref_updates;
  
- enum branch_track {
-       BRANCH_TRACK_UNSPECIFIED = -1,
-       BRANCH_TRACK_NEVER = 0,
-       BRANCH_TRACK_REMOTE,
-       BRANCH_TRACK_ALWAYS,
-       BRANCH_TRACK_EXPLICIT,
-       BRANCH_TRACK_OVERRIDE
- };
  enum rebase_setup_type {
        AUTOREBASE_NEVER = 0,
        AUTOREBASE_LOCAL,
@@@ -942,7 -935,6 +933,6 @@@ enum push_default_type 
        PUSH_DEFAULT_UNSPECIFIED
  };
  
- extern enum branch_track git_branch_track;
  extern enum rebase_setup_type autorebase;
  extern enum push_default_type push_default;
  
@@@ -1423,20 -1415,18 +1413,20 @@@ extern void *read_object_with_reference
  extern struct object *peel_to_type(const char *name, int namelen,
                                   struct object *o, enum object_type);
  
 +enum date_mode_type {
 +      DATE_NORMAL = 0,
 +      DATE_RELATIVE,
 +      DATE_SHORT,
 +      DATE_ISO8601,
 +      DATE_ISO8601_STRICT,
 +      DATE_RFC2822,
 +      DATE_STRFTIME,
 +      DATE_RAW,
 +      DATE_UNIX
 +};
 +
  struct date_mode {
 -      enum date_mode_type {
 -              DATE_NORMAL = 0,
 -              DATE_RELATIVE,
 -              DATE_SHORT,
 -              DATE_ISO8601,
 -              DATE_ISO8601_STRICT,
 -              DATE_RFC2822,
 -              DATE_STRFTIME,
 -              DATE_RAW,
 -              DATE_UNIX
 -      } type;
 +      enum date_mode_type type;
        const char *strftime_fmt;
        int local;
  };
@@@ -1575,6 -1565,62 +1565,6 @@@ extern int odb_mkstemp(struct strbuf *t
   */
  extern int odb_pack_keep(const char *name);
  
 -/*
 - * Iterate over the files in the loose-object parts of the object
 - * directory "path", triggering the following callbacks:
 - *
 - *  - loose_object is called for each loose object we find.
 - *
 - *  - loose_cruft is called for any files that do not appear to be
 - *    loose objects. Note that we only look in the loose object
 - *    directories "objects/[0-9a-f]{2}/", so we will not report
 - *    "objects/foobar" as cruft.
 - *
 - *  - loose_subdir is called for each top-level hashed subdirectory
 - *    of the object directory (e.g., "$OBJDIR/f0"). It is called
 - *    after the objects in the directory are processed.
 - *
 - * Any callback that is NULL will be ignored. Callbacks returning non-zero
 - * will end the iteration.
 - *
 - * In the "buf" variant, "path" is a strbuf which will also be used as a
 - * scratch buffer, but restored to its original contents before
 - * the function returns.
 - */
 -typedef int each_loose_object_fn(const struct object_id *oid,
 -                               const char *path,
 -                               void *data);
 -typedef int each_loose_cruft_fn(const char *basename,
 -                              const char *path,
 -                              void *data);
 -typedef int each_loose_subdir_fn(unsigned int nr,
 -                               const char *path,
 -                               void *data);
 -int for_each_file_in_obj_subdir(unsigned int subdir_nr,
 -                              struct strbuf *path,
 -                              each_loose_object_fn obj_cb,
 -                              each_loose_cruft_fn cruft_cb,
 -                              each_loose_subdir_fn subdir_cb,
 -                              void *data);
 -int for_each_loose_file_in_objdir(const char *path,
 -                                each_loose_object_fn obj_cb,
 -                                each_loose_cruft_fn cruft_cb,
 -                                each_loose_subdir_fn subdir_cb,
 -                                void *data);
 -int for_each_loose_file_in_objdir_buf(struct strbuf *path,
 -                                    each_loose_object_fn obj_cb,
 -                                    each_loose_cruft_fn cruft_cb,
 -                                    each_loose_subdir_fn subdir_cb,
 -                                    void *data);
 -
 -/*
 - * Iterate over loose objects in both the local
 - * repository and any alternates repositories (unless the
 - * LOCAL_ONLY flag is set).
 - */
 -#define FOR_EACH_OBJECT_LOCAL_ONLY 0x1
 -extern int for_each_loose_object(each_loose_object_fn, void *, unsigned flags);
 -
  /*
   * Set this to 0 to prevent sha1_object_info_extended() from fetching missing
   * blobs. This has a difference only if extensions.partialClone is set.
diff --combined config.c
index 4446909229a0f7b14d7428ad9860c9a655c77df8,66dca7978a85a60edcc9a97c14efeab235715ab9..f97ea347568695a19d1d339e35084e11c68ea85d
+++ b/config.c
@@@ -6,6 -6,7 +6,7 @@@
   *
   */
  #include "cache.h"
+ #include "branch.h"
  #include "config.h"
  #include "repository.h"
  #include "lockfile.h"
@@@ -117,12 -118,12 +118,12 @@@ static long config_buf_ftell(struct con
  }
  
  #define MAX_INCLUDE_DEPTH 10
 -static const char include_depth_advice[] =
 +static const char include_depth_advice[] = N_(
  "exceeded maximum include depth (%d) while including\n"
  "     %s\n"
  "from\n"
  "     %s\n"
 -"Do you have circular includes?";
 +"Do you have circular includes?");
  static int handle_path_include(const char *path, struct config_include_data *inc)
  {
        int ret = 0;
  
        expanded = expand_user_path(path, 0);
        if (!expanded)
 -              return error("could not expand include path '%s'", path);
 +              return error(_("could not expand include path '%s'"), path);
        path = expanded;
  
        /*
                char *slash;
  
                if (!cf || !cf->path)
 -                      return error("relative config includes must come from files");
 +                      return error(_("relative config includes must come from files"));
  
                slash = find_last_dir_sep(cf->path);
                if (slash)
  
        if (!access_or_die(path, R_OK, 0)) {
                if (++inc->depth > MAX_INCLUDE_DEPTH)
 -                      die(include_depth_advice, MAX_INCLUDE_DEPTH, path,
 +                      die(_(include_depth_advice), MAX_INCLUDE_DEPTH, path,
                            !cf ? "<unknown>" :
                            cf->name ? cf->name :
                            "the command line");
@@@ -343,13 -344,13 +344,13 @@@ static int git_config_parse_key_1(cons
  
        if (last_dot == NULL || last_dot == key) {
                if (!quiet)
 -                      error("key does not contain a section: %s", key);
 +                      error(_("key does not contain a section: %s"), key);
                return -CONFIG_NO_SECTION_OR_NAME;
        }
  
        if (!last_dot[1]) {
                if (!quiet)
 -                      error("key does not contain variable name: %s", key);
 +                      error(_("key does not contain variable name: %s"), key);
                return -CONFIG_NO_SECTION_OR_NAME;
        }
  
                        if (!iskeychar(c) ||
                            (i == baselen + 1 && !isalpha(c))) {
                                if (!quiet)
 -                                      error("invalid key: %s", key);
 +                                      error(_("invalid key: %s"), key);
                                goto out_free_ret_1;
                        }
                        c = tolower(c);
                } else if (c == '\n') {
                        if (!quiet)
 -                              error("invalid key (newline): %s", key);
 +                              error(_("invalid key (newline): %s"), key);
                        goto out_free_ret_1;
                }
                if (store_key)
@@@ -415,7 -416,7 +416,7 @@@ int git_config_parse_parameter(const ch
  
        pair = strbuf_split_str(text, '=', 2);
        if (!pair[0])
 -              return error("bogus config parameter: %s", text);
 +              return error(_("bogus config parameter: %s"), text);
  
        if (pair[0]->len && pair[0]->buf[pair[0]->len - 1] == '=') {
                strbuf_setlen(pair[0], pair[0]->len - 1);
        strbuf_trim(pair[0]);
        if (!pair[0]->len) {
                strbuf_list_free(pair);
 -              return error("bogus config parameter: %s", text);
 +              return error(_("bogus config parameter: %s"), text);
        }
  
        if (git_config_parse_key(pair[0]->buf, &canonical_name, NULL)) {
@@@ -462,7 -463,7 +463,7 @@@ int git_config_from_parameters(config_f
        envw = xstrdup(env);
  
        if (sq_dequote_to_argv(envw, &argv, &nr, &alloc) < 0) {
 -              ret = error("bogus format in " CONFIG_DATA_ENVIRONMENT);
 +              ret = error(_("bogus format in %s"), CONFIG_DATA_ENVIRONMENT);
                goto out;
        }
  
@@@ -933,7 -934,7 +934,7 @@@ int git_parse_ulong(const char *value, 
        return 1;
  }
  
 -static int git_parse_ssize_t(const char *value, ssize_t *ret)
 +int git_parse_ssize_t(const char *value, ssize_t *ret)
  {
        intmax_t tmp;
        if (!git_parse_signed(value, &tmp, maximum_signed_value_of_type(ssize_t)))
@@@ -1166,7 -1167,7 +1167,7 @@@ static int git_default_core_config(cons
                else {
                        int abbrev = git_config_int(var, value);
                        if (abbrev < minimum_abbrev || abbrev > 40)
 -                              return error("abbrev length out of range: %d", abbrev);
 +                              return error(_("abbrev length out of range: %d"), abbrev);
                        default_abbrev = abbrev;
                }
                return 0;
                        comment_line_char = value[0];
                        auto_comment_line_char = 0;
                } else
 -                      return error("core.commentChar should only be one character");
 +                      return error(_("core.commentChar should only be one character"));
                return 0;
        }
  
                                         var, value);
        }
  
 +      if (!strcmp(var, "core.usereplacerefs")) {
 +              read_replace_refs = git_config_bool(var, value);
 +              return 0;
 +      }
 +
        /* Add other config variables here and to Documentation/config.txt. */
        return 0;
  }
@@@ -1396,7 -1392,7 +1397,7 @@@ static int git_default_branch_config(co
                else if (!strcmp(value, "always"))
                        autorebase = AUTOREBASE_ALWAYS;
                else
 -                      return error("malformed value for %s", var);
 +                      return error(_("malformed value for %s"), var);
                return 0;
        }
  
@@@ -1422,9 -1418,9 +1423,9 @@@ static int git_default_push_config(cons
                else if (!strcmp(value, "current"))
                        push_default = PUSH_DEFAULT_CURRENT;
                else {
 -                      error("malformed value for %s: %s", var, value);
 -                      return error("Must be one of nothing, matching, simple, "
 -                                   "upstream or current.");
 +                      error(_("malformed value for %s: %s"), var, value);
 +                      return error(_("must be one of nothing, matching, simple, "
 +                                     "upstream or current"));
                }
                return 0;
        }
@@@ -1603,10 -1599,10 +1604,10 @@@ int git_config_from_blob_oid(config_fn_
  
        buf = read_object_file(oid, &type, &size);
        if (!buf)
 -              return error("unable to load config blob object '%s'", name);
 +              return error(_("unable to load config blob object '%s'"), name);
        if (type != OBJ_BLOB) {
                free(buf);
 -              return error("reference '%s' does not point to a blob", name);
 +              return error(_("reference '%s' does not point to a blob"), name);
        }
  
        ret = git_config_from_mem(fn, CONFIG_ORIGIN_BLOB, name, buf, size,
@@@ -1623,7 -1619,7 +1624,7 @@@ static int git_config_from_blob_ref(con
        struct object_id oid;
  
        if (get_oid(name, &oid) < 0)
 -              return error("unable to resolve config blob '%s'", name);
 +              return error(_("unable to resolve config blob '%s'"), name);
        return git_config_from_blob_oid(fn, name, &oid, data);
  }
  
@@@ -1653,7 -1649,7 +1654,7 @@@ unsigned long git_env_ulong(const char 
  {
        const char *v = getenv(k);
        if (v && !git_parse_ulong(v, &val))
 -              die("failed to parse %s", k);
 +              die(_("failed to parse %s"), k);
        return val;
  }
  
@@@ -2370,7 -2366,7 +2371,7 @@@ static int store_aux_event(enum config_
  
        if (type == CONFIG_EVENT_SECTION) {
                if (cf->var.len < 2 || cf->var.buf[cf->var.len - 1] != '.')
 -                      return error("invalid section name '%s'", cf->var.buf);
 +                      return error(_("invalid section name '%s'"), cf->var.buf);
  
                /* Is this the section we were looking for? */
                store->is_keys_section =
@@@ -2426,7 -2422,7 +2427,7 @@@ static int store_aux(const char *key, c
  
  static int write_error(const char *filename)
  {
 -      error("failed to write new configuration file %s", filename);
 +      error(_("failed to write new configuration file %s"), filename);
  
        /* Same error code as "failed to rename". */
        return 4;
@@@ -2677,7 -2673,7 +2678,7 @@@ int git_config_set_multivar_in_file_gen
         */
        fd = hold_lock_file_for_update(&lock, config_filename, 0);
        if (fd < 0) {
 -              error_errno("could not lock config file %s", config_filename);
 +              error_errno(_("could not lock config file %s"), config_filename);
                ret = CONFIG_NO_LOCK;
                goto out_free;
        }
        in_fd = open(config_filename, O_RDONLY);
        if ( in_fd < 0 ) {
                if ( ENOENT != errno ) {
 -                      error_errno("opening %s", config_filename);
 +                      error_errno(_("opening %s"), config_filename);
                        ret = CONFIG_INVALID_FILE; /* same as "invalid config file" */
                        goto out_free;
                }
                        store.value_regex = (regex_t*)xmalloc(sizeof(regex_t));
                        if (regcomp(store.value_regex, value_regex,
                                        REG_EXTENDED)) {
 -                              error("invalid pattern: %s", value_regex);
 +                              error(_("invalid pattern: %s"), value_regex);
                                FREE_AND_NULL(store.value_regex);
                                ret = CONFIG_INVALID_PATTERN;
                                goto out_free;
                if (git_config_from_file_with_options(store_aux,
                                                      config_filename,
                                                      &store, &opts)) {
 -                      error("invalid config file %s", config_filename);
 +                      error(_("invalid config file %s"), config_filename);
                        ret = CONFIG_INVALID_FILE;
                        goto out_free;
                }
                if (contents == MAP_FAILED) {
                        if (errno == ENODEV && S_ISDIR(st.st_mode))
                                errno = EISDIR;
 -                      error_errno("unable to mmap '%s'", config_filename);
 +                      error_errno(_("unable to mmap '%s'"), config_filename);
                        ret = CONFIG_INVALID_FILE;
                        contents = NULL;
                        goto out_free;
                in_fd = -1;
  
                if (chmod(get_lock_file_path(&lock), st.st_mode & 07777) < 0) {
 -                      error_errno("chmod on %s failed", get_lock_file_path(&lock));
 +                      error_errno(_("chmod on %s failed"), get_lock_file_path(&lock));
                        ret = CONFIG_NO_WRITE;
                        goto out_free;
                }
        }
  
        if (commit_lock_file(&lock) < 0) {
 -              error_errno("could not write config file %s", config_filename);
 +              error_errno(_("could not write config file %s"), config_filename);
                ret = CONFIG_NO_WRITE;
                goto out_free;
        }
@@@ -2992,7 -2988,7 +2993,7 @@@ static int git_config_copy_or_rename_se
        memset(&store, 0, sizeof(store));
  
        if (new_name && !section_name_is_ok(new_name)) {
 -              ret = error("invalid section name: %s", new_name);
 +              ret = error(_("invalid section name: %s"), new_name);
                goto out_no_rollback;
        }
  
  
        out_fd = hold_lock_file_for_update(&lock, config_filename, 0);
        if (out_fd < 0) {
 -              ret = error("could not lock config file %s", config_filename);
 +              ret = error(_("could not lock config file %s"), config_filename);
                goto out;
        }
  
        }
  
        if (chmod(get_lock_file_path(&lock), st.st_mode & 07777) < 0) {
 -              ret = error_errno("chmod on %s failed",
 +              ret = error_errno(_("chmod on %s failed"),
                                  get_lock_file_path(&lock));
                goto out;
        }
        config_file = NULL;
  commit_and_out:
        if (commit_lock_file(&lock) < 0)
 -              ret = error_errno("could not write config file %s",
 +              ret = error_errno(_("could not write config file %s"),
                                  config_filename);
  out:
        if (config_file)
@@@ -3159,7 -3155,7 +3160,7 @@@ int git_config_copy_section(const char 
  #undef config_error_nonbool
  int config_error_nonbool(const char *var)
  {
 -      return error("missing value for '%s'", var);
 +      return error(_("missing value for '%s'"), var);
  }
  
  int parse_config_key(const char *var,
diff --combined config.h
index 2d5c18b05f85e1a6a7f954442f5d7565e9769212,75ba1d45ffa2e0d8b5cca3fd18a9531f47744ea4..ab46e0165d8ffa782a796d0e2b23337aa9004b51
+++ b/config.h
@@@ -1,6 -1,11 +1,11 @@@
  #ifndef CONFIG_H
  #define CONFIG_H
  
+ #include "hashmap.h"
+ #include "string-list.h"
+ struct object_id;
  /* git_config_parse_key() returns these negated: */
  #define CONFIG_INVALID_KEY 1
  #define CONFIG_NO_SECTION_OR_NAME 2
@@@ -82,7 -87,6 +87,7 @@@ extern void git_config(config_fn_t fn, 
  extern int config_with_options(config_fn_t fn, void *,
                               struct git_config_source *config_source,
                               const struct config_options *opts);
 +extern int git_parse_ssize_t(const char *, ssize_t *);
  extern int git_parse_ulong(const char *, unsigned long *);
  extern int git_parse_maybe_bool(const char *);
  extern int git_config_int(const char *, const char *);
@@@ -189,14 -193,9 +194,14 @@@ struct config_set 
  
  extern void git_configset_init(struct config_set *cs);
  extern int git_configset_add_file(struct config_set *cs, const char *filename);
 -extern int git_configset_get_value(struct config_set *cs, const char *key, const char **value);
  extern const struct string_list *git_configset_get_value_multi(struct config_set *cs, const char *key);
  extern void git_configset_clear(struct config_set *cs);
 +
 +/*
 + * These functions return 1 if not found, and 0 if found, leaving the found
 + * value in the 'dest' pointer.
 + */
 +extern int git_configset_get_value(struct config_set *cs, const char *key, const char **dest);
  extern int git_configset_get_string_const(struct config_set *cs, const char *key, const char **dest);
  extern int git_configset_get_string(struct config_set *cs, const char *key, char **dest);
  extern int git_configset_get_int(struct config_set *cs, const char *key, int *dest);
diff --combined convert.h
index 6d0ee887ed710b3ea3dadf315a4dd3bfb807e39e,76c654385d813bfc72b9be44a11272ff9b87228f..831559f10d4442b35a43c642b0fd6c203d996f3c
+++ b/convert.h
@@@ -7,6 -7,8 +7,8 @@@
  #include "string-list.h"
  
  struct index_state;
+ struct object_id;
+ struct strbuf;
  
  #define CONV_EOL_RNDTRP_DIE   (1<<0) /* Die if CRLF to LF to CRLF is different */
  #define CONV_EOL_RNDTRP_WARN  (1<<1) /* Warn if CRLF to LF to CRLF is different */
@@@ -57,40 -59,35 +59,40 @@@ struct delayed_checkout 
  
  extern enum eol core_eol;
  extern char *check_roundtrip_encoding;
 -extern const char *get_cached_convert_stats_ascii(const struct index_state *istate,
 -                                                const char *path);
 -extern const char *get_wt_convert_stats_ascii(const char *path);
 -extern const char *get_convert_attr_ascii(const char *path);
 +const char *get_cached_convert_stats_ascii(const struct index_state *istate,
 +                                         const char *path);
 +const char *get_wt_convert_stats_ascii(const char *path);
 +const char *get_convert_attr_ascii(const struct index_state *istate,
 +                                 const char *path);
  
  /* returns 1 if *dst was used */
 -extern int convert_to_git(const struct index_state *istate,
 -                        const char *path, const char *src, size_t len,
 -                        struct strbuf *dst, int conv_flags);
 -extern int convert_to_working_tree(const char *path, const char *src,
 -                                 size_t len, struct strbuf *dst);
 -extern int async_convert_to_working_tree(const char *path, const char *src,
 -                                       size_t len, struct strbuf *dst,
 -                                       void *dco);
 -extern int async_query_available_blobs(const char *cmd, struct string_list *available_paths);
 -extern int renormalize_buffer(const struct index_state *istate,
 -                            const char *path, const char *src, size_t len,
 -                            struct strbuf *dst);
 +int convert_to_git(const struct index_state *istate,
 +                 const char *path, const char *src, size_t len,
 +                 struct strbuf *dst, int conv_flags);
 +int convert_to_working_tree(const struct index_state *istate,
 +                          const char *path, const char *src,
 +                          size_t len, struct strbuf *dst);
 +int async_convert_to_working_tree(const struct index_state *istate,
 +                                const char *path, const char *src,
 +                                size_t len, struct strbuf *dst,
 +                                void *dco);
 +int async_query_available_blobs(const char *cmd,
 +                              struct string_list *available_paths);
 +int renormalize_buffer(const struct index_state *istate,
 +                     const char *path, const char *src, size_t len,
 +                     struct strbuf *dst);
  static inline int would_convert_to_git(const struct index_state *istate,
                                       const char *path)
  {
        return convert_to_git(istate, path, NULL, 0, NULL, 0);
  }
  /* Precondition: would_convert_to_git_filter_fd(path) == true */
 -extern void convert_to_git_filter_fd(const struct index_state *istate,
 -                                   const char *path, int fd,
 -                                   struct strbuf *dst,
 -                                   int conv_flags);
 -extern int would_convert_to_git_filter_fd(const char *path);
 +void convert_to_git_filter_fd(const struct index_state *istate,
 +                            const char *path, int fd,
 +                            struct strbuf *dst,
 +                            int conv_flags);
 +int would_convert_to_git_filter_fd(const struct index_state *istate,
 +                                 const char *path);
  
  /*****************************************************************
   *
  
  struct stream_filter; /* opaque */
  
 -extern struct stream_filter *get_stream_filter(const char *path, const struct object_id *);
 -extern void free_stream_filter(struct stream_filter *);
 -extern int is_null_stream_filter(struct stream_filter *);
 +struct stream_filter *get_stream_filter(const struct index_state *istate,
 +                                      const char *path,
 +                                      const struct object_id *);
 +void free_stream_filter(struct stream_filter *);
 +int is_null_stream_filter(struct stream_filter *);
  
  /*
   * Use as much input up to *isize_p and fill output up to *osize_p;
   * such filters know there is no more input coming and it is time for
   * them to produce the remaining output based on the buffered input.
   */
 -extern int stream_filter(struct stream_filter *,
 -                       const char *input, size_t *isize_p,
 -                       char *output, size_t *osize_p);
 +int stream_filter(struct stream_filter *,
 +                const char *input, size_t *isize_p,
 +                char *output, size_t *osize_p);
  
  #endif /* CONVERT_H */
diff --combined diffcore.h
index 81281a398b4f218f22d1d9ed50df99589832fe83,0dd1e9a63a05de7774ebdea4f2236ce584c32d0c..8d81a45f510c0aed0cafcd3dce638f18fc6566f7
@@@ -4,6 -4,10 +4,10 @@@
  #ifndef DIFFCORE_H
  #define DIFFCORE_H
  
+ #include "cache.h"
+ struct diff_options;
  /* This header file is internal between diff.c and its diff transformers
   * (e.g. diffcore-rename, diffcore-pickaxe).  Never include this header
   * in anything else.
@@@ -50,17 -54,17 +54,17 @@@ struct diff_filespec 
        struct userdiff_driver *driver;
  };
  
 -extern struct diff_filespec *alloc_filespec(const char *);
 -extern void free_filespec(struct diff_filespec *);
 -extern void fill_filespec(struct diff_filespec *, const struct object_id *,
 -                        int, unsigned short);
 +struct diff_filespec *alloc_filespec(const char *);
 +void free_filespec(struct diff_filespec *);
 +void fill_filespec(struct diff_filespec *, const struct object_id *,
 +                 int, unsigned short);
  
  #define CHECK_SIZE_ONLY 1
  #define CHECK_BINARY    2
 -extern int diff_populate_filespec(struct diff_filespec *, unsigned int);
 -extern void diff_free_filespec_data(struct diff_filespec *);
 -extern void diff_free_filespec_blob(struct diff_filespec *);
 -extern int diff_filespec_is_binary(struct diff_filespec *);
 +int diff_populate_filespec(struct diff_filespec *, unsigned int);
 +void diff_free_filespec_data(struct diff_filespec *);
 +void diff_free_filespec_blob(struct diff_filespec *);
 +int diff_filespec_is_binary(struct diff_filespec *);
  
  struct diff_filepair {
        struct diff_filespec *one;
@@@ -86,9 -90,9 +90,9 @@@
  
  #define DIFF_PAIR_MODE_CHANGED(p) ((p)->one->mode != (p)->two->mode)
  
 -extern void diff_free_filepair(struct diff_filepair *);
 +void diff_free_filepair(struct diff_filepair *);
  
 -extern int diff_unmodified_pair(struct diff_filepair *);
 +int diff_unmodified_pair(struct diff_filepair *);
  
  struct diff_queue_struct {
        struct diff_filepair **queue;
        } while (0)
  
  extern struct diff_queue_struct diff_queued_diff;
 -extern struct diff_filepair *diff_queue(struct diff_queue_struct *,
 -                                      struct diff_filespec *,
 -                                      struct diff_filespec *);
 -extern void diff_q(struct diff_queue_struct *, struct diff_filepair *);
 +struct diff_filepair *diff_queue(struct diff_queue_struct *,
 +                               struct diff_filespec *,
 +                               struct diff_filespec *);
 +void diff_q(struct diff_queue_struct *, struct diff_filepair *);
  
 -extern void diffcore_break(int);
 -extern void diffcore_rename(struct diff_options *);
 -extern void diffcore_merge_broken(void);
 -extern void diffcore_pickaxe(struct diff_options *);
 -extern void diffcore_order(const char *orderfile);
 +void diffcore_break(int);
 +void diffcore_rename(struct diff_options *);
 +void diffcore_merge_broken(void);
 +void diffcore_pickaxe(struct diff_options *);
 +void diffcore_order(const char *orderfile);
  
  /* low-level interface to diffcore_order */
  struct obj_order {
@@@ -138,11 -142,11 +142,11 @@@ void diff_debug_queue(const char *, str
  #define diff_debug_queue(a,b) do { /* nothing */ } while (0)
  #endif
  
 -extern int diffcore_count_changes(struct diff_filespec *src,
 -                                struct diff_filespec *dst,
 -                                void **src_count_p,
 -                                void **dst_count_p,
 -                                unsigned long *src_copied,
 -                                unsigned long *literal_added);
 +int diffcore_count_changes(struct diff_filespec *src,
 +                         struct diff_filespec *dst,
 +                         void **src_count_p,
 +                         void **dst_count_p,
 +                         unsigned long *src_copied,
 +                         unsigned long *literal_added);
  
  #endif
diff --combined environment.c
index 68523b6b0ecd3bf924b075bd47bf0cd3426795f3,0c04a6da7a948bbb0626f55a11571769cc100d51..3f3c8746c2b6e30c5d9e40772078a39c3a9638c8
@@@ -8,6 -8,7 +8,7 @@@
   * are.
   */
  #include "cache.h"
+ #include "branch.h"
  #include "repository.h"
  #include "config.h"
  #include "refs.h"
@@@ -51,7 -52,7 +52,7 @@@ const char *editor_program
  const char *askpass_program;
  const char *excludes_file;
  enum auto_crlf auto_crlf = AUTO_CRLF_FALSE;
 -int check_replace_refs = 1; /* NEEDSWORK: rename to read_replace_refs */
 +int read_replace_refs = 1;
  char *git_replace_ref_base;
  enum eol core_eol = EOL_UNSET;
  int global_conv_flags_eol = CONV_EOL_RNDTRP_WARN;
@@@ -146,7 -147,7 +147,7 @@@ static char *expand_namespace(const cha
                        strbuf_addf(&buf, "refs/namespaces/%s", (*c)->buf);
        strbuf_list_free(components);
        if (check_refname_format(buf.buf, 0))
 -              die("bad git namespace path \"%s\"", raw_namespace);
 +              die(_("bad git namespace path \"%s\""), raw_namespace);
        strbuf_addch(&buf, '/');
        return strbuf_detach(&buf, NULL);
  }
@@@ -182,7 -183,7 +183,7 @@@ void setup_git_env(const char *git_dir
        argv_array_clear(&to_free);
  
        if (getenv(NO_REPLACE_OBJECTS_ENVIRONMENT))
 -              check_replace_refs = 0;
 +              read_replace_refs = 0;
        replace_ref_base = getenv(GIT_REPLACE_REF_BASE_ENVIRONMENT);
        free(git_replace_ref_base);
        git_replace_ref_base = xstrdup(replace_ref_base ? replace_ref_base
@@@ -328,7 -329,7 +329,7 @@@ char *get_graft_file(struct repository 
  static void set_git_dir_1(const char *path)
  {
        if (setenv(GIT_DIR_ENVIRONMENT, path, 1))
 -              die("could not set GIT_DIR to '%s'", path);
 +              die(_("could not set GIT_DIR to '%s'"), path);
        setup_git_env(path);
  }
  
diff --combined object-store.h
index 162156f5dc66d491eaf010136caa9c3ebc02483e,b6f2c732c42e1a4429d9e8c47f951a9f26ca1a9f..67e66227d9c41e2f3036d0aeb89afaf5a17ec98a
@@@ -1,6 -1,7 +1,7 @@@
  #ifndef OBJECT_STORE_H
  #define OBJECT_STORE_H
  
+ #include "cache.h"
  #include "oidmap.h"
  #include "list.h"
  #include "sha1-array.h"
@@@ -262,94 -263,4 +263,94 @@@ int oid_object_info_extended(struct rep
                             const struct object_id *,
                             struct object_info *, unsigned flags);
  
 +/*
 + * Iterate over the files in the loose-object parts of the object
 + * directory "path", triggering the following callbacks:
 + *
 + *  - loose_object is called for each loose object we find.
 + *
 + *  - loose_cruft is called for any files that do not appear to be
 + *    loose objects. Note that we only look in the loose object
 + *    directories "objects/[0-9a-f]{2}/", so we will not report
 + *    "objects/foobar" as cruft.
 + *
 + *  - loose_subdir is called for each top-level hashed subdirectory
 + *    of the object directory (e.g., "$OBJDIR/f0"). It is called
 + *    after the objects in the directory are processed.
 + *
 + * Any callback that is NULL will be ignored. Callbacks returning non-zero
 + * will end the iteration.
 + *
 + * In the "buf" variant, "path" is a strbuf which will also be used as a
 + * scratch buffer, but restored to its original contents before
 + * the function returns.
 + */
 +typedef int each_loose_object_fn(const struct object_id *oid,
 +                               const char *path,
 +                               void *data);
 +typedef int each_loose_cruft_fn(const char *basename,
 +                              const char *path,
 +                              void *data);
 +typedef int each_loose_subdir_fn(unsigned int nr,
 +                               const char *path,
 +                               void *data);
 +int for_each_file_in_obj_subdir(unsigned int subdir_nr,
 +                              struct strbuf *path,
 +                              each_loose_object_fn obj_cb,
 +                              each_loose_cruft_fn cruft_cb,
 +                              each_loose_subdir_fn subdir_cb,
 +                              void *data);
 +int for_each_loose_file_in_objdir(const char *path,
 +                                each_loose_object_fn obj_cb,
 +                                each_loose_cruft_fn cruft_cb,
 +                                each_loose_subdir_fn subdir_cb,
 +                                void *data);
 +int for_each_loose_file_in_objdir_buf(struct strbuf *path,
 +                                    each_loose_object_fn obj_cb,
 +                                    each_loose_cruft_fn cruft_cb,
 +                                    each_loose_subdir_fn subdir_cb,
 +                                    void *data);
 +
 +/* Flags for for_each_*_object() below. */
 +enum for_each_object_flags {
 +      /* Iterate only over local objects, not alternates. */
 +      FOR_EACH_OBJECT_LOCAL_ONLY = (1<<0),
 +
 +      /* Only iterate over packs obtained from the promisor remote. */
 +      FOR_EACH_OBJECT_PROMISOR_ONLY = (1<<1),
 +
 +      /*
 +       * Visit objects within a pack in packfile order rather than .idx order
 +       */
 +      FOR_EACH_OBJECT_PACK_ORDER = (1<<2),
 +};
 +
 +/*
 + * Iterate over all accessible loose objects without respect to
 + * reachability. By default, this includes both local and alternate objects.
 + * The order in which objects are visited is unspecified.
 + *
 + * Any flags specific to packs are ignored.
 + */
 +int for_each_loose_object(each_loose_object_fn, void *,
 +                        enum for_each_object_flags flags);
 +
 +/*
 + * Iterate over all accessible packed objects without respect to reachability.
 + * By default, this includes both local and alternate packs.
 + *
 + * Note that some objects may appear twice if they are found in multiple packs.
 + * Each pack is visited in an unspecified order. By default, objects within a
 + * pack are visited in pack-idx order (i.e., sorted by oid).
 + */
 +typedef int each_packed_object_fn(const struct object_id *oid,
 +                                struct packed_git *pack,
 +                                uint32_t pos,
 +                                void *data);
 +int for_each_object_in_pack(struct packed_git *p,
 +                          each_packed_object_fn, void *data,
 +                          enum for_each_object_flags flags);
 +int for_each_packed_object(each_packed_object_fn, void *,
 +                         enum for_each_object_flags flags);
 +
  #endif /* OBJECT_STORE_H */
diff --combined repository.h
index 58961037c4acbe825b0a8b257e9601da8bd29b37,13c87996789f68a4371d1b0a55c6d6ff52a73251..9f16c42c1ed04af3bf2e7767c4fd6c05b28ccf9c
@@@ -1,6 -1,8 +1,8 @@@
  #ifndef REPOSITORY_H
  #define REPOSITORY_H
  
+ #include "path.h"
  struct config_set;
  struct git_hash_algo;
  struct index_state;
@@@ -108,16 -110,19 +110,16 @@@ struct set_gitdir_args 
        const char *alternate_db;
  };
  
 -extern void repo_set_gitdir(struct repository *repo,
 -                          const char *root,
 -                          const struct set_gitdir_args *extra_args);
 -extern void repo_set_worktree(struct repository *repo, const char *path);
 -extern void repo_set_hash_algo(struct repository *repo, int algo);
 -extern void initialize_the_repository(void);
 -extern int repo_init(struct repository *r,
 -                   const char *gitdir,
 -                   const char *worktree);
 -extern int repo_submodule_init(struct repository *submodule,
 -                             struct repository *superproject,
 -                             const char *path);
 -extern void repo_clear(struct repository *repo);
 +void repo_set_gitdir(struct repository *repo, const char *root,
 +                   const struct set_gitdir_args *extra_args);
 +void repo_set_worktree(struct repository *repo, const char *path);
 +void repo_set_hash_algo(struct repository *repo, int algo);
 +void initialize_the_repository(void);
 +int repo_init(struct repository *r, const char *gitdir, const char *worktree);
 +int repo_submodule_init(struct repository *submodule,
 +                      struct repository *superproject,
 +                      const char *path);
 +void repo_clear(struct repository *repo);
  
  /*
   * Populates the repository's index from its index_file, an index struct will
   * than zero if an error occured.  If the repository's index has already been
   * populated then the number of entries will simply be returned.
   */
 -extern int repo_read_index(struct repository *repo);
 +int repo_read_index(struct repository *repo);
  
  #endif /* REPOSITORY_H */
diff --combined revision.h
index 51bb57d889b316aaf90c416446ea995d5e2e9e25,850e50878317a9afec6c3aac5a52699d3f66d58e..007278cc119fded9f97832d87ffe5d6b95a5ce41
@@@ -1,6 -1,7 +1,7 @@@
  #ifndef REVISION_H
  #define REVISION_H
  
+ #include "commit.h"
  #include "parse-options.h"
  #include "grep.h"
  #include "notes.h"
@@@ -230,7 -231,7 +231,7 @@@ struct rev_info 
        struct revision_sources *sources;
  };
  
 -extern int ref_excluded(struct string_list *, const char *path);
 +int ref_excluded(struct string_list *, const char *path);
  void clear_ref_exclusion(struct string_list **);
  void add_ref_exclusion(struct string_list **, const char *exclude);
  
@@@ -252,39 -253,39 +253,39 @@@ struct setup_revision_opt 
        unsigned revarg_opt;
  };
  
 -extern void init_revisions(struct rev_info *revs, const char *prefix);
 -extern int setup_revisions(int argc, const char **argv, struct rev_info *revs,
 -                         struct setup_revision_opt *);
 -extern void parse_revision_opt(struct rev_info *revs, struct parse_opt_ctx_t *ctx,
 -                             const struct option *options,
 -                             const char * const usagestr[]);
 +void init_revisions(struct rev_info *revs, const char *prefix);
 +int setup_revisions(int argc, const char **argv, struct rev_info *revs,
 +                  struct setup_revision_opt *);
 +void parse_revision_opt(struct rev_info *revs, struct parse_opt_ctx_t *ctx,
 +                      const struct option *options,
 +                      const char * const usagestr[]);
  #define REVARG_CANNOT_BE_FILENAME 01
  #define REVARG_COMMITTISH 02
 -extern int handle_revision_arg(const char *arg, struct rev_info *revs,
 -                             int flags, unsigned revarg_opt);
 +int handle_revision_arg(const char *arg, struct rev_info *revs,
 +                      int flags, unsigned revarg_opt);
  
 -extern void reset_revision_walk(void);
 -extern int prepare_revision_walk(struct rev_info *revs);
 -extern struct commit *get_revision(struct rev_info *revs);
 -extern char *get_revision_mark(const struct rev_info *revs,
 -                             const struct commit *commit);
 -extern void put_revision_mark(const struct rev_info *revs,
 -                            const struct commit *commit);
 +void reset_revision_walk(void);
 +int prepare_revision_walk(struct rev_info *revs);
 +struct commit *get_revision(struct rev_info *revs);
 +char *get_revision_mark(const struct rev_info *revs,
 +                      const struct commit *commit);
 +void put_revision_mark(const struct rev_info *revs,
 +                     const struct commit *commit);
  
 -extern void mark_parents_uninteresting(struct commit *commit);
 -extern void mark_tree_uninteresting(struct tree *tree);
 +void mark_parents_uninteresting(struct commit *commit);
 +void mark_tree_uninteresting(struct tree *tree);
  
 -extern void show_object_with_name(FILE *, struct object *, const char *);
 +void show_object_with_name(FILE *, struct object *, const char *);
  
 -extern void add_pending_object(struct rev_info *revs,
 -                             struct object *obj, const char *name);
 -extern void add_pending_oid(struct rev_info *revs,
 -                          const char *name, const struct object_id *oid,
 -                          unsigned int flags);
 +void add_pending_object(struct rev_info *revs,
 +                      struct object *obj, const char *name);
 +void add_pending_oid(struct rev_info *revs,
 +                   const char *name, const struct object_id *oid,
 +                   unsigned int flags);
  
 -extern void add_head_to_pending(struct rev_info *);
 -extern void add_reflogs_to_pending(struct rev_info *, unsigned int flags);
 -extern void add_index_objects_to_pending(struct rev_info *, unsigned int flags);
 +void add_head_to_pending(struct rev_info *);
 +void add_reflogs_to_pending(struct rev_info *, unsigned int flags);
 +void add_index_objects_to_pending(struct rev_info *, unsigned int flags);
  
  enum commit_action {
        commit_ignore,
        commit_error
  };
  
 -extern enum commit_action get_commit_action(struct rev_info *revs,
 -                                          struct commit *commit);
 -extern enum commit_action simplify_commit(struct rev_info *revs,
 -                                        struct commit *commit);
 +enum commit_action get_commit_action(struct rev_info *revs,
 +                                   struct commit *commit);
 +enum commit_action simplify_commit(struct rev_info *revs,
 +                                 struct commit *commit);
  
  enum rewrite_result {
        rewrite_one_ok,
  
  typedef enum rewrite_result (*rewrite_parent_fn_t)(struct rev_info *revs, struct commit **pp);
  
 -extern int rewrite_parents(struct rev_info *revs, struct commit *commit,
 -      rewrite_parent_fn_t rewrite_parent);
 +int rewrite_parents(struct rev_info *revs,
 +                  struct commit *commit,
 +                  rewrite_parent_fn_t rewrite_parent);
  
  /*
   * The log machinery saves the original parent list so that
   * get_saved_parents() will transparently return commit->parents if
   * history simplification is off.
   */
 -extern struct commit_list *get_saved_parents(struct rev_info *revs, const struct commit *commit);
 +struct commit_list *get_saved_parents(struct rev_info *revs, const struct commit *commit);
  
  #endif
diff --combined submodule.h
index c98cd983e1e13d15605bb0a30d2a558fa08226bf,3adbc08915e7df067bb10f1caaf7578dfbe10a89..7d476cefa7eea0c183bf515a6f48f1fa27ca8b25
@@@ -1,11 -1,17 +1,17 @@@
  #ifndef SUBMODULE_H
  #define SUBMODULE_H
  
- struct repository;
- struct diff_options;
  struct argv_array;
+ struct cache_entry;
+ struct diff_options;
+ struct index_state;
+ struct object_id;
  struct oid_array;
+ struct pathspec;
  struct remote;
+ struct repository;
+ struct string_list;
+ struct strbuf;
  
  enum {
        RECURSE_SUBMODULES_ONLY = -5,
@@@ -33,62 -39,62 +39,62 @@@ struct submodule_update_strategy 
  };
  #define SUBMODULE_UPDATE_STRATEGY_INIT {SM_UPDATE_UNSPECIFIED, NULL}
  
 -extern int is_gitmodules_unmerged(const struct index_state *istate);
 -extern int is_staging_gitmodules_ok(struct index_state *istate);
 -extern int update_path_in_gitmodules(const char *oldpath, const char *newpath);
 -extern int remove_path_from_gitmodules(const char *path);
 -extern void stage_updated_gitmodules(struct index_state *istate);
 -extern void set_diffopt_flags_from_submodule_config(struct diff_options *,
 -              const char *path);
 -extern int git_default_submodule_config(const char *var, const char *value, void *cb);
 +int is_gitmodules_unmerged(const struct index_state *istate);
 +int is_staging_gitmodules_ok(struct index_state *istate);
 +int update_path_in_gitmodules(const char *oldpath, const char *newpath);
 +int remove_path_from_gitmodules(const char *path);
 +void stage_updated_gitmodules(struct index_state *istate);
 +void set_diffopt_flags_from_submodule_config(struct diff_options *,
 +                                           const char *path);
 +int git_default_submodule_config(const char *var, const char *value, void *cb);
  
  struct option;
  int option_parse_recurse_submodules_worktree_updater(const struct option *opt,
                                                     const char *arg, int unset);
 -extern int is_submodule_active(struct repository *repo, const char *path);
 +int is_submodule_active(struct repository *repo, const char *path);
  /*
   * Determine if a submodule has been populated at a given 'path' by checking if
   * the <path>/.git resolves to a valid git repository.
   * If return_error_code is NULL, die on error.
   * Otherwise the return error code is the same as of resolve_gitdir_gently.
   */
 -extern int is_submodule_populated_gently(const char *path, int *return_error_code);
 -extern void die_in_unpopulated_submodule(const struct index_state *istate,
 -                                       const char *prefix);
 -extern void die_path_inside_submodule(const struct index_state *istate,
 -                                    const struct pathspec *ps);
 -extern enum submodule_update_type parse_submodule_update_type(const char *value);
 -extern int parse_submodule_update_strategy(const char *value,
 -              struct submodule_update_strategy *dst);
 -extern const char *submodule_strategy_to_string(const struct submodule_update_strategy *s);
 -extern void handle_ignore_submodules_arg(struct diff_options *, const char *);
 -extern void show_submodule_summary(struct diff_options *o, const char *path,
 -              struct object_id *one, struct object_id *two,
 -              unsigned dirty_submodule);
 -extern void show_submodule_inline_diff(struct diff_options *o, const char *path,
 -              struct object_id *one, struct object_id *two,
 -              unsigned dirty_submodule);
 +int is_submodule_populated_gently(const char *path, int *return_error_code);
 +void die_in_unpopulated_submodule(const struct index_state *istate,
 +                                const char *prefix);
 +void die_path_inside_submodule(const struct index_state *istate,
 +                             const struct pathspec *ps);
 +enum submodule_update_type parse_submodule_update_type(const char *value);
 +int parse_submodule_update_strategy(const char *value,
 +                                  struct submodule_update_strategy *dst);
 +const char *submodule_strategy_to_string(const struct submodule_update_strategy *s);
 +void handle_ignore_submodules_arg(struct diff_options *, const char *);
 +void show_submodule_summary(struct diff_options *o, const char *path,
 +                          struct object_id *one, struct object_id *two,
 +                          unsigned dirty_submodule);
 +void show_submodule_inline_diff(struct diff_options *o, const char *path,
 +                              struct object_id *one, struct object_id *two,
 +                              unsigned dirty_submodule);
  /* Check if we want to update any submodule.*/
 -extern int should_update_submodules(void);
 +int should_update_submodules(void);
  /*
   * Returns the submodule struct if the given ce entry is a submodule
   * and it should be updated. Returns NULL otherwise.
   */
 -extern const struct submodule *submodule_from_ce(const struct cache_entry *ce);
 -extern void check_for_new_submodule_commits(struct object_id *oid);
 -extern int fetch_populated_submodules(struct repository *r,
 -                                    const struct argv_array *options,
 -                                    const char *prefix,
 -                                    int command_line_option,
 -                                    int default_option,
 -                                    int quiet, int max_parallel_jobs);
 -extern unsigned is_submodule_modified(const char *path, int ignore_untracked);
 -extern int submodule_uses_gitfile(const char *path);
 +const struct submodule *submodule_from_ce(const struct cache_entry *ce);
 +void check_for_new_submodule_commits(struct object_id *oid);
 +int fetch_populated_submodules(struct repository *r,
 +                             const struct argv_array *options,
 +                             const char *prefix,
 +                             int command_line_option,
 +                             int default_option,
 +                             int quiet, int max_parallel_jobs);
 +unsigned is_submodule_modified(const char *path, int ignore_untracked);
 +int submodule_uses_gitfile(const char *path);
  
  #define SUBMODULE_REMOVAL_DIE_ON_ERROR (1<<0)
  #define SUBMODULE_REMOVAL_IGNORE_UNTRACKED (1<<1)
  #define SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED (1<<2)
 -extern int bad_to_remove_submodule(const char *path, unsigned flags);
 +int bad_to_remove_submodule(const char *path, unsigned flags);
  
  int add_submodule_odb(const char *path);
  
   * Checks if there are submodule changes in a..b. If a is the null OID,
   * checks b and all its ancestors instead.
   */
 -extern int submodule_touches_in_range(struct object_id *a,
 -                                    struct object_id *b);
 -extern int find_unpushed_submodules(struct oid_array *commits,
 -                                  const char *remotes_name,
 -                                  struct string_list *needs_pushing);
 +int submodule_touches_in_range(struct object_id *a,
 +                             struct object_id *b);
 +int find_unpushed_submodules(struct oid_array *commits,
 +                           const char *remotes_name,
 +                           struct string_list *needs_pushing);
  struct refspec;
 -extern int push_unpushed_submodules(struct oid_array *commits,
 -                                  const struct remote *remote,
 -                                  const struct refspec *rs,
 -                                  const struct string_list *push_options,
 -                                  int dry_run);
 +int push_unpushed_submodules(struct oid_array *commits,
 +                           const struct remote *remote,
 +                           const struct refspec *rs,
 +                           const struct string_list *push_options,
 +                           int dry_run);
  /*
   * Given a submodule path (as in the index), return the repository
   * path of that submodule in 'buf'. Return -1 on error or when the
@@@ -116,10 -122,10 +122,10 @@@ int submodule_to_gitdir(struct strbuf *
  
  #define SUBMODULE_MOVE_HEAD_DRY_RUN (1<<0)
  #define SUBMODULE_MOVE_HEAD_FORCE   (1<<1)
 -extern int submodule_move_head(const char *path,
 -                             const char *old,
 -                             const char *new_head,
 -                             unsigned flags);
 +int submodule_move_head(const char *path,
 +                      const char *old,
 +                      const char *new_head,
 +                      unsigned flags);
  
  void submodule_unset_core_worktree(const struct submodule *sub);
  
   * a submodule by clearing any repo-specific environment variables, but
   * retaining any config in the environment.
   */
 -extern void prepare_submodule_repo_env(struct argv_array *out);
 +void prepare_submodule_repo_env(struct argv_array *out);
  
  #define ABSORB_GITDIR_RECURSE_SUBMODULES (1<<0)
 -extern void absorb_git_dir_into_superproject(const char *prefix,
 -                                           const char *path,
 -                                           unsigned flags);
 +void absorb_git_dir_into_superproject(const char *prefix,
 +                                    const char *path,
 +                                    unsigned flags);
  
  /*
   * Return the absolute path of the working tree of the superproject, which this
   * project is a submodule of. If this repository is not a submodule of
   * another repository, return NULL.
   */
 -extern const char *get_superproject_working_tree(void);
 +const char *get_superproject_working_tree(void);
  
  #endif
diff --combined unpack-trees.h
index 534358fcc5603e0996ed1b07ddd7c7de9dce4331,48bc69cb4725c9df032baf1937adaa988a774cc4..847f217dbaecea678f48d5086e7099c3c24a53c4
@@@ -1,11 -1,14 +1,14 @@@
  #ifndef UNPACK_TREES_H
  #define UNPACK_TREES_H
  
- #include "tree-walk.h"
+ #include "cache.h"
  #include "argv-array.h"
+ #include "string-list.h"
+ #include "tree-walk.h"
  
  #define MAX_UNPACK_TREES 8
  
+ struct cache_entry;
  struct unpack_trees_options;
  struct exclude_list;
  
@@@ -82,8 -85,8 +85,8 @@@ struct unpack_trees_options 
        struct exclude_list *el; /* for internal use */
  };
  
 -extern int unpack_trees(unsigned n, struct tree_desc *t,
 -              struct unpack_trees_options *options);
 +int unpack_trees(unsigned n, struct tree_desc *t,
 +               struct unpack_trees_options *options);
  
  int verify_uptodate(const struct cache_entry *ce,
                    struct unpack_trees_options *o);
diff --combined utf8.h
index ce1c2696e069782807354a846f2cfe075e1dfd5c,dd5ee1052a849e85954d4425e0714fb38dcf1c1f..edea55e093a4713dcd0056da9a31b63f0cb51272
--- 1/utf8.h
--- 2/utf8.h
+++ b/utf8.h
@@@ -1,6 -1,8 +1,8 @@@
  #ifndef GIT_UTF8_H
  #define GIT_UTF8_H
  
+ struct strbuf;
  typedef unsigned int ucs_char_t;  /* assuming 32bit int */
  
  size_t display_mode_esc_sequence_len(const char *s);
@@@ -25,14 -27,14 +27,14 @@@ void strbuf_utf8_replace(struct strbuf 
  
  #ifndef NO_ICONV
  char *reencode_string_iconv(const char *in, size_t insz,
 -                          iconv_t conv, int *outsz);
 -char *reencode_string_len(const char *in, int insz,
 +                          iconv_t conv, size_t *outsz);
 +char *reencode_string_len(const char *in, size_t insz,
                          const char *out_encoding,
                          const char *in_encoding,
 -                        int *outsz);
 +                        size_t *outsz);
  #else
 -static inline char *reencode_string_len(const char *a, int b,
 -                                      const char *c, const char *d, int *e)
 +static inline char *reencode_string_len(const char *a, size_t b,
 +                                      const char *c, const char *d, size_t *e)
  { if (e) *e = 0; return NULL; }
  #endif