Skip to content

Commit

Permalink
simplify inclusion of system header files.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Junio C Hamano committed Dec 20, 2006
1 parent 6d2fa7f commit 8502357
Show file tree
Hide file tree
Showing 72 changed files with 42 additions and 201 deletions.
1 change: 0 additions & 1 deletion archive-tar.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/*
* Copyright (c) 2005, 2006 Rene Scharfe
*/
#include <time.h>
#include "cache.h"
#include "commit.h"
#include "strbuf.h"
Expand Down
1 change: 0 additions & 1 deletion archive-zip.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/*
* Copyright (c) 2006 Rene Scharfe
*/
#include <time.h>
#include "cache.h"
#include "commit.h"
#include "blob.h"
Expand Down
1 change: 0 additions & 1 deletion blob.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "cache.h"
#include "blob.h"
#include <stdlib.h>

const char *blob_type = "blob";

Expand Down
2 changes: 0 additions & 2 deletions builtin-add.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
*
* Copyright (C) 2006 Linus Torvalds
*/
#include <fnmatch.h>

#include "cache.h"
#include "builtin.h"
#include "dir.h"
Expand Down
1 change: 0 additions & 1 deletion builtin-apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* This applies patches on top of some (arbitrary) version of the SCM.
*
*/
#include <fnmatch.h>
#include "cache.h"
#include "cache-tree.h"
#include "quote.h"
Expand Down
1 change: 0 additions & 1 deletion builtin-archive.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Copyright (c) 2006 Franck Bui-Huu
* Copyright (c) 2006 Rene Scharfe
*/
#include <time.h>
#include "cache.h"
#include "builtin.h"
#include "archive.h"
Expand Down
4 changes: 0 additions & 4 deletions builtin-blame.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
#include "revision.h"
#include "xdiff-interface.h"

#include <time.h>
#include <sys/time.h>
#include <regex.h>

static char blame_usage[] =
"git-blame [-c] [-l] [-t] [-f] [-n] [-p] [-L n,m] [-S <revs-file>] [-M] [-C] [-C] [commit] [--] file\n"
" -c, --compatibility Use the same output mode as git-annotate (Default: off)\n"
Expand Down
2 changes: 1 addition & 1 deletion builtin-branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* Based on git-branch.sh by Junio C Hamano.
*/

#include "color.h"
#include "cache.h"
#include "color.h"
#include "refs.h"
#include "commit.h"
#include "builtin.h"
Expand Down
1 change: 0 additions & 1 deletion builtin-for-each-ref.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "tree.h"
#include "blob.h"
#include "quote.h"
#include <fnmatch.h>

/* Quoting styles */
#define QUOTE_NONE 0
Expand Down
3 changes: 0 additions & 3 deletions builtin-grep.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
#include "tag.h"
#include "tree-walk.h"
#include "builtin.h"
#include <regex.h>
#include "grep.h"
#include <fnmatch.h>
#include <sys/wait.h>

/*
* git grep pathspecs are somewhat different from diff-tree pathspecs;
Expand Down
2 changes: 0 additions & 2 deletions builtin-log.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
#include "log-tree.h"
#include "builtin.h"
#include "tag.h"
#include <time.h>
#include <sys/time.h>

static int default_show_root = 1;

Expand Down
2 changes: 0 additions & 2 deletions builtin-ls-files.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
*
* Copyright (C) Linus Torvalds, 2005
*/
#include <fnmatch.h>

#include "cache.h"
#include "quote.h"
#include "dir.h"
Expand Down
9 changes: 0 additions & 9 deletions builtin-mailinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@
* Another stupid program, this one parsing the headers of an
* email to figure out authorship and subject
*/
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#ifndef NO_ICONV
#include <iconv.h>
#endif
#include "git-compat-util.h"
#include "cache.h"
#include "builtin.h"

Expand Down
7 changes: 0 additions & 7 deletions builtin-mailsplit.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@
* It just splits a mbox into a list of files: "0001" "0002" ..
* so you can process them further from there.
*/
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <stdio.h>
#include "cache.h"
#include "builtin.h"

Expand Down
2 changes: 0 additions & 2 deletions builtin-mv.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
*
* Copyright (C) 2006 Johannes Schindelin
*/
#include <fnmatch.h>

#include "cache.h"
#include "builtin.h"
#include "dir.h"
Expand Down
1 change: 0 additions & 1 deletion builtin-name-rev.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <stdlib.h>
#include "builtin.h"
#include "cache.h"
#include "commit.h"
Expand Down
2 changes: 0 additions & 2 deletions builtin-pack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
#include "diff.h"
#include "revision.h"
#include "list-objects.h"
#include <sys/time.h>
#include <signal.h>

static const char pack_usage[] = "\
git-pack-objects [{ -q | --progress | --all-progress }] \n\
Expand Down
1 change: 0 additions & 1 deletion builtin-repo-config.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "builtin.h"
#include "cache.h"
#include <regex.h>

static const char git_config_set_usage[] =
"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";
Expand Down
2 changes: 1 addition & 1 deletion builtin-runstatus.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "wt-status.h"
#include "cache.h"
#include "wt-status.h"

extern int wt_status_use_color;

Expand Down
1 change: 0 additions & 1 deletion builtin-shortlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "diff.h"
#include "path-list.h"
#include "revision.h"
#include <string.h>

