Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional header cleanups (removing unnecessary includes) #1617

Closed
wants to merge 12 commits into from

Conversation

newren
Copy link

@newren newren commented Nov 26, 2023

Here are a number of header cleanups, to remove unnecessary includes.

(Sorry for the multiple day delay from when I said I'd send in an update; COVID sucks and knocked me out for multiple days and has me running on near empty.)

Changes since v1:

  • Dropped three changes that conflicted with changes in next & seen (in attr.c, trace2.c, and test-trace2.c). After topics in next & seen merge down, I can submit a future patch that still does the relevant part of the cleanups that I'm dropping for now.

cc: Elijah Newren newren@gmail.com

@newren newren force-pushed the header-cleanup-6 branch 2 times, most recently from a88f2d3 to c9d409c Compare November 27, 2023 14:55
There are three kinds of unnecessary includes:
  * includes which aren't directly needed, but which include some other
    forgotten include
  * includes which could be replaced by a simple forward declaration of
    some structs
  * includes which aren't needed at all

Remove the third kind of include.  Subsequent commits (and a subsequent
series) will work on removing some of the other kinds of includes.

Signed-off-by: Elijah Newren <newren@gmail.com>
@newren newren changed the title Additional header cleanups Additional header cleanups (removing unnecessary includes) Dec 1, 2023
@newren
Copy link
Author

newren commented Dec 3, 2023

/submit

Copy link

gitgitgadget bot commented Dec 3, 2023

Submitted as pull.1617.git.1701585682.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-1617/newren/header-cleanup-6-v1

To fetch this version to local tag pr-1617/newren/header-cleanup-6-v1:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-1617/newren/header-cleanup-6-v1

@@ -12,7 +12,6 @@
#include "strvec.h"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the Git mailing list, Junio C Hamano wrote (reply to this):

"Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes:

> diff --git a/trace2.c b/trace2.c
> index 6dc74dff4c7..d4220af9ae1 100644
> --- a/trace2.c
> +++ b/trace2.c
> @@ -1,12 +1,8 @@
>  #include "git-compat-util.h"
> -#include "config.h"
> -#include "json-writer.h"
> -#include "quote.h"
>  #include "repository.h"
>  #include "run-command.h"
>  #include "sigchain.h"
>  #include "thread-utils.h"
> -#include "version.h"
>  #include "trace.h"
>  #include "trace2.h"
>  #include "trace2/tr2_cfg.h"

An in-flight topic seem to want to see git_env_bool() that is
declared in parse.h that is pulled in via inclusion of config.h
hence this hunk breaks 'seen'.

> diff --git a/t/helper/test-trace2.c b/t/helper/test-trace2.c
> index d5ca0046c89..a0032ee3964 100644
> --- a/t/helper/test-trace2.c
> +++ b/t/helper/test-trace2.c
> @@ -2,7 +2,6 @@
>  #include "strvec.h"
>  #include "run-command.h"
>  #include "exec-cmd.h"
> -#include "config.h"
>  #include "repository.h"
>  #include "trace2.h"

An in-flight topic starts using "struct key_value_info" that is
available via the inclusion of "config.h", hence this hunk breaks
the build of 'seen'.

> diff --git a/t/helper/test-fast-rebase.c b/t/helper/test-fast-rebase.c
> index cac20a72b3f..f9472c99143 100644
> --- a/t/helper/test-fast-rebase.c
> +++ b/t/helper/test-fast-rebase.c
> @@ -24,7 +24,6 @@
>  #include "read-cache-ll.h"
>  #include "refs.h"
>  #include "revision.h"
> -#include "sequencer.h"
>  #include "setup.h"
>  #include "strvec.h"
>  #include "tree.h"

I'll register the following evil merge as the merge-fix/ for this
topic.

In addition, t/helper/test-fast-rebase.c that is touched by this
step will simply disappear with the cc/git-replay topic, so it may
not be a bad idea to exclude it from the patchset.

Thanks.

diff --git a/t/helper/test-trace2.c b/t/helper/test-trace2.c
index 16089f04e1..55c06e4269 100644
--- a/t/helper/test-trace2.c
+++ b/t/helper/test-trace2.c
@@ -1,4 +1,5 @@
 #include "test-tool.h"
+#include "config-parse.h"
 #include "strvec.h"
 #include "run-command.h"
 #include "exec-cmd.h"
diff --git a/trace2.c b/trace2.c
index 4fa059199c..452428b09b 100644
--- a/trace2.c
+++ b/trace2.c
@@ -1,4 +1,5 @@
 #include "git-compat-util.h"
+#include "parse.h"
 #include "repository.h"
 #include "run-command.h"
 #include "sigchain.h"

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the Git mailing list, Junio C Hamano wrote (reply to this):

Junio C Hamano <gitster@pobox.com> writes:

> "Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
>> diff --git a/trace2.c b/trace2.c
>> index 6dc74dff4c7..d4220af9ae1 100644
>> --- a/trace2.c
>> ...
> An in-flight topic seem to want to see git_env_bool() that is
> declared in parse.h that is pulled in via inclusion of config.h
> hence this hunk breaks 'seen'.
>
>> diff --git a/t/helper/test-trace2.c b/t/helper/test-trace2.c
>> index d5ca0046c89..a0032ee3964 100644
>> --- a/t/helper/test-trace2.c
>> ...
> An in-flight topic starts using "struct key_value_info" that is
> available via the inclusion of "config.h", hence this hunk breaks
> the build of 'seen'.

It seems that we have gained another topic in flight that gets
broken by this change.  I can keep piling merge-fixes on top, but it
does not look like a strategy that would scale well.

Can we get this series thoroughly reviewed quickly to merge it down
via 'next' to 'master' soonish, so that other topics can be rebased
on the result, or is that too much to ask during the Winter lull?

Thanks.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the Git mailing list, Elijah Newren wrote (reply to this):

On Wed, Dec 20, 2023 at 11:34 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> Junio C Hamano <gitster@pobox.com> writes:
>
> > "Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes:
> >
> >> diff --git a/trace2.c b/trace2.c
> >> index 6dc74dff4c7..d4220af9ae1 100644
> >> --- a/trace2.c
> >> ...
> > An in-flight topic seem to want to see git_env_bool() that is
> > declared in parse.h that is pulled in via inclusion of config.h
> > hence this hunk breaks 'seen'.
> >
> >> diff --git a/t/helper/test-trace2.c b/t/helper/test-trace2.c
> >> index d5ca0046c89..a0032ee3964 100644
> >> --- a/t/helper/test-trace2.c
> >> ...
> > An in-flight topic starts using "struct key_value_info" that is
> > available via the inclusion of "config.h", hence this hunk breaks
> > the build of 'seen'.
>
> It seems that we have gained another topic in flight that gets
> broken by this change.  I can keep piling merge-fixes on top, but it
> does not look like a strategy that would scale well.
>
> Can we get this series thoroughly reviewed quickly to merge it down
> via 'next' to 'master' soonish, so that other topics can be rebased
> on the result, or is that too much to ask during the Winter lull?
>
> Thanks.

The Winter lull is my winter surge, so I can certainly quickly make
whatever changes are required (well, assuming I can shake this
fever...).  But that doesn't help much with reviewing, since that
should be done by someone other than the author.  However, these
particular type of changes are pretty innocuous; there's really not
anything clever going on, it's just a lot of gruntwork, and
does-it-compile is most of the review.

Anyway, I'll reroll, dropping or holding back any changes that
conflict with next or seen, and see if that encourages anyone to chime
in.

Copy link

gitgitgadget bot commented Dec 9, 2023

This branch is now known as en/header-cleanup.

Copy link

gitgitgadget bot commented Dec 9, 2023

This patch series was integrated into seen via git@c921012.

@gitgitgadget gitgitgadget bot added the seen label Dec 9, 2023
Copy link

gitgitgadget bot commented Dec 9, 2023

There was a status update in the "New Topics" section about the branch en/header-cleanup on the Git mailing list:

Remove unused header "#include".

Has a few interactions with topics in flight.
source: <pull.1617.git.1701585682.gitgitgadget@gmail.com>

Copy link

gitgitgadget bot commented Dec 10, 2023

This patch series was integrated into seen via git@30fdd87.

Copy link

gitgitgadget bot commented Dec 11, 2023

This patch series was integrated into seen via git@e805b6f.

Copy link

gitgitgadget bot commented Dec 12, 2023

There was a status update in the "Cooking" section about the branch en/header-cleanup on the Git mailing list:

Remove unused header "#include".

Has a few interactions with topics in flight.
source: <pull.1617.git.1701585682.gitgitgadget@gmail.com>

Copy link

gitgitgadget bot commented Dec 13, 2023

This patch series was integrated into seen via git@e7dd90b.

Copy link

gitgitgadget bot commented Dec 13, 2023

This patch series was integrated into seen via git@e850ab5.

Copy link

gitgitgadget bot commented Dec 13, 2023

This patch series was integrated into seen via git@050f7d8.

Copy link

gitgitgadget bot commented Dec 14, 2023

This patch series was integrated into seen via git@3bc315c.

Copy link

gitgitgadget bot commented Dec 15, 2023

This patch series was integrated into seen via git@60801d6.

Copy link

gitgitgadget bot commented Dec 19, 2023

This patch series was integrated into seen via git@0e79e20.

Copy link

gitgitgadget bot commented Dec 19, 2023

There was a status update in the "Cooking" section about the branch en/header-cleanup on the Git mailing list:

Remove unused header "#include".

Has a few interactions with topics in flight.
source: <pull.1617.git.1701585682.gitgitgadget@gmail.com>

Copy link

gitgitgadget bot commented Dec 19, 2023

This patch series was integrated into seen via git@9d58804.

Copy link

gitgitgadget bot commented Dec 19, 2023

This patch series was integrated into seen via git@e052b39.

Copy link

gitgitgadget bot commented Dec 20, 2023

User Elijah Newren <newren@gmail.com> has been added to the cc: list.

Copy link

gitgitgadget bot commented Dec 20, 2023

This patch series was integrated into seen via git@6ada328.

Copy link

gitgitgadget bot commented Dec 20, 2023

There was a status update in the "Cooking" section about the branch en/header-cleanup on the Git mailing list:

Remove unused header "#include".

Has a few interactions with topics in flight.
source: <pull.1617.git.1701585682.gitgitgadget@gmail.com>

Copy link

gitgitgadget bot commented Dec 22, 2023

This patch series was integrated into seen via git@0df8c6a.

Each of these were checked with
   gcc -E -I. ${SOURCE_FILE} | grep ${HEADER_FILE}
to ensure that removing the direct inclusion of the header actually
resulted in that header no longer being included at all (i.e. that
no other header pulled it in transitively).

...except for a few cases where we verified that although the header
was brought in transitively, nothing from it was directly used in
that source file.  These cases were:
  * builtin/credential-cache.c
  * builtin/pull.c
  * builtin/send-pack.c

Signed-off-by: Elijah Newren <newren@gmail.com>
The unnecessary include in the header transitively pulled in some
other headers actually needed by source files, though.  Have those
source files explicitly include the headers they need.

Signed-off-by: Elijah Newren <newren@gmail.com>
The unnecessary include in the header transitively pulled in some
other headers actually needed by source files, though.  Have those
source files explicitly include the headers they need.

Signed-off-by: Elijah Newren <newren@gmail.com>
The unnecessary include in the header transitively pulled in some
other headers actually needed by source files, though.  Have those
source files explicitly include the headers they need.

Signed-off-by: Elijah Newren <newren@gmail.com>
The unnecessary include in the header transitively pulled in some
other headers actually needed by source files, though.  Have those
source files explicitly include the headers they need.

Signed-off-by: Elijah Newren <newren@gmail.com>
The unnecessary include in the header transitively pulled in some
other headers actually needed by source files, though.  Have those
source files explicitly include the headers they need.

Signed-off-by: Elijah Newren <newren@gmail.com>
The unnecessary include in the header transitively pulled in some
other headers actually needed by source files, though.  Have those
source files explicitly include the headers they need.

Signed-off-by: Elijah Newren <newren@gmail.com>
The unnecessary include in the header transitively pulled in some
other headers actually needed by source files, though.  Have those
source files explicitly include the headers they need.

Signed-off-by: Elijah Newren <newren@gmail.com>
The unnecessary include in the header transitively pulled in some
other headers actually needed by source files, though.  Have those
source files explicitly include the headers they need.

Signed-off-by: Elijah Newren <newren@gmail.com>
The next commit will remove a bunch of unnecessary includes, but to do
so, we need some of the lower level direct includes that files rely on
to be explicitly specified.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
@newren
Copy link
Author

newren commented Dec 23, 2023

/submit

Copy link

gitgitgadget bot commented Dec 23, 2023

Submitted as pull.1617.v2.git.1703351700.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-1617/newren/header-cleanup-6-v2

To fetch this version to local tag pr-1617/newren/header-cleanup-6-v2:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-1617/newren/header-cleanup-6-v2

Copy link

gitgitgadget bot commented Dec 26, 2023

This patch series was integrated into seen via git@03af80b.

Copy link

gitgitgadget bot commented Dec 28, 2023

This patch series was integrated into seen via git@9dc33c9.

Copy link

gitgitgadget bot commented Dec 28, 2023

There was a status update in the "Cooking" section about the branch en/header-cleanup on the Git mailing list:

Remove unused header "#include".

Will merge to 'next'.
source: <pull.1617.v2.git.1703351700.gitgitgadget@gmail.com>

Copy link

gitgitgadget bot commented Dec 28, 2023

This patch series was integrated into seen via git@8d37d73.

Copy link

gitgitgadget bot commented Dec 28, 2023

This patch series was integrated into next via git@1ccddc2.

@gitgitgadget gitgitgadget bot added the next label Dec 28, 2023
Copy link

gitgitgadget bot commented Jan 3, 2024

This patch series was integrated into seen via git@944e794.

Copy link

gitgitgadget bot commented Jan 3, 2024

There was a status update in the "Cooking" section about the branch en/header-cleanup on the Git mailing list:

Remove unused header "#include".

Will merge to 'master'.
source: <pull.1617.v2.git.1703351700.gitgitgadget@gmail.com>

Copy link

gitgitgadget bot commented Jan 3, 2024

This patch series was integrated into seen via git@97a62a5.

Copy link

gitgitgadget bot commented Jan 4, 2024

This patch series was integrated into seen via git@7473779.

Copy link

gitgitgadget bot commented Jan 5, 2024

This patch series was integrated into seen via git@d2dc98b.

Copy link

gitgitgadget bot commented Jan 6, 2024

There was a status update in the "Cooking" section about the branch en/header-cleanup on the Git mailing list:

Remove unused header "#include".

Will merge to 'master'.
source: <pull.1617.v2.git.1703351700.gitgitgadget@gmail.com>

Copy link

gitgitgadget bot commented Jan 9, 2024

This patch series was integrated into seen via git@492ee03.

Copy link

gitgitgadget bot commented Jan 9, 2024

This patch series was integrated into master via git@492ee03.

Copy link

gitgitgadget bot commented Jan 9, 2024

This patch series was integrated into next via git@492ee03.

@gitgitgadget gitgitgadget bot added the master label Jan 9, 2024
@gitgitgadget gitgitgadget bot closed this Jan 9, 2024
Copy link

gitgitgadget bot commented Jan 9, 2024

Closed via 492ee03.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant