Makefile: add check-headers target
PATCH v4 1/2 Makefile: add check-headers target
This allows us to ensure that each header can be included individually without needing to include other headers first.
Implicitly include git-compat-util.h during the check since the implementation files will have already included it.
---
Changes since last time:
We now automatically include git-compat-util.h during the check per the CodingGuidelines rule to always include it in all .c files.
We now use a case statement to special-case common-cmds.h, which allows us to replace usage of git ls-files and a pipe with a simpler for header in ... loop.
Makefile | 6 ++++++ check-headers.sh | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100755 check-headers.sh
Makefile +6 -0
@@ -2408,6 +2408,12 @@ check-docs:: check-builtins:: ./check-builtins.sh +### Make sure headers include their dependencies +# +check-headers:: + ./check-headers.sh $(CC) $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) + + ### Test suite coverage testing # .PHONY: coverage coverage-clean coverage-compile coverage-test coverage-report
check-headers.sh new file +34 -0
@@ -0,0 +1,34 @@ +#!/bin/sh + +exit_code=0 + +maybe_exit () { + status="$1" + if test "$status" != 0 + then + exit_code="$status" + if test -n "$CHECK_HEADERS_STOP" + then + exit "$status" + fi + fi +} + +for header in *.h ewah/*.h vcs-svn/*.h xdiff/*.h +do + case "$header" in + common-cmds.h) + # should only be included by help.c + ;; + *) + subdir=$(dirname "$header") && + echo "HEADER $header" && + "$@" -Wno-unused -I"$subdir" -include git-compat-util.h \ + -c -o "$header".check -x c - <"$header" && + rm "$header".check || + maybe_exit $? + ;; + esac +done + +exit $exit_code
Signature · 1 line
2.0.4.1.g929bde9
PATCH v4 2/2 headers: include dependent headers
Add dependent headers so that including a header does not require including additional headers.
Move the unicode interval types to unicode_width.h so that we can include them from utf8.h.
This makes it so that "gcc -c $header" succeeds for each header.
---
Changes since last time:
This patch was redone to no longer add git-compat-util.h additions, as it was run using the new check-headers.
The unicode interval types were moved into unicode_width.h to minimize dependencies.
archive.h | 1 + attr.h | 2 ++ blob.h | 1 + branch.h | 2 ++ column.h | 2 ++ commit.h | 1 + convert.h | 2 ++ csum-file.h | 2 ++ diff.h | 2 +- diffcore.h | 2 ++ dir.h | 2 ++ ewah/ewok_rlw.h | 2 ++ fsck.h | 2 ++ gpg-interface.h | 2 ++ graph.h | 2 ++ khash.h | 2 ++ line-log.h | 1 + list-objects.h | 2 ++ ll-merge.h | 2 ++ mailmap.h | 2 ++ merge-recursive.h | 2 ++ notes-merge.h | 4 ++++ notes-utils.h | 1 + notes.h | 1 + object.h | 2 ++ pack-bitmap.h | 2 ++ pack-objects.h | 2 ++ patch-ids.h | 3 +++ reachable.h | 2 ++ reflog-walk.h | 1 + refs.h | 3 +++ remote.h | 1 + resolve-undo.h | 4 ++++ send-pack.h | 3 +++ sequencer.h | 2 ++ shortlog.h | 1 + submodule.h | 5 +++-- tree-walk.h | 2 ++ tree.h | 1 + unicode_width.h | 12 ++++++++++++ unpack-trees.h | 2 ++ url.h | 2 ++ utf8.c | 5 ----- utf8.h | 3 ++- walker.h | 1 + wt-status.h | 1 + xdiff/xdiffi.h | 2 ++ xdiff/xemit.h | 3 +++ xdiff/xprepare.h | 3 ++- xdiff/xutils.h | 3 ++- 50 files changed, 104 insertions(+), 11 deletions(-)
archive.h +1 -0
@@ -1,6 +1,7 @@#ifndef ARCHIVE_H #define ARCHIVE_H +#include "cache.h" #include "pathspec.h" struct archiver_args {
attr.h +2 -0
@@ -1,6 +1,8 @@#ifndef ATTR_H #define ATTR_H +#include "cache.h" +/* An attribute is a pointer to this opaque structure */ struct git_attr ;
blob.h +1 -0
@@ -1,6 +1,7 @@#ifndef BLOB_H #define BLOB_H +#include "cache.h" #include "object.h" extern const char *blob_type;
branch.h +2 -0
@@ -3,6 +3,8 @@/* Functions for acting on the information about branches. */ +#include "cache.h" +/* * Creates a new branch, where head is the branch currently checked * out, name is the new branch name, start_name is the name of the
column.h +2 -0
@@ -1,6 +1,8 @@#ifndef COLUMN_H #define COLUMN_H +#include "string-list.h" +#define COL_LAYOUT_MASK 0x000F#define COL_ENABLE_MASK 0x0030/* always, never or auto */ #define COL_PARSEOPT 0x0040/* --column is given from cmdline */
commit.h +1 -0
@@ -1,6 +1,7 @@#ifndef COMMIT_H #define COMMIT_H +#include "cache.h" #include "object.h" #include "tree.h" #include "strbuf.h"
convert.h +2 -0
@@ -4,6 +4,8 @@#ifndef CONVERT_H #define CONVERT_H +#include "strbuf.h" +enum safe_crlf {SAFE_CRLF_FALSE =0 , SAFE_CRLF_FAIL = 1,
csum-file.h +2 -0
@@ -1,6 +1,8 @@#ifndef CSUM_FILE_H #define CSUM_FILE_H +#include "cache.h" +struct progress ;/* A SHA1-protected file */
diff.h +1 -1
@@ -6,11 +6,11 @@#include "tree-walk.h" #include "pathspec.h" +#include "strbuf.h" struct rev_info ;struct diff_options ;struct diff_queue_struct ; -struct strbuf ;struct diff_filespec ;struct userdiff_driver ;struct sha1_array ;
diffcore.h +2 -0
@@ -9,6 +9,8 @@* in anything else. */ +#include "diff.h" +/* We internally use unsigned short as the score value, * and rely on an int capable to hold 32-bits. -B can take * -Bmerge_score/break_score format and the two scores are
dir.h +2 -0
@@ -3,7 +3,9 @@/* See Documentation/technical/api-directory-listing.txt */ +#include "cache.h" #include "strbuf.h" +#include "pathspec.h" struct dir_entry {unsigned int len;
ewah/ewok_rlw.h +2 -0
@@ -20,6 +20,8 @@#ifndef __EWOK_RLW_H__#define __EWOK_RLW_H__ +#include "ewok.h" +#define RLW_RUNNING_BITS (sizeof(eword_t) * 4)#define RLW_LITERAL_BITS (sizeof(eword_t) * 8 - 1 - RLW_RUNNING_BITS)
fsck.h +2 -0
@@ -1,6 +1,8 @@#ifndef GIT_FSCK_H #define GIT_FSCK_H +#include "cache.h" +#define FSCK_ERROR 1#define FSCK_WARN 2
gpg-interface.h +2 -0
@@ -1,6 +1,8 @@ #ifndef GPG_INTERFACE_H #define GPG_INTERFACE_H +#include "strbuf.h" + struct signature_check { char *payload; char *gpg_output;
graph.h +2 -0
@@ -1,6 +1,8 @@#ifndef GRAPH_H #define GRAPH_H +#include "revision.h" +/* A graph is a pointer to this opaque structure */ struct git_graph ;
khash.h +2 -0
@@ -26,6 +26,8 @@#ifndef __AC_KHASH_H#define __AC_KHASH_H +#include "cache.h" +#define AC_VERSION_KHASH_H "0.2.8"typedef uint32_t khint32_t ;
line-log.h +1 -0
@@ -2,6 +2,7 @@#define LINE_LOG_H #include "diffcore.h" +#include "string-list.h" struct rev_info ;struct commit ;
list-objects.h +2 -0
@@ -1,6 +1,8 @@#ifndef LIST_OBJECTS_H #define LIST_OBJECTS_H +#include "revision.h" +typedef void (*show_commit_fn )(struct commit *,void *);typedef void (*show_object_fn )(struct object *,const struct name_path *,const char *,void *);void traverse_commit_list (struct rev_info *,show_commit_fn ,show_object_fn ,void *);
ll-merge.h +2 -0
@@ -5,6 +5,8 @@ #ifndef LL_MERGE_H #define LL_MERGE_H +#include "xdiff/xdiff.h" + struct ll_merge_options { unsigned virtual_ancestor : 1; unsigned variant : 2; /* favor ours, favor theirs, or union merge */
mailmap.h +2 -0
@@ -1,6 +1,8 @@#ifndef MAILMAP_H #define MAILMAP_H +#include "string-list.h" +int read_mailmap (struct string_list *map,char **repo_abbrev);void clear_mailmap (struct string_list *map);
merge-recursive.h +2 -0
@@ -1,6 +1,8 @@#ifndef MERGE_RECURSIVE_H #define MERGE_RECURSIVE_H +#include "commit.h" +#include "strbuf.h" #include "string-list.h" struct merge_options {
notes-merge.h +4 -0
@@ -1,6 +1,10 @@#ifndef NOTES_MERGE_H #define NOTES_MERGE_H +#include "commit.h" +#include "strbuf.h" +#include "notes.h" +#define NOTES_MERGE_WORKTREE "NOTES_MERGE_WORKTREE" enum notes_merge_verbosity {
notes-utils.h +1 -0
@@ -1,6 +1,7 @@#ifndef NOTES_UTILS_H #define NOTES_UTILS_H +#include "commit.h" #include "notes.h" /*
notes.h +1 -0
@@ -1,6 +1,7 @@#ifndef NOTES_H #define NOTES_H +#include "strbuf.h" #include "string-list.h" /*
object.h +2 -0
@@ -1,6 +1,8 @@ #ifndef OBJECT_H #define OBJECT_H +#include "cache.h" + struct object_list { struct object *item; struct object_list *next;
pack-bitmap.h +2 -0
@@ -3,7 +3,9 @@#include "ewah/ewok.h" #include "khash.h" +#include "pack.h" #include "pack-objects.h" +#include "revision.h" struct bitmap_disk_entry {uint32_t object_pos;
pack-objects.h +2 -0
@@ -1,6 +1,8 @@ #ifndef PACK_OBJECTS_H #define PACK_OBJECTS_H +#include "pack.h" + struct object_entry { struct pack_idx_entry idx; unsigned long size; /* uncompressed size */
patch-ids.h +3 -0
@@ -1,6 +1,9 @@ #ifndef PATCH_IDS_H #define PATCH_IDS_H +#include "commit.h" +#include "diff.h" + struct patch_id { unsigned char patch_id[20]; char seen;
reachable.h +2 -0
@@ -1,6 +1,8 @@#ifndef REACHEABLE_H #define REACHEABLE_H +#include "revision.h" +struct progress ;extern void mark_reachable_objects (struct rev_info *revs,int mark_reflog,struct progress *);
reflog-walk.h +1 -0
@@ -2,6 +2,7 @@#define REFLOG_WALK_H #include "cache.h" +#include "commit.h" struct reflog_walk_info ;
refs.h +3 -0
@@ -1,6 +1,9 @@ #ifndef REFS_H #define REFS_H +#include "strbuf.h" +#include "string-list.h" + struct ref_lock { char *ref_name; char *orig_ref_name;
remote.h +1 -0
@@ -2,6 +2,7 @@#define REMOTE_H #include "parse-options.h" +#include "strbuf.h" #include "hashmap.h" enum {
resolve-undo.h +4 -0
@@ -1,6 +1,10 @@ #ifndef RESOLVE_UNDO_H #define RESOLVE_UNDO_H +#include "cache.h" +#include "pathspec.h" +#include "string-list.h" + struct resolve_undo_info { unsigned int mode[3]; unsigned char sha1[3][20];
send-pack.h +3 -0
@@ -1,6 +1,9 @@ #ifndef SEND_PACK_H #define SEND_PACK_H +#include "remote.h" +#include "run-command.h" + struct send_pack_args { unsigned verbose:1, quiet:1,
sequencer.h +2 -0
@@ -1,6 +1,8 @@#ifndef SEQUENCER_H #define SEQUENCER_H +#include "strbuf.h" +#define SEQ_DIR "sequencer"#define SEQ_HEAD_FILE "sequencer/head"#define SEQ_TODO_FILE "sequencer/todo"
shortlog.h +1 -0
@@ -1,6 +1,7 @@#ifndef SHORTLOG_H #define SHORTLOG_H +#include "commit.h" #include "string-list.h" struct shortlog {
submodule.h +3 -2
@@ -1,8 +1,9 @@#ifndef SUBMODULE_H #define SUBMODULE_H -struct diff_options ; -struct argv_array ; +#include "argv-array.h" +#include "diff.h" +#include "string-list.h" enum { RECURSE_SUBMODULES_ON_DEMAND = -1,
tree-walk.h +2 -0
@@ -1,6 +1,8 @@ #ifndef TREE_WALK_H #define TREE_WALK_H +#include "strbuf.h" + struct name_entry { const unsigned char *sha1; const char *path;
tree.h +1 -0
@@ -1,6 +1,7 @@#ifndef TREE_H #define TREE_H +#include "cache.h" #include "object.h" extern const char *tree_type;
unicode_width.h +12 -0
@@ -1,3 +1,13 @@ +#ifndef UNICODE_WIDTH_H +#define UNICODE_WIDTH_H + +typedef unsigned int ucs_char_t ;/* assuming 32bit int */ + +struct interval { +ucs_char_t first; +ucs_char_t last; +}; +static const struct interval zero_width[] = { {0x0300 ,0x036F }, { 0x0483, 0x0489 },
@@ -321,3 +331,5 @@ static const struct interval double_width[] = { { 0x20000, 0x2FFFD }, { 0x30000, 0x3FFFD } }; + +#endif
unpack-trees.h +2 -0
@@ -1,7 +1,9 @@#ifndef UNPACK_TREES_H #define UNPACK_TREES_H +#include "cache.h" #include "string-list.h" +#include "tree-walk.h" #define MAX_UNPACK_TREES 8
url.h +2 -0
@@ -1,6 +1,8 @@#ifndef URL_H #define URL_H +#include "strbuf.h" +extern int is_url (const char *url);extern int is_urlschemechar (int first_flag,int ch);extern char *url_decode (const char *url);
utf8.c +0 -5
@@ -4,11 +4,6 @@/* This code is originally from http://www.cl.cam.ac.uk/~mgk25/ucs/ */ -struct interval { -ucs_char_t first; -ucs_char_t last; -}; -size_t display_mode_esc_sequence_len (const char *s) {const char *p = s;
utf8.h +2 -1
@@ -1,7 +1,8 @@#ifndef GIT_UTF8_H #define GIT_UTF8_H -typedef unsigned int ucs_char_t ;/* assuming 32bit int */ +#include "strbuf.h" +#include "unicode_width.h" size_t display_mode_esc_sequence_len (const char *s);int utf8_width (const char **start,size_t *remainder_p);
walker.h +1 -0
@@ -2,6 +2,7 @@#define WALKER_H #include "remote.h" +#include "pathspec.h" struct walker {void *data;
wt-status.h +1 -0
@@ -4,6 +4,7 @@#include <stdio.h> #include "string-list.h" #include "color.h" +#include "pathspec.h" enum color_wt_status {WT_STATUS_HEADER =0 ,
xdiff/xdiffi.h +2 -0
@@ -23,6 +23,8 @@ #if !defined(XDIFFI_H) #define XDIFFI_H +#include "xdiff.h" +#include "xtypes.h" typedef struct s_diffdata { long nrec;
xdiff/xemit.h +3 -0
@@ -23,6 +23,9 @@#if !defined(XEMIT_H )#define XEMIT_H +#include "xdiff.h" +#include "xdiffi.h" +#include "xtypes.h" typedef int (*emit_func_t )(xdfenv_t *xe,xdchange_t *xscr,xdemitcb_t *ecb,xdemitconf_t const *xecfg);
xdiff/xprepare.h +2 -1
@@ -23,7 +23,8 @@#if !defined(XPREPARE_H )#define XPREPARE_H - +#include "xdiff.h" +#include "xtypes.h" int xdl_prepare_env (mmfile_t *mf1,mmfile_t *mf2,xpparam_t const *xpp,xdfenv_t *xe);
xdiff/xutils.h +2 -1
@@ -23,7 +23,8 @@#if !defined(XUTILS_H )#define XUTILS_H - +#include "xdiff.h" +#include "xtypes.h" long xdl_bogosqrt (long n); int xdl_emit_diffrec(char const *rec, long size, char const *pre, long psize,
Signature · 1 line
2.0.4.1.g929bde9