static const char shortlog_usage[] =
"git-shortlog [-n] [-s] [<commit-id>... ]";
Expand Down
2 changes: 0 additions & 2 deletions builtin-show-branch.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <stdlib.h>
#include <fnmatch.h>
#include "cache.h"
#include "commit.h"
#include "refs.h"
Expand Down
3 changes: 0 additions & 3 deletions builtin-stripspace.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "builtin.h"

/*
Expand Down
1 change: 0 additions & 1 deletion builtin-tar-tree.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/*
* Copyright (c) 2005, 2006 Rene Scharfe
*/
#include <time.h>
#include "cache.h"
#include "commit.h"
#include "tar.h"
Expand Down
2 changes: 0 additions & 2 deletions builtin-unpack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
#include "tag.h"
#include "tree.h"

#include <sys/time.h>

static int dry_run, quiet, recover, has_errors;
static const char unpack_usage[] = "git-unpack-objects [-n] [-q] [-r] < pack-file";

Expand Down
3 changes: 0 additions & 3 deletions builtin-upload-archive.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/*
* Copyright (c) 2006 Franck Bui-Huu
*/
#include <time.h>
#include <sys/wait.h>
#include <sys/poll.h>
#include "cache.h"
#include "builtin.h"
#include "archive.h"
Expand Down
5 changes: 1 addition & 4 deletions color.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#include "color.h"
#include "cache.h"
#include "git-compat-util.h"

#include <stdarg.h>
#include "color.h"

#define COLOR_RESET "\033[m"

Expand Down
4 changes: 0 additions & 4 deletions compat/mmap.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include "../git-compat-util.h"

void *gitfakemmap(void *start, size_t length, int prot , int flags, int fd, off_t offset)
Expand Down
3 changes: 1 addition & 2 deletions compat/setenv.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include <stdlib.h>
#include <string.h>
#include "../git-compat-util.h"

int gitsetenv(const char *name, const char *value, int replace)
{
Expand Down
2 changes: 1 addition & 1 deletion compat/strlcpy.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <string.h>
#include "../git-compat-util.h"

size_t gitstrlcpy(char *dest, const char *src, size_t size)
{
Expand Down
3 changes: 1 addition & 2 deletions compat/unsetenv.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include <stdlib.h>
#include <string.h>
#include "../git-compat-util.h"

void gitunsetenv (const char *name)
{
Expand Down
1 change: 0 additions & 1 deletion config.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*
*/
#include "cache.h"
#include <regex.h>

#define MAXNAME (256)

Expand Down
6 changes: 0 additions & 6 deletions connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@
#include "pkt-line.h"
#include "quote.h"
#include "refs.h"
#include <sys/wait.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <signal.h>

static char *server_capabilities;

Expand Down
4 changes: 0 additions & 4 deletions convert-objects.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */
#define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */
#define _GNU_SOURCE
#include <time.h>
#include "cache.h"
#include "blob.h"
#include "commit.h"
Expand Down
16 changes: 3 additions & 13 deletions daemon.c
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
#include <signal.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/poll.h>
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <syslog.h>
#include <pwd.h>
#include <grp.h>
#include <limits.h>
#include "pkt-line.h"
#include "cache.h"
#include "pkt-line.h"
#include "exec_cmd.h"
#include "interpolate.h"

#include <syslog.h>

#ifndef HOST_NAME_MAX
#define HOST_NAME_MAX 256
#endif
Expand Down
3 changes: 0 additions & 3 deletions date.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
* Copyright (C) Linus Torvalds, 2005
*/

#include <time.h>
#include <sys/time.h>

#include "cache.h"

static time_t my_mktime(struct tm *tm)
Expand Down
5 changes: 1 addition & 4 deletions diff-delta.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@
* licensing gets turned into GPLv2 within this project.
*/

#include <stdlib.h>
#include <string.h>
#include "delta.h"

#include "git-compat-util.h"
#include "delta.h"

/* maximum hash entry list for the same hash bucket */
#define HASH_LIMIT 64
Expand Down
3 changes: 0 additions & 3 deletions diff.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/*
* Copyright (C) 2005 Junio C Hamano
*/
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
#include "cache.h"
#include "quote.h"
#include "diff.h"
Expand Down
1 change: 0 additions & 1 deletion diffcore-order.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "cache.h"
#include "diff.h"
#include "diffcore.h"
#include <fnmatch.h>

static char **order;
static int order_cnt;
Expand Down
2 changes: 0 additions & 2 deletions diffcore-pickaxe.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#include "diff.h"
#include "diffcore.h"

#include <regex.h>

static unsigned int contains(struct diff_filespec *one,
const char *needle, unsigned long len,
regex_t *regexp)
Expand Down
3 changes: 0 additions & 3 deletions dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
* Copyright (C) Linus Torvalds, 2005-2006
* Junio Hamano, 2005-2006
*/
#include <dirent.h>
#include <fnmatch.h>

#include "cache.h"
#include "dir.h"

Expand Down
2 changes: 0 additions & 2 deletions entry.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <sys/types.h>
#include <dirent.h>
#include "cache.h"
#include "blob.h"

Expand Down
1 change: 0 additions & 1 deletion fetch-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "tag.h"
#include "exec_cmd.h"
#include "sideband.h"
#include <sys/wait.h>

static int keep_pack;
static int quiet;
Expand Down
3 changes: 1 addition & 2 deletions fetch.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "fetch.h"

#include "cache.h"
#include "fetch.h"
#include "commit.h"
#include "tree.h"
#include "tree-walk.h"
Expand Down
Loading

0 comments on commit 8502357

Please sign in to comment.