From bfddbc5e1e68373ba96441ca228236667912265c Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 10 Dec 2006 13:50:59 -0800 Subject: diff --numstat: show binary with '-' to match "apply --numstat" This changes the --numstat output for binary files from "0 0" to "- -" to match what "apply --numstat" does. Signed-off-by: Junio C Hamano --- diff.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'diff.c') diff --git a/diff.c b/diff.c index 33153787b8..d6d17f4734 100644 --- a/diff.c +++ b/diff.c @@ -802,7 +802,10 @@ static void show_numstat(struct diffstat_t* data, struct diff_options *options) for (i = 0; i < data->nr; i++) { struct diffstat_file *file = data->files[i]; - printf("%d\t%d\t", file->added, file->deleted); + if (file->is_binary) + printf("-\t-\t"); + else + printf("%d\t%d\t", file->added, file->deleted); if (options->line_termination && quote_c_style(file->name, NULL, NULL, 0)) quote_c_style(file->name, NULL, stdout, 0); -- cgit v1.3 From a159ca0cb7e0acdd37cb066327dcb020d95602d0 Mon Sep 17 00:00:00 2001 From: Andy Parkins Date: Wed, 13 Dec 2006 09:13:28 +0000 Subject: Allow subcommand.color and color.subcommand color configuration While adding colour to the branch command it was pointed out that a config option like "branch.color" conflicts with the pre-existing "branch.something" namespace used for specifying default merge urls and branches. The suggested solution was to flip the order of the components to "color.branch", which I did for colourising branch. This patch does the same thing for - git-log (color.diff) - git-status (color.status) - git-diff (color.diff) - pager (color.pager) I haven't removed the old config options; but they should probably be deprecated and eventually removed to prevent future namespace collisions. I've done this deprecation by changing the documentation for the config file to match the new names; and adding the "color.XXX" options to contrib/completion/git-completion.bash. Unfortunately git-svn reads "diff.color" and "pager.color"; which I don't like to change unilaterally. Signed-off-by: Andy Parkins Signed-off-by: Junio C Hamano --- Documentation/config.txt | 12 ++++++------ builtin-log.c | 2 +- config.c | 2 +- contrib/completion/git-completion.bash | 3 +++ diff.c | 4 ++-- wt-status.c | 4 ++-- 6 files changed, 15 insertions(+), 12 deletions(-) (limited to 'diff.c') diff --git a/Documentation/config.txt b/Documentation/config.txt index 21ec55797b..f5a552ee87 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -137,16 +137,16 @@ branch..merge:: this option, `git pull` defaults to merge the first refspec fetched. Specify multiple values to get an octopus merge. -pager.color:: +color.pager:: A boolean to enable/disable colored output when the pager is in use (default is true). -diff.color:: +color.diff:: When true (or `always`), always use colors in patch. When false (or `never`), never. When set to `auto`, use colors only when the output is to the terminal. -diff.color.:: +color.diff.:: Use customized color for diff colorization. `` specifies which part of the patch to use the specified color, and is one of `plain` (context text), `meta` @@ -271,19 +271,19 @@ showbranch.default:: The default set of branches for gitlink:git-show-branch[1]. See gitlink:git-show-branch[1]. -status.color:: +color.status:: A boolean to enable/disable color in the output of gitlink:git-status[1]. May be set to `true` (or `always`), `false` (or `never`) or `auto`, in which case colors are used only when the output is to a terminal. Defaults to false. -status.color.:: +color.status.:: Use customized color for status colorization. `` is one of `header` (the header text of the status message), `updated` (files which are updated but not committed), `changed` (files which are changed but not updated in the index), or `untracked` (files which are not tracked by git). The values of - these variables may be specified as in diff.color.. + these variables may be specified as in color.diff.. tar.umask:: By default, gitlink:git-tar-tree[1] sets file and directories modes diff --git a/builtin-log.c b/builtin-log.c index 7acf5d3b0c..6821a08442 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -118,7 +118,7 @@ static int git_format_config(const char *var, const char *value) strcat(extra_headers, value); return 0; } - if (!strcmp(var, "diff.color")) { + if (!strcmp(var, "diff.color") || !strcmp(var, "color.diff")) { return 0; } return git_log_config(var, value); diff --git a/config.c b/config.c index 3cae3901aa..1bdef44a3a 100644 --- a/config.c +++ b/config.c @@ -314,7 +314,7 @@ int git_default_config(const char *var, const char *value) return 0; } - if (!strcmp(var, "pager.color")) { + if (!strcmp(var, "pager.color") || !strcmp(var, "color.pager")) { pager_use_color = git_config_bool(var,value); return 0; } diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 447ec20467..9c4d23a23c 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -712,10 +712,13 @@ _git_repo_config () core.legacyHeaders i18n.commitEncoding diff.color + color.diff diff.renameLimit diff.renames pager.color + color.pager status.color + color.status log.showroot show.difftree showbranch.default diff --git a/diff.c b/diff.c index 33153787b8..726b01e75e 100644 --- a/diff.c +++ b/diff.c @@ -60,7 +60,7 @@ int git_diff_ui_config(const char *var, const char *value) diff_rename_limit_default = git_config_int(var, value); return 0; } - if (!strcmp(var, "diff.color")) { + if (!strcmp(var, "diff.color") || !strcmp(var, "color.diff")) { diff_use_color_default = git_config_colorbool(var, value); return 0; } @@ -74,7 +74,7 @@ int git_diff_ui_config(const char *var, const char *value) diff_detect_rename_default = DIFF_DETECT_RENAME; return 0; } - if (!strncmp(var, "diff.color.", 11)) { + if (!strncmp(var, "diff.color.", 11) || !strncmp(var, "color.diff.", 11)) { int slot = parse_diff_color_slot(var, 11); color_parse(value, var, diff_colors[slot]); return 0; diff --git a/wt-status.c b/wt-status.c index de1be5bc66..df582a03ef 100644 --- a/wt-status.c +++ b/wt-status.c @@ -297,11 +297,11 @@ void wt_status_print(struct wt_status *s) int git_status_config(const char *k, const char *v) { - if (!strcmp(k, "status.color")) { + if (!strcmp(k, "status.color") || !strcmp(k, "color.status")) { wt_status_use_color = git_config_colorbool(k, v); return 0; } - if (!strncmp(k, "status.color.", 13)) { + if (!strncmp(k, "status.color.", 13) || !strncmp(k, "color.status", 13)) { int slot = parse_status_slot(k, 13); color_parse(v, k, wt_status_colors[slot]); } -- cgit v1.3 From 1510fea781cb0517eeba8c378964f7bc4f9577ab Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 14 Dec 2006 06:15:57 -0500 Subject: Avoid accessing a slow working copy during diffcore operations. The Cygwin folks have done a fine job at creating a POSIX layer on Windows That Just Works(tm). However it comes with a penalty; accessing files in the working tree by way of stat/open/mmap can be slower for diffcore than inflating the data from a blob which is stored in a packfile. This performance problem is especially an issue in merge-recursive when dealing with nearly 7000 added files, as we are loading each file's content from the working directory to perform rename detection. I have literally seen (and sadly watched) paint dry in less time than it takes for merge-recursive to finish such a merge. On the other hand this very same merge runs very fast on Solaris. If Git is compiled with NO_FAST_WORKING_DIRECTORY set then we will avoid looking at the working directory when the blob in question is available within a packfile and the caller doesn't need the data unpacked into a temporary file. We don't use loose objects as they have the same open/mmap/close costs as the working directory file access, but have the additional CPU overhead of needing to inflate the content before use. So it is still faster to use the working tree file over the loose object. If the caller needs the file data unpacked into a temporary file its likely because they are going to call an external diff program, passing the file as a parameter. In this case reusing the working tree file will be faster as we don't need to inflate the data and write it out to a temporary file. The NO_FAST_WORKING_DIRECTORY feature is enabled by default on Cygwin, as that is the platform which currently appears to benefit the most from this option. Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- Makefile | 7 +++++++ diff.c | 24 +++++++++++++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) (limited to 'diff.c') diff --git a/Makefile b/Makefile index 2d17fa7027..676d426a9e 100644 --- a/Makefile +++ b/Makefile @@ -69,6 +69,9 @@ all: # # Define NO_MMAP if you want to avoid mmap. # +# Define NO_FAST_WORKING_DIRECTORY if accessing objects in pack files is +# generally faster on your platform than accessing the working directory. +# # Define NO_IPV6 if you lack IPv6 support and getaddrinfo(). # # Define NO_SOCKADDR_STORAGE if your platform does not have struct @@ -355,6 +358,7 @@ ifeq ($(uname_O),Cygwin) NO_SYMLINK_HEAD = YesPlease NEEDS_LIBICONV = YesPlease NO_C99_FORMAT = YesPlease + NO_FAST_WORKING_DIRECTORY = UnfortunatelyYes # There are conflicting reports about this. # On some boxes NO_MMAP is needed, and not so elsewhere. # Try uncommenting this if you see things break -- YMMV. @@ -506,6 +510,9 @@ ifdef NO_MMAP COMPAT_CFLAGS += -DNO_MMAP COMPAT_OBJS += compat/mmap.o endif +ifdef NO_FAST_WORKING_DIRECTORY + BASIC_CFLAGS += -DNO_FAST_WORKING_DIRECTORY +endif ifdef NO_IPV6 BASIC_CFLAGS += -DNO_IPV6 endif diff --git a/diff.c b/diff.c index 2df14b2469..77ba641aa4 100644 --- a/diff.c +++ b/diff.c @@ -12,6 +12,12 @@ #include "xdiff-interface.h" #include "color.h" +#ifdef NO_FAST_WORKING_DIRECTORY +#define FAST_WORKING_DIRECTORY 0 +#else +#define FAST_WORKING_DIRECTORY 1 +#endif + static int use_size_cache; static int diff_detect_rename_default; @@ -1158,7 +1164,7 @@ void fill_filespec(struct diff_filespec *spec, const unsigned char *sha1, * the work tree has that object contents, return true, so that * prepare_temp_file() does not have to inflate and extract. */ -static int work_tree_matches(const char *name, const unsigned char *sha1) +static int reuse_worktree_file(const char *name, const unsigned char *sha1, int want_file) { struct cache_entry *ce; struct stat st; @@ -1179,6 +1185,18 @@ static int work_tree_matches(const char *name, const unsigned char *sha1) if (!active_cache) return 0; + /* We want to avoid the working directory if our caller + * doesn't need the data in a normal file, this system + * is rather slow with its stat/open/mmap/close syscalls, + * and the object is contained in a pack file. The pack + * is probably already open and will be faster to obtain + * the data through than the working directory. Loose + * objects however would tend to be slower as they need + * to be individually opened and inflated. + */ + if (FAST_WORKING_DIRECTORY && !want_file && has_sha1_pack(sha1, NULL)) + return 0; + len = strlen(name); pos = cache_name_pos(name, len); if (pos < 0) @@ -1265,7 +1283,7 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only) if (s->data) return err; if (!s->sha1_valid || - work_tree_matches(s->path, s->sha1)) { + reuse_worktree_file(s->path, s->sha1, 0)) { struct stat st; int fd; if (lstat(s->path, &st) < 0) { @@ -1372,7 +1390,7 @@ static void prepare_temp_file(const char *name, } if (!one->sha1_valid || - work_tree_matches(name, one->sha1)) { + reuse_worktree_file(name, one->sha1, 1)) { struct stat st; if (lstat(name, &st) < 0) { if (errno == ENOENT) -- cgit v1.3 From ebd124c6783da5e064963611ee17741cd173f6b5 Mon Sep 17 00:00:00 2001 From: Nicolas Pitre Date: Thu, 14 Dec 2006 23:15:44 -0500 Subject: make commit message a little more consistent and conforting It is nicer to let the user know when a commit succeeded all the time, not only the first time. Also the commit sha1 is much more useful than the tree sha1 in this case. This patch also introduces a -q switch to supress this message as well as the summary of created/deleted files. Signed-off-by: Nicolas Pitre Signed-off-by: Junio C Hamano --- Documentation/core-tutorial.txt | 14 +++----------- Documentation/diff-options.txt | 5 +++++ Documentation/git-commit.txt | 3 +++ Documentation/tutorial-2.txt | 29 ++++++++++++++++++++--------- builtin-commit-tree.c | 2 -- diff.c | 38 +++++++++++++++++++++++++++++++++++++- diff.h | 1 + git-commit.sh | 19 +++++++++++++++---- t/t1200-tutorial.sh | 2 -- 9 files changed, 84 insertions(+), 29 deletions(-) (limited to 'diff.c') diff --git a/Documentation/core-tutorial.txt b/Documentation/core-tutorial.txt index 47505aa20a..1c311590c7 100644 --- a/Documentation/core-tutorial.txt +++ b/Documentation/core-tutorial.txt @@ -336,17 +336,9 @@ $ commit=$(echo 'Initial commit' | git-commit-tree $tree) $ git-update-ref HEAD $commit ------------------------------------------------ -which will say: - ----------------- -Committing initial tree 8988da15d077d4829fc51d8544c097def6644dbb ----------------- - -just to warn you about the fact that it created a totally new commit -that is not related to anything else. Normally you do this only *once* -for a project ever, and all later commits will be parented on top of an -earlier commit, and you'll never see this "Committing initial tree" -message ever again. +In this case this creates a totally new commit that is not related to +anything else. Normally you do this only *once* for a project ever, and +all later commits will be parented on top of an earlier commit. Again, normally you'd never actually do this by hand. There is a helpful script called `git commit` that will do all of this for you. So diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt index 9cdd171af7..f12082e134 100644 --- a/Documentation/diff-options.txt +++ b/Documentation/diff-options.txt @@ -21,6 +21,11 @@ deleted lines in decimal notation and pathname without abbreviation, to make it more machine friendly. +--shortstat:: + Output only the last line of the --stat format containing total + number of modified files, as well as number of added and deleted + lines. + --summary:: Output a condensed summary of extended header information such as creations, renames and mode changes. diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt index 97d66ef4d2..0b74cd708e 100644 --- a/Documentation/git-commit.txt +++ b/Documentation/git-commit.txt @@ -113,6 +113,9 @@ but can be used to amend a merge commit. as well. This is usually not what you want unless you are concluding a conflicted merge. +-q|--quiet:: + Supress commit summary message. + \--:: Do not interpret any more arguments as options. diff --git a/Documentation/tutorial-2.txt b/Documentation/tutorial-2.txt index 6389de5ef7..8606381e6c 100644 --- a/Documentation/tutorial-2.txt +++ b/Documentation/tutorial-2.txt @@ -22,14 +22,14 @@ defaulting to local storage area $ echo 'hello world' > file.txt $ git add . $ git commit -a -m "initial commit" -Committing initial tree 92b8b694ffb1675e5975148e1121810081dbdffe +Created initial commit 54196cc2703dc165cbd373a65a4dcf22d50ae7f7 create mode 100644 file.txt $ echo 'hello world!' >file.txt $ git commit -a -m "add emphasis" +Created commit c4d59f390b9cfd4318117afde11d601c1085f241 ------------------------------------------------ -What are the 40 digits of hex that git responded to the first commit -with? +What are the 40 digits of hex that git responded to the commit with? We saw in part one of the tutorial that commits have names like this. It turns out that every object in the git history is stored under @@ -39,13 +39,25 @@ the same data twice (since identical data is given an identical SHA1 name), and that the contents of a git object will never change (since that would change the object's name as well). +It is expected that the content of the commit object you created while +following the example above generates a different SHA1 hash than +the one shown above because the commit object records the time when +it was created and the name of the person performing the commit. + We can ask git about this particular object with the cat-file -command--just cut-and-paste from the reply to the initial commit, to -save yourself typing all 40 hex digits: +command. Don't copy the 40 hex digits from this example but use those +from your own version. Note that you can shorten it to only a few +characters to save yourself typing all 40 hex digits: ------------------------------------------------ -$ git cat-file -t 92b8b694ffb1675e5975148e1121810081dbdffe -tree +$ git-cat-file -t 54196cc2 +commit +$ git-cat-file commit 54196cc2 +tree 92b8b694ffb1675e5975148e1121810081dbdffe +author J. Bruce Fields 1143414668 -0500 +committer J. Bruce Fields 1143414668 -0500 + +initial commit ------------------------------------------------ A tree can refer to one or more "blob" objects, each corresponding to @@ -102,8 +114,7 @@ $ find .git/objects/ and the contents of these files is just the compressed data plus a header identifying their length and their type. The type is either a -blob, a tree, a commit, or a tag. We've seen a blob and a tree now, -so next we should look at a commit. +blob, a tree, a commit, or a tag. The simplest commit to find is the HEAD commit, which we can find from .git/HEAD: diff --git a/builtin-commit-tree.c b/builtin-commit-tree.c index e2e690a1ae..856f3cd841 100644 --- a/builtin-commit-tree.c +++ b/builtin-commit-tree.c @@ -107,8 +107,6 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix) if (new_parent(parents)) parents++; } - if (!parents) - fprintf(stderr, "Committing initial tree %s\n", argv[1]); init_buffer(&buffer, &size); add_buffer(&buffer, &size, "tree %s\n", sha1_to_hex(tree_sha1)); diff --git a/diff.c b/diff.c index 77ba641aa4..99744354a7 100644 --- a/diff.c +++ b/diff.c @@ -801,6 +801,35 @@ static void show_stats(struct diffstat_t* data, struct diff_options *options) set, total_files, adds, dels, reset); } +static void show_shortstats(struct diffstat_t* data) +{ + int i, adds = 0, dels = 0, total_files = data->nr; + + if (data->nr == 0) + return; + + for (i = 0; i < data->nr; i++) { + if (!data->files[i]->is_binary && + !data->files[i]->is_unmerged) { + int added = data->files[i]->added; + int deleted= data->files[i]->deleted; + if (!data->files[i]->is_renamed && + (added + deleted == 0)) { + total_files--; + } else { + adds += added; + dels += deleted; + } + } + free(data->files[i]->name); + free(data->files[i]); + } + free(data->files); + + printf(" %d files changed, %d insertions(+), %d deletions(-)\n", + total_files, adds, dels); +} + static void show_numstat(struct diffstat_t* data, struct diff_options *options) { int i; @@ -1771,6 +1800,7 @@ int diff_setup_done(struct diff_options *options) options->output_format &= ~(DIFF_FORMAT_RAW | DIFF_FORMAT_NUMSTAT | DIFF_FORMAT_DIFFSTAT | + DIFF_FORMAT_SHORTSTAT | DIFF_FORMAT_SUMMARY | DIFF_FORMAT_PATCH); @@ -1781,6 +1811,7 @@ int diff_setup_done(struct diff_options *options) if (options->output_format & (DIFF_FORMAT_PATCH | DIFF_FORMAT_NUMSTAT | DIFF_FORMAT_DIFFSTAT | + DIFF_FORMAT_SHORTSTAT | DIFF_FORMAT_SUMMARY | DIFF_FORMAT_CHECKDIFF)) options->recursive = 1; @@ -1872,6 +1903,9 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac) else if (!strcmp(arg, "--numstat")) { options->output_format |= DIFF_FORMAT_NUMSTAT; } + else if (!strcmp(arg, "--shortstat")) { + options->output_format |= DIFF_FORMAT_SHORTSTAT; + } else if (!strncmp(arg, "--stat", 6)) { char *end; int width = options->stat_width; @@ -2646,7 +2680,7 @@ void diff_flush(struct diff_options *options) separator++; } - if (output_format & (DIFF_FORMAT_DIFFSTAT|DIFF_FORMAT_NUMSTAT)) { + if (output_format & (DIFF_FORMAT_DIFFSTAT|DIFF_FORMAT_SHORTSTAT|DIFF_FORMAT_NUMSTAT)) { struct diffstat_t diffstat; memset(&diffstat, 0, sizeof(struct diffstat_t)); @@ -2660,6 +2694,8 @@ void diff_flush(struct diff_options *options) show_numstat(&diffstat, options); if (output_format & DIFF_FORMAT_DIFFSTAT) show_stats(&diffstat, options); + else if (output_format & DIFF_FORMAT_SHORTSTAT) + show_shortstats(&diffstat); separator++; } diff --git a/diff.h b/diff.h index 101b2b505d..eff445596d 100644 --- a/diff.h +++ b/diff.h @@ -29,6 +29,7 @@ typedef void (*diff_format_fn_t)(struct diff_queue_struct *q, #define DIFF_FORMAT_NUMSTAT 0x0004 #define DIFF_FORMAT_SUMMARY 0x0008 #define DIFF_FORMAT_PATCH 0x0010 +#define DIFF_FORMAT_SHORTSTAT 0x0020 /* These override all above */ #define DIFF_FORMAT_NAME 0x0100 diff --git a/git-commit.sh b/git-commit.sh index 05828bb113..a30bda19d5 100755 --- a/git-commit.sh +++ b/git-commit.sh @@ -80,6 +80,7 @@ no_edit= log_given= log_message= verify=t +quiet= verbose= signoff= force_author= @@ -241,6 +242,10 @@ $1" signoff=t shift ;; + -q|--q|--qu|--qui|--quie|--quiet) + quiet=t + shift + ;; -v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose) verbose=t shift @@ -615,11 +620,17 @@ then git-rerere fi -if test -x "$GIT_DIR"/hooks/post-commit && test "$ret" = 0 +if test "$ret" = 0 then - "$GIT_DIR"/hooks/post-commit + if test -x "$GIT_DIR"/hooks/post-commit + then + "$GIT_DIR"/hooks/post-commit + fi + if test -z "$quiet" + then + echo "Created${initial_commit:+ initial} commit $commit" + git-diff-tree --shortstat --summary --root --no-commit-id HEAD + fi fi -test "$ret" = 0 && git-diff-tree --summary --root --no-commit-id HEAD - exit "$ret" diff --git a/t/t1200-tutorial.sh b/t/t1200-tutorial.sh index 0272dd4293..eebe643bda 100755 --- a/t/t1200-tutorial.sh +++ b/t/t1200-tutorial.sh @@ -37,8 +37,6 @@ test_expect_success 'tree' "test 8988da15d077d4829fc51d8544c097def6644dbb = $tre output="$(echo "Initial commit" | git-commit-tree $(git-write-tree) 2>&1 > .git/refs/heads/master)" -test_expect_success 'commit' "test 'Committing initial tree 8988da15d077d4829fc51d8544c097def6644dbb' = \"$output\"" - git-diff-index -p HEAD > diff.output test_expect_success 'git-diff-index -p HEAD' 'cmp diff.expect diff.output' -- cgit v1.3 From 5caf92322303a0942e0cee5a93cb24f2d8d44022 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 19 Dec 2006 18:26:48 -0800 Subject: fix populate-filespec I hand munged the original patch when committing 1510fea78, and screwed up the conversion. Signed-off-by: Junio C Hamano --- diff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'diff.c') diff --git a/diff.c b/diff.c index 99744354a7..6e6f2a765c 100644 --- a/diff.c +++ b/diff.c @@ -1223,7 +1223,7 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int * objects however would tend to be slower as they need * to be individually opened and inflated. */ - if (FAST_WORKING_DIRECTORY && !want_file && has_sha1_pack(sha1, NULL)) + if (!FAST_WORKING_DIRECTORY && !want_file && has_sha1_pack(sha1, NULL)) return 0; len = strlen(name); -- cgit v1.3 From 85023577a8f4b540aa64aa37f6f44578c0c305a3 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 19 Dec 2006 14:34:12 -0800 Subject: 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 --- archive-tar.c | 1 - archive-zip.c | 1 - blob.c | 1 - builtin-add.c | 2 -- builtin-apply.c | 1 - builtin-archive.c | 1 - builtin-blame.c | 4 ---- builtin-branch.c | 2 +- builtin-for-each-ref.c | 1 - builtin-grep.c | 3 --- builtin-log.c | 2 -- builtin-ls-files.c | 2 -- builtin-mailinfo.c | 9 --------- builtin-mailsplit.c | 7 ------- builtin-mv.c | 2 -- builtin-name-rev.c | 1 - builtin-pack-objects.c | 2 -- builtin-repo-config.c | 1 - builtin-runstatus.c | 2 +- builtin-shortlog.c | 1 - builtin-show-branch.c | 2 -- builtin-stripspace.c | 3 --- builtin-tar-tree.c | 1 - builtin-unpack-objects.c | 2 -- builtin-upload-archive.c | 3 --- color.c | 5 +---- compat/mmap.c | 4 ---- compat/setenv.c | 3 +-- compat/strlcpy.c | 2 +- compat/unsetenv.c | 3 +-- config.c | 1 - connect.c | 6 ------ convert-objects.c | 4 ---- daemon.c | 16 +++------------- date.c | 3 --- diff-delta.c | 5 +---- diff.c | 3 --- diffcore-order.c | 1 - diffcore-pickaxe.c | 2 -- dir.c | 3 --- entry.c | 2 -- fetch-pack.c | 1 - fetch.c | 3 +-- fsck-objects.c | 3 --- git-compat-util.h | 25 ++++++++++++++++++++++++- git.c | 14 +------------- grep.c | 1 - help.c | 3 +-- ident.c | 3 --- imap-send.c | 7 ------- index-pack.c | 5 ----- interpolate.c | 2 -- lockfile.c | 1 - merge-base.c | 1 - merge-index.c | 4 ---- merge-recursive.c | 7 ------- path-list.c | 1 - path.c | 1 - receive-pack.c | 1 - refs.c | 4 +--- revision.c | 1 - rsh.c | 6 +----- run-command.c | 1 - ssh-upload.c | 2 -- strbuf.c | 4 +--- test-date.c | 3 --- test-delta.c | 8 +------- tree.c | 1 - unpack-trees.c | 2 -- upload-pack.c | 3 --- var.c | 3 --- wt-status.c | 2 +- 72 files changed, 42 insertions(+), 201 deletions(-) (limited to 'diff.c') diff --git a/archive-tar.c b/archive-tar.c index ff0f6e2929..af47fdc955 100644 --- a/archive-tar.c +++ b/archive-tar.c @@ -1,7 +1,6 @@ /* * Copyright (c) 2005, 2006 Rene Scharfe */ -#include #include "cache.h" #include "commit.h" #include "strbuf.h" diff --git a/archive-zip.c b/archive-zip.c index 36e922a1f2..f31b8ed823 100644 --- a/archive-zip.c +++ b/archive-zip.c @@ -1,7 +1,6 @@ /* * Copyright (c) 2006 Rene Scharfe */ -#include #include "cache.h" #include "commit.h" #include "blob.h" diff --git a/blob.c b/blob.c index d1af2e62f1..9776beac58 100644 --- a/blob.c +++ b/blob.c @@ -1,6 +1,5 @@ #include "cache.h" #include "blob.h" -#include const char *blob_type = "blob"; diff --git a/builtin-add.c b/builtin-add.c index b3f920676a..c8a114fefb 100644 --- a/builtin-add.c +++ b/builtin-add.c @@ -3,8 +3,6 @@ * * Copyright (C) 2006 Linus Torvalds */ -#include - #include "cache.h" #include "builtin.h" #include "dir.h" diff --git a/builtin-apply.c b/builtin-apply.c index 436d9e1880..1c35837068 100644 --- a/builtin-apply.c +++ b/builtin-apply.c @@ -6,7 +6,6 @@ * This applies patches on top of some (arbitrary) version of the SCM. * */ -#include #include "cache.h" #include "cache-tree.h" #include "quote.h" diff --git a/builtin-archive.c b/builtin-archive.c index a8a1f079bf..391cf43911 100644 --- a/builtin-archive.c +++ b/builtin-archive.c @@ -2,7 +2,6 @@ * Copyright (c) 2006 Franck Bui-Huu * Copyright (c) 2006 Rene Scharfe */ -#include #include "cache.h" #include "builtin.h" #include "archive.h" diff --git a/builtin-blame.c b/builtin-blame.c index a250724463..9bf6ec951f 100644 --- a/builtin-blame.c +++ b/builtin-blame.c @@ -15,10 +15,6 @@ #include "revision.h" #include "xdiff-interface.h" -#include -#include -#include - static char blame_usage[] = "git-blame [-c] [-l] [-t] [-f] [-n] [-p] [-L n,m] [-S ] [-M] [-C] [-C] [commit] [--] file\n" " -c, --compatibility Use the same output mode as git-annotate (Default: off)\n" diff --git a/builtin-branch.c b/builtin-branch.c index 560309cb15..515330c155 100644 --- a/builtin-branch.c +++ b/builtin-branch.c @@ -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" diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c index 227aa3cd7f..af72a12a57 100644 --- a/builtin-for-each-ref.c +++ b/builtin-for-each-ref.c @@ -6,7 +6,6 @@ #include "tree.h" #include "blob.h" #include "quote.h" -#include /* Quoting styles */ #define QUOTE_NONE 0 diff --git a/builtin-grep.c b/builtin-grep.c index 9873e3d1db..3b1b1cbbfa 100644 --- a/builtin-grep.c +++ b/builtin-grep.c @@ -10,10 +10,7 @@ #include "tag.h" #include "tree-walk.h" #include "builtin.h" -#include #include "grep.h" -#include -#include /* * git grep pathspecs are somewhat different from diff-tree pathspecs; diff --git a/builtin-log.c b/builtin-log.c index 17014f70a2..8df3c1394a 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -11,8 +11,6 @@ #include "log-tree.h" #include "builtin.h" #include "tag.h" -#include -#include static int default_show_root = 1; diff --git a/builtin-ls-files.c b/builtin-ls-files.c index bc79ce40fc..21c2a6e2d9 100644 --- a/builtin-ls-files.c +++ b/builtin-ls-files.c @@ -5,8 +5,6 @@ * * Copyright (C) Linus Torvalds, 2005 */ -#include - #include "cache.h" #include "quote.h" #include "dir.h" diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c index b8d7dbc0b7..e6472293d4 100644 --- a/builtin-mailinfo.c +++ b/builtin-mailinfo.c @@ -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 -#include -#include -#include -#ifndef NO_ICONV -#include -#endif -#include "git-compat-util.h" #include "cache.h" #include "builtin.h" diff --git a/builtin-mailsplit.c b/builtin-mailsplit.c index 91a699d34d..3bca855aae 100644 --- a/builtin-mailsplit.c +++ b/builtin-mailsplit.c @@ -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 -#include -#include -#include -#include -#include -#include #include "cache.h" #include "builtin.h" diff --git a/builtin-mv.c b/builtin-mv.c index d14a4a7f5c..737af350b8 100644 --- a/builtin-mv.c +++ b/builtin-mv.c @@ -3,8 +3,6 @@ * * Copyright (C) 2006 Johannes Schindelin */ -#include - #include "cache.h" #include "builtin.h" #include "dir.h" diff --git a/builtin-name-rev.c b/builtin-name-rev.c index 618aa314d2..b4f15cc38a 100644 --- a/builtin-name-rev.c +++ b/builtin-name-rev.c @@ -1,4 +1,3 @@ -#include #include "builtin.h" #include "cache.h" #include "commit.h" diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c index a2dc7d1d9d..807be8c3f8 100644 --- a/builtin-pack-objects.c +++ b/builtin-pack-objects.c @@ -12,8 +12,6 @@ #include "diff.h" #include "revision.h" #include "list-objects.h" -#include -#include static const char pack_usage[] = "\ git-pack-objects [{ -q | --progress | --all-progress }] \n\ diff --git a/builtin-repo-config.c b/builtin-repo-config.c index a38099a63d..a7ab4cee58 100644 --- a/builtin-repo-config.c +++ b/builtin-repo-config.c @@ -1,6 +1,5 @@ #include "builtin.h" #include "cache.h" -#include 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"; diff --git a/builtin-runstatus.c b/builtin-runstatus.c index 0b63037dd0..4b489b1214 100644 --- a/builtin-runstatus.c +++ b/builtin-runstatus.c @@ -1,5 +1,5 @@ -#include "wt-status.h" #include "cache.h" +#include "wt-status.h" extern int wt_status_use_color; diff --git a/builtin-shortlog.c b/builtin-shortlog.c index 3fc43dd7dd..edb40429ec 100644 --- a/builtin-shortlog.c +++ b/builtin-shortlog.c @@ -4,7 +4,6 @@ #include "diff.h" #include "path-list.h" #include "revision.h" -#include static const char shortlog_usage[] = "git-shortlog [-n] [-s] [... ]"; diff --git a/builtin-show-branch.c b/builtin-show-branch.c index a38ac34efb..b9d9781d4d 100644 --- a/builtin-show-branch.c +++ b/builtin-show-branch.c @@ -1,5 +1,3 @@ -#include -#include #include "cache.h" #include "commit.h" #include "refs.h" diff --git a/builtin-stripspace.c b/builtin-stripspace.c index 09cc9108cd..f0d4d9e2d1 100644 --- a/builtin-stripspace.c +++ b/builtin-stripspace.c @@ -1,6 +1,3 @@ -#include -#include -#include #include "builtin.h" /* diff --git a/builtin-tar-tree.c b/builtin-tar-tree.c index 4d4cfec878..11e62fc141 100644 --- a/builtin-tar-tree.c +++ b/builtin-tar-tree.c @@ -1,7 +1,6 @@ /* * Copyright (c) 2005, 2006 Rene Scharfe */ -#include #include "cache.h" #include "commit.h" #include "tar.h" diff --git a/builtin-unpack-objects.c b/builtin-unpack-objects.c index e6d7574844..d351e02649 100644 --- a/builtin-unpack-objects.c +++ b/builtin-unpack-objects.c @@ -8,8 +8,6 @@ #include "tag.h" #include "tree.h" -#include - static int dry_run, quiet, recover, has_errors; static const char unpack_usage[] = "git-unpack-objects [-n] [-q] [-r] < pack-file"; diff --git a/builtin-upload-archive.c b/builtin-upload-archive.c index 45c92e163c..e4156f8f48 100644 --- a/builtin-upload-archive.c +++ b/builtin-upload-archive.c @@ -1,9 +1,6 @@ /* * Copyright (c) 2006 Franck Bui-Huu */ -#include -#include -#include #include "cache.h" #include "builtin.h" #include "archive.h" diff --git a/color.c b/color.c index d8c8399d59..09d82eec3d 100644 --- a/color.c +++ b/color.c @@ -1,8 +1,5 @@ -#include "color.h" #include "cache.h" -#include "git-compat-util.h" - -#include +#include "color.h" #define COLOR_RESET "\033[m" diff --git a/compat/mmap.c b/compat/mmap.c index a4d2e507f7..0fd46e793d 100644 --- a/compat/mmap.c +++ b/compat/mmap.c @@ -1,7 +1,3 @@ -#include -#include -#include -#include #include "../git-compat-util.h" void *gitfakemmap(void *start, size_t length, int prot , int flags, int fd, off_t offset) diff --git a/compat/setenv.c b/compat/setenv.c index b7d7678598..3a22ea7b75 100644 --- a/compat/setenv.c +++ b/compat/setenv.c @@ -1,5 +1,4 @@ -#include -#include +#include "../git-compat-util.h" int gitsetenv(const char *name, const char *value, int replace) { diff --git a/compat/strlcpy.c b/compat/strlcpy.c index b66856a3a5..4024c36030 100644 --- a/compat/strlcpy.c +++ b/compat/strlcpy.c @@ -1,4 +1,4 @@ -#include +#include "../git-compat-util.h" size_t gitstrlcpy(char *dest, const char *src, size_t size) { diff --git a/compat/unsetenv.c b/compat/unsetenv.c index 3a5e4ec04a..eb29f5e084 100644 --- a/compat/unsetenv.c +++ b/compat/unsetenv.c @@ -1,5 +1,4 @@ -#include -#include +#include "../git-compat-util.h" void gitunsetenv (const char *name) { diff --git a/config.c b/config.c index 8cbdd178bd..e86b2328ab 100644 --- a/config.c +++ b/config.c @@ -6,7 +6,6 @@ * */ #include "cache.h" -#include #define MAXNAME (256) diff --git a/connect.c b/connect.c index f7edba82c4..66daa11a57 100644 --- a/connect.c +++ b/connect.c @@ -3,12 +3,6 @@ #include "pkt-line.h" #include "quote.h" #include "refs.h" -#include -#include -#include -#include -#include -#include static char *server_capabilities; diff --git a/convert-objects.c b/convert-objects.c index 881258311a..a630132985 100644 --- a/convert-objects.c +++ b/convert-objects.c @@ -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 #include "cache.h" #include "blob.h" #include "commit.h" diff --git a/daemon.c b/daemon.c index e66bb802da..b129b83e40 100644 --- a/daemon.c +++ b/daemon.c @@ -1,20 +1,10 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "pkt-line.h" #include "cache.h" +#include "pkt-line.h" #include "exec_cmd.h" #include "interpolate.h" +#include + #ifndef HOST_NAME_MAX #define HOST_NAME_MAX 256 #endif diff --git a/date.c b/date.c index 1825922732..7acb8cbd91 100644 --- a/date.c +++ b/date.c @@ -4,9 +4,6 @@ * Copyright (C) Linus Torvalds, 2005 */ -#include -#include - #include "cache.h" static time_t my_mktime(struct tm *tm) diff --git a/diff-delta.c b/diff-delta.c index fa16d06c8d..9f998d0a73 100644 --- a/diff-delta.c +++ b/diff-delta.c @@ -18,11 +18,8 @@ * licensing gets turned into GPLv2 within this project. */ -#include -#include -#include "delta.h" - #include "git-compat-util.h" +#include "delta.h" /* maximum hash entry list for the same hash bucket */ #define HASH_LIMIT 64 diff --git a/diff.c b/diff.c index 6e6f2a765c..91f956b23b 100644 --- a/diff.c +++ b/diff.c @@ -1,9 +1,6 @@ /* * Copyright (C) 2005 Junio C Hamano */ -#include -#include -#include #include "cache.h" #include "quote.h" #include "diff.h" diff --git a/diffcore-order.c b/diffcore-order.c index aef6da6044..7ad0946185 100644 --- a/diffcore-order.c +++ b/diffcore-order.c @@ -4,7 +4,6 @@ #include "cache.h" #include "diff.h" #include "diffcore.h" -#include static char **order; static int order_cnt; diff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c index cfcce315ba..de44adabf0 100644 --- a/diffcore-pickaxe.c +++ b/diffcore-pickaxe.c @@ -5,8 +5,6 @@ #include "diff.h" #include "diffcore.h" -#include - static unsigned int contains(struct diff_filespec *one, const char *needle, unsigned long len, regex_t *regexp) diff --git a/dir.c b/dir.c index e6a61ee913..16401d8017 100644 --- a/dir.c +++ b/dir.c @@ -5,9 +5,6 @@ * Copyright (C) Linus Torvalds, 2005-2006 * Junio Hamano, 2005-2006 */ -#include -#include - #include "cache.h" #include "dir.h" diff --git a/entry.c b/entry.c index b2ea0efa82..88df713947 100644 --- a/entry.c +++ b/entry.c @@ -1,5 +1,3 @@ -#include -#include #include "cache.h" #include "blob.h" diff --git a/fetch-pack.c b/fetch-pack.c index 743eab7efa..92322cf4da 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -5,7 +5,6 @@ #include "tag.h" #include "exec_cmd.h" #include "sideband.h" -#include static int keep_pack; static int quiet; diff --git a/fetch.c b/fetch.c index 663b4b2f42..f69be82f10 100644 --- a/fetch.c +++ b/fetch.c @@ -1,6 +1,5 @@ -#include "fetch.h" - #include "cache.h" +#include "fetch.h" #include "commit.h" #include "tree.h" #include "tree-walk.h" diff --git a/fsck-objects.c b/fsck-objects.c index 46b628cb94..409aea02b4 100644 --- a/fsck-objects.c +++ b/fsck-objects.c @@ -1,6 +1,3 @@ -#include -#include - #include "cache.h" #include "commit.h" #include "tree.h" diff --git a/git-compat-util.h b/git-compat-util.h index 0272d043d0..bc296b3a45 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -11,6 +11,11 @@ #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) +#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 +#define _BSD_SOURCE + #include #include #include @@ -22,9 +27,27 @@ #include #include #include -#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef NO_ICONV +#include +#endif /* On most systems would have given us this, but * not on some systems (e.g. GNU/Hurd). diff --git a/git.c b/git.c index 016ee8adb7..73cf4d4e01 100644 --- a/git.c +++ b/git.c @@ -1,20 +1,8 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "git-compat-util.h" +#include "builtin.h" #include "exec_cmd.h" #include "cache.h" #include "quote.h" -#include "builtin.h" - const char git_usage_string[] = "git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate] [--bare] [--git-dir=GIT_DIR] [--help] COMMAND [ARGS]"; diff --git a/grep.c b/grep.c index 0fc078ec0a..fcc6762302 100644 --- a/grep.c +++ b/grep.c @@ -1,5 +1,4 @@ #include "cache.h" -#include #include "grep.h" void append_grep_pattern(struct grep_opt *opt, const char *pat, diff --git a/help.c b/help.c index 0824c25226..341b9e370e 100644 --- a/help.c +++ b/help.c @@ -3,12 +3,11 @@ * * Builtin help-related commands (help, usage, version) */ -#include #include "cache.h" #include "builtin.h" #include "exec_cmd.h" #include "common-cmds.h" - +#include /* most GUI terminals set COLUMNS (although some don't export it) */ static int term_columns(void) diff --git a/ident.c b/ident.c index d7faba6a70..6ad8fedd60 100644 --- a/ident.c +++ b/ident.c @@ -7,9 +7,6 @@ */ #include "cache.h" -#include -#include - static char git_default_date[50]; static void copy_gecos(struct passwd *w, char *name, int sz) diff --git a/imap-send.c b/imap-send.c index a6a65680ee..894cbbdf53 100644 --- a/imap-send.c +++ b/imap-send.c @@ -24,13 +24,6 @@ #include "cache.h" -#include -#include -#include -#include -#include -#include - typedef struct store_conf { char *name; const char *path; /* should this be here? its interpretation is driver-specific */ diff --git a/index-pack.c b/index-pack.c index c05feae161..43e007f823 100644 --- a/index-pack.c +++ b/index-pack.c @@ -1,8 +1,3 @@ -#define _XOPEN_SOURCE 600 -#include -#include -#include - #include "cache.h" #include "delta.h" #include "pack.h" diff --git a/interpolate.c b/interpolate.c index 5d9d1889f0..f992ef7753 100644 --- a/interpolate.c +++ b/interpolate.c @@ -2,8 +2,6 @@ * Copyright 2006 Jon Loeliger */ -#include - #include "git-compat-util.h" #include "interpolate.h" diff --git a/lockfile.c b/lockfile.c index 2a2fea3cb6..261baff049 100644 --- a/lockfile.c +++ b/lockfile.c @@ -1,7 +1,6 @@ /* * Copyright (c) 2005, Junio C Hamano */ -#include #include "cache.h" static struct lock_file *lock_file_list; diff --git a/merge-base.c b/merge-base.c index 009caf804b..385f4ba386 100644 --- a/merge-base.c +++ b/merge-base.c @@ -1,4 +1,3 @@ -#include #include "cache.h" #include "commit.h" diff --git a/merge-index.c b/merge-index.c index 646d090c58..a9983dd78a 100644 --- a/merge-index.c +++ b/merge-index.c @@ -1,7 +1,3 @@ -#include -#include -#include - #include "cache.h" static const char *pgm; diff --git a/merge-recursive.c b/merge-recursive.c index 6dd6e2e5af..1de273ea1e 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -3,13 +3,6 @@ * Fredrik Kuivinen. * The thieves were Alex Riesen and Johannes Schindelin, in June/July 2006 */ -#include -#include -#include -#include -#include -#include -#include #include "cache.h" #include "cache-tree.h" #include "commit.h" diff --git a/path-list.c b/path-list.c index f8800f8e66..caaa5cc57b 100644 --- a/path-list.c +++ b/path-list.c @@ -1,4 +1,3 @@ -#include #include "cache.h" #include "path-list.h" diff --git a/path.c b/path.c index d2c076d7cb..066f621955 100644 --- a/path.c +++ b/path.c @@ -11,7 +11,6 @@ * which is what it's designed for. */ #include "cache.h" -#include static char bad_path[] = "/bad-path/"; diff --git a/receive-pack.c b/receive-pack.c index 5e5510bc3d..59b682c03a 100644 --- a/receive-pack.c +++ b/receive-pack.c @@ -6,7 +6,6 @@ #include "exec_cmd.h" #include "commit.h" #include "object.h" -#include static const char receive_pack_usage[] = "git-receive-pack "; diff --git a/refs.c b/refs.c index d911b9e860..a101ff3bf8 100644 --- a/refs.c +++ b/refs.c @@ -1,10 +1,8 @@ -#include "refs.h" #include "cache.h" +#include "refs.h" #include "object.h" #include "tag.h" -#include - /* ISSYMREF=01 and ISPACKED=02 are public interfaces */ #define REF_KNOWS_PEELED 04 diff --git a/revision.c b/revision.c index 993bb668a2..7b6f91f83e 100644 --- a/revision.c +++ b/revision.c @@ -6,7 +6,6 @@ #include "diff.h" #include "refs.h" #include "revision.h" -#include #include "grep.h" static char *path_name(struct name_path *path, const char *name) diff --git a/rsh.c b/rsh.c index f34409e1bc..5754a230e2 100644 --- a/rsh.c +++ b/rsh.c @@ -1,10 +1,6 @@ -#include -#include -#include - +#include "cache.h" #include "rsh.h" #include "quote.h" -#include "cache.h" #define COMMAND_SIZE 4096 diff --git a/run-command.c b/run-command.c index 61908682b9..492ad3e64c 100644 --- a/run-command.c +++ b/run-command.c @@ -1,6 +1,5 @@ #include "cache.h" #include "run-command.h" -#include #include "exec_cmd.h" int run_command_v_opt(int argc, const char **argv, int flags) diff --git a/ssh-upload.c b/ssh-upload.c index 20b15eab57..0b52ae15cb 100644 --- a/ssh-upload.c +++ b/ssh-upload.c @@ -12,8 +12,6 @@ #include "rsh.h" #include "refs.h" -#include - static unsigned char local_version = 1; static unsigned char remote_version; diff --git a/strbuf.c b/strbuf.c index 9d9d8bed91..7f14b0fb59 100644 --- a/strbuf.c +++ b/strbuf.c @@ -1,7 +1,5 @@ -#include -#include -#include "strbuf.h" #include "cache.h" +#include "strbuf.h" void strbuf_init(struct strbuf *sb) { sb->buf = NULL; diff --git a/test-date.c b/test-date.c index 93e802759f..62e8f2387a 100644 --- a/test-date.c +++ b/test-date.c @@ -1,6 +1,3 @@ -#include -#include - #include "cache.h" int main(int argc, char **argv) diff --git a/test-delta.c b/test-delta.c index 1be8ee0c72..795aa08377 100644 --- a/test-delta.c +++ b/test-delta.c @@ -8,13 +8,7 @@ * published by the Free Software Foundation. */ -#include -#include -#include -#include -#include -#include -#include +#include "git-compat-util.h" #include "delta.h" static const char usage[] = diff --git a/tree.c b/tree.c index ea386e5066..b6f02fecc4 100644 --- a/tree.c +++ b/tree.c @@ -4,7 +4,6 @@ #include "commit.h" #include "tag.h" #include "tree-walk.h" -#include const char *tree_type = "tree"; diff --git a/unpack-trees.c b/unpack-trees.c index b8689ebc86..2e2232cbb0 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -1,5 +1,3 @@ -#include -#include #include "cache.h" #include "dir.h" #include "tree.h" diff --git a/upload-pack.c b/upload-pack.c index 4572fff07c..32b06b2e66 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -1,6 +1,3 @@ -#include -#include -#include #include "cache.h" #include "refs.h" #include "pkt-line.h" diff --git a/var.c b/var.c index a57a33b81a..39977b949a 100644 --- a/var.c +++ b/var.c @@ -4,9 +4,6 @@ * Copyright (C) Eric Biederman, 2005 */ #include "cache.h" -#include -#include -#include static const char var_usage[] = "git-var [-l | ]"; diff --git a/wt-status.c b/wt-status.c index cface6ca88..db427384ff 100644 --- a/wt-status.c +++ b/wt-status.c @@ -1,6 +1,6 @@ +#include "cache.h" #include "wt-status.h" #include "color.h" -#include "cache.h" #include "object.h" #include "dir.h" #include "commit.h" -- cgit v1.3 From e6d40d65df07059fc655fabe62fa5b575ead7815 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 22 Dec 2006 03:20:11 +0100 Subject: diff --check: fix off by one error When parsing the diff line starting with '@@', the line number of the '+' file is parsed. For the subsequent line parses, the line number should therefore be incremented after the parse, not before it. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- diff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'diff.c') diff --git a/diff.c b/diff.c index 33153787b8..b003c00016 100644 --- a/diff.c +++ b/diff.c @@ -825,8 +825,6 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len) if (line[0] == '+') { int i, spaces = 0; - data->lineno++; - /* check space before tab */ for (i = 1; i < len && (line[i] == ' ' || line[i] == '\t'); i++) if (line[i] == ' ') @@ -841,6 +839,8 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len) if (isspace(line[len - 1])) printf("%s:%d: white space at end: %.*s\n", data->filename, data->lineno, (int)len, line); + + data->lineno++; } else if (line[0] == ' ') data->lineno++; else if (line[0] == '@') { -- cgit v1.3