* [PATCH] compat: drop inclusion of <git-compat-util.h>
@ 2024-02-24 20:32 Junio C Hamano
2024-02-24 22:25 ` Kyle Lippincott
0 siblings, 1 reply; 2+ messages in thread
From: Junio C Hamano @ 2024-02-24 20:32 UTC (permalink / raw)
To: git
These two header files are included from ordinary source files that
already include <git-compat-util.h> as the first header file as they
should. There is no need to include the compat-util in these
headers.
"make hdr-check" is not affected, as it is designed to assume that
what <git-compat-util.h> offers is available to everybody without
being included.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
* There is an obvious alternative that goes in the complete
opposite direction possible, to update "make hdr-check" to ensure
that things that are depended upon in each header file
(e.g. pager.h refers to uintmax_t) are brought in by the header
file to include the compat-util in it, i.e.
diff --git c/Makefile w/Makefile
index 78e874099d..d7b360f15e 100644
--- c/Makefile
+++ w/Makefile
@@ -3259,7 +3259,7 @@ HCO = $(patsubst %.h,%.hco,$(CHK_HDRS))
HCC = $(HCO:hco=hcc)
%.hcc: %.h
- @echo '#include "git-compat-util.h"' >$@
+ @echo '/* #include "git-compat-util.h" */' >$@
@echo '#include "$<"' >>$@
$(HCO): %.hco: %.hcc FORCE
which would require in a noisy diff to add inclusion of
git-compat-util.h to many header files. For purposes of folks
who may want to carve out only pieces of our source tree, such an
approach might work better, but for that to happen and yield any
useful result, I suspect that compat-util header needs to be
split into "compatibility essentials" and other "it is convenient
if these are available everywhere, even though they do not have
much to do with hiding system dependencies from the sources"
parts first.
compat/compiler.h | 1 -
compat/disk.h | 1 -
2 files changed, 2 deletions(-)
diff --git c/compat/compiler.h w/compat/compiler.h
index 10dbb65937..e9ad9db84f 100644
--- c/compat/compiler.h
+++ w/compat/compiler.h
@@ -1,7 +1,6 @@
#ifndef COMPILER_H
#define COMPILER_H
-#include "git-compat-util.h"
#include "strbuf.h"
#ifdef __GLIBC__
diff --git c/compat/disk.h w/compat/disk.h
index 6c979c27d8..23bc1bef86 100644
--- c/compat/disk.h
+++ w/compat/disk.h
@@ -1,7 +1,6 @@
#ifndef COMPAT_DISK_H
#define COMPAT_DISK_H
-#include "git-compat-util.h"
#include "abspath.h"
#include "gettext.h"
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] compat: drop inclusion of <git-compat-util.h>
2024-02-24 20:32 [PATCH] compat: drop inclusion of <git-compat-util.h> Junio C Hamano
@ 2024-02-24 22:25 ` Kyle Lippincott
0 siblings, 0 replies; 2+ messages in thread
From: Kyle Lippincott @ 2024-02-24 22:25 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
On Sat, Feb 24, 2024 at 12:33 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> These two header files are included from ordinary source files that
> already include <git-compat-util.h> as the first header file as they
> should. There is no need to include the compat-util in these
> headers.
>
> "make hdr-check" is not affected, as it is designed to assume that
> what <git-compat-util.h> offers is available to everybody without
> being included.
>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>
> * There is an obvious alternative that goes in the complete
> opposite direction possible, to update "make hdr-check" to ensure
> that things that are depended upon in each header file
> (e.g. pager.h refers to uintmax_t) are brought in by the header
> file to include the compat-util in it, i.e.
>
> diff --git c/Makefile w/Makefile
> index 78e874099d..d7b360f15e 100644
> --- c/Makefile
> +++ w/Makefile
> @@ -3259,7 +3259,7 @@ HCO = $(patsubst %.h,%.hco,$(CHK_HDRS))
> HCC = $(HCO:hco=hcc)
>
> %.hcc: %.h
> - @echo '#include "git-compat-util.h"' >$@
> + @echo '/* #include "git-compat-util.h" */' >$@
> @echo '#include "$<"' >>$@
>
> $(HCO): %.hco: %.hcc FORCE
>
> which would require in a noisy diff to add inclusion of
> git-compat-util.h to many header files. For purposes of folks
> who may want to carve out only pieces of our source tree, such an
> approach might work better, but for that to happen and yield any
> useful result, I suspect that compat-util header needs to be
> split into "compatibility essentials" and other "it is convenient
> if these are available everywhere, even though they do not have
> much to do with hiding system dependencies from the sources"
> parts first.
>
> compat/compiler.h | 1 -
> compat/disk.h | 1 -
> 2 files changed, 2 deletions(-)
LG, thanks. I agree with the direction from this patch: I think we
should not be including git-compat-util.h in header files, whether
they're "internal only" or part of the "external interface" of a
library. It does far too much and makes too many assumptions about
when it's being included. I plan on writing up some more thoughts on
this on a different thread, but it's taking some time to get those
into a shareable state.
>
> diff --git c/compat/compiler.h w/compat/compiler.h
> index 10dbb65937..e9ad9db84f 100644
> --- c/compat/compiler.h
> +++ w/compat/compiler.h
> @@ -1,7 +1,6 @@
> #ifndef COMPILER_H
> #define COMPILER_H
>
> -#include "git-compat-util.h"
> #include "strbuf.h"
>
> #ifdef __GLIBC__
> diff --git c/compat/disk.h w/compat/disk.h
> index 6c979c27d8..23bc1bef86 100644
> --- c/compat/disk.h
> +++ w/compat/disk.h
> @@ -1,7 +1,6 @@
> #ifndef COMPAT_DISK_H
> #define COMPAT_DISK_H
>
> -#include "git-compat-util.h"
> #include "abspath.h"
> #include "gettext.h"
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-02-24 22:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-24 20:32 [PATCH] compat: drop inclusion of <git-compat-util.h> Junio C Hamano
2024-02-24 22:25 ` Kyle Lippincott
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox