Header includes cleanup
cover Header includes cleanup
This is just the beginning for this project. I'm slowly cleaning up the header includes one chunk at a time. I hope my patches aren't too messy, I've learned how to better utilize git to make patches and organize my commits logically so I'll submit neater chunks henceforth. You can expect patches from me nightly until I've finished this project.
Regards,
Nathaniel P Dawson
PATCH 1/5 Header includes cleanup
Deleted all header includes of git-compat-util.h, strbuf.h, cache.h, and commit.h where builtin.h was already included since builtin.h includes them.
--- builtin-add.c | 1 - builtin-annotate.c | 1 - builtin-apply.c | 5 ++--- builtin-archive.c | 1 - builtin-blame.c | 3 --- builtin-branch.c | 5 +---- builtin-bundle.c | 1 - builtin-cat-file.c | 3 +-- builtin-check-attr.c | 1 - builtin-check-ref-format.c | 3 +-- builtin-checkout-index.c | 1 - builtin-checkout.c | 4 +--- builtin-clean.c | 1 - builtin-commit-tree.c | 4 +--- builtin-commit.c | 5 +---- builtin-config.c | 1 - builtin-count-objects.c | 3 +-- builtin-describe.c | 4 +--- builtin-diff-files.c | 4 +--- builtin-diff-index.c | 4 +--- builtin-diff-tree.c | 4 +--- builtin-diff.c | 6 ++---- builtin-fast-export.c | 2 -- builtin-fetch--tool.c | 2 -- builtin-fetch.c | 4 +--- builtin-fmt-merge-msg.c | 2 -- builtin-for-each-ref.c | 6 ++---- builtin-fsck.c | 2 -- builtin-gc.c | 1 - builtin-grep.c | 4 +--- builtin-help.c | 1 - builtin-init-db.c | 1 - builtin-log.c | 4 +--- builtin-ls-files.c | 3 +-- builtin-ls-remote.c | 1 - builtin-ls-tree.c | 4 +--- builtin-mailinfo.c | 2 -- builtin-mailsplit.c | 1 - builtin-merge-base.c | 2 -- builtin-merge-file.c | 1 - builtin-merge-ours.c | 1 - builtin-merge.c | 4 +--- builtin-mv.c | 1 - builtin-name-rev.c | 2 -- builtin-pack-objects.c | 2 -- builtin-prune-packed.c | 1 - builtin-prune.c | 4 +--- builtin-push.c | 3 +-- builtin-read-tree.c | 3 +-- builtin-reflog.c | 2 -- builtin-rerere.c | 1 - builtin-rev-list.c | 6 ++---- builtin-revert.c | 2 -- builtin-rm.c | 1 - builtin-shortlog.c | 2 -- builtin-show-branch.c | 4 +--- builtin-show-ref.c | 1 - builtin-stripspace.c | 1 - builtin-symbolic-ref.c | 1 - builtin-tag.c | 1 - builtin-tar-tree.c | 2 -- builtin-unpack-objects.c | 2 -- builtin-update-index.c | 3 +-- builtin-update-ref.c | 3 +-- builtin-upload-archive.c | 1 - builtin-verify-pack.c | 1 - builtin-verify-tag.c | 1 - builtin-write-tree.c | 1 - diff-no-index.c | 4 +--- fast-import.c | 2 -- git.c | 1 - help.c | 1 - merge-recursive.c | 6 ++---- 73 files changed, 34 insertions(+), 145 deletions(-)
builtin-add.c +0 -1
@@ -3,7 +3,6 @@* * Copyright (C) 2006 Linus Torvalds */ -#include "cache.h" #include "builtin.h" #include "dir.h" #include "exec_cmd.h"
builtin-annotate.c +0 -1
@@ -3,7 +3,6 @@* * Copyright (C) 2006 Ryan Anderson */ -#include "git-compat-util.h" #include "builtin.h" int cmd_annotate (int argc,const char **argv,const char *prefix)
builtin-apply.c +2 -3
@@ -6,12 +6,11 @@* This applies patches on top of some (arbitrary) version of the SCM. * */ -#include "cache.h" +#include "builtin.h" +#include "blob.h" #include "cache-tree.h" #include "quote.h" -#include "blob.h" #include "delta.h" -#include "builtin.h" #include "string-list.h" #include "dir.h" #include "parse-options.h"
builtin-archive.c +0 -1
@@ -2,7 +2,6 @@* Copyright (c) 2006 Franck Bui-Huu * Copyright (c) 2006 Rene Scharfe */ -#include "cache.h" #include "builtin.h" #include "archive.h" #include "parse-options.h"
builtin-blame.c +0 -3
@@ -3,11 +3,8 @@* * Copyright (c) 2006, Junio C Hamano */ - -#include "cache.h" #include "builtin.h" #include "blob.h" -#include "commit.h" #include "tag.h" #include "tree-walk.h" #include "diff.h"
builtin-branch.c +1 -4
@@ -4,12 +4,9 @@* Copyright (c) 2006 Kristian Høgsberg <[email protected]> * Based on git-branch.sh by Junio C Hamano. */ - -#include "cache.h" +#include "builtin.h" #include "color.h" #include "refs.h" -#include "commit.h" -#include "builtin.h" #include "remote.h" #include "parse-options.h" #include "branch.h"
builtin-bundle.c +0 -1
@@ -1,5 +1,4 @@#include "builtin.h" -#include "cache.h" #include "bundle.h" /*
builtin-cat-file.c +1 -2
@@ -3,11 +3,10 @@* * Copyright (C) Linus Torvalds, 2005 */ -#include "cache.h" +#include "builtin.h" #include "exec_cmd.h" #include "tag.h" #include "tree.h" -#include "builtin.h" #include "parse-options.h" #define BATCH 1
builtin-check-attr.c +0 -1
@@ -1,5 +1,4 @@#include "builtin.h" -#include "cache.h" #include "attr.h" #include "quote.h" #include "parse-options.h"
builtin-check-ref-format.c +1 -2
@@ -2,9 +2,8 @@* GIT - The information manager from hell */ -#include "cache.h" -#include "refs.h" #include "builtin.h" +#include "refs.h" int cmd_check_ref_format (int argc,const char **argv,const char *prefix) {
builtin-checkout-index.c +0 -1
@@ -37,7 +37,6 @@* but get used to it in scripting!). */ #include "builtin.h" -#include "cache.h" #include "quote.h" #include "cache-tree.h" #include "parse-options.h"
builtin-checkout.c +1 -3
@@ -1,8 +1,7 @@ -#include "cache.h" #include "builtin.h" +#include "blob.h" #include "parse-options.h" #include "refs.h" -#include "commit.h" #include "tree.h" #include "tree-walk.h" #include "unpack-trees.h"
@@ -13,7 +12,6 @@#include "diff.h" #include "revision.h" #include "remote.h" -#include "blob.h" #include "xdiff-interface.h" #include "ll-merge.h"
builtin-clean.c +0 -1
@@ -7,7 +7,6 @@*/ #include "builtin.h" -#include "cache.h" #include "dir.h" #include "parse-options.h" #include "quote.h"
builtin-commit-tree.c +1 -3
@@ -3,10 +3,8 @@* * Copyright (C) Linus Torvalds, 2005 */ -#include "cache.h" -#include "commit.h" -#include "tree.h" #include "builtin.h" +#include "tree.h" #include "utf8.h" #define BLOCKING (1ul << 14)
builtin-commit.c +1 -4
@@ -5,20 +5,17 @@* Based on git-commit.sh by Junio C Hamano and Linus Torvalds */ -#include "cache.h" +#include "builtin.h" #include "cache-tree.h" #include "color.h" #include "dir.h" -#include "builtin.h" #include "diff.h" #include "diffcore.h" -#include "commit.h" #include "revision.h" #include "wt-status.h" #include "run-command.h" #include "refs.h" #include "log-tree.h" -#include "strbuf.h" #include "utf8.h" #include "parse-options.h" #include "string-list.h"
builtin-config.c +0 -1
@@ -1,5 +1,4 @@#include "builtin.h" -#include "cache.h" #include "color.h" #include "parse-options.h"
builtin-count-objects.c +1 -2
@@ -4,9 +4,8 @@* Copyright (c) 2006 Junio C Hamano */ -#include "cache.h" -#include "dir.h" #include "builtin.h" +#include "dir.h" #include "parse-options.h" static void count_objects(DIR *d, char *path, int len, int verbose,
builtin-describe.c +1 -3
@@ -1,8 +1,6 @@ -#include "cache.h" -#include "commit.h" +#include "builtin.h" #include "tag.h" #include "refs.h" -#include "builtin.h" #include "exec_cmd.h" #include "parse-options.h"
builtin-diff-files.c +1 -3
@@ -3,11 +3,9 @@* * Copyright (C) Linus Torvalds, 2005 */ -#include "cache.h" +#include "builtin.h" #include "diff.h" -#include "commit.h" #include "revision.h" -#include "builtin.h" static const char diff_files_usage[] ="git diff-files [-q] [-0/-1/2/3 |-c|--cc] [<common diff options>] [<path>...]"
builtin-diff-index.c +1 -3
@@ -1,8 +1,6 @@ -#include "cache.h" +#include "builtin.h" #include "diff.h" -#include "commit.h" #include "revision.h" -#include "builtin.h" static const char diff_cache_usage[] ="git diff-index [-m] [--cached] "
builtin-diff-tree.c +1 -3
@@ -1,8 +1,6 @@ -#include "cache.h" +#include "builtin.h" #include "diff.h" -#include "commit.h" #include "log-tree.h" -#include "builtin.h" static struct rev_info log_tree_opt;
builtin-diff.c +2 -4
@@ -3,16 +3,14 @@* * Copyright (c) 2006 Junio C Hamano */ -#include "cache.h" -#include "color.h" -#include "commit.h" +#include "builtin.h" #include "blob.h" +#include "color.h" #include "tag.h" #include "diff.h" #include "diffcore.h" #include "revision.h" #include "log-tree.h" -#include "builtin.h" struct blobinfo {unsigned char sha1[20 ];
builtin-fast-export.c +0 -2
@@ -4,8 +4,6 @@* Copyright (C) 2007 Johannes E. Schindelin */ #include "builtin.h" -#include "cache.h" -#include "commit.h" #include "object.h" #include "tag.h" #include "diff.h"
builtin-fetch--tool.c +0 -2
@@ -1,7 +1,5 @@#include "builtin.h" -#include "cache.h" #include "refs.h" -#include "commit.h" #include "sigchain.h" static char *get_stdin (void )
builtin-fetch.c +1 -3
@@ -1,10 +1,8 @@/* * "git fetch" */ -#include "cache.h" -#include "refs.h" -#include "commit.h" #include "builtin.h" +#include "refs.h" #include "string-list.h" #include "remote.h" #include "transport.h"
builtin-fmt-merge-msg.c +0 -2
@@ -1,6 +1,4 @@#include "builtin.h" -#include "cache.h" -#include "commit.h" #include "diff.h" #include "revision.h" #include "tag.h"
builtin-for-each-ref.c +2 -4
@@ -1,11 +1,9 @@#include "builtin.h" -#include "cache.h" -#include "refs.h" +#include "blob.h" #include "object.h" +#include "refs.h" #include "tag.h" -#include "commit.h" #include "tree.h" -#include "blob.h" #include "quote.h" #include "parse-options.h"
builtin-fsck.c +0 -2
@@ -1,6 +1,4 @@#include "builtin.h" -#include "cache.h" -#include "commit.h" #include "tree.h" #include "blob.h" #include "tag.h"
builtin-gc.c +0 -1
@@ -11,7 +11,6 @@*/ #include "builtin.h" -#include "cache.h" #include "parse-options.h" #include "run-command.h"
builtin-grep.c +1 -3
@@ -3,13 +3,11 @@* * Copyright (c) 2006 Junio C Hamano */ -#include "cache.h" +#include "builtin.h" #include "blob.h" #include "tree.h" -#include "commit.h" #include "tag.h" #include "tree-walk.h" -#include "builtin.h" #include "grep.h" #ifndef NO_EXTERNAL_GREP
builtin-help.c +0 -1
@@ -3,7 +3,6 @@* * Builtin help command */ -#include "cache.h" #include "builtin.h" #include "exec_cmd.h" #include "common-cmds.h"
builtin-init-db.c +0 -1
@@ -3,7 +3,6 @@* * Copyright (C) Linus Torvalds, 2005 */ -#include "cache.h" #include "builtin.h" #include "exec_cmd.h"
builtin-log.c +1 -3
@@ -4,13 +4,11 @@* (C) Copyright 2006 Linus Torvalds * 2006 Junio Hamano */ -#include "cache.h" +#include "builtin.h" #include "color.h" -#include "commit.h" #include "diff.h" #include "revision.h" #include "log-tree.h" -#include "builtin.h" #include "tag.h" #include "reflog-walk.h" #include "patch-ids.h"
builtin-ls-files.c +1 -2
@@ -5,10 +5,9 @@* * Copyright (C) Linus Torvalds, 2005 */ -#include "cache.h" +#include "builtin.h" #include "quote.h" #include "dir.h" -#include "builtin.h" #include "tree.h" #include "parse-options.h"
builtin-ls-remote.c +0 -1
@@ -1,5 +1,4 @@#include "builtin.h" -#include "cache.h" #include "transport.h" #include "remote.h"
builtin-ls-tree.c +1 -3
@@ -3,12 +3,10 @@* * Copyright (C) Linus Torvalds, 2005 */ -#include "cache.h" +#include "builtin.h" #include "blob.h" #include "tree.h" -#include "commit.h" #include "quote.h" -#include "builtin.h" static int line_termination ='\n' ;#define LS_RECURSIVE 1
builtin-mailinfo.c +0 -2
@@ -2,10 +2,8 @@* Another stupid program, this one parsing the headers of an * email to figure out authorship and subject */ -#include "cache.h" #include "builtin.h" #include "utf8.h" -#include "strbuf.h" static FILE *cmitmsg, *patchfile, *fin, *fout;
builtin-mailsplit.c +0 -1
@@ -4,7 +4,6 @@* It just splits a mbox into a list of files: "0001" "0002" .. * so you can process them further from there. */ -#include "cache.h" #include "builtin.h" #include "string-list.h"
builtin-merge-base.c +0 -2
@@ -1,6 +1,4 @@#include "builtin.h" -#include "cache.h" -#include "commit.h" #include "parse-options.h" static int show_merge_base (struct commit **rev,int rev_nr,int show_all)
builtin-merge-file.c +0 -1
@@ -1,5 +1,4 @@#include "builtin.h" -#include "cache.h" #include "xdiff/xdiff.h" #include "xdiff-interface.h" #include "parse-options.h"
builtin-merge-ours.c +0 -1
@@ -7,7 +7,6 @@* * Pretend we resolved the heads, but declare our tree trumps everybody else. */ -#include "git-compat-util.h" #include "builtin.h" static const char *diff_index_args[] = {
builtin-merge.c +1 -3
@@ -6,13 +6,11 @@* Based on git-merge.sh by Junio C Hamano. */ -#include "cache.h" -#include "parse-options.h" #include "builtin.h" +#include "parse-options.h" #include "run-command.h" #include "diff.h" #include "refs.h" -#include "commit.h" #include "diffcore.h" #include "revision.h" #include "unpack-trees.h"
builtin-mv.c +0 -1
@@ -3,7 +3,6 @@* * Copyright (C) 2006 Johannes Schindelin */ -#include "cache.h" #include "builtin.h" #include "dir.h" #include "cache-tree.h"
builtin-name-rev.c +0 -2
@@ -1,6 +1,4 @@#include "builtin.h" -#include "cache.h" -#include "commit.h" #include "tag.h" #include "refs.h" #include "parse-options.h"
builtin-pack-objects.c +0 -2
@@ -1,9 +1,7 @@#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"
builtin-prune-packed.c +0 -1
@@ -1,5 +1,4 @@#include "builtin.h" -#include "cache.h" #include "progress.h" static const char prune_packed_usage[] =
builtin-prune.c +1 -3
@@ -1,8 +1,6 @@ -#include "cache.h" -#include "commit.h" +#include "builtin.h" #include "diff.h" #include "revision.h" -#include "builtin.h" #include "reachable.h" #include "parse-options.h" #include "dir.h"
builtin-push.c +1 -2
@@ -1,10 +1,9 @@/* * "git push" */ -#include "cache.h" +#include "builtin.h" #include "refs.h" #include "run-command.h" -#include "builtin.h" #include "remote.h" #include "transport.h" #include "parse-options.h"
builtin-read-tree.c +1 -2
@@ -4,14 +4,13 @@* Copyright (C) Linus Torvalds, 2005 */ -#include "cache.h" +#include "builtin.h" #include "object.h" #include "tree.h" #include "tree-walk.h" #include "cache-tree.h" #include "unpack-trees.h" #include "dir.h" -#include "builtin.h" static int nr_trees;static struct tree *trees[MAX_UNPACK_TREES ];
builtin-reflog.c +0 -2
@@ -1,6 +1,4 @@ -#include "cache.h" #include "builtin.h" -#include "commit.h" #include "refs.h" #include "dir.h" #include "tree-walk.h"
builtin-rerere.c +0 -1
@@ -1,5 +1,4 @@#include "builtin.h" -#include "cache.h" #include "dir.h" #include "string-list.h" #include "rerere.h"
builtin-rev-list.c +2 -4
@@ -1,14 +1,12 @@ -#include "cache.h" +#include "builtin.h" +#include "blob.h" #include "refs.h" #include "tag.h" -#include "commit.h" #include "tree.h" -#include "blob.h" #include "tree-walk.h" #include "diff.h" #include "revision.h" #include "list-objects.h" -#include "builtin.h" #include "log-tree.h" #include "graph.h"
builtin-revert.c +0 -2
@@ -1,7 +1,5 @@ -#include "cache.h" #include "builtin.h" #include "object.h" -#include "commit.h" #include "tag.h" #include "wt-status.h" #include "run-command.h"
builtin-rm.c +0 -1
@@ -3,7 +3,6 @@* * Copyright (C) Linus Torvalds 2006 */ -#include "cache.h" #include "builtin.h" #include "dir.h" #include "cache-tree.h"
builtin-shortlog.c +0 -2
@@ -1,6 +1,4 @@#include "builtin.h" -#include "cache.h" -#include "commit.h" #include "diff.h" #include "string-list.h" #include "revision.h"
builtin-show-branch.c +1 -3
@@ -1,7 +1,5 @@ -#include "cache.h" -#include "commit.h" -#include "refs.h" #include "builtin.h" +#include "refs.h" static const char show_branch_usage[] ="git show-branch [--sparse] [--current] [--all] [--remotes] [--topo-order] [--more=count | --list | --independent | --merge-base ] [--topics] [<refs>...] | --reflog[=n[,b]] <branch>" ;
builtin-show-ref.c +0 -1
@@ -1,5 +1,4 @@#include "builtin.h" -#include "cache.h" #include "refs.h" #include "object.h" #include "tag.h"
builtin-stripspace.c +0 -1
@@ -1,5 +1,4 @@#include "builtin.h" -#include "cache.h" /* * Returns the length of a line, without trailing spaces.
builtin-symbolic-ref.c +0 -1
@@ -1,5 +1,4 @@#include "builtin.h" -#include "cache.h" #include "refs.h" #include "parse-options.h"
builtin-tag.c +0 -1
@@ -6,7 +6,6 @@* Based on git-tag.sh and mktag.c by Linus Torvalds. */ -#include "cache.h" #include "builtin.h" #include "refs.h" #include "tag.h"
builtin-tar-tree.c +0 -2
@@ -1,8 +1,6 @@/* * Copyright (c) 2005, 2006 Rene Scharfe */ -#include "cache.h" -#include "commit.h" #include "tar.h" #include "builtin.h" #include "quote.h"
builtin-unpack-objects.c +0 -2
@@ -1,10 +1,8 @@#include "builtin.h" -#include "cache.h" #include "object.h" #include "delta.h" #include "pack.h" #include "blob.h" -#include "commit.h" #include "tag.h" #include "tree.h" #include "tree-walk.h"
builtin-update-index.c +1 -2
@@ -3,11 +3,10 @@* * Copyright (C) Linus Torvalds, 2005 */ -#include "cache.h" +#include "builtin.h" #include "quote.h" #include "cache-tree.h" #include "tree-walk.h" -#include "builtin.h" #include "refs.h" /*
builtin-update-ref.c +1 -2
@@ -1,6 +1,5 @@ -#include "cache.h" -#include "refs.h" #include "builtin.h" +#include "refs.h" #include "parse-options.h" static const char *const git_update_ref_usage[] = {
builtin-upload-archive.c +0 -1
@@ -1,7 +1,6 @@/* * Copyright (c) 2006 Franck Bui-Huu */ -#include "cache.h" #include "builtin.h" #include "archive.h" #include "pkt-line.h"
builtin-verify-pack.c +0 -1
@@ -1,5 +1,4 @@#include "builtin.h" -#include "cache.h" #include "pack.h" #include "pack-revindex.h"
builtin-verify-tag.c +0 -1
@@ -5,7 +5,6 @@* * Based on git-verify-tag.sh */ -#include "cache.h" #include "builtin.h" #include "tag.h" #include "run-command.h"
builtin-write-tree.c +0 -1
@@ -4,7 +4,6 @@* Copyright (C) Linus Torvalds, 2005 */ #include "builtin.h" -#include "cache.h" #include "tree.h" #include "cache-tree.h"
diff-no-index.c +1 -3
@@ -4,16 +4,14 @@* Copyright (c) 2008 by Junio C Hamano */ -#include "cache.h" +#include "builtin.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" static int read_directory (const char *path,struct string_list *list)
fast-import.c +0 -2
@@ -141,11 +141,9 @@ Format of STDIN stream:*/ #include "builtin.h" -#include "cache.h" #include "object.h" #include "blob.h" #include "tree.h" -#include "commit.h" #include "delta.h" #include "pack.h" #include "refs.h"
git.c +0 -1
@@ -1,6 +1,5 @@#include "builtin.h" #include "exec_cmd.h" -#include "cache.h" #include "quote.h" #include "run-command.h"
help.c +0 -1
@@ -1,4 +1,3 @@ -#include "cache.h" #include "builtin.h" #include "exec_cmd.h" #include "levenshtein.h"
merge-recursive.c +2 -4
@@ -3,11 +3,9 @@* Fredrik Kuivinen. * The thieves were Alex Riesen and Johannes Schindelin, in June/July 2006 */ -#include "cache.h" -#include "cache-tree.h" -#include "commit.h" -#include "blob.h" #include "builtin.h" +#include "blob.h" +#include "cache-tree.h" #include "tree-walk.h" #include "diff.h" #include "diffcore.h"
Signature · 1 line
1.6.1.3
PATCH 2/5 Header includes cleanup
Deleted header includes of object.h where blob.h was included since blob.h includes it.
--- alloc.c | 1 - builtin-for-each-ref.c | 1 - builtin-pack-objects.c | 1 - builtin-unpack-objects.c | 3 +-- fast-import.c | 1 - fsck.c | 1 - object.c | 1 - 7 files changed, 1 insertions(+), 8 deletions(-)
alloc.c +0 -1
@@ -10,7 +10,6 @@* for the new allocation is. */ #include "cache.h" -#include "object.h" #include "blob.h" #include "tree.h" #include "commit.h"
builtin-for-each-ref.c +0 -1
@@ -1,6 +1,5 @@#include "builtin.h" #include "blob.h" -#include "object.h" #include "refs.h" #include "tag.h" #include "tree.h"
builtin-pack-objects.c +0 -1
@@ -1,6 +1,5 @@#include "builtin.h" #include "attr.h" -#include "object.h" #include "blob.h" #include "tag.h" #include "tree.h"
builtin-unpack-objects.c +1 -2
@@ -1,8 +1,7 @@#include "builtin.h" -#include "object.h" +#include "blob.h" #include "delta.h" #include "pack.h" -#include "blob.h" #include "tag.h" #include "tree.h" #include "tree-walk.h"
fast-import.c +0 -1
@@ -141,7 +141,6 @@ Format of STDIN stream:*/ #include "builtin.h" -#include "object.h" #include "blob.h" #include "tree.h" #include "delta.h"
fsck.c +0 -1
@@ -1,5 +1,4 @@#include "cache.h" -#include "object.h" #include "blob.h" #include "tree.h" #include "tree-walk.h"
object.c +0 -1
@@ -1,5 +1,4 @@#include "cache.h" -#include "object.h" #include "blob.h" #include "tree.h" #include "commit.h"
Signature · 1 line
1.6.1.3
PATCH 3/5 Header includes cleanup
Deleted header includes of git-compat-util.h, strbuf.h, hash.h where cache.h was included since cache.h includes them.
--- builtin-clone.c | 1 - builtin-remote.c | 1 - connect.c | 1 - diffcore-rename.c | 1 - editor.c | 1 - hash.c | 1 - parse-options.c | 3 +-- shell.c | 1 - test-delta.c | 3 +-- 9 files changed, 2 insertions(+), 11 deletions(-)
builtin-clone.c +0 -1
@@ -16,7 +16,6 @@#include "tree-walk.h" #include "unpack-trees.h" #include "transport.h" -#include "strbuf.h" #include "dir.h" #include "pack-refs.h" #include "sigchain.h"
builtin-remote.c +0 -1
@@ -3,7 +3,6 @@#include "transport.h" #include "remote.h" #include "string-list.h" -#include "strbuf.h" #include "run-command.h" #include "refs.h"
connect.c +0 -1
@@ -1,4 +1,3 @@ -#include "git-compat-util.h" #include "cache.h" #include "pkt-line.h" #include "quote.h"
diffcore-rename.c +0 -1
@@ -4,7 +4,6 @@#include "cache.h" #include "diff.h" #include "diffcore.h" -#include "hash.h" /* Table of rename/copy destinations */
editor.c +0 -1
@@ -1,5 +1,4 @@#include "cache.h" -#include "strbuf.h" #include "run-command.h" int launch_editor (const char *path,struct strbuf *buffer,const char *const *env)
hash.c +0 -1
@@ -2,7 +2,6 @@* Some generic hashing helpers. */ #include "cache.h" -#include "hash.h" /* * Look up a hash entry in the hash table. Return the pointer to
parse-options.c +1 -2
@@ -1,6 +1,5 @@ -#include "git-compat-util.h" -#include "parse-options.h" #include "cache.h" +#include "parse-options.h" #include "commit.h" #define OPT_SHORT 1
shell.c +0 -1
@@ -1,7 +1,6 @@#include "cache.h" #include "quote.h" #include "exec_cmd.h" -#include "strbuf.h" static int do_generic_cmd (const char *me,char *arg) {
test-delta.c +1 -2
@@ -8,9 +8,8 @@* published by the Free Software Foundation. */ -#include "git-compat-util.h" -#include "delta.h" #include "cache.h" +#include "delta.h" static const char usage_str[] ="test-delta (-d|-p) <from_file> <data_file> <out_file>" ;
Signature · 1 line
1.6.1.3
PATCH 4/5 Header includes cleanup
Deleted header includes of object.h, tree.h, strbuf.h, and decorate.h where commit.h was included since commit.h includes them.
--- alloc.c | 1 - builtin-receive-pack.c | 1 - builtin-reset.c | 2 -- builtin.h | 2 -- bundle.c | 1 - fsck.c | 3 +-- index-pack.c | 1 - list-objects.c | 1 - object.c | 1 - read-cache.c | 1 - revision.c | 2 -- server-info.c | 1 - sha1_file.c | 1 - sha1_name.c | 1 - tag.c | 1 - tree.c | 3 +-- upload-pack.c | 1 - walker.c | 1 - wt-status.c | 3 +-- 19 files changed, 3 insertions(+), 25 deletions(-)
alloc.c +0 -1
@@ -11,7 +11,6 @@*/ #include "cache.h" #include "blob.h" -#include "tree.h" #include "commit.h" #include "tag.h"
builtin-receive-pack.c +0 -1
@@ -5,7 +5,6 @@#include "run-command.h" #include "exec_cmd.h" #include "commit.h" -#include "object.h" #include "remote.h" #include "transport.h"
builtin-reset.c +0 -2
@@ -9,13 +9,11 @@*/ #include "cache.h" #include "tag.h" -#include "object.h" #include "commit.h" #include "run-command.h" #include "refs.h" #include "diff.h" #include "diffcore.h" -#include "tree.h" #include "branch.h" #include "parse-options.h"
builtin.h +0 -2
@@ -1,8 +1,6 @@#ifndef BUILTIN_H #define BUILTIN_H -#include "git-compat-util.h" -#include "strbuf.h" #include "cache.h" #include "commit.h"
bundle.c +0 -1
@@ -1,6 +1,5 @@#include "cache.h" #include "bundle.h" -#include "object.h" #include "commit.h" #include "diff.h" #include "revision.h"
fsck.c +1 -2
@@ -1,8 +1,7 @@#include "cache.h" #include "blob.h" -#include "tree.h" -#include "tree-walk.h" #include "commit.h" +#include "tree-walk.h" #include "tag.h" #include "fsck.h"
index-pack.c +0 -1
@@ -5,7 +5,6 @@#include "blob.h" #include "commit.h" #include "tag.h" -#include "tree.h" #include "progress.h" #include "fsck.h" #include "exec_cmd.h"
list-objects.c +0 -1
@@ -1,7 +1,6 @@#include "cache.h" #include "tag.h" #include "commit.h" -#include "tree.h" #include "blob.h" #include "diff.h" #include "tree-walk.h"
object.c +0 -1
@@ -1,6 +1,5 @@#include "cache.h" #include "blob.h" -#include "tree.h" #include "commit.h" #include "tag.h"
read-cache.c +0 -1
@@ -8,7 +8,6 @@#include "cache-tree.h" #include "refs.h" #include "dir.h" -#include "tree.h" #include "commit.h" #include "diff.h" #include "diffcore.h"
revision.c +0 -2
@@ -1,7 +1,6 @@#include "cache.h" #include "tag.h" #include "blob.h" -#include "tree.h" #include "commit.h" #include "diff.h" #include "refs.h"
@@ -10,7 +9,6 @@#include "grep.h" #include "reflog-walk.h" #include "patch-ids.h" -#include "decorate.h" #include "log-tree.h" volatile show_early_output_fn_t show_early_output;
server-info.c +0 -1
@@ -1,6 +1,5 @@#include "cache.h" #include "refs.h" -#include "object.h" #include "commit.h" #include "tag.h"
sha1_file.c +0 -1
@@ -12,7 +12,6 @@#include "blob.h" #include "commit.h" #include "tag.h" -#include "tree.h" #include "refs.h" #include "pack-revindex.h" #include "sha1-lookup.h"
sha1_name.c +0 -1
@@ -1,7 +1,6 @@#include "cache.h" #include "tag.h" #include "commit.h" -#include "tree.h" #include "blob.h" #include "tree-walk.h" #include "refs.h"
tag.c +0 -1
@@ -1,7 +1,6 @@#include "cache.h" #include "tag.h" #include "commit.h" -#include "tree.h" #include "blob.h" const char *tag_type ="tag" ;
tree.c +1 -2
@@ -1,8 +1,7 @@#include "cache.h" #include "cache-tree.h" -#include "tree.h" -#include "blob.h" #include "commit.h" +#include "blob.h" #include "tag.h" #include "tree-walk.h"
upload-pack.c +0 -1
@@ -3,7 +3,6 @@#include "pkt-line.h" #include "sideband.h" #include "tag.h" -#include "object.h" #include "commit.h" #include "exec_cmd.h" #include "diff.h"
walker.c +0 -1
@@ -1,7 +1,6 @@#include "cache.h" #include "walker.h" #include "commit.h" -#include "tree.h" #include "tree-walk.h" #include "tag.h" #include "blob.h"
wt-status.c +1 -2
@@ -1,9 +1,8 @@#include "cache.h" #include "wt-status.h" #include "color.h" -#include "object.h" -#include "dir.h" #include "commit.h" +#include "dir.h" #include "diff.h" #include "revision.h" #include "diffcore.h"
Signature · 1 line
1.6.1.3
PATCH 5/5 Header includes cleanup
Deleted header includes of tree-walk.h where diff.h was included since diff.h includes it.
--- builtin-blame.c | 1 - builtin-checkout.c | 3 +-- builtin-pack-objects.c | 1 - builtin-reflog.c | 1 - builtin-rev-list.c | 1 - list-objects.c | 1 - merge-recursive.c | 1 - 7 files changed, 1 insertions(+), 8 deletions(-)
builtin-blame.c +0 -1
@@ -6,7 +6,6 @@#include "builtin.h" #include "blob.h" #include "tag.h" -#include "tree-walk.h" #include "diff.h" #include "diffcore.h" #include "revision.h"
builtin-checkout.c +1 -2
@@ -3,13 +3,12 @@#include "parse-options.h" #include "refs.h" #include "tree.h" -#include "tree-walk.h" +#include "diff.h" #include "unpack-trees.h" #include "dir.h" #include "run-command.h" #include "merge-recursive.h" #include "branch.h" -#include "diff.h" #include "revision.h" #include "remote.h" #include "xdiff-interface.h"
builtin-pack-objects.c +0 -1
@@ -7,7 +7,6 @@#include "pack.h" #include "pack-revindex.h" #include "csum-file.h" -#include "tree-walk.h" #include "diff.h" #include "revision.h" #include "list-objects.h"
builtin-reflog.c +0 -1
@@ -1,7 +1,6 @@#include "builtin.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 -1
@@ -3,7 +3,6 @@#include "refs.h" #include "tag.h" #include "tree.h" -#include "tree-walk.h" #include "diff.h" #include "revision.h" #include "list-objects.h"
list-objects.c +0 -1
@@ -3,7 +3,6 @@#include "commit.h" #include "blob.h" #include "diff.h" -#include "tree-walk.h" #include "revision.h" #include "list-objects.h"
merge-recursive.c +0 -1
@@ -6,7 +6,6 @@#include "builtin.h" #include "blob.h" #include "cache-tree.h" -#include "tree-walk.h" #include "diff.h" #include "diffcore.h" #include "tag.h"
Signature · 1 line
1.6.1.3
Please wrap your lines at ca. 75 columns.
Quoted 5 lines · Nathaniel P Dawson
This is just the beginning for this project. I'm slowly cleaning up the header includes one chunk at a time. I hope my patches aren't too messy, I've learned how to better utilize git to make patches and organize my commits logically so I'll submit neater chunks henceforth. You can expect patches from me nightly until I've finished this project.
You have removed includes that are implied by other includes, i.e. if foo.h includes bar.h, then you removed #include "bar.h" from *.c if there is #include "foo.h".
IMO, this is not a good guiding principle to reduce includes. A better principle is to keep #include "bar.h" in a source or header file iff a feature that is declared or defined in bar.h is *used* *directly* in that source or header file, regardless of whether bar.h is included in foo.h that is itself included in that source or header file.
If this latter principle is obeyed, then the build won't break by removing the include of foo.h (for the reason that nothing of foo.h is *use* *directly* anymore).
-- Hannes
I'm sorry, I must have misunderstood the task on the janitor list. Could you explain it a bit better so I would be able to do it properly?
And as for line wrapping I apologize, emacs on my laptop was apparently not turning on auto-fill but has been rectified.
Regards,
Nathaniel P Dawson
Quoted 25 lines · Johannes Sixt
Please wrap your lines at ca. 75 columns.
Quoted 5 lines · Nathaniel P Dawson
This is just the beginning for this project. I'm slowly cleaning up the header includes one chunk at a time. I hope my patches aren't too messy, I've learned how to better utilize git to make patches and organize my commits logically so I'll submit neater chunks henceforth. You can expect patches from me nightly until I've finished this project.
You have removed includes that are implied by other includes, i.e. if
foo.hincludesbar.h, then you removed #include "bar.h" from *.c if there is #include "foo.h".IMO, this is not a good guiding principle to reduce includes. A better principle is to keep #include "
bar.h" in a source or header file iff a feature that is declared or defined inbar.his *used* *directly* in that source or header file, regardless of whetherbar.his included infoo.hthat is itself included in that source or header file.If this latter principle is obeyed, then the build won't break by removing the include of
foo.h(for the reason that nothing offoo.his *use* *directly* anymore).-- Hannes
Quoted 3 lines · Nathaniel P Dawson
I'm sorry, I must have misunderstood the task on the janitor list. Could you explain it a bit better so I would be able to do it properly?
Actually I added this task to the Janitor page on the wiki because I was tired of having to find which other includes are needed each time I include "revision.h". And I think there are other worthwile include cleanup that could be done.
I think it's a good thing that you started working on it even if in the end we decide that we want these cleanup to be done otherwise. At least we will hopefully have clarified our include header policy.
Thanks,
Christian.
Quoted 14 lines · Johannes Sixt
Please wrap your lines at ca. 75 columns.
Quoted 6 lines · Nathaniel P Dawson
This is just the beginning for this project. I'm slowly cleaning up the header includes one chunk at a time. I hope my patches aren't too messy, I've learned how to better utilize git to make patches and organize my commits logically so I'll submit neater chunks henceforth. You can expect patches from me nightly until I've finished this project.
You have removed includes that are implied by other includes, i.e. if
foo.hincludesbar.h, then you removed #include "bar.h" from *.c if there is #include "foo.h".
Quoted 5 lines
IMO, this is not a good guiding principle to reduce includes. A better principle is to keep #include "
bar.h" in a source or header file iff a feature that is declared or defined inbar.his *used* *directly* in that source or header file, regardless of whetherbar.his included infoo.hthat is itself included in that source or header file.
In theory, it's perhaps the best way to do it. But we don't do that for system header includes. And I think it makes it very difficult to cleanup header includes, because you have to check what is needed for each feature in a file. So I think we have to choose between basically no header include cleanup or a cleanup like the one Nathaniel started.
Quoted 3 lines
If this latter principle is obeyed, then the build won't break by removing the include of
foo.h(for the reason that nothing offoo.his *use* *directly* anymore).
I think it's more likely that we will add features rather than remove some. And it's not very difficult if we remove some, to remove "foo.h" and add "bar.h" at the same time.
For example, many files include "cache.h", does it really make sense to try to remove these #include because we could replace them by only includes of "git-compat-util.h" and "hash.h"? I don't think so.
Best regards,
Christian.
Quoted 3 lines · Christian Couder
I think it's a good thing that you started working on it even if in the end we decide that we want these cleanup to be done otherwise. At least we will hopefully have clarified our include header policy.
Before seeing a lot of patches to change #include all over the place, I'd like to see a simple guiding principle described, not just a subjective "I think this makes things better" but with "... because of X and Y and Z".
The document Documentation/CodingGuidelines describes the only policy that exists currently: git-compat-util.h must be the first thing the compiler sees. The language should probably be stronger than what appears there:
- The first #include in C files, except in platform specific compat/ implementations, should be git-compat-util.h or another well-known header file that includes it at the beginning, namely cache.h or builtin.h.
Even though http.h may include "cache.h" at the very beginning, I'd rather not to see http-walker.c lose inclusion of "cache.h". It will force us to remember that http.h is Ok to include as the first file, and that won't scale.
The reason git-compat-util.h must be the first is because inclusion of all the system header files is supposed to happen there, and there are some platforms that have broken system header dependencies we do not want application writers to care about, and the compat-util header knows about them.
Quoted 25 lines · Junio C Hamano
Quoted 3 lines · Christian Couder
I think it's a good thing that you started working on it even if in the end we decide that we want these cleanup to be done otherwise. At least we will hopefully have clarified our include header policy.
Before seeing a lot of patches to change #include all over the place, I'd like to see a simple guiding principle described, not just a subjective "I think this makes things better" but with "... because of X and Y and Z".
The document
Documentation/CodingGuidelinesdescribes the only policy that exists currently:git-compat-util.hmust be the first thing the compiler sees. The language should probably be stronger than what appears there:- The first #include in C files, except in platform specific compat/ implementations, should be
git-compat-util.hor another well-known header file that includes it at the beginning, namelycache.horbuiltin.h.Even though
http.hmay include "cache.h" at the very beginning, I'd rather not to seehttp-walker.close inclusion of "cache.h". It will force us to remember thathttp.his Ok to include as the first file, and that won't scale.
Quoted 5 lines
The reason
git-compat-util.hmust be the first is because inclusion of all the system header files is supposed to happen there, and there are some platforms that have broken system header dependencies we do not want application writers to care about, and the compat-util header knows about them.
Ok, so I suggest the following simple guiding principles:
- git-compat-util.h or cache.h or builtin.h should always be the first #include in C files,
- header files should include other incude files if and only if the other includes are needed to compile them,
- a header file should be included in a C file only if it is needed to compile the C file (it is not ok to include it only because it includes many other headers that are needed)
- other than the above rules, it is ok to reduce the number of includes as much as possible
What do you think?
By the way, Nathaniel, you should try to give more meaningful titles to the individual patches in your patch series and perhaps make them smaller so that they are easier to review and have less conflicts with other patches.
For example your patch "[PATCH 1/5] Header includes cleanup" could be splitted and the resulting patches could be renamed like this
"delete includes of 'git-compat-util.h' where 'builtin.h' is included" "delete includes of 'cache.h' where 'builtin.h' is included" "delete includes of 'strbuf.h' where 'builtin.h' is included" "delete includes of 'commit.h' where 'builtin.h' is included"
Or perhaps Junio would prefer that you work on a C file by C file basis? Like for example:
"delete useless includes in 'builtin-diff-files.c'" "delete useless includes in 'builtin-diff-index.c'"
...
Thanks,
Christian.
Quoted 7 lines · Christian Couder
Ok, so I suggest the following simple guiding principles:
-
git-compat-util.horcache.horbuiltin.hshould always be the first #include in C files,- header files should include other incude files if and only if the other includes are needed to compile them,
This is unclear.
Long before I started touching git, I used to be religious about making header files self contained. For a header file frotz.h in the project, I used to insist that
$ cat >1.c <<\EOF
#include "frotz.h"
EOF
$ cc -Wall -c 1.cdid not fail.
Are you talking about that by "to compile them"?
I stopped doing that long time ago, partly because the rule was cumbersome to enforce, but primarily because it was not helping much in the larger picture.
Such a rule, together with strict rules such as the order of including other header files in the header files themselves, may make life easier for programmers who touch .c files but never .h files, because they can include only the necessary .h files and in any order. But in practice, people need to touch both .h and .c files and when they need to include new system header files, they need to follow the inclusion order rule somewhere anyway---at that point, it does not matter much if the rule applies to only .h files or both .h and .c files.
So for example, you cannot compile
$ cat >1.c <<\EOF
#include "revision.h"
EOF
$ cc -Wll -c 1.cin git.git project, but I do not think it is a problem.
Quoted 3 lines
- a header file should be included in a C file only if it is needed to compile the C file (it is not ok to include it only because it includes many other headers that are needed)
If that is the rule, perhaps the problem lies not in a .c program that includes such a .h header, but in the .h itself that includes many other header files.
Quoted 4 lines
- other than the above rules, it is ok to reduce the number of includes as much as possible
What do you think?
What you did not write and I forgot to mention, which is a logical conclusion of the first rule, is that C files should not directly include common system header files such as unistd, sys/stat, etc.
There are exceptions to any rule. For example, inclusion of syslog.h in daemon.c is OK because most of the rest of the system does not even use syslog. If we later find a platform whose syslog.h has some funny inter-header dependencies, however, we will need to include it in the git-compat-util.h and resolve the dependencies there, like we do for other system header files.
Quoted 5 lines
Or perhaps Junio would prefer that you work on a C file by C file basis? Like for example:
"delete useless includes in '
builtin-diff-files.c'" "delete useless includes in 'builtin-diff-index.c'"
If the series does not involve .h file clean-up, then a series that consists of one patch per .c file would be easier to handle, I think.
Quoted 7 lines · Junio C Hamano
Quoted 3 lines
- a header file should be included in a C file only if it is needed to compile the C file (it is not ok to include it only because it includes many other headers that are needed)
If that is the rule, perhaps the problem lies not in a .c program that includes such a .h header, but in the .h itself that includes many other header files.
If this were combined with splitting gigantic .h files (like cache.h) into smaller logical units, then we could in theory speed up recompilation times with make (we would also need to correctly track header dependencies, but gcc -M can do this fairly easily).
But it does come at the price of actually having to consider which include files are necessary. I can't think of more than half a dozen times in the last year I have actually had to add a #include while working on a git .c file, mostly because everything and the kitchen sink is included by cache.h.
So I don't know if it is worth it.
-Peff
Hi,
Quoted 14 lines · Jeff King
Quoted 7 lines · Junio C Hamano
Quoted 3 lines
- a header file should be included in a C file only if it is needed to compile the C file (it is not ok to include it only because it includes many other headers that are needed)
If that is the rule, perhaps the problem lies not in a .c program that includes such a .h header, but in the .h itself that includes many other header files.
If this were combined with splitting gigantic .h files (like
cache.h) into smaller logical units, then we could in theory speed up recompilation times with make (we would also need to correctly track header dependencies, but gcc -M can do this fairly easily).
Quoted 5 lines
But it does come at the price of actually having to consider which include files are necessary. I can't think of more than half a dozen times in the last year I have actually had to add a #include while working on a git .c file, mostly because everything and the kitchen sink is included by
cache.h.
Yeah, I think the best feature of the actual design is the simplicity, and that's why we don't have to add new #include very often. So let's keep this simplicity by having and applying rules to keep things simple for the developer.
Quoted 1 line
So I don't know if it is worth it.
I am not sure what you are talking about here, but if you mean that you don't think it's worth splitting gigantic .h files (like cache.h) into smaller logical units, then I agree.
Best regards,
Christian.
Quoted 5 lines · Christian Couder
Quoted 1 line
So I don't know if it is worth it.
I am not sure what you are talking about here, but if you mean that you don't think it's worth splitting gigantic .h files (like
cache.h) into smaller logical units, then I agree.
What I meant was "there is a tradeoff between faster compilation times and potentially more programmer effort, and I don't know if that tradeoff is worth it". So I think you understood what I was saying, and I think your point is reasonable.
-Peff
Quoted 15 lines · Junio C Hamano
Quoted 7 lines · Christian Couder
Ok, so I suggest the following simple guiding principles:
-
git-compat-util.horcache.horbuiltin.hshould always be the first #include in C files,- header files should include other incude files if and only if the other includes are needed to compile them,
This is unclear.
Long before I started touching git, I used to be religious about making header files self contained. For a header file
frotz.hin the project, I used to insist that
Quoted 8 lines
$ cat >1.c <<\EOF #include "frotz.h" EOF $ cc -Wall -c 1.cdid not fail.
Are you talking about that by "to compile them"?
Well, I wanted to say that for a header file frotz.h in the project:
$ cat >1.c <<\EOF #include "cache.h" #include "frotz.h" EOF $ cc -Wall -c 1.c
should not fail.
(Ok, in practice, let's say that something like:
$ cc -Wall -DSHA1_HEADER='<openssl/sha.h>' -c 1.c
should not fail.)
Quoted 13 lines
I stopped doing that long time ago, partly because the rule was cumbersome to enforce, but primarily because it was not helping much in the larger picture.
Such a rule, together with strict rules such as the order of including other header files in the header files themselves, may make life easier for programmers who touch .c files but never .h files, because they can include only the necessary .h files and in any order. But in practice, people need to touch both .h and .c files and when they need to include new system header files, they need to follow the inclusion order rule somewhere anyway---at that point, it does not matter much if the rule applies to only .h files or both .h and .c files.
Quoted 8 lines
So for example, you cannot compile
$ cat >1.c <<\EOF #include "revision.h" EOF $ cc -Wll -c 1.cin git.git project, but I do not think it is a problem.
I think it may become a problem if a header needs more headers to be included before it, and those latter headers again need more headers and so on.
The advantage of having and using "cache.h" is that things are quite simple. You include cache.h and then a few more headers for special features you need, and, here you go, you can code up something quite interesting without worrying too much about includes. (Though the compilation time is perhaps a little longer than it could be.)
If we loose this simplicity because we don't take care or for some theoretical reason, then I think we have lost everything that really matters.
A simple patch like this:
---------8<------------
$ gdiff
revision.h +2 -0
@@ -3,6 +3,8 @@#include "parse-options.h" #include "grep.h" +#include "diff.h" +#include "commit.h" #define SEEN (1u<<0)#define UNINTERESTING (1u<<1)
---------8<------------
makes the following just work(tm):
$ cat >1.c <<\EOF #include "cache.h" #include "revision.h" EOF $ cc -Wall -DSHA1_HEADER='<openssl/sha.h>' -c 1.c $
(By the way it's this kind of patches that I hoped would get posted first.)
Quoted 3 lines
Quoted 3 lines
- a header file should be included in a C file only if it is needed to compile the C file (it is not ok to include it only because it includes many other headers that are needed)
I should have said "a header file other than git-compat-util.h or cache.h should be included ..."
Quoted 3 lines
If that is the rule, perhaps the problem lies not in a .c program that includes such a .h header, but in the .h itself that includes many other header files.
It depends if the .h that includes many other header files does that for a good reason or not.
Quoted 8 lines
Quoted 4 lines
- other than the above rules, it is ok to reduce the number of includes as much as possible
What do you think?
What you did not write and I forgot to mention, which is a logical conclusion of the first rule, is that C files should not directly include common system header files such as unistd, sys/stat, etc.
Yeah, I forgot to restate that.
Quoted 6 lines
There are exceptions to any rule. For example, inclusion of
syslog.hindaemon.cis OK because most of the rest of the system does not even use syslog. If we later find a platform whosesyslog.hhas some funny inter-header dependencies, however, we will need to include it in thegit-compat-util.hand resolve the dependencies there, like we do for other system header files.
Ok, I will state that too.
If you agree I will post a patch to "Documentation/CodingGuidelines" with the above clarifications. (I can also post an improved version of my patch to "revision.h".)
Thanks,
Christian.
Quoted 8 lines
Quoted 5 lines
Or perhaps Junio would prefer that you work on a C file by C file basis? Like for example:
"delete useless includes in '
builtin-diff-files.c'" "delete useless includes in 'builtin-diff-index.c'"If the series does not involve .h file clean-up, then a series that consists of one patch per .c file would be easier to handle, I think.