stylefix: pointers bind to the variable, not the type
RFC PATCH 1/3 stylefix: pointers bind to the variable, not the type
---
This is an RFC patch but this is probably fine as-is, and is orthogonal to the next two patches.
builtin/clone.c | 7 ++++--- commit.c | 2 +- commit.h | 2 +- reflog-walk.c | 2 +- reflog-walk.h | 2 +- refs.h | 2 +- remote-curl.c | 2 +- 7 files changed, 10 insertions(+), 9 deletions(-)
builtin/clone.c +4 -3
@@ -685,9 +685,10 @@ static void write_config(struct string_list *config) } } -static void write_refspec_config (const char * src_ref_prefix, -const struct ref * our_head_points_at, -const struct ref * remote_head_points_at,struct strbuf * branch_top) +static void write_refspec_config (const char *src_ref_prefix, +const struct ref *our_head_points_at, +const struct ref *remote_head_points_at, +struct strbuf *branch_top) {struct strbuf key =STRBUF_INIT ;struct strbuf value =STRBUF_INIT ;
commit.c +1 -1
@@ -1256,7 +1256,7 @@ static void parse_gpg_output(struct signature_check *sigc) } } -void check_commit_signature (const struct commit * commit,struct signature_check *sigc) +void check_commit_signature (const struct commit *commit,struct signature_check *sigc) {struct strbuf payload =STRBUF_INIT ;struct strbuf signature =STRBUF_INIT ;
commit.h +1 -1
@@ -346,7 +346,7 @@ extern void print_commit_list(struct commit_list *list,* at all. This may allocate memory for sig->gpg_output, sig->gpg_status, * sig->signer and sig->key. */ -extern void check_commit_signature (const struct commit * commit,struct signature_check *sigc); +extern void check_commit_signature (const struct commit *commit,struct signature_check *sigc);int compare_commits_by_commit_date (const void *a_,const void *b_,void *unused);
reflog-walk.c +1 -1
@@ -133,7 +133,7 @@ struct reflog_walk_info {struct commit_reflog *last_commit_reflog; }; -void init_reflog_walk (struct reflog_walk_info ** info) +void init_reflog_walk (struct reflog_walk_info **info) { *info =xcalloc (1 ,sizeof (struct reflog_walk_info )); }
reflog-walk.h +1 -1
@@ -5,7 +5,7 @@struct reflog_walk_info ; -extern void init_reflog_walk (struct reflog_walk_info ** info); +extern void init_reflog_walk (struct reflog_walk_info **info);extern int add_reflog_for_walk (struct reflog_walk_info *info,struct commit *commit,const char *name); extern void fake_reflog_parent(struct reflog_walk_info *info,
refs.h +1 -1
@@ -77,7 +77,7 @@ static inline const char *has_glob_specials(const char *pattern)extern int for_each_rawref (each_ref_fn ,void *);extern void warn_dangling_symref (FILE *fp,const char *msg_fmt,const char *refname); -extern void warn_dangling_symrefs (FILE *fp,const char *msg_fmt,const struct string_list * refnames); +extern void warn_dangling_symrefs (FILE *fp,const char *msg_fmt,const struct string_list *refnames);/* * Lock the packed-refs file for writing. Flags is passed to
remote-curl.c +1 -1
@@ -221,7 +221,7 @@ static int show_http_message(struct strbuf *type, struct strbuf *charset,return 0 ; } -static struct discovery *discover_refs (const char *service,int for_push) +static struct discovery *discover_refs (const char *service,int for_push) {struct strbuf exp =STRBUF_INIT ;struct strbuf type =STRBUF_INIT ;
Signature · 1 line
2.1.0.30.g0bdc89a
RFC PATCH 2/3 headers: improve header dependencies
Add missing includes or forward declarations where needed.
---
If enum date_type were moved to object.h then we wouldn't need to include cache.h from commit.h, but this patch doesn't touch that.
If we want to avoid including cache.h, another possibility is moving enum object_type to something like object-types.h so that e.g. dir.h wouldn't need to include all of cache.h.
Do we prefer these forward declarations or full-on #includes of the corresponding header? Forward declarations seemed like the least intrusive, which is why some of the files do that in this patch.
color.h | 2 ++ commit.h | 2 +- diffcore.h | 2 ++ dir.h | 1 + graph.h | 3 +++ object.h | 2 ++ parse-options.h | 2 ++ pathspec.h | 2 ++ quote.h | 2 ++ refs.h | 5 +++++ remote.h | 2 ++ sequencer.h | 4 ++++ strbuf.h | 2 ++ submodule.h | 3 +++ tag.h | 1 + tree-walk.h | 2 ++ tree.h | 2 ++ utf8.h | 4 ++++ 18 files changed, 42 insertions(+), 1 deletion(-)
color.h +2 -0
@@ -1,6 +1,8 @@#ifndef COLOR_H #define COLOR_H +#include "git-compat-util.h" +struct strbuf ;/* 2 + (2 * num_attrs) + 8 + 1 + 8 + 'm' + NUL */
commit.h +1 -1
@@ -1,7 +1,7 @@#ifndef COMMIT_H #define COMMIT_H -#include "object.h" +#include "cache.h" #include "tree.h" #include "strbuf.h" #include "decorate.h"
diffcore.h +2 -0
@@ -4,6 +4,8 @@#ifndef DIFFCORE_H #define DIFFCORE_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.
dir.h +1 -0
@@ -3,6 +3,7 @@/* See Documentation/technical/api-directory-listing.txt */ +#include "cache.h" #include "strbuf.h" struct dir_entry {
graph.h +3 -0
@@ -3,6 +3,9 @@/* A graph is a pointer to this opaque structure */ struct git_graph ; +struct commit ; +struct rev_info ; +struct strbuf ;/* * Set up a custom scheme for column colors.
object.h +2 -0
@@ -1,6 +1,8 @@ #ifndef OBJECT_H #define OBJECT_H +enum object_type; + struct object_list { struct object *item; struct object_list *next;
parse-options.h +2 -0
@@ -1,6 +1,8 @@#ifndef PARSE_OPTIONS_H #define PARSE_OPTIONS_H +#include "git-compat-util.h" +enum parse_opt_type {/* special types */ OPTION_END,
pathspec.h +2 -0
@@ -1,6 +1,8 @@#ifndef PATHSPEC_H #define PATHSPEC_H +#include "git-compat-util.h" +/* Pathspec magic */ #define PATHSPEC_FROMTOP (1<<0)#define PATHSPEC_MAXDEPTH (1<<1)
quote.h +2 -0
@@ -1,6 +1,8 @@#ifndef QUOTE_H #define QUOTE_H +#include "git-compat-util.h" +struct strbuf ;/* Help to copy the thing properly quoted for the shell safety.
refs.h +5 -0
@@ -1,6 +1,11 @@ #ifndef REFS_H #define REFS_H +#include "git-compat-util.h" + +struct strbuf; +struct string_list; + struct ref_lock { char *ref_name; char *orig_ref_name;
remote.h +2 -0
@@ -3,6 +3,8 @@#include "parse-options.h" +struct strbuf ; +enum {REMOTE_CONFIG ,REMOTE_REMOTES ,
sequencer.h +4 -0
@@ -1,6 +1,10 @@#ifndef SEQUENCER_H #define SEQUENCER_H +#include "git-compat-util.h" + +struct strbuf ; +#define SEQ_DIR "sequencer"#define SEQ_HEAD_FILE "sequencer/head"#define SEQ_TODO_FILE "sequencer/todo"
strbuf.h +2 -0
@@ -1,6 +1,8 @@#ifndef STRBUF_H #define STRBUF_H +#include "git-compat-util.h" +/* See Documentation/technical/api-strbuf.txt */ extern char strbuf_slopbuf[];
submodule.h +3 -0
@@ -1,8 +1,11 @@#ifndef SUBMODULE_H #define SUBMODULE_H +#include "git-compat-util.h" +struct diff_options ;struct argv_array ; +struct string_list ;enum { RECURSE_SUBMODULES_ON_DEMAND = -1,
tag.h +1 -0
@@ -1,6 +1,7 @@#ifndef TAG_H #define TAG_H +#include "git-compat-util.h" #include "object.h" extern const char *tag_type;
tree-walk.h +2 -0
@@ -1,6 +1,8 @@ #ifndef TREE_WALK_H #define TREE_WALK_H +struct strbuf; + struct name_entry { const unsigned char *sha1; const char *path;
tree.h +2 -0
@@ -3,6 +3,8 @@#include "object.h" +struct pathspec ; +extern const char *tree_type;struct tree {
utf8.h +4 -0
@@ -1,6 +1,10 @@#ifndef GIT_UTF8_H #define GIT_UTF8_H +#include "git-compat-util.h" + +struct strbuf ; +typedef unsigned int ucs_char_t ;/* assuming 32bit int */ size_t display_mode_esc_sequence_len (const char *s);
Signature · 1 line
2.1.0.30.g0bdc89a
RFC PATCH 3/3 core: improve header dependencies
Remove includes that have already been included by another header.
---
This patch is the culmination of the previous patches and is a pure removal.
builtin/add.c | 3 --- builtin/blame.c | 4 ---- builtin/branch.c | 4 ---- builtin/checkout.c | 4 ---- builtin/diff-files.c | 3 --- builtin/diff-index.c | 3 --- builtin/diff.c | 3 --- builtin/fast-export.c | 7 ------- builtin/fmt-merge-msg.c | 5 ----- builtin/log.c | 6 ------ builtin/merge-base.c | 4 ---- builtin/merge.c | 5 ----- builtin/pack-objects.c | 4 ---- builtin/prune.c | 4 ---- builtin/reflog.c | 3 --- builtin/rev-list.c | 3 --- builtin/rev-parse.c | 4 ---- builtin/revert.c | 3 --- builtin/shortlog.c | 5 ----- builtin/tag.c | 4 ---- bundle.c | 4 ---- combine-diff.c | 3 --- commit.c | 5 ----- diff-lib.c | 3 --- diff-no-index.c | 4 ---- graph.c | 3 --- http-push.c | 3 --- line-log.c | 7 ------- list-objects.c | 4 ---- pack-bitmap-write.c | 3 --- pack-bitmap.c | 3 --- pretty.c | 5 ----- reachable.c | 3 --- reflog-walk.c | 4 ---- remote.c | 4 ---- revision.c | 6 ------ sequencer.c | 4 ---- shallow.c | 3 --- submodule.c | 4 ---- test-revision-walking.c | 3 --- transport-helper.c | 4 ---- upload-pack.c | 5 ----- wt-status.c | 5 ----- 43 files changed, 173 deletions(-)
builtin/add.c +0 -3
@@ -3,15 +3,12 @@* * Copyright (C) 2006 Linus Torvalds */ -#include "cache.h" #include "builtin.h" #include "dir.h" #include "pathspec.h" #include "exec_cmd.h" #include "cache-tree.h" #include "run-command.h" -#include "parse-options.h" -#include "diff.h" #include "diffcore.h" #include "revision.h" #include "bulk-checkin.h"
builtin/blame.c +0 -4
@@ -8,19 +8,15 @@#include "cache.h" #include "builtin.h" #include "blob.h" -#include "commit.h" #include "tag.h" #include "tree-walk.h" -#include "diff.h" #include "diffcore.h" #include "revision.h" #include "quote.h" #include "xdiff-interface.h" #include "cache-tree.h" -#include "string-list.h" #include "mailmap.h" #include "mergesort.h" -#include "parse-options.h" #include "prio-queue.h" #include "utf8.h" #include "userdiff.h"
builtin/branch.c +0 -4
@@ -8,14 +8,10 @@#include "cache.h" #include "color.h" #include "refs.h" -#include "commit.h" #include "builtin.h" #include "remote.h" -#include "parse-options.h" #include "branch.h" -#include "diff.h" #include "revision.h" -#include "string-list.h" #include "column.h" #include "utf8.h" #include "wt-status.h"
builtin/checkout.c +0 -4
@@ -1,9 +1,6 @@#include "cache.h" #include "builtin.h" -#include "parse-options.h" #include "refs.h" -#include "commit.h" -#include "tree.h" #include "tree-walk.h" #include "cache-tree.h" #include "unpack-trees.h"
@@ -11,7 +8,6 @@#include "run-command.h" #include "merge-recursive.h" #include "branch.h" -#include "diff.h" #include "revision.h" #include "remote.h" #include "blob.h"
builtin/diff-files.c +0 -3
@@ -3,9 +3,6 @@* * Copyright (C) Linus Torvalds, 2005 */ -#include "cache.h" -#include "diff.h" -#include "commit.h" #include "revision.h" #include "builtin.h" #include "submodule.h"
builtin/diff-index.c +0 -3
@@ -1,6 +1,3 @@ -#include "cache.h" -#include "diff.h" -#include "commit.h" #include "revision.h" #include "builtin.h" #include "submodule.h"
builtin/diff.c +0 -3
@@ -3,12 +3,9 @@* * Copyright (c) 2006 Junio C Hamano */ -#include "cache.h" #include "color.h" -#include "commit.h" #include "blob.h" #include "tag.h" -#include "diff.h" #include "diffcore.h" #include "revision.h" #include "log-tree.h"
builtin/fast-export.c +0 -7
@@ -4,18 +4,11 @@* Copyright (C) 2007 Johannes E. Schindelin */ #include "builtin.h" -#include "cache.h" -#include "commit.h" -#include "object.h" #include "tag.h" -#include "diff.h" #include "diffcore.h" #include "log-tree.h" #include "revision.h" -#include "decorate.h" -#include "string-list.h" #include "utf8.h" -#include "parse-options.h" #include "quote.h" #include "remote.h"
builtin/fmt-merge-msg.c +0 -5
@@ -1,13 +1,8 @@#include "builtin.h" -#include "cache.h" -#include "commit.h" -#include "diff.h" #include "revision.h" #include "tag.h" -#include "string-list.h" #include "branch.h" #include "fmt-merge-msg.h" -#include "gpg-interface.h" static const char *const fmt_merge_msg_usage[] = {N_ ("git fmt-merge-msg [-m <message>] [--log[=<n>]|--no-log] [--file <file>]" ),
builtin/log.c +0 -6
@@ -4,10 +4,7 @@* (C) Copyright 2006 Linus Torvalds * 2006 Junio Hamano */ -#include "cache.h" #include "color.h" -#include "commit.h" -#include "diff.h" #include "revision.h" #include "log-tree.h" #include "builtin.h"
@@ -17,14 +14,11 @@#include "run-command.h" #include "shortlog.h" #include "remote.h" -#include "string-list.h" -#include "parse-options.h" #include "line-log.h" #include "branch.h" #include "streaming.h" #include "version.h" #include "mailmap.h" -#include "gpg-interface.h" /* Set a default date-time format for git log ("log.date" config variable) */ static const char *default_date_mode =NULL ;
builtin/merge-base.c +0 -4
@@ -1,10 +1,6 @@#include "builtin.h" -#include "cache.h" -#include "commit.h" #include "refs.h" -#include "diff.h" #include "revision.h" -#include "parse-options.h" static int show_merge_base (struct commit **rev,int rev_nr,int show_all) {
builtin/merge.c +0 -5
@@ -6,13 +6,9 @@* Based on git-merge.sh by Junio C Hamano. */ -#include "cache.h" -#include "parse-options.h" #include "builtin.h" #include "run-command.h" -#include "diff.h" #include "refs.h" -#include "commit.h" #include "diffcore.h" #include "revision.h" #include "unpack-trees.h"
@@ -27,7 +23,6 @@#include "resolve-undo.h" #include "remote.h" #include "fmt-merge-msg.h" -#include "gpg-interface.h" #define DEFAULT_TWOHEAD (1<<0)#define DEFAULT_OCTOPUS (1<<1)
builtin/pack-objects.c +0 -4
@@ -1,9 +1,6 @@#include "builtin.h" -#include "cache.h" #include "attr.h" -#include "object.h" #include "blob.h" -#include "commit.h" #include "tag.h" #include "tree.h" #include "delta.h"
@@ -11,7 +8,6 @@#include "pack-revindex.h" #include "csum-file.h" #include "tree-walk.h" -#include "diff.h" #include "revision.h" #include "list-objects.h" #include "pack-objects.h"
builtin/prune.c +0 -4
@@ -1,10 +1,6 @@ -#include "cache.h" -#include "commit.h" -#include "diff.h" #include "revision.h" #include "builtin.h" #include "reachable.h" -#include "parse-options.h" #include "progress.h" #include "dir.h"
builtin/reflog.c +0 -3
@@ -1,10 +1,7 @@ -#include "cache.h" #include "builtin.h" -#include "commit.h" #include "refs.h" #include "dir.h" #include "tree-walk.h" -#include "diff.h" #include "revision.h" #include "reachable.h"
builtin/rev-list.c +0 -3
@@ -1,6 +1,3 @@ -#include "cache.h" -#include "commit.h" -#include "diff.h" #include "revision.h" #include "list-objects.h" #include "pack.h"
builtin/rev-parse.c +0 -4
@@ -3,13 +3,9 @@* * Copyright (C) Linus Torvalds, 2005 */ -#include "cache.h" -#include "commit.h" #include "refs.h" #include "quote.h" #include "builtin.h" -#include "parse-options.h" -#include "diff.h" #include "revision.h" #include "split-index.h"
builtin/revert.c +0 -3
@@ -1,7 +1,4 @@ -#include "cache.h" #include "builtin.h" -#include "parse-options.h" -#include "diff.h" #include "revision.h" #include "rerere.h" #include "dir.h"
builtin/shortlog.c +0 -5
@@ -1,13 +1,8 @@#include "builtin.h" -#include "cache.h" -#include "commit.h" -#include "diff.h" -#include "string-list.h" #include "revision.h" #include "utf8.h" #include "mailmap.h" #include "shortlog.h" -#include "parse-options.h" static char const *const shortlog_usage[] = {N_ ("git shortlog [<options>] [<revision range>] [[--] [<path>...]]" ),
builtin/tag.c +0 -4
@@ -6,15 +6,11 @@* Based on git-tag.sh and mktag.c by Linus Torvalds. */ -#include "cache.h" #include "builtin.h" #include "refs.h" #include "tag.h" #include "run-command.h" -#include "parse-options.h" -#include "diff.h" #include "revision.h" -#include "gpg-interface.h" #include "sha1-array.h" #include "column.h"
bundle.c +0 -4
@@ -1,8 +1,4 @@ -#include "cache.h" #include "bundle.h" -#include "object.h" -#include "commit.h" -#include "diff.h" #include "revision.h" #include "list-objects.h" #include "run-command.h"
combine-diff.c +0 -3
@@ -1,7 +1,4 @@ -#include "cache.h" -#include "commit.h" #include "blob.h" -#include "diff.h" #include "diffcore.h" #include "quote.h" #include "xdiff-interface.h"
commit.c +0 -5
@@ -1,12 +1,7 @@ -#include "cache.h" #include "tag.h" -#include "commit.h" #include "pkt-line.h" #include "utf8.h" -#include "diff.h" #include "revision.h" -#include "notes.h" -#include "gpg-interface.h" #include "mergesort.h" #include "commit-slab.h" #include "prio-queue.h"
diff-lib.c +0 -3
@@ -1,10 +1,7 @@/* * Copyright (C) 2005 Junio C Hamano */ -#include "cache.h" #include "quote.h" -#include "commit.h" -#include "diff.h" #include "diffcore.h" #include "revision.h" #include "cache-tree.h"
diff-no-index.c +0 -4
@@ -4,17 +4,13 @@* Copyright (c) 2008 by Junio C Hamano */ -#include "cache.h" #include "color.h" -#include "commit.h" #include "blob.h" #include "tag.h" -#include "diff.h" #include "diffcore.h" #include "revision.h" #include "log-tree.h" #include "builtin.h" -#include "string-list.h" #include "dir.h" static int read_directory_contents (const char *path,struct string_list *list)
graph.c +0 -3
@@ -1,8 +1,5 @@ -#include "cache.h" -#include "commit.h" #include "color.h" #include "graph.h" -#include "diff.h" #include "revision.h" /* Internal API */
http-push.c +0 -3
@@ -1,10 +1,7 @@ -#include "cache.h" -#include "commit.h" #include "tag.h" #include "blob.h" #include "http.h" #include "refs.h" -#include "diff.h" #include "revision.h" #include "exec_cmd.h" #include "remote.h"
line-log.c +0 -7
@@ -1,15 +1,8 @@ -#include "git-compat-util.h" #include "line-range.h" -#include "cache.h" #include "tag.h" #include "blob.h" -#include "tree.h" -#include "diff.h" -#include "commit.h" -#include "decorate.h" #include "revision.h" #include "xdiff-interface.h" -#include "strbuf.h" #include "log-tree.h" #include "graph.h" #include "userdiff.h"
list-objects.c +0 -4
@@ -1,9 +1,5 @@ -#include "cache.h" #include "tag.h" -#include "commit.h" -#include "tree.h" #include "blob.h" -#include "diff.h" #include "tree-walk.h" #include "revision.h" #include "list-objects.h"
pack-bitmap-write.c +0 -3
@@ -1,7 +1,4 @@ -#include "cache.h" -#include "commit.h" #include "tag.h" -#include "diff.h" #include "revision.h" #include "list-objects.h" #include "progress.h"
pack-bitmap.c +0 -3
@@ -1,7 +1,4 @@ -#include "cache.h" -#include "commit.h" #include "tag.h" -#include "diff.h" #include "revision.h" #include "progress.h" #include "list-objects.h"
pretty.c +0 -5
@@ -1,15 +1,10 @@ -#include "cache.h" -#include "commit.h" #include "utf8.h" -#include "diff.h" #include "revision.h" -#include "string-list.h" #include "mailmap.h" #include "log-tree.h" #include "notes.h" #include "color.h" #include "reflog-walk.h" -#include "gpg-interface.h" static char *user_format; static struct cmt_fmt_map {
reachable.c +0 -3
@@ -1,9 +1,6 @@ -#include "cache.h" #include "refs.h" #include "tag.h" -#include "commit.h" #include "blob.h" -#include "diff.h" #include "revision.h" #include "reachable.h" #include "cache-tree.h"
reflog-walk.c +0 -4
@@ -1,9 +1,5 @@ -#include "cache.h" -#include "commit.h" #include "refs.h" -#include "diff.h" #include "revision.h" -#include "string-list.h" #include "reflog-walk.h" struct complete_reflogs {
remote.c +0 -4
@@ -1,12 +1,8 @@ -#include "cache.h" #include "remote.h" #include "refs.h" -#include "commit.h" -#include "diff.h" #include "revision.h" #include "dir.h" #include "tag.h" -#include "string-list.h" #include "mergesort.h" enum map_direction {FROM_SRC ,FROM_DST };
revision.c +0 -6
@@ -1,18 +1,12 @@ -#include "cache.h" #include "tag.h" #include "blob.h" -#include "tree.h" -#include "commit.h" -#include "diff.h" #include "refs.h" #include "revision.h" #include "graph.h" #include "grep.h" #include "reflog-walk.h" #include "patch-ids.h" -#include "decorate.h" #include "log-tree.h" -#include "string-list.h" #include "line-log.h" #include "mailmap.h" #include "commit-slab.h"
sequencer.c +0 -4
@@ -1,14 +1,10 @@ -#include "cache.h" #include "sequencer.h" #include "dir.h" -#include "object.h" -#include "commit.h" #include "tag.h" #include "run-command.h" #include "exec_cmd.h" #include "utf8.h" #include "cache-tree.h" -#include "diff.h" #include "revision.h" #include "rerere.h" #include "merge-recursive.h"
shallow.c +0 -3
@@ -1,11 +1,8 @@ -#include "cache.h" -#include "commit.h" #include "tag.h" #include "pkt-line.h" #include "remote.h" #include "refs.h" #include "sha1-array.h" -#include "diff.h" #include "revision.h" #include "commit-slab.h" #include "sigchain.h"
submodule.c +0 -4
@@ -1,13 +1,9 @@ -#include "cache.h" #include "submodule.h" #include "dir.h" -#include "diff.h" -#include "commit.h" #include "revision.h" #include "run-command.h" #include "diffcore.h" #include "refs.h" -#include "string-list.h" #include "sha1-array.h" #include "argv-array.h" #include "blob.h"
test-revision-walking.c +0 -3
@@ -8,9 +8,6 @@* published by the Free Software Foundation. */ -#include "cache.h" -#include "commit.h" -#include "diff.h" #include "revision.h" static void print_commit (struct commit *commit)
transport-helper.c +0 -4
@@ -1,13 +1,9 @@ -#include "cache.h" #include "transport.h" #include "quote.h" #include "run-command.h" -#include "commit.h" -#include "diff.h" #include "revision.h" #include "quote.h" #include "remote.h" -#include "string-list.h" #include "thread-utils.h" #include "sigchain.h" #include "argv-array.h"
upload-pack.c +0 -5
@@ -1,19 +1,14 @@ -#include "cache.h" #include "refs.h" #include "pkt-line.h" #include "sideband.h" #include "tag.h" -#include "object.h" -#include "commit.h" #include "exec_cmd.h" -#include "diff.h" #include "revision.h" #include "list-objects.h" #include "run-command.h" #include "connect.h" #include "sigchain.h" #include "version.h" -#include "string-list.h" static const char upload_pack_usage[] ="git upload-pack [--strict] [--timeout=<n>] <dir>" ;
wt-status.c +0 -5
@@ -1,10 +1,6 @@ -#include "cache.h" #include "pathspec.h" #include "wt-status.h" -#include "object.h" #include "dir.h" -#include "commit.h" -#include "diff.h" #include "revision.h" #include "diffcore.h" #include "quote.h"
@@ -14,7 +10,6 @@#include "refs.h" #include "submodule.h" #include "column.h" -#include "strbuf.h" #include "utf8.h" static const char cut_line[] =
Signature · 1 line
2.1.0.30.g0bdc89a
Re: [RFC PATCH 3/3] core: improve header dependencies
Quoted 1 line · David Aguilar
Remove includes that have already been included by another header.
Hmm, I am not sure if that is a good move, and suspect that it is incompatible with what your 2/3 attempts to do, at least at the philosophical level.
I am guessing that your 2/3 wants to see
gcc $header.h
to be happy. One benefit from doing such a change is that sources that want to use declaration made in $header.h have to include that $header.h without having to worry about what other things the implementation detail of $header.h needs. If function F or type T is declared in header H, you include H and you are done.
That is nice and tidy, but if that is the goal, then after making H include its own dependency H1 that happen to declare functions F1, F2 and types T1, T2 (which are necessary for H to be complete as standalone), if the source that used to include both H and H1 because it uses F and F1 should still explicitly include H1, no?
For example, you dropped "diff.h" from builtin/add.c, but the implementation of builtin/add.c needs access to diff_options struct, which is in "diff.h", not whatever happened to include indirectly that is already included by builtin/add.c. I do not think it is a good idea, and more importantly I suspect that it is not consistent with what you tried to do with your 2/3.
But it is entirely possible I am misunderstanding the real motivation behind these changes. The log message justifies why removal is safe i.e. "have already been included indirectly", and the title claims it is an improvement, but there is no explanation why it is an improvement (which would have also explained the motivation behind it), so it is a bit hard for me to guess.
Re: [RFC PATCH 3/3] core: improve header dependencies
Quoted 31 lines · Junio C Hamano
Quoted 1 line · David Aguilar
Remove includes that have already been included by another header.
Hmm, I am not sure if that is a good move, and suspect that it is incompatible with what your 2/3 attempts to do, at least at the philosophical level.
I am guessing that your 2/3 wants to see
gcc $header.h
to be happy. One benefit from doing such a change is that sources that want to use declaration made in $header.h have to include that $header.h without having to worry about what other things the implementation detail of $header.h needs. If function F or type T is declared in header H, you include H and you are done.
That is nice and tidy, but if that is the goal, then after making H include its own dependency H1 that happen to declare functions F1, F2 and types T1, T2 (which are necessary for H to be complete as standalone), if the source that used to include both H and H1 because it uses F and F1 should still explicitly include H1, no?
For example, you dropped "
diff.h" frombuiltin/add.c, but the implementation ofbuiltin/add.cneeds access todiff_optionsstruct, which is in "diff.h", not whatever happened to include indirectly that is already included bybuiltin/add.c. I do not think it is a good idea, and more importantly I suspect that it is not consistent with what you tried to do with your 2/3.
Quoted 6 lines
But it is entirely possible I am misunderstanding the real motivation behind these changes. The log message justifies why removal is safe i.e. "have already been included indirectly", and the title claims it is an improvement, but there is no explanation why it is an improvement (which would have also explained the motivation behind it), so it is a bit hard for me to guess.
The commit messages can certainly be improved.
Patch 2/3 is really a question in patch form:
Should we (a) forward-declare structs in headers that use pointers to those structs, or (b) full-on #include the headers that define those structs?
Making "gcc $header.h" happy might be good but that wasn't the original motivation; approach (b) would satisfy that.
This old (and maybe uneditable these days?) wiki page contains items that were the motivation for these patches:
https://git.wiki.kernel.org/index.php/Janitor
- Some Git headers depend on other headers to compile cleanly, in this case it might be a good idea to include the needed headers in the header that needs them."
- For example "revision.h" depends on "commit.h" and "diff.h", so "revision.h" should include them.
- Of course after that it makes sense to clean up the "*.c" source files that include all these headers, to remove the headers that are no more needed there.
Most importantly, though, is this part:
- Contact the mail list to see how to proceed.
;-)
Patch 3/3 is the item about cleaning up *.c files, but we may want to reformulate these items and take a different approach.
Thoughts?
Signature · 1 line
David
Re: [RFC PATCH 2/3] headers: improve header dependencies
In reply to David AguilarQuoted 1 line · David Aguilar
Add missing includes or forward declarations where needed.
Sorry, but I am not sure what the "missing includes" refers to in the above.
As far as I know, we never aimed to make "gcc -c $header.h" happy. I suspect that that is what you are trying to do here?
Thanks.