+
Skip to content

Conversation

dscho
Copy link
Member

@dscho dscho commented Oct 8, 2025

Following in the footsteps of the many, many recent #include refactorings, this patch series orders the #include statements in compat/mingw.c.

cc: Patrick Steinhardt ps@pks.im
cc: Matthias Aßhauer mha1993@live.de
cc: Johannes Sixt j6t@kdbg.org

dscho added 2 commits October 8, 2025 11:03
We want to make them relative to the top-level directory.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
It allows for more consistent patches that way.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho dscho self-assigned this Oct 8, 2025
@dscho
Copy link
Member Author

dscho commented Oct 9, 2025

/submit

Copy link

gitgitgadget bot commented Oct 9, 2025

Submitted as pull.1985.git.1759995961.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-1985/dscho/organize-mingw-includes-v1

To fetch this version to local tag pr-1985/dscho/organize-mingw-includes-v1:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-1985/dscho/organize-mingw-includes-v1

Copy link

gitgitgadget bot commented Oct 10, 2025

On the Git mailing list, Patrick Steinhardt wrote (reply to this):

On Thu, Oct 09, 2025 at 07:45:59AM +0000, Johannes Schindelin via GitGitGadget wrote:
> Following in the footsteps of the many, many recent #include refactorings,
> this patch series orders the #include statements in compat/mingw.c.

Both of these patches look good to me and I like the improved
consistency that they bring. I may also do the same for our code in
"refs/", where some of the files use relative includes, as well. Might
be worth to document this somewhere if it isn't already, but that
doesn't have to be part of your patch series here.

Sorting them also makes sense. It's another thing where I wish that we
had a tool to enforce this. clang-format supports this in theory, but
it's disabled right now. And I'm not even sure whether it can be told to
include e.g. "git-compat-util.h" first.

Thanks!

Patrick

Copy link

gitgitgadget bot commented Oct 10, 2025

User Patrick Steinhardt <ps@pks.im> has been added to the cc: list.

Copy link

gitgitgadget bot commented Oct 10, 2025

On the Git mailing list, Johannes Schindelin wrote (reply to this):

Hi Patrick,

On Fri, 10 Oct 2025, Patrick Steinhardt wrote:

> On Thu, Oct 09, 2025 at 07:45:59AM +0000, Johannes Schindelin via GitGitGadget wrote:
> > Following in the footsteps of the many, many recent #include refactorings,
> > this patch series orders the #include statements in compat/mingw.c.
> 
> Both of these patches look good to me and I like the improved
> consistency that they bring. I may also do the same for our code in
> "refs/", where some of the files use relative includes, as well. Might
> be worth to document this somewhere if it isn't already, but that
> doesn't have to be part of your patch series here.

There's already such a lot of documentation that I fear it is intimidating
to any new contributor (and if I was one, I'd be tempted to read it
exclusively via AI summaries). I don't want to add to that amount.

> Sorting them also makes sense. It's another thing where I wish that we
> had a tool to enforce this. clang-format supports this in theory, but
> it's disabled right now. And I'm not even sure whether it can be told to
> include e.g. "git-compat-util.h" first.

In theory, I am totally with you: Sorting `#include`s is a job best left
to tools. But then, I say the same about formatting, and I see a lot of
appetite on this list for preventing that to become a tool-driven job, and
instead requiring developer time to be spent on it. Therefore, I don't
want to spend any effort trying to get this automated when I see small
chances of success in the endeavor of freeing up cognitive cycles for
tasks I find more intellectually rewarding than figuring out where a space
or a line break goes.

Ciao,
Johannes

Copy link

gitgitgadget bot commented Oct 10, 2025

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

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

>> Sorting them also makes sense. It's another thing where I wish that we
>> had a tool to enforce this. clang-format supports this in theory, but
>> it's disabled right now. And I'm not even sure whether it can be told to
>> include e.g. "git-compat-util.h" first.
>
> In theory, I am totally with you: Sorting `#include`s is a job best left
> to tools. But then, I say the same about formatting,

