]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
13 months agosymlinks.h: move declarations for symlinks.c functions from cache.h
Elijah Newren [Sat, 22 Apr 2023 20:17:09 +0000 (20:17 +0000)] 
symlinks.h: move declarations for symlinks.c functions from cache.h

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agotreewide: be explicit about dependence on strbuf.h
Elijah Newren [Sat, 22 Apr 2023 20:17:08 +0000 (20:17 +0000)] 
treewide: be explicit about dependence on strbuf.h

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agoprotocol.h: move definition of DEFAULT_GIT_PORT from cache.h
Elijah Newren [Sun, 16 Apr 2023 03:03:05 +0000 (03:03 +0000)] 
protocol.h: move definition of DEFAULT_GIT_PORT from cache.h

Michael J Gruber noticed that connection via the git:// protocol no
longer worked after a recent header clean-up.  This was caused by
funny interaction of few gotchas.  First, a necessary definition

#define DEFAULT_GIT_PORT 9418

was made invisible to a place where

const char *port = STR(DEFAULT_GIT_PORT);

was expecting to turn the integer into "9418" with a clever STR()
macro, and ended up stringifying it to

const char *port = "DEFAULT_GIT_PORT";

without giving any chance to compilers to notice such a mistake.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agomailmap, quote: move declarations of global vars to correct unit
Elijah Newren [Tue, 11 Apr 2023 07:42:04 +0000 (00:42 -0700)] 
mailmap, quote: move declarations of global vars to correct unit

Since earlier commits removed the inclusion of cache.h from mailmap.c
and quote.c, it feels odd to have the extern declarations of
global variables in cache.h rather than the actual header included
by the source file.  Move these global variable extern declarations
from cache.h to mailmap.c and quote.c.

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agotreewide: reduce includes of cache.h in other headers
Elijah Newren [Tue, 11 Apr 2023 07:42:03 +0000 (00:42 -0700)] 
treewide: reduce includes of cache.h in other headers

We had a handful of headers including cache.h that didn't need to
anymore.  Drop those includes and replace them with includes of
smaller files, or forward declarations.  However, note that two .c
files now need to directly include cache.h, though they should have
been including it all along given they are directly using structs
defined in it.

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agotreewide: remove double forward declaration of read_in_full
Elijah Newren [Tue, 11 Apr 2023 07:42:02 +0000 (00:42 -0700)] 
treewide: remove double forward declaration of read_in_full

