Subject: Re: [PATCH v2 21/22] diff.h: reduce unnecessary includes

From: Ævar Arnfjörð Bjarmason <[email-masked]>
Date: Mon, 01 May 2023 19:11:22 +0200

On Sat, Apr 22 2023, Elijah Newren via GitGitGadget wrote:

> From: Elijah Newren <[email-masked]>
>
> Signed-off-by: Elijah Newren <[email-masked]>
> ---
>  attr.c              | 1 +
>  diff.h              | 1 -
>  http-push.c         | 1 +
>  line-log.c          | 1 +
>  pack-bitmap-write.c | 1 +
>  reflog.c            | 1 +
>  tree-diff.c         | 1 +
>  7 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/attr.c b/attr.c
> index 2d8aeb8b58c..ddf2b0cbc2e 100644
> --- a/attr.c
> +++ b/attr.c
> @@ -20,6 +20,7 @@
>  #include "object-store.h"
>  #include "setup.h"
>  #include "thread-utils.h"
> +#include "tree-walk.h"
>  
>  const char git_attr__true[] = "(builtin)true";
>  const char git_attr__false[] = "\0(builtin)false";
> diff --git a/diff.h b/diff.h
> index 53aeb02a54b..69e574f4315 100644
> --- a/diff.h
> +++ b/diff.h
> @@ -4,7 +4,6 @@
>  #ifndef DIFF_H
>  #define DIFF_H
>  
> -#include "tree-walk.h"
>  #include "pathspec.h"
>  #include "oidset.h"
>  #include "strbuf.h"
> diff --git a/http-push.c b/http-push.c
> index 3f184986362..866ba243a89 100644
> --- a/http-push.c
> +++ b/http-push.c
> @@ -16,6 +16,7 @@
>  #include "sigchain.h"
>  #include "strvec.h"
>  #include "tree.h"
> +#include "tree-walk.h"
>  #include "packfile.h"
>  #include "object-store.h"
>  #include "commit-reach.h"
> diff --git a/line-log.c b/line-log.c
> index 10c19daec4a..6a7ac312a43 100644
> --- a/line-log.c
> +++ b/line-log.c
> @@ -18,6 +18,7 @@
>  #include "setup.h"
>  #include "strvec.h"
>  #include "bloom.h"
> +#include "tree-walk.h"
>  
>  static void range_set_grow(struct range_set *rs, size_t extra)
>  {
> diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c
> index 3d3fd380654..cdffe2ce47d 100644
> --- a/pack-bitmap-write.c
> +++ b/pack-bitmap-write.c
> @@ -19,6 +19,7 @@
>  #include "prio-queue.h"
>  #include "trace2.h"
>  #include "tree.h"
> +#include "tree-walk.h"
>  
>  struct bitmapped_commit {
>  	struct commit *commit;
> diff --git a/reflog.c b/reflog.c
> index 57dc7c0d051..ee1bf5d032c 100644
> --- a/reflog.c
> +++ b/reflog.c
> @@ -5,6 +5,7 @@
>  #include "refs.h"
>  #include "revision.h"
>  #include "tree.h"
> +#include "tree-walk.h"
>  #include "worktree.h"
>  
>  /* Remember to update object flag allocation in object.h */
> diff --git a/tree-diff.c b/tree-diff.c
> index 9ea2dd7a6c3..20bb15f38d9 100644
> --- a/tree-diff.c
> +++ b/tree-diff.c
> @@ -5,6 +5,7 @@
>  #include "diff.h"
>  #include "diffcore.h"
>  #include "tree.h"
> +#include "tree-walk.h"
>  
>  /*
>   * Some mode bits are also used internally for computations.

This, unlike the preceding 20/22 really does seem to strictly match its
$subject, i.e. diff.h didn't need tree-walk.h, but some stuff using it
needed it, so we're moving the include to those users themselves.