I am afraid that it is apples-to-oranges comparison.  Nobody has to
read the #include directives; they may have to see if a header they
care about (because they are planning to add a call to a function
that hasn't been used in the particular C source file, perhaps) is
already included, and sorted list of includes is a good tool to help
them.  IOW, they do not read them, they scan in them.  But the code,
the result of formatting, must be readable by people.

Copy link

gitgitgadget bot commented Oct 10, 2025

This patch series was integrated into seen via git@4bf6293.

@gitgitgadget gitgitgadget bot added the seen label Oct 10, 2025
@@ -1,22 +1,22 @@
#define USE_THE_REPOSITORY_VARIABLE
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, Matthias Aßhauer wrote (reply to this):

On Thu, 9 Oct 2025, Johannes Schindelin via GitGitGadget wrote:

> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>
> We want to make them relative to the top-level directory.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
> compat/mingw.c | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/compat/mingw.c b/compat/mingw.c
> index 8538e3d172..da99473f56 100644
> --- a/compat/mingw.c
> +++ b/compat/mingw.c
> @@ -1,22 +1,22 @@
> #define USE_THE_REPOSITORY_VARIABLE
> #define DISABLE_SIGN_COMPARE_WARNINGS
>
> -#include "../git-compat-util.h"
> +#include "git-compat-util.h"
> #include "win32.h"

Isn't this include also relative to compat/ and should become #include "compat/win32.h"?

> #include <aclapi.h>
> #include <sddl.h>
> #include <conio.h>
> #include <wchar.h>
> -#include "../strbuf.h"
> -#include "../run-command.h"
> -#include "../abspath.h"
> -#include "../alloc.h"
> +#include "strbuf.h"
> +#include "run-command.h"
> +#include "abspath.h"
> +#include "alloc.h"
> #include "win32/lazyload.h"

Same situation here.

best regards

Matthias

Copy link

gitgitgadget bot commented Oct 11, 2025

User Matthias Aßhauer <mha1993@live.de> has been added to the cc: list.

Copy link

gitgitgadget bot commented Oct 11, 2025

This branch is now known as js/mingw-includes-cleanup.

@@ -1,22 +1,22 @@
#define USE_THE_REPOSITORY_VARIABLE
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, Johannes Sixt wrote (reply to this):

Am 09.10.25 um 09:46 schrieb Johannes Schindelin via GitGitGadget:
> From: Johannes Schindelin <johannes.schindelin@gmx.de>
> 
> We want to make them relative to the top-level directory.
> 
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
>  compat/mingw.c | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/compat/mingw.c b/compat/mingw.c
> index 8538e3d172..da99473f56 100644
> --- a/compat/mingw.c
> +++ b/compat/mingw.c
> @@ -1,22 +1,22 @@
>  #define USE_THE_REPOSITORY_VARIABLE
>  #define DISABLE_SIGN_COMPARE_WARNINGS
>  
> -#include "../git-compat-util.h"
> +#include "git-compat-util.h"
>  #include "win32.h"
>  #include <aclapi.h>
>  #include <sddl.h>
>  #include <conio.h>
>  #include <wchar.h>
> -#include "../strbuf.h"
> -#include "../run-command.h"
> -#include "../abspath.h"
> -#include "../alloc.h"
> +#include "strbuf.h"
> +#include "run-command.h"
> +#include "abspath.h"
> +#include "alloc.h"
>  #include "win32/lazyload.h"
> -#include "../config.h"
> -#include "../environment.h"
> -#include "../trace2.h"
> -#include "../symlinks.h"
> -#include "../wrapper.h"
> +#include "config.h"
> +#include "environment.h"
> +#include "trace2.h"
> +#include "symlinks.h"
> +#include "wrapper.h"
>  #include "dir.h"
>  #include "gettext.h"
>  #define SECURITY_WIN32

Why is this needed?

With #include "foo" it is quite clear that the file is first looked up
from the directory of the file being processed. The changed code
requires that the top-level directory is among the -I directives of the
command lines. Then it would be much more logical to use #include <foo>
instead. But that I wouldn't regard as desirable, either, because the
included file isn't from a subordinate module or library.

So, IMO, the status quo is perfect and does not need this change.

-- Hannes

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):

Johannes Sixt <j6t@kdbg.org> writes:

> Why is this needed?

;-)

As pointed out by Matthias, the changes in the posted patch are not
complete/comprehensive.

> With #include "foo" it is quite clear that the file is first looked up
> from the directory of the file being processed. The changed code
> requires that the top-level directory is among the -I directives of the
> command lines. Then it would be much more logical to use #include <foo>
> instead.

I actually prefer that, but that is a taste thing I do not want to
impose on this project.

> So, IMO, the status quo is perfect and does not need this change.

I tend to agree, but it would be a waste of time to further discuss
on this.  As long as it does not break compilation, I'll just let
the patch graduate.

My preference is to 

 * always name custom headers using the path from the top-level (we
   use -I in BASIC_CFLAGS exactly for this purpose), 
   e.g.

	#include "compat/win32.h" (good)
	#include "win32.h" (not good)

 * compat header that aims to replace system supplied headers like
   <regex.h> should use -I appropriately and appear as if they are
   from the system, e.g.

	#include <regex.h> (good)
	#include "compat/regex/regex.h" (not good)

If somebody truly wants to improve things once the dust settles from
these patches, I would appreciate they keep the above in mind.

THanks.

Copy link

gitgitgadget bot commented Oct 12, 2025

User Johannes Sixt <j6t@kdbg.org> has been added to the cc: list.

Copy link

gitgitgadget bot commented Oct 13, 2025

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

Copy link

gitgitgadget bot commented Oct 13, 2025

This patch series was integrated into next via git@b7144c1.

@gitgitgadget gitgitgadget bot added the next label Oct 13, 2025
Copy link

gitgitgadget bot commented Oct 14, 2025

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

Copy link

gitgitgadget bot commented Oct 14, 2025

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

Copy link

gitgitgadget bot commented Oct 14, 2025

This patch series was integrated into seen via git@37368fa.

Copy link

gitgitgadget bot commented Oct 14, 2025

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

Code clean-up.

Will merge to 'master'.
source: <pull.1985.git.1759995961.gitgitgadget@gmail.com>

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.

1 participant

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载