cache.h's nature of a dumping ground of includes prevented it from
being included in some compat/ files, forcing us into a workaround
of having a double forward declaration of the read_in_full() function
(see commit 14086b0a13 ("compat/pread.c: Add a forward declaration to
fix a warning", 2007-11-17)).  Now that we have moved functions like
read_in_full() from cache.h to wrapper.h, and wrapper.h isn't littered
with unrelated and scary #defines, get rid of the extra forward
declaration and just have compat/pread.c include wrapper.h.

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agocache.h: remove unnecessary includes
Elijah Newren [Tue, 11 Apr 2023 07:42:01 +0000 (00:42 -0700)] 
cache.h: remove unnecessary includes

cache.h did not need any of these headers, and nothing that depended
upon cache.h needed them either.  Simply expunge these includes.

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agotreewide: remove cache.h inclusion due to pager.h changes
Elijah Newren [Tue, 11 Apr 2023 07:42:00 +0000 (00:42 -0700)] 
treewide: remove cache.h inclusion due to pager.h changes

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agopager.h: move declarations for pager.c functions from cache.h
Elijah Newren [Tue, 11 Apr 2023 07:41:59 +0000 (00:41 -0700)] 
pager.h: move declarations for pager.c functions from cache.h

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agotreewide: remove cache.h inclusion due to editor.h changes
Elijah Newren [Tue, 11 Apr 2023 07:41:58 +0000 (00:41 -0700)] 
treewide: remove cache.h inclusion due to editor.h changes

This actually only affects sideband.c, but helps towards removing
cache.h inclusion in conjunction with some of the upcoming patches
that will be applied.

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoeditor: move editor-related functions and declarations into common file
Elijah Newren [Tue, 11 Apr 2023 07:41:57 +0000 (00:41 -0700)] 
editor: move editor-related functions and declarations into common file

cache.h and strbuf.[ch] had editor-related functions.  Move these into
editor.[ch].

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agotreewide: remove cache.h inclusion due to object.h changes
Elijah Newren [Tue, 11 Apr 2023 07:41:56 +0000 (00:41 -0700)] 
treewide: remove cache.h inclusion due to object.h changes

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoobject.h: move some inline functions and defines from cache.h
Elijah Newren [Tue, 11 Apr 2023 07:41:55 +0000 (00:41 -0700)] 
object.h: move some inline functions and defines from cache.h

The object_type() inline function is very tied to the enum object_type
declaration within object.h, and just seemed to make more sense to live
there.  That makes S_ISGITLINK and some other defines make sense to go
with it, as well as the create_ce_mode() and canon_mode() inline
functions.  Move all these inline functions and defines from cache.h to
object.h.

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agotreewide: remove cache.h inclusion due to object-file.h changes
Elijah Newren [Tue, 11 Apr 2023 07:41:54 +0000 (00:41 -0700)] 
treewide: remove cache.h inclusion due to object-file.h changes

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoobject-file.h: move declarations for object-file.c functions from cache.h
Elijah Newren [Tue, 11 Apr 2023 07:41:53 +0000 (00:41 -0700)] 
object-file.h: move declarations for object-file.c functions from cache.h

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agotreewide: remove cache.h inclusion due to git-zlib changes
Elijah Newren [Tue, 11 Apr 2023 07:41:52 +0000 (00:41 -0700)] 
treewide: remove cache.h inclusion due to git-zlib changes

This actually only affects http-backend.c, but the git-zlib changes
are going to be instrumental in pulling out an object-file.h which
will help with several more files.

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agogit-zlib: move declarations for git-zlib functions from cache.h
Elijah Newren [Tue, 11 Apr 2023 07:41:51 +0000 (00:41 -0700)] 
git-zlib: move declarations for git-zlib functions from cache.h

Move functions from cache.h for zlib.c into a new header file.  Since
adding a "zlib.h" would cause issues with the real zlib, rename zlib.c
to git-zlib.c while we are at it.

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agotreewide: remove cache.h inclusion due to object-name.h changes
Elijah Newren [Tue, 11 Apr 2023 07:41:50 +0000 (00:41 -0700)] 
treewide: remove cache.h inclusion due to object-name.h changes

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoobject-name.h: move declarations for object-name.c functions from cache.h
Elijah Newren [Tue, 11 Apr 2023 07:41:49 +0000 (00:41 -0700)] 
object-name.h: move declarations for object-name.c functions from cache.h

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agotreewide: remove unnecessary cache.h inclusion
Elijah Newren [Tue, 11 Apr 2023 07:41:48 +0000 (00:41 -0700)] 
treewide: remove unnecessary cache.h inclusion

Several files were including cache.h solely to get other headers, such
as trace.h and trace2.h.  Since the last few commits have modified
files to make these dependencies more explicit, the inclusion of cache.h
is no longer needed in several cases.  Remove it.

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agotreewide: be explicit about dependence on mem-pool.h
Elijah Newren [Tue, 11 Apr 2023 07:41:47 +0000 (00:41 -0700)] 
treewide: be explicit about dependence on mem-pool.h

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agotreewide: be explicit about dependence on oid-array.h
Elijah Newren [Tue, 11 Apr 2023 03:00:42 +0000 (03:00 +0000)] 
treewide: be explicit about dependence on oid-array.h

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agotreewide: be explicit about dependence on pack-revindex.h
Elijah Newren [Tue, 11 Apr 2023 03:00:41 +0000 (03:00 +0000)] 
treewide: be explicit about dependence on pack-revindex.h

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agotreewide: be explicit about dependence on convert.h
Elijah Newren [Tue, 11 Apr 2023 03:00:40 +0000 (03:00 +0000)] 
treewide: be explicit about dependence on convert.h

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agotreewide: be explicit about dependence on advice.h
Elijah Newren [Tue, 11 Apr 2023 03:00:39 +0000 (03:00 +0000)] 
treewide: be explicit about dependence on advice.h

Dozens of files made use of advice functions, without explicitly
including advice.h.  This made it more difficult to find which files
could remove a dependence on cache.h.  Make C files explicitly include
advice.h if they are using it.

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agotreewide: be explicit about dependence on trace.h & trace2.h
Elijah Newren [Tue, 11 Apr 2023 03:00:38 +0000 (03:00 +0000)] 
treewide: be explicit about dependence on trace.h & trace2.h

Dozens of files made use of trace and trace2 functions, without
explicitly including trace.h or trace2.h.  This made it more difficult
to find which files could remove a dependence on cache.h.  Make C files
explicitly include trace.h or trace2.h if they are using them.

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoMerge branch 'ab/remove-implicit-use-of-the-repository' into en/header-split-cache-h
Junio C Hamano [Tue, 4 Apr 2023 15:25:52 +0000 (08:25 -0700)] 
Merge branch 'ab/remove-implicit-use-of-the-repository' into en/header-split-cache-h

* ab/remove-implicit-use-of-the-repository:
  libs: use "struct repository *" argument, not "the_repository"
  post-cocci: adjust comments for recent repo_* migration
  cocci: apply the "revision.h" part of "the_repository.pending"
  cocci: apply the "rerere.h" part of "the_repository.pending"
  cocci: apply the "refs.h" part of "the_repository.pending"
  cocci: apply the "promisor-remote.h" part of "the_repository.pending"
  cocci: apply the "packfile.h" part of "the_repository.pending"
  cocci: apply the "pretty.h" part of "the_repository.pending"
  cocci: apply the "object-store.h" part of "the_repository.pending"
  cocci: apply the "diff.h" part of "the_repository.pending"
  cocci: apply the "commit.h" part of "the_repository.pending"
  cocci: apply the "commit-reach.h" part of "the_repository.pending"
  cocci: apply the "cache.h" part of "the_repository.pending"
  cocci: add missing "the_repository" macros to "pending"
  cocci: sort "the_repository" rules by header
  cocci: fix incorrect & verbose "the_repository" rules
  cocci: remove dead rule from "the_repository.pending.cocci"

14 months agolibs: use "struct repository *" argument, not "the_repository"
Ævar Arnfjörð Bjarmason [Tue, 28 Mar 2023 13:58:58 +0000 (15:58 +0200)] 
libs: use "struct repository *" argument, not "the_repository"

As can easily be seen from grepping in our sources, we had these uses
of "the_repository" in various library code in cases where the
function in question was already getting a "struct repository *"
argument. Let's use that argument instead.

Out of these changes only the changes to "cache-tree.c",
"commit-reach.c", "shallow.c" and "upload-pack.c" would have cleanly
applied before the migration away from the "repo_*()" wrapper macros
in the preceding commits.

The rest aren't new, as we'd previously implicitly refer to
"the_repository", but it's now more obvious that we were doing the
wrong thing all along, and should have used the parameter instead.

The change to change "get_index_format_default(the_repository)" in
"read-cache.c" to use the "r" variable instead should arguably have
been part of [1], or in the subsequent cleanup in [2]. Let's do it
here, as can be seen from the initial code in [3] it's not important
that we use "the_repository" there, but would prefer to always use the
current repository.

This change excludes the "the_repository" use in "upload-pack.c"'s
upload_pack_advertise(), as the in-flight [4] makes that change.

1. ee1f0c242ef (read-cache: add index.skipHash config option,
   2023-01-06)
2. 6269f8eaad0 (treewide: always have a valid "index_state.repo"
   member, 2023-01-17)
3. 7211b9e7534 (repo-settings: consolidate some config settings,
   2019-08-13)
4. <Y/hbUsGPVNAxTdmS@coredump.intra.peff.net>

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agopost-cocci: adjust comments for recent repo_* migration
Ævar Arnfjörð Bjarmason [Tue, 28 Mar 2023 13:58:57 +0000 (15:58 +0200)] 
post-cocci: adjust comments for recent repo_* migration

In preceding commits we changed many calls to macros that were
providing a "the_repository" argument to invoke corresponding repo_*()
function instead. Let's follow-up and adjust references to those in
comments, which coccinelle didn't (and inherently can't) catch.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agococci: apply the "revision.h" part of "the_repository.pending"
Ævar Arnfjörð Bjarmason [Tue, 28 Mar 2023 13:58:56 +0000 (15:58 +0200)] 
cocci: apply the "revision.h" part of "the_repository.pending"

Apply the part of "the_repository.pending.cocci" pertaining to
"revision.h".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agococci: apply the "rerere.h" part of "the_repository.pending"
Ævar Arnfjörð Bjarmason [Tue, 28 Mar 2023 13:58:55 +0000 (15:58 +0200)] 
cocci: apply the "rerere.h" part of "the_repository.pending"

Apply the part of "the_repository.pending.cocci" pertaining to
"rerere.h".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agococci: apply the "refs.h" part of "the_repository.pending"
Ævar Arnfjörð Bjarmason [Tue, 28 Mar 2023 13:58:54 +0000 (15:58 +0200)] 
cocci: apply the "refs.h" part of "the_repository.pending"

Apply the part of "the_repository.pending.cocci" pertaining to
"refs.h".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agococci: apply the "promisor-remote.h" part of "the_repository.pending"
Ævar Arnfjörð Bjarmason [Tue, 28 Mar 2023 13:58:53 +0000 (15:58 +0200)] 
cocci: apply the "promisor-remote.h" part of "the_repository.pending"

Apply the part of "the_repository.pending.cocci" pertaining to
"promisor-remote.h".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agococci: apply the "packfile.h" part of "the_repository.pending"
Ævar Arnfjörð Bjarmason [Tue, 28 Mar 2023 13:58:52 +0000 (15:58 +0200)] 
cocci: apply the "packfile.h" part of "the_repository.pending"

Apply the part of "the_repository.pending.cocci" pertaining to
"packfile.h".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agococci: apply the "pretty.h" part of "the_repository.pending"
Ævar Arnfjörð Bjarmason [Tue, 28 Mar 2023 13:58:51 +0000 (15:58 +0200)] 
cocci: apply the "pretty.h" part of "the_repository.pending"

Apply the part of "the_repository.pending.cocci" pertaining to
"pretty.h".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agococci: apply the "object-store.h" part of "the_repository.pending"
Ævar Arnfjörð Bjarmason [Tue, 28 Mar 2023 13:58:50 +0000 (15:58 +0200)] 
cocci: apply the "object-store.h" part of "the_repository.pending"

Apply the part of "the_repository.pending.cocci" pertaining to
"object-store.h".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agococci: apply the "diff.h" part of "the_repository.pending"
Ævar Arnfjörð Bjarmason [Tue, 28 Mar 2023 13:58:49 +0000 (15:58 +0200)] 
cocci: apply the "diff.h" part of "the_repository.pending"

Apply the part of "the_repository.pending.cocci" pertaining to
"diff.h".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agococci: apply the "commit.h" part of "the_repository.pending"
Ævar Arnfjörð Bjarmason [Tue, 28 Mar 2023 13:58:48 +0000 (15:58 +0200)] 
cocci: apply the "commit.h" part of "the_repository.pending"

Apply the part of "the_repository.pending.cocci" pertaining to
"commit.h".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agococci: apply the "commit-reach.h" part of "the_repository.pending"
Ævar Arnfjörð Bjarmason [Tue, 28 Mar 2023 13:58:47 +0000 (15:58 +0200)] 
cocci: apply the "commit-reach.h" part of "the_repository.pending"

Apply the part of "the_repository.pending.cocci" pertaining to
"commit-reach.h".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agococci: apply the "cache.h" part of "the_repository.pending"
Ævar Arnfjörð Bjarmason [Tue, 28 Mar 2023 13:58:46 +0000 (15:58 +0200)] 
cocci: apply the "cache.h" part of "the_repository.pending"

Apply the part of "the_repository.pending.cocci" pertaining to
"cache.h".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agococci: add missing "the_repository" macros to "pending"
Ævar Arnfjörð Bjarmason [Tue, 28 Mar 2023 13:58:45 +0000 (15:58 +0200)] 
cocci: add missing "the_repository" macros to "pending"

In the case of diff.h, rerere.h and revision.h the macros were added
in [1], [2] and [3] when "the_repository.pending.cocci" didn't
exist. None of the subsequently added migration rules covered
them. Let's add those missing rules.

In the case of macros in "cache.h", "commit.h", "packfile.h",
"promisor-remote.h" and "refs.h" those aren't guarded by
"NO_THE_REPOSITORY_COMPATIBILITY_MACROS", but they're also macros that
add "the_repository" as the first argument, so we should migrate away
from them.

1. 2abf3503854 (revision.c: remove implicit dependency on the_index,
   2018-09-21)
2. e6757652350 (diff.c: remove implicit dependency on the_index,
   2018-09-21)
3. 35843b1123e (rerere.c: remove implicit dependency on the_index,
   2018-09-21)

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agococci: sort "the_repository" rules by header
Ævar Arnfjörð Bjarmason [Tue, 28 Mar 2023 13:58:44 +0000 (15:58 +0200)] 
cocci: sort "the_repository" rules by header

Sort the "the_repository.pending.cocci" file by which header the
macros are in, and add a comment to that effect in front of the
rules. This will make subsequent commits easier to follow, as we'll be
applying these rules on a header-by-header basis.

Once we've fully applied "the_repository.pending.cocci" we'll keep
this rules around for a while in "the_repository.cocci", to help any
outstanding topics and out-of-tree code to resolve textual or semantic
conflicts with these changes, but eventually we'll remove the
"the_repository.cocci" as a follow-up.

So even if some of these functions are subsequently moved and/or split
into other or new headers there's no risk of this becoming stale, if
and when that happens the we should be removing these rules anyway.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agococci: fix incorrect & verbose "the_repository" rules
Ævar Arnfjörð Bjarmason [Tue, 28 Mar 2023 13:58:43 +0000 (15:58 +0200)] 
cocci: fix incorrect & verbose "the_repository" rules

When these rules started being added in [1] they didn't use a ";"
after the ")", and would thus catch uses of these macros within
expressions. But as of [2] the new additions were broken in that
they'd only match a subset of the users of these macros.

Rather than narrowly fixing that, let's have these use the much less
verbose pattern introduced in my recent [3]: There's no need to
exhaustively enumerate arguments if we use the "..." syntax. This
means that we can fold all of these different rules into one.

1. afd69dcc219 (object-store: prepare read_object_file to deal with
   any repo, 2018-11-13)
2. 21a9651ba3f (commit-reach: prepare get_merge_bases to handle any
   repo, 2018-11-13)
3. 0e6550a2c63 (cocci: add a index-compatibility.pending.cocci,
   2022-11-19)

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agococci: remove dead rule from "the_repository.pending.cocci"
Ævar Arnfjörð Bjarmason [Tue, 28 Mar 2023 13:58:42 +0000 (15:58 +0200)] 
cocci: remove dead rule from "the_repository.pending.cocci"

The "parse_commit_gently" macro went away in [1], so we don't need to
carry this for its migration.

1. ea3f7e598c8 (revision: use repository from rev_info when parsing
   commits, 2020-06-23)

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agocsum-file.h: remove unnecessary inclusion of cache.h
Elijah Newren [Tue, 21 Mar 2023 06:26:08 +0000 (06:26 +0000)] 
csum-file.h: remove unnecessary inclusion of cache.h

With the change in the last commit to move several functions to
write-or-die.h, csum-file.h no longer needs to include cache.h.
However, removing that include forces several other C files, which
directly or indirectly dependend upon csum-file.h's inclusion of
cache.h, to now be more explicit about their dependencies.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agowrite-or-die.h: move declarations for write-or-die.c functions from cache.h
Elijah Newren [Tue, 21 Mar 2023 06:26:07 +0000 (06:26 +0000)] 
write-or-die.h: move declarations for write-or-die.c functions from cache.h

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agotreewide: remove cache.h inclusion due to setup.h changes
Elijah Newren [Tue, 21 Mar 2023 06:26:06 +0000 (06:26 +0000)] 
treewide: remove cache.h inclusion due to setup.h changes

By moving several declarations to setup.h, the previous patch made it
possible to remove the include of cache.h in several source files.  Do
so.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agosetup.h: move declarations for setup.c functions from cache.h
Elijah Newren [Tue, 21 Mar 2023 06:26:05 +0000 (06:26 +0000)] 
setup.h: move declarations for setup.c functions from cache.h

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agotreewide: remove cache.h inclusion due to environment.h changes
Elijah Newren [Tue, 21 Mar 2023 06:26:04 +0000 (06:26 +0000)] 
treewide: remove cache.h inclusion due to environment.h changes

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoenvironment.h: move declarations for environment.c functions from cache.h
Elijah Newren [Tue, 21 Mar 2023 06:26:03 +0000 (06:26 +0000)] 
environment.h: move declarations for environment.c functions from cache.h

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agotreewide: remove unnecessary includes of cache.h
Elijah Newren [Tue, 21 Mar 2023 06:26:02 +0000 (06:26 +0000)] 
treewide: remove unnecessary includes of cache.h

The last several commits were geared at replacing the include of cache.h
in strbuf.c with an include of git-compat-util.h.  Unfortunately, I had
to drop a patch moving some functions from cache.h to object-name.h, due
to excessive conflicts with other in-flight topics.

However, even without that patch, the series of patches so far allows us
to modify a number of C files to replace an include of cache.h with
git-compat-util.h.  Do that to reduce our dependencies.

(If we could have kept our object-name.h patch in this series, it would
have also let us reduce the includes in checkout.c and fmt-merge-msg.c
in addition to strbuf.c).

Just to ensure that nothing else was bringing in cache.h, all of the
affected files have been checked to ensure that
    gcc -E -I. $SOURCE_FILE | grep '"cache.h"'
found no hits and that
    make DEVELOPER=1 ${OBJECT_FILE_FOR_SOURCE_FILE}
successfully compiles without warnings.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agowrapper.h: move declarations for wrapper.c functions from cache.h
Elijah Newren [Tue, 21 Mar 2023 06:26:01 +0000 (06:26 +0000)] 
wrapper.h: move declarations for wrapper.c functions from cache.h

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agopath.h: move function declarations for path.c functions from cache.h
Elijah Newren [Tue, 21 Mar 2023 06:26:00 +0000 (06:26 +0000)] 
path.h: move function declarations for path.c functions from cache.h

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agocache.h: remove expand_user_path()
Elijah Newren [Tue, 21 Mar 2023 06:25:59 +0000 (06:25 +0000)] 
cache.h: remove expand_user_path()

expand_user_path() was renamed to interpolate_path() back in mid-2021,
but reinstated with a #define and a NEEDSWORK comment that we would
eventually want to get rid of it.  Do so now.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoabspath.h: move absolute path functions from cache.h
Elijah Newren [Tue, 21 Mar 2023 06:25:58 +0000 (06:25 +0000)] 
abspath.h: move absolute path functions from cache.h

This is another step towards letting us remove the include of cache.h in
strbuf.c.  It does mean that we also need to add includes of abspath.h
in a number of C files.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoenvironment: move comment_line_char from cache.h
Elijah Newren [Tue, 21 Mar 2023 06:25:57 +0000 (06:25 +0000)] 
environment: move comment_line_char from cache.h

This is one step towards making strbuf.c not depend upon cache.h.
Additional steps will follow in subsequent commits.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agotreewide: remove unnecessary cache.h inclusion from several sources
Elijah Newren [Tue, 21 Mar 2023 06:25:56 +0000 (06:25 +0000)] 
treewide: remove unnecessary cache.h inclusion from several sources

A number of files were apparently including cache.h solely to get
gettext.h.  By making those files explicitly include gettext.h, we can
already drop the include of cache.h in these files.  On top of that,
there were some files using cache.h that didn't need to for any reason.
Remove these unnecessary includes.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agotreewide: remove unnecessary inclusion of gettext.h
Elijah Newren [Tue, 21 Mar 2023 06:25:55 +0000 (06:25 +0000)] 
treewide: remove unnecessary inclusion of gettext.h

Looking at things from the opposite angle of the last patch, we had a
few files that were including gettext.h and perhaps needed it at some
point in history, but no longer require it.  Remove the include.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agotreewide: be explicit about dependence on gettext.h
Elijah Newren [Tue, 21 Mar 2023 06:25:54 +0000 (06:25 +0000)] 
treewide: be explicit about dependence on gettext.h

Dozens of files made use of gettext functions, without explicitly
including gettext.h.  This made it more difficult to find which files
could remove a dependence on cache.h.  Make C files explicitly include
gettext.h if they are using it.

However, while compat/fsmonitor/fsm-ipc-darwin.c should also gain an
include of gettext.h, it was left out to avoid conflicting with an
in-flight topic.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agotreewide: remove unnecessary cache.h inclusion from a few headers
Elijah Newren [Tue, 21 Mar 2023 06:25:53 +0000 (06:25 +0000)] 
treewide: remove unnecessary cache.h inclusion from a few headers

Ever since a64215b6cd ("object.h: stop depending on cache.h; make
cache.h depend on object.h", 2023-02-24), we have a few headers that
could have replaced their include of cache.h with an include of
object.h.  Make that change now.

Some C files had to start including cache.h after this change (or some
smaller header it had brought in), because the C files were depending
on things from cache.h but were only formerly implicitly getting
cache.h through one of these headers being modified in this patch.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoThe second batch
Junio C Hamano [Sun, 19 Mar 2023 22:03:22 +0000 (15:03 -0700)] 
The second batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoMerge branch 'jk/add-p-unmerged-fix'
Junio C Hamano [Sun, 19 Mar 2023 22:03:13 +0000 (15:03 -0700)] 
Merge branch 'jk/add-p-unmerged-fix'

"git add -p" while the index is unmerged sometimes failed to parse
the diff output it internally produces and died, which has been
corrected.

* jk/add-p-unmerged-fix:
  add-patch: handle "* Unmerged path" lines

14 months agoMerge branch 'ew/fetch-no-write-fetch-head-fix'
Junio C Hamano [Sun, 19 Mar 2023 22:03:13 +0000 (15:03 -0700)] 
Merge branch 'ew/fetch-no-write-fetch-head-fix'

* ew/fetch-no-write-fetch-head-fix:
  fetch: pass --no-write-fetch-head to subprocesses

14 months agoMerge branch 'fc/advice-diverged-history'
Junio C Hamano [Sun, 19 Mar 2023 22:03:12 +0000 (15:03 -0700)] 
Merge branch 'fc/advice-diverged-history'

After "git pull" that is configured with pull.rebase=false
merge.ff=only fails due to our end having our own development, give
advice messages to get out of the "Not possible to fast-forward"
state.

* fc/advice-diverged-history:
  advice: add diverging advice for novices

14 months agoMerge branch 'ab/fix-strategy-opts-parsing'
Junio C Hamano [Sun, 19 Mar 2023 22:03:12 +0000 (15:03 -0700)] 
Merge branch 'ab/fix-strategy-opts-parsing'

The code to parse "git rebase -X<opt>" was not prepared to see an
unparsable option string, which has been corrected.

* ab/fix-strategy-opts-parsing:
  sequencer.c: fix overflow & segfault in parse_strategy_opts()

14 months agoMerge branch 'ds/reprepare-alternates-when-repreparing-packfiles'
Junio C Hamano [Sun, 19 Mar 2023 22:03:12 +0000 (15:03 -0700)] 
Merge branch 'ds/reprepare-alternates-when-repreparing-packfiles'

Once we start running, we assumed that the list of alternate object
databases would never change.  Hook into the machinery used to
update the list of packfiles during runtime to update this list as
well.

* ds/reprepare-alternates-when-repreparing-packfiles:
  object-file: reprepare alternates when necessary

14 months agoMerge branch 'jk/format-patch-change-format-for-empty-commits'
Junio C Hamano [Sun, 19 Mar 2023 22:03:12 +0000 (15:03 -0700)] 
Merge branch 'jk/format-patch-change-format-for-empty-commits'

"git format-patch" learned to write a log-message only output file
for empty commits.

* jk/format-patch-change-format-for-empty-commits:
  format-patch: output header for empty commits

14 months agoMerge branch 'jk/bundle-use-dash-for-stdfiles'
Junio C Hamano [Sun, 19 Mar 2023 22:03:12 +0000 (15:03 -0700)] 
Merge branch 'jk/bundle-use-dash-for-stdfiles'

"git bundle" learned that "-" is a common way to say that the input
comes from the standard input and/or the output goes to the
standard output.  It used to work only for output and only from the
root level of the working tree.

* jk/bundle-use-dash-for-stdfiles:
  parse-options: use prefix_filename_except_for_dash() helper
  parse-options: consistently allocate memory in fix_filename()
  bundle: don't blindly apply prefix_filename() to "-"
  bundle: document handling of "-" as stdin
  bundle: let "-" mean stdin for reading operations

14 months agoMerge branch 'jk/bundle-progress'
Junio C Hamano [Sun, 19 Mar 2023 22:03:11 +0000 (15:03 -0700)] 
Merge branch 'jk/bundle-progress'

Simplify UI to control progress meter given by "git bundle" command.

* jk/bundle-progress:
  bundle: turn on --all-progress-implied by default

14 months agoMerge branch 'as/doc-markup-fix'
Junio C Hamano [Sun, 19 Mar 2023 22:03:11 +0000 (15:03 -0700)] 
Merge branch 'as/doc-markup-fix'

Fix for a mis-mark-up in doc made in Git 2.39 days.

* as/doc-markup-fix:
  git-merge-tree.txt: replace spurious HTML entity

14 months agoMerge branch 'rj/avoid-switching-to-already-used-branch'
Junio C Hamano [Sun, 19 Mar 2023 22:03:11 +0000 (15:03 -0700)] 
Merge branch 'rj/avoid-switching-to-already-used-branch'

A few subcommands have been taught to stop users from working on a
branch that is being used in another worktree linked to the same
repository.

* rj/avoid-switching-to-already-used-branch:
  switch: reject if the branch is already checked out elsewhere (test)
  rebase: refuse to switch to a branch already checked out elsewhere (test)
  branch: fix die_if_checked_out() when ignore_current_worktree
  worktree: introduce is_shared_symref()

14 months agoMerge branch 'rj/bisect-already-used-branch'
Junio C Hamano [Sun, 19 Mar 2023 22:03:11 +0000 (15:03 -0700)] 
Merge branch 'rj/bisect-already-used-branch'

Allow "git bisect reset" to check out the original branch when the
branch is already checked out in a different worktree linked to the
same repository.

* rj/bisect-already-used-branch:
  bisect: fix "reset" when branch is checked out elsewhere

14 months agoMerge branch 'zh/push-to-delete-onelevel-ref'
Junio C Hamano [Sun, 19 Mar 2023 22:03:10 +0000 (15:03 -0700)] 
Merge branch 'zh/push-to-delete-onelevel-ref'

"git push" has been taught to allow deletion of refs with one-level
names to help repairing a repository who acquired such a ref by
mistake.  In general, we don't encourage use of such a ref, and
creation or update to such a ref is rejected as before.

* zh/push-to-delete-onelevel-ref:
  push: allow delete single-level ref
  receive-pack: fix funny ref error messsage

14 months agoMerge branch 'ak/restore-both-incompatible-with-conflicts'
Junio C Hamano [Sun, 19 Mar 2023 22:03:10 +0000 (15:03 -0700)] 
Merge branch 'ak/restore-both-incompatible-with-conflicts'

"git restore" supports options like "--ours" that are only
meaningful during a conflicted merge, but these options are only
meaningful when updating the working tree files.  These options are
marked to be incompatible when both "--staged" and "--worktree" are
in effect.

* ak/restore-both-incompatible-with-conflicts:
  restore: fault --staged --worktree with merge opts

14 months agoMerge branch 'ew/commit-reach-clean-up-flags-fix'
Junio C Hamano [Sun, 19 Mar 2023 22:03:10 +0000 (15:03 -0700)] 
Merge branch 'ew/commit-reach-clean-up-flags-fix'

Fix a segfaulting loop.  The function and its caller may need
further clean-up.

* ew/commit-reach-clean-up-flags-fix:
  commit-reach: avoid NULL dereference

14 months agoMerge branch 'ab/avoid-losing-exit-codes-in-tests'
Junio C Hamano [Sun, 19 Mar 2023 22:03:10 +0000 (15:03 -0700)] 
Merge branch 'ab/avoid-losing-exit-codes-in-tests'

Test clean-up.

* ab/avoid-losing-exit-codes-in-tests:
  tests: don't lose misc "git" exit codes
  tests: don't lose exit status with "test <op> $(git ...)"
  tests: don't lose "git" exit codes in "! ( git ... | grep )"
  tests: don't lose exit status with "(cd ...; test <op> $(git ...))"
  t/lib-patch-mode.sh: fix ignored exit codes
  auto-crlf tests: don't lose exit code in loops and outside tests

14 months agoStart the 2.41 cycle
Junio C Hamano [Fri, 17 Mar 2023 21:03:20 +0000 (14:03 -0700)] 
Start the 2.41 cycle

Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 months agoMerge branch 'fz/rebase-msg-update'
Junio C Hamano [Fri, 17 Mar 2023 21:03:10 +0000 (14:03 -0700)] 
Merge branch 'fz/rebase-msg-update'

Message update.

* fz/rebase-msg-update:
  rebase: fix capitalisation autoSquash in i18n string

14 months agoMerge branch 'ew/fetch-hiderefs'
Junio C Hamano [Fri, 17 Mar 2023 21:03:10 +0000 (14:03 -0700)] 
Merge branch 'ew/fetch-hiderefs'

A new "fetch.hideRefs" option can be used to exclude specified refs
from "rev-list --objects --stdin --not --all" traversal for
checking object connectivity, most useful when there are many
unrelated histories in a single repository.

* ew/fetch-hiderefs:
  fetch: support hideRefs to speed up connectivity checks

14 months agoMerge branch 'mc/credential-helper-www-authenticate'
Junio C Hamano [Fri, 17 Mar 2023 21:03:10 +0000 (14:03 -0700)] 
Merge branch 'mc/credential-helper-www-authenticate'

Allow information carried on the WWW-AUthenticate header to be
passed to the credential helpers.

* mc/credential-helper-www-authenticate:
  credential: add WWW-Authenticate header to cred requests
  http: read HTTP WWW-Authenticate response headers
  t5563: add tests for basic and anoymous HTTP access

14 months agoMerge branch 'jc/gpg-lazy-init'
Junio C Hamano [Fri, 17 Mar 2023 21:03:10 +0000 (14:03 -0700)] 
Merge branch 'jc/gpg-lazy-init'

Instead of forcing each command to choose to honor GPG related
configuration variables, make the subsystem lazily initialize
itself.

* jc/gpg-lazy-init:
  drop pure pass-through config callbacks
  gpg-interface: lazily initialize and read the configuration

14 months agoMerge branch 'jk/unused-post-2.39-part2'
Junio C Hamano [Fri, 17 Mar 2023 21:03:09 +0000 (14:03 -0700)] 
Merge branch 'jk/unused-post-2.39-part2'

More work towards -Wunused.

* jk/unused-post-2.39-part2: (21 commits)
  help: mark unused parameter in git_unknown_cmd_config()
  run_processes_parallel: mark unused callback parameters
  userformat_want_item(): mark unused parameter
  for_each_commit_graft(): mark unused callback parameter
  rewrite_parents(): mark unused callback parameter
  fetch-pack: mark unused parameter in callback function
  notes: mark unused callback parameters
  prio-queue: mark unused parameters in comparison functions
  for_each_object: mark unused callback parameters
  list-objects: mark unused callback parameters
  mark unused parameters in signal handlers
  run-command: mark error routine parameters as unused
  mark "pointless" data pointers in callbacks
  ref-filter: mark unused callback parameters
  http-backend: mark unused parameters in virtual functions
  http-backend: mark argc/argv unused
  object-name: mark unused parameters in disambiguate callbacks
  serve: mark unused parameters in virtual functions
  serve: use repository pointer to get config
  ls-refs: drop config caching
  ...

14 months agoMerge branch 'en/header-cleanup'
Junio C Hamano [Fri, 17 Mar 2023 21:03:08 +0000 (14:03 -0700)] 
Merge branch 'en/header-cleanup'

Code clean-up to clarify the rule that "git-compat-util.h" must be
the first to be included.

* en/header-cleanup:
  diff.h: remove unnecessary include of object.h
  Remove unnecessary includes of builtin.h
  treewide: replace cache.h with more direct headers, where possible
  replace-object.h: move read_replace_refs declaration from cache.h to here
  object-store.h: move struct object_info from cache.h
  dir.h: refactor to no longer need to include cache.h
  object.h: stop depending on cache.h; make cache.h depend on object.h
  ident.h: move ident-related declarations out of cache.h
  pretty.h: move has_non_ascii() declaration from commit.h
  cache.h: remove dependence on hex.h; make other files include it explicitly
  hex.h: move some hex-related declarations from cache.h
  hash.h: move some oid-related declarations from cache.h
  alloc.h: move ALLOC_GROW() functions from cache.h
  treewide: remove unnecessary cache.h includes in source files
  treewide: remove unnecessary cache.h includes
  treewide: remove unnecessary git-compat-util.h includes in headers
  treewide: ensure one of the appropriate headers is sourced first

14 months agoMerge branch 'en/dir-api-cleanup'
Junio C Hamano [Fri, 17 Mar 2023 21:03:08 +0000 (14:03 -0700)] 
Merge branch 'en/dir-api-cleanup'

Code clean-up to clarify directory traversal API.

* en/dir-api-cleanup:
  unpack-trees: add usage notices around df_conflict_entry
  unpack-trees: special case read-tree debugging as internal usage
  unpack-trees: rewrap a few overlong lines from previous patch
  unpack-trees: mark fields only used internally as internal
  unpack_trees: start splitting internal fields from public API
  sparse-checkout: avoid using internal API of unpack-trees, take 2
  sparse-checkout: avoid using internal API of unpack-trees
  unpack-trees: clean up some flow control
  dir: mark output only fields of dir_struct as such
  dir: add a usage note to exclude_per_dir
  dir: separate public from internal portion of dir_struct
  unpack-trees: heed requests to overwrite ignored files
  t2021: fix platform-specific leftover cruft

14 months agoMerge branch 'jk/fsck-indices-in-worktrees'
Junio C Hamano [Fri, 17 Mar 2023 21:03:08 +0000 (14:03 -0700)] 
Merge branch 'jk/fsck-indices-in-worktrees'

"git fsck" learned to check the index files in other worktrees,
just like "git gc" honors them as anchoring points.

* jk/fsck-indices-in-worktrees:
  fsck: check even zero-entry index files
  fsck: mention file path for index errors
  fsck: check index files in all worktrees
  fsck: factor out index fsck

15 months agoGit 2.40 v2.40.0
Junio C Hamano [Sun, 12 Mar 2023 21:34:41 +0000 (14:34 -0700)] 
Git 2.40

Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agoMerge tag 'l10n-2.40.0-rnd1' of https://github.com/git-l10n/git-po
Junio C Hamano [Sun, 12 Mar 2023 21:33:14 +0000 (14:33 -0700)] 
Merge tag 'l10n-2.40.0-rnd1' of https://github.com/git-l10n/git-po

l10n-2.40.0-rnd1

* tag 'l10n-2.40.0-rnd1' of https://github.com/git-l10n/git-po:
  l10n: zh_CN v2.40.0 round 1
  l10n: update German translation
  l10n: tr: Update Turkish translations for v.2.40.0
  l10n: fr: v2.40.0 rnd 2
  l10n: fr: v2.40.0 rnd 1
  l10n: fr: fix some typos
  l10n: po-id for 2.40 (round 1)
  l10n: sv.po: Update Swedish translation (5490t0f0u)
  l10n: bg.po: Updated Bulgarian translation (5490t)
  l10n: Update Catalan translation

15 months agoMerge branch 'fz/po-zh_CN' of github.com:fangyi-zhou/git-po
Jiang Xin [Fri, 10 Mar 2023 14:50:14 +0000 (22:50 +0800)] 
Merge branch 'fz/po-zh_CN' of github.com:fangyi-zhou/git-po

* 'fz/po-zh_CN' of github.com:fangyi-zhou/git-po:
  l10n: zh_CN v2.40.0 round 1

15 months agoobject-file: reprepare alternates when necessary
Derrick Stolee [Wed, 8 Mar 2023 18:47:32 +0000 (18:47 +0000)] 
object-file: reprepare alternates when necessary

When an object is not found in a repository's object store, we sometimes
call reprepare_packed_git() to see if the object was temporarily moved
into a new pack-file (and its old pack-file or loose object was
deleted). This process does a scan of each pack directory within each
odb, but does not reevaluate if the odb list needs updating.

Extend reprepare_packed_git() to also reprepare the alternate odb list
by setting loaded_alternates to zero and calling prepare_alt_odb(). This
will add newly-discoverd odbs to the linked list, but will not duplicate
existing ones nor will it remove existing ones that are no longer listed
in the alternates file. Do this under the object read lock to avoid
readers from interacting with a potentially incomplete odb being added
to the odb list.

If the alternates file was edited to _remove_ some alternates during the
course of the Git process, Git will continue to see alternates that were
ever valid for that repository. ODBs are not removed from the list, the
same as the existing behavior before this change. Git already has
protections against an alternate directory disappearing from the
filesystem during the lifetime of a process, and those are still in
effect.

This change is specifically for concurrent changes to the repository, so
it is difficult to create a test that guarantees this behavior is
correct. I manually verified by introducing a reprepare_packed_git() call
into get_revision() and stepped into that call in a debugger with a
parent 'git log' process. Multiple runs of prepare_alt_odb() kept
the_repository->objects->odb as a single-item chain until I added a
.git/objects/info/alternates file in a different process. The next run
added the new odb to the chain and subsequent runs did not add to the
chain.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agofetch: pass --no-write-fetch-head to subprocesses
Eric Wong [Wed, 8 Mar 2023 22:22:05 +0000 (22:22 +0000)] 
fetch: pass --no-write-fetch-head to subprocesses

It seems a user would expect this option would work regardless
of whether it's fetching from a single remote, many remotes,
or recursing into submodules.

Signed-off-by: Eric Wong <e@80x24.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agoadd-patch: handle "* Unmerged path" lines
Jeff King [Thu, 9 Mar 2023 08:58:16 +0000 (03:58 -0500)] 
add-patch: handle "* Unmerged path" lines

When we generate a diff with --cached, unmerged entries have no oid for
their index entry:

  $ git diff-index --abbrev --cached HEAD
  :100644 000000 f719efd 0000000 U my-conflict

So when we are asked to produce a patch, since we only have one side, we
just emit a special message:

  $ git diff-index --cached -p HEAD
  * Unmerged path my-conflict

This confuses interactive-patch modes that look at cached diffs. For
example:

  $ git reset -p
  BUG: add-patch.c:498: diff starts with unexpected line:
  * Unmerged path my-conflict

Making things even more confusing, you'll get that error only if the
unmerged entry is alphabetically the first changed file. Otherwise, we
simply stick the unrecognized line to the end of the previous hunk.
There it's mostly harmless, as it eventually gets fed back to "git
apply", which happily ignores it. But it's still shown to the user
attached to the hunk, which is wrong.

So let's handle these lines as a noop. There's not really anything
useful to do with a conflicted merge in this case, and that's what we do
for other cases like "add -p". There we get a "diff --cc" line, which we
accept as starting a new file, but we refuse to use any of its hunks
(their headers start with "@@@" and not "@@ ", so we silently ignore
them).

It seems like simply recognizing the line and continuing in our parsing
loop would work. But we actually need to run the rest of the loop body
to handle matching up our colored/filtered output. But that code assumes
that we have some active file_diff we're working on. So instead, we'll
just insert a dummy entry into our array. This ends up the same as if we
saw a "diff --cc" line (a file with no hunks).

Reported-by: Philippe Blain <levraiphilippeblain@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agosequencer.c: fix overflow & segfault in parse_strategy_opts()
Ævar Arnfjörð Bjarmason [Tue, 7 Mar 2023 18:21:59 +0000 (19:21 +0100)] 
sequencer.c: fix overflow & segfault in parse_strategy_opts()

The split_cmdline() function introduced in [1] returns an "int". If
it's negative it signifies an error. The option parsing in [2] didn't
account for this, and assigned the value directly to the "size_t
xopts_nr". We'd then attempt to loop over all of these elements, and
access uninitialized memory.

There's a few things that use this for option parsing, but one way to
trigger it is with a bad value to "-X <strategy-option>", e.g:

git rebase -X"bad argument\""

In another context this might be a security issue, but in this case
someone who's already able to inject arguments directly to our
commands would be past other defenses, making this potential
escalation a moot point.

As the example above & test case shows the error reporting leaves
something to be desired. The function will loop over the
whitespace-split values, but when it encounters an error we'll only
report the first element, which is OK, not the second "argument\""
whose quote is unbalanced.

This is an inherent limitation of the current API, and the issue
affects other API users. Let's not attempt to fix that now. If and
when that happens these tests will need to be adjusted to assert the
new output.

1. 2b11e3170e9 (If you have a config containing something like this:,
   2006-06-05)
2. ca6c6b45dd9 (sequencer (rebase -i): respect strategy/strategy_opts
   settings, 2017-01-02)

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agoadvice: add diverging advice for novices
Felipe Contreras [Wed, 8 Mar 2023 02:48:33 +0000 (20:48 -0600)] 
advice: add diverging advice for novices

The user might not necessarily know why ff only was configured, maybe an
admin did it, or the installer (Git for Windows), or perhaps they just
followed some online advice.

This can happen not only on pull.ff=only, but merge.ff=only too.

Even worse if the user has configured pull.rebase=false and
merge.ff=only, because in those cases a diverging merge will constantly
keep failing. There's no trivial way to get out of this other than
`git merge --no-ff`.

Let's not assume our users are experts in git who completely understand
all their configurations.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Acked-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agoMerge branch 'l10n-de-2.40' of github.com:ralfth/git
Jiang Xin [Wed, 8 Mar 2023 01:10:20 +0000 (09:10 +0800)] 
Merge branch 'l10n-de-2.40' of github.com:ralfth/git

* 'l10n-de-2.40' of github.com:ralfth/git:
  l10n: update German translation

15 months agoMerge branch 'po-id' of github.com:bagasme/git-po
Jiang Xin [Wed, 8 Mar 2023 00:28:02 +0000 (08:28 +0800)] 
Merge branch 'po-id' of github.com:bagasme/git-po

* 'po-id' of github.com:bagasme/git-po:
  l10n: po-id for 2.40 (round 1)

15 months agoMerge branch 'catalan' of github.com:Softcatala/git-po
Jiang Xin [Wed, 8 Mar 2023 00:27:07 +0000 (08:27 +0800)] 
Merge branch 'catalan' of github.com:Softcatala/git-po

* 'catalan' of github.com:Softcatala/git-po:
  l10n: Update Catalan translation

15 months agoMerge branch 'fr_2.40.0_rnd1' of github.com:jnavila/git
Jiang Xin [Wed, 8 Mar 2023 00:26:00 +0000 (08:26 +0800)] 
Merge branch 'fr_2.40.0_rnd1' of github.com:jnavila/git

* 'fr_2.40.0_rnd1' of github.com:jnavila/git:
  l10n: fr: v2.40.0 rnd 2
  l10n: fr: v2.40.0 rnd 1
  l10n: fr: fix some typos

15 months agoMerge branch 'master' of github.com:nafmo/git-l10n-sv
Jiang Xin [Wed, 8 Mar 2023 00:25:07 +0000 (08:25 +0800)] 
Merge branch 'master' of github.com:nafmo/git-l10n-sv

* 'master' of github.com:nafmo/git-l10n-sv:
  l10n: sv.po: Update Swedish translation (5490t0f0u)

15 months agoMerge branch 'master' of github.com:alshopov/git-po
Jiang Xin [Wed, 8 Mar 2023 00:23:16 +0000 (08:23 +0800)] 
Merge branch 'master' of github.com:alshopov/git-po

* 'master' of github.com:alshopov/git-po:
  l10n: bg.po: Updated Bulgarian translation (5490t)

15 months agoMerge branch 'turkish' of github.com:bitigchi/git-po
Jiang Xin [Wed, 8 Mar 2023 00:22:01 +0000 (08:22 +0800)] 
Merge branch 'turkish' of github.com:bitigchi/git-po

* 'turkish' of github.com:bitigchi/git-po:
  l10n: tr: Update Turkish translations for v.2.40.0