simplify inclusion of system header files.
This is a mechanical clean-up of the way *.c files include system header files. (1) sources under compat/, platform sha-1 implementations, and xdelta code are exempt from the following rules; (2) the first #include must be "git-compat-util.h" or one of our own header file that includes it first (e.g. config.h, builtin.h, pkt-line.h); (3) system headers that are included in "git-compat-util.h" need not be included in individual C source files. (4) "git-compat-util.h" does not have to include subsystem specific header files (e.g. expat.h). Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Dec 19, 2006 at 14:34 UTC
85023577a8f4b540aa64aa37f6f44578c0c305a3
72 files changed
+42
-201
archive-tar.c
-1
@@ -1,7 +1,6 @@
1
/*
2
* Copyright (c) 2005, 2006 Rene Scharfe
3
*/
4
-#include <time.h>
4
#include "cache.h"
5
#include "commit.h"
6
#include "strbuf.h"
archive-zip.c
-1
@@ -1,7 +1,6 @@
1
/*
2
* Copyright (c) 2006 Rene Scharfe
3
*/
4
-#include <time.h>
4
#include "cache.h"
5
#include "commit.h"
6
#include "blob.h"
blob.c
-1
@@ -1,6 +1,5 @@
1
#include "cache.h"
2
#include "blob.h"
3
-#include <stdlib.h>
3
4
const char *blob_type = "blob";
5
builtin-add.c
-2
@@ -3,8 +3,6 @@
3
*
4
* Copyright (C) 2006 Linus Torvalds
5
*/
6
-#include <fnmatch.h>
7
-
6
#include "cache.h"
7
#include "builtin.h"
8
#include "dir.h"
builtin-apply.c
-1
@@ -6,7 +6,6 @@
6
* This applies patches on top of some (arbitrary) version of the SCM.
7
*
8
*/
9
-#include <fnmatch.h>
9
#include "cache.h"
10
#include "cache-tree.h"
11
#include "quote.h"
builtin-archive.c
-1
@@ -2,7 +2,6 @@
2
* Copyright (c) 2006 Franck Bui-Huu
3
* Copyright (c) 2006 Rene Scharfe
4
*/
5
-#include <time.h>
5
#include "cache.h"
6
#include "builtin.h"
7
#include "archive.h"
builtin-blame.c
-4
@@ -15,10 +15,6 @@
15
#include "revision.h"
16
#include "xdiff-interface.h"
17
18
-#include <time.h>
19
-#include <sys/time.h>
20
-#include <regex.h>
21
-
18
static char blame_usage[] =
19
"git-blame [-c] [-l] [-t] [-f] [-n] [-p] [-L n,m] [-S <revs-file>] [-M] [-C] [-C] [commit] [--] file\n"
20
" -c, --compatibility Use the same output mode as git-annotate (Default: off)\n"
builtin-branch.c
+1
-1
@@ -5,8 +5,8 @@
5
* Based on git-branch.sh by Junio C Hamano.
6
*/
7
8
-#include "color.h"
8
#include "cache.h"
9
+#include "color.h"
10
#include "refs.h"
11
#include "commit.h"
12
#include "builtin.h"
builtin-for-each-ref.c
-1
@@ -6,7 +6,6 @@
6
#include "tree.h"
7
#include "blob.h"
8
#include "quote.h"
9
-#include <fnmatch.h>
9
10
/* Quoting styles */
11
#define QUOTE_NONE 0
builtin-grep.c
-3
@@ -10,10 +10,7 @@
10
#include "tag.h"
11
#include "tree-walk.h"
12
#include "builtin.h"
13
-#include <regex.h>
13
#include "grep.h"
15
-#include <fnmatch.h>
16
-#include <sys/wait.h>
14
15
/*
16
* git grep pathspecs are somewhat different from diff-tree pathspecs;
builtin-log.c
-2
@@ -11,8 +11,6 @@
11
#include "log-tree.h"
12
#include "builtin.h"
13
#include "tag.h"
14
-#include <time.h>
15
-#include <sys/time.h>
14
15
static int default_show_root = 1;
16
builtin-ls-files.c
-2
@@ -5,8 +5,6 @@
5
*
6
* Copyright (C) Linus Torvalds, 2005
7
*/
8
-#include <fnmatch.h>
9
-
8
#include "cache.h"
9
#include "quote.h"
10
#include "dir.h"
builtin-mailinfo.c
-9
@@ -2,15 +2,6 @@
2
* Another stupid program, this one parsing the headers of an
3
* email to figure out authorship and subject
4
*/
5
-#define _GNU_SOURCE
6
-#include <stdio.h>
7
-#include <stdlib.h>
8
-#include <string.h>
9
-#include <ctype.h>
10
-#ifndef NO_ICONV
11
-#include <iconv.h>
12
-#endif
13
-#include "git-compat-util.h"
5
#include "cache.h"
6
#include "builtin.h"
7
builtin-mailsplit.c
-7
@@ -4,13 +4,6 @@
4
* It just splits a mbox into a list of files: "0001" "0002" ..
5
* so you can process them further from there.
6
*/
7
-#include <unistd.h>
8
-#include <stdlib.h>
9
-#include <fcntl.h>
10
-#include <sys/types.h>
11
-#include <sys/stat.h>
12
-#include <string.h>
13
-#include <stdio.h>
7
#include "cache.h"
8
#include "builtin.h"
9
builtin-mv.c
-2
@@ -3,8 +3,6 @@
3
*
4
* Copyright (C) 2006 Johannes Schindelin
5
*/
6
-#include <fnmatch.h>
7
-
6
#include "cache.h"
7
#include "builtin.h"
8
#include "dir.h"
builtin-name-rev.c
-1
@@ -1,4 +1,3 @@
1
-#include <stdlib.h>
1
#include "builtin.h"
2
#include "cache.h"
3
#include "commit.h"
builtin-pack-objects.c
-2
@@ -12,8 +12,6 @@
12
#include "diff.h"
13
#include "revision.h"
14
#include "list-objects.h"
15
-#include <sys/time.h>
16
-#include <signal.h>
15
16
static const char pack_usage[] = "\
17
git-pack-objects [{ -q | --progress | --all-progress }] \n\
builtin-repo-config.c
-1
@@ -1,6 +1,5 @@
1
#include "builtin.h"
2
#include "cache.h"
3
-#include <regex.h>
3
4
static const char git_config_set_usage[] =
5
"git-repo-config [ --global ] [ --bool | --int ] [--get | --get-all | --get-regexp | --replace-all | --add | --unset | --unset-all] name [value [value_regex]] | --rename-section old_name new_name | --list";
builtin-runstatus.c
+1
-1
@@ -1,5 +1,5 @@
1
-#include "wt-status.h"
1
#include "cache.h"
2
+#include "wt-status.h"
3
4
extern int wt_status_use_color;
5
builtin-shortlog.c
-1
@@ -4,7 +4,6 @@
4
#include "diff.h"
5
#include "path-list.h"
6
#include "revision.h"
7
-#include <string.h>
7
8
static const char shortlog_usage[] =
9
"git-shortlog [-n] [-s] [<commit-id>... ]";
builtin-show-branch.c
-2
@@ -1,5 +1,3 @@
1
-#include <stdlib.h>
2
-#include <fnmatch.h>
1
#include "cache.h"
2
#include "commit.h"
3
#include "refs.h"
builtin-stripspace.c
-3
@@ -1,6 +1,3 @@
1
-#include <stdio.h>
2
-#include <string.h>
3
-#include <ctype.h>
1
#include "builtin.h"
2
3
/*
builtin-tar-tree.c
-1
@@ -1,7 +1,6 @@
1
/*
2
* Copyright (c) 2005, 2006 Rene Scharfe
3
*/
4
-#include <time.h>
4
#include "cache.h"
5
#include "commit.h"
6
#include "tar.h"
builtin-unpack-objects.c
-2
@@ -8,8 +8,6 @@
8
#include "tag.h"
9
#include "tree.h"
10
11
-#include <sys/time.h>
12
-
11
static int dry_run, quiet, recover, has_errors;
12
static const char unpack_usage[] = "git-unpack-objects [-n] [-q] [-r] < pack-file";
13
builtin-upload-archive.c
-3
@@ -1,9 +1,6 @@
1
/*
2
* Copyright (c) 2006 Franck Bui-Huu
3
*/
4
-#include <time.h>
5
-#include <sys/wait.h>
6
-#include <sys/poll.h>
4
#include "cache.h"
5
#include "builtin.h"
6
#include "archive.h"
color.c
+1
-4
@@ -1,8 +1,5 @@
1
-#include "color.h"
1
#include "cache.h"
3
-#include "git-compat-util.h"
4
-
5
-#include <stdarg.h>
2
+#include "color.h"
3
4
#define COLOR_RESET "\033[m"
5
compat/mmap.c
-4
@@ -1,7 +1,3 @@
1
-#include <stdio.h>
2
-#include <stdlib.h>
3
-#include <unistd.h>
4
-#include <errno.h>
1
#include "../git-compat-util.h"
2
3
void *gitfakemmap(void *start, size_t length, int prot , int flags, int fd, off_t offset)
compat/setenv.c
+1
-2
@@ -1,5 +1,4 @@
1
-#include <stdlib.h>
2
-#include <string.h>
1
+#include "../git-compat-util.h"
2
3
int gitsetenv(const char *name, const char *value, int replace)
4
{
compat/strlcpy.c
+1
-1
@@ -1,4 +1,4 @@
1
-#include <string.h>
1
+#include "../git-compat-util.h"
2
3
size_t gitstrlcpy(char *dest, const char *src, size_t size)
4
{
compat/unsetenv.c
+1
-2
@@ -1,5 +1,4 @@
1
-#include <stdlib.h>
2
-#include <string.h>
1
+#include "../git-compat-util.h"
2
3
void gitunsetenv (const char *name)
4
{
config.c
-1
@@ -6,7 +6,6 @@
6
*
7
*/
8
#include "cache.h"
9
-#include <regex.h>
9
10
#define MAXNAME (256)
11
connect.c
-6
@@ -3,12 +3,6 @@
3
#include "pkt-line.h"
4
#include "quote.h"
5
#include "refs.h"
6
-#include <sys/wait.h>
7
-#include <sys/socket.h>
8
-#include <netinet/in.h>
9
-#include <arpa/inet.h>
10
-#include <netdb.h>
11
-#include <signal.h>
6
7
static char *server_capabilities;
8
convert-objects.c
-4
@@ -1,7 +1,3 @@
1
-#define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */
2
-#define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */
3
-#define _GNU_SOURCE
4
-#include <time.h>
1
#include "cache.h"
2
#include "blob.h"
3
#include "commit.h"
daemon.c
+3
-13
@@ -1,20 +1,10 @@
1
-#include <signal.h>
2
-#include <sys/wait.h>
3
-#include <sys/socket.h>
4
-#include <sys/time.h>
5
-#include <sys/poll.h>
6
-#include <netdb.h>
7
-#include <netinet/in.h>
8
-#include <arpa/inet.h>
9
-#include <syslog.h>
10
-#include <pwd.h>
11
-#include <grp.h>
12
-#include <limits.h>
13
-#include "pkt-line.h"
1
#include "cache.h"
2
+#include "pkt-line.h"
3
#include "exec_cmd.h"
4
#include "interpolate.h"
5
6
+#include <syslog.h>
7
+
8
#ifndef HOST_NAME_MAX
9
#define HOST_NAME_MAX 256
10
#endif
date.c
-3
@@ -4,9 +4,6 @@
4
* Copyright (C) Linus Torvalds, 2005
5
*/
6
7
-#include <time.h>
8
-#include <sys/time.h>
9
-
7
#include "cache.h"
8
9
static time_t my_mktime(struct tm *tm)
diff-delta.c
+1
-4
@@ -18,11 +18,8 @@
18
* licensing gets turned into GPLv2 within this project.
19
*/
20
21
-#include <stdlib.h>
22
-#include <string.h>
23
-#include "delta.h"
24
-
21
#include "git-compat-util.h"
22
+#include "delta.h"
23
24
/* maximum hash entry list for the same hash bucket */
25
#define HASH_LIMIT 64
diff.c
-3
@@ -1,9 +1,6 @@
1
/*
2
* Copyright (C) 2005 Junio C Hamano
3
*/
4
-#include <sys/types.h>
5
-#include <sys/wait.h>
6
-#include <signal.h>
4
#include "cache.h"
5
#include "quote.h"
6
#include "diff.h"
diffcore-order.c
-1
@@ -4,7 +4,6 @@
4
#include "cache.h"
5
#include "diff.h"
6
#include "diffcore.h"
7
-#include <fnmatch.h>
7
8
static char **order;
9
static int order_cnt;
diffcore-pickaxe.c
-2
@@ -5,8 +5,6 @@
5
#include "diff.h"
6
#include "diffcore.h"
7
8
-#include <regex.h>
9
-
8
static unsigned int contains(struct diff_filespec *one,
9
const char *needle, unsigned long len,
10
regex_t *regexp)
dir.c
-3
@@ -5,9 +5,6 @@
5
* Copyright (C) Linus Torvalds, 2005-2006
6
* Junio Hamano, 2005-2006
7
*/
8
-#include <dirent.h>
9
-#include <fnmatch.h>
10
-
8
#include "cache.h"
9
#include "dir.h"
10
entry.c
-2
@@ -1,5 +1,3 @@
1
-#include <sys/types.h>
2
-#include <dirent.h>
1
#include "cache.h"
2
#include "blob.h"
3
fetch-pack.c
-1
@@ -5,7 +5,6 @@
5
#include "tag.h"
6
#include "exec_cmd.h"
7
#include "sideband.h"
8
-#include <sys/wait.h>
8
9
static int keep_pack;
10
static int quiet;
fetch.c
+1
-2
@@ -1,6 +1,5 @@
1
-#include "fetch.h"
2
-
1
#include "cache.h"
2
+#include "fetch.h"
3
#include "commit.h"
4
#include "tree.h"
5
#include "tree-walk.h"
fsck-objects.c
-3
@@ -1,6 +1,3 @@
1
-#include <sys/types.h>
2
-#include <dirent.h>
3
-
1
#include "cache.h"
2
#include "commit.h"
3
#include "tree.h"
git-compat-util.h
+24
-1
@@ -11,6 +11,11 @@
11
12
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
13
14
+#define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */
15
+#define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */
16
+#define _GNU_SOURCE
17
+#define _BSD_SOURCE
18
+
19
#include <unistd.h>
20
#include <stdio.h>
21
#include <sys/stat.h>
@@ -22,9 +27,27 @@
27
#include <errno.h>
28
#include <limits.h>
29
#include <sys/param.h>
25
-#include <netinet/in.h>
30
#include <sys/types.h>
31
#include <dirent.h>
32
+#include <sys/time.h>
33
+#include <time.h>
34
+#include <signal.h>
35
+#include <sys/wait.h>
36
+#include <fnmatch.h>
37
+#include <sys/poll.h>
38
+#include <sys/socket.h>
39
+#include <assert.h>
40
+#include <regex.h>
41
+#include <netinet/in.h>
42
+#include <netinet/tcp.h>
43
+#include <arpa/inet.h>
44
+#include <netdb.h>
45
+#include <pwd.h>
46
+#include <grp.h>
47
+
48
+#ifndef NO_ICONV
49
+#include <iconv.h>
50
+#endif
51
52
/* On most systems <limits.h> would have given us this, but
53
* not on some systems (e.g. GNU/Hurd).
git.c
+1
-13
@@ -1,20 +1,8 @@
1
-#include <stdio.h>
2
-#include <sys/types.h>
3
-#include <sys/stat.h>
4
-#include <dirent.h>
5
-#include <unistd.h>
6
-#include <stdlib.h>
7
-#include <string.h>
8
-#include <errno.h>
9
-#include <limits.h>
10
-#include <stdarg.h>
11
-#include "git-compat-util.h"
1
+#include "builtin.h"
2
#include "exec_cmd.h"
3
#include "cache.h"
4
#include "quote.h"
5
16
-#include "builtin.h"
17
-
6
const char git_usage_string[] =
7
"git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate] [--bare] [--git-dir=GIT_DIR] [--help] COMMAND [ARGS]";
8
grep.c
-1
@@ -1,5 +1,4 @@
1
#include "cache.h"
2
-#include <regex.h>
2
#include "grep.h"
3
4
void append_grep_pattern(struct grep_opt *opt, const char *pat,
help.c
+1
-2
@@ -3,12 +3,11 @@
3
*
4
* Builtin help-related commands (help, usage, version)
5
*/
6
-#include <sys/ioctl.h>
6
#include "cache.h"
7
#include "builtin.h"
8
#include "exec_cmd.h"
9
#include "common-cmds.h"
11
-
10
+#include <sys/ioctl.h>
11
12
/* most GUI terminals set COLUMNS (although some don't export it) */
13
static int term_columns(void)
ident.c
-3
@@ -7,9 +7,6 @@
7
*/
8
#include "cache.h"
9
10
-#include <pwd.h>
11
-#include <netdb.h>
12
-
10
static char git_default_date[50];
11
12
static void copy_gecos(struct passwd *w, char *name, int sz)
imap-send.c
-7
@@ -24,13 +24,6 @@
24
25
#include "cache.h"
26
27
-#include <assert.h>
28
-#include <netinet/in.h>
29
-#include <netinet/tcp.h>
30
-#include <arpa/inet.h>
31
-#include <sys/socket.h>
32
-#include <netdb.h>
33
-
27
typedef struct store_conf {
28
char *name;
29
const char *path; /* should this be here? its interpretation is driver-specific */
index-pack.c
-5
@@ -1,8 +1,3 @@
1
-#define _XOPEN_SOURCE 600
2
-#include <unistd.h>
3
-#include <sys/time.h>
4
-#include <signal.h>
5
-
1
#include "cache.h"
2
#include "delta.h"
3
#include "pack.h"
interpolate.c
-2
@@ -2,8 +2,6 @@
2
* Copyright 2006 Jon Loeliger
3
*/
4
5
-#include <string.h>
6
-
5
#include "git-compat-util.h"
6
#include "interpolate.h"
7
lockfile.c
-1
@@ -1,7 +1,6 @@
1
/*
2
* Copyright (c) 2005, Junio C Hamano
3
*/
4
-#include <signal.h>
4
#include "cache.h"
5
6
static struct lock_file *lock_file_list;
merge-base.c
-1
@@ -1,4 +1,3 @@
1
-#include <stdlib.h>
1
#include "cache.h"
2
#include "commit.h"
3
merge-index.c
-4
@@ -1,7 +1,3 @@
1
-#include <sys/types.h>
2
-#include <sys/wait.h>
3
-#include <signal.h>
4
-
1
#include "cache.h"
2
3
static const char *pgm;
merge-recursive.c
-7
@@ -3,13 +3,6 @@
3
* Fredrik Kuivinen.
4
* The thieves were Alex Riesen and Johannes Schindelin, in June/July 2006
5
*/
6
-#include <stdarg.h>
7
-#include <string.h>
8
-#include <assert.h>
9
-#include <sys/wait.h>
10
-#include <sys/types.h>
11
-#include <sys/stat.h>
12
-#include <time.h>
6
#include "cache.h"
7
#include "cache-tree.h"
8
#include "commit.h"
path-list.c
-1
@@ -1,4 +1,3 @@
1
-#include <stdio.h>
1
#include "cache.h"
2
#include "path-list.h"
3
path.c
-1
@@ -11,7 +11,6 @@
11
* which is what it's designed for.
12
*/
13
#include "cache.h"
14
-#include <pwd.h>
14
15
static char bad_path[] = "/bad-path/";
16
receive-pack.c
-1
@@ -6,7 +6,6 @@
6
#include "exec_cmd.h"
7
#include "commit.h"
8
#include "object.h"
9
-#include <sys/wait.h>
9
10
static const char receive_pack_usage[] = "git-receive-pack <git-dir>";
11
refs.c
+1
-3
@@ -1,10 +1,8 @@
1
-#include "refs.h"
1
#include "cache.h"
2
+#include "refs.h"
3
#include "object.h"
4
#include "tag.h"
5
6
-#include <errno.h>
7
-
6
/* ISSYMREF=01 and ISPACKED=02 are public interfaces */
7
#define REF_KNOWS_PEELED 04
8
revision.c
-1
@@ -6,7 +6,6 @@
6
#include "diff.h"
7
#include "refs.h"
8
#include "revision.h"
9
-#include <regex.h>
9
#include "grep.h"
10
11
static char *path_name(struct name_path *path, const char *name)
rsh.c
+1
-5
@@ -1,10 +1,6 @@
1
-#include <string.h>
2
-#include <sys/types.h>
3
-#include <sys/socket.h>
4
-
1
+#include "cache.h"
2
#include "rsh.h"
3
#include "quote.h"
7
-#include "cache.h"
4
5
#define COMMAND_SIZE 4096
6
run-command.c
-1
@@ -1,6 +1,5 @@
1
#include "cache.h"
2
#include "run-command.h"
3
-#include <sys/wait.h>
3
#include "exec_cmd.h"
4
5
int run_command_v_opt(int argc, const char **argv, int flags)
ssh-upload.c
-2
@@ -12,8 +12,6 @@
12
#include "rsh.h"
13
#include "refs.h"
14
15
-#include <string.h>
16
-
15
static unsigned char local_version = 1;
16
static unsigned char remote_version;
17
strbuf.c
+1
-3
@@ -1,7 +1,5 @@
1
-#include <stdio.h>
2
-#include <stdlib.h>
3
-#include "strbuf.h"
1
#include "cache.h"
2
+#include "strbuf.h"
3
4
void strbuf_init(struct strbuf *sb) {
5
sb->buf = NULL;
test-date.c
-3
@@ -1,6 +1,3 @@
1
-#include <stdio.h>
2
-#include <time.h>
3
-
1
#include "cache.h"
2
3
int main(int argc, char **argv)
test-delta.c
+1
-7
@@ -8,13 +8,7 @@
8
* published by the Free Software Foundation.
9
*/
10
11
-#include <stdio.h>
12
-#include <unistd.h>
13
-#include <string.h>
14
-#include <fcntl.h>
15
-#include <sys/types.h>
16
-#include <sys/stat.h>
17
-#include <sys/mman.h>
11
+#include "git-compat-util.h"
12
#include "delta.h"
13
14
static const char usage[] =
tree.c
-1
@@ -4,7 +4,6 @@
4
#include "commit.h"
5
#include "tag.h"
6
#include "tree-walk.h"
7
-#include <stdlib.h>
7
8
const char *tree_type = "tree";
9
unpack-trees.c
-2
@@ -1,5 +1,3 @@
1
-#include <signal.h>
2
-#include <sys/time.h>
1
#include "cache.h"
2
#include "dir.h"
3
#include "tree.h"
upload-pack.c
-3
@@ -1,6 +1,3 @@
1
-#include <signal.h>
2
-#include <sys/wait.h>
3
-#include <sys/poll.h>
1
#include "cache.h"
2
#include "refs.h"
3
#include "pkt-line.h"
var.c
-3
@@ -4,9 +4,6 @@
4
* Copyright (C) Eric Biederman, 2005
5
*/
6
#include "cache.h"
7
-#include <stdio.h>
8
-#include <errno.h>
9
-#include <string.h>
7
8
static const char var_usage[] = "git-var [-l | <variable>]";
9
wt-status.c
+1
-1
@@ -1,6 +1,6 @@
1
+#include "cache.h"
2
#include "wt-status.h"
3
#include "color.h"
3
-#include "cache.h"
4
#include "object.h"
5
#include "dir.h"
6
#include "commit.h"