Skip to contentSkip to conversation

git: remove duplicate includes

PATCH In review Rose via GitGitGadget 2 participants 2 messages Dec 14, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 git: remove duplicate includes

From: Seija Kijin <[email protected]>

These files are already included; we do not need to include them again

---
git: remove duplicate includes

These files are already included; we do not need to include them again

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1394%2FAtariDreams%2Finclude-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1394/AtariDreams/include-v1
Pull-Request: https://github.com/git/git/pull/1394

 pack-write.c   | 1 -
 sequencer.c    | 1 -
 unpack-trees.c | 1 -
 3 files changed, 3 deletions(-)
pack-write.c +0 -1
index 00787e306db..33637297487 100644
@@ -5,7 +5,6 @@
 #include "chunk-format.h"
 #include "pack-mtimes.h"
 #include "oidmap.h"
-#include "chunk-format.h"
 #include "pack-objects.h"
 
 void reset_pack_idx_option(struct pack_idx_option *opts)
sequencer.c +0 -1
index dbd56121e24..bcb662e23be 100644
@@ -36,7 +36,6 @@
 #include "rebase-interactive.h"
 #include "reset.h"
 #include "branch.h"
-#include "log-tree.h"
 
 #define GIT_REFLOG_ACTION "GIT_REFLOG_ACTION"
 
unpack-trees.c +0 -1
index 8a762aa0772..d11bef96bf3 100644
@@ -19,7 +19,6 @@
 #include "promisor-remote.h"
 #include "entry.h"
 #include "parallel-checkout.h"
-#include "sparse-index.h"
 
 /*
  * Error messages expected by scripts out of plumbing commands such as

base-commit: 57e2c6ebbe7108b35ba30184dcbcb6c34c929ad8

Signature · 1 line
gitgitgadget
#1 lore raw
Quoted 1 line · Rose via GitGitGadget

These files are already included; we do not need to include them again

These all look good to me. I'm guessing you found them with something like:

git grep '^#include' '*.h' '*.c' | sort | uniq -d

and then looking over the output (it has many false positives because sometimes includes are found in multiple conditionals).

There's one more in compat/regex/regex.h, where we include stddef.h unconditionally, but also if HAVE_STDDEF_H is defined (which I think we'd never set ourselves). The conditional bit comes from upstream, I think, via d18f76dccf (compat/regex: use the regex engine from gawk for compat, 2010-08-17). The unconditional one is from just after that, in a997bf423d (compat/regex: get the gawk regex engine to compile within git, 2010-08-17).

It's probably best to leave it as-is, since the "clean" fix would be to remove the unused conditional, but that takes us further from upstream, which would be a pain if we ever want to re-import a new version.

So I think your patch covers all of the cases we'd want to fix.

-Peff