]> git.ipfire.org Git - thirdparty/git.git/commit
fast-import: introduce 'struct fast_import_state'
authorChristian Couder <christian.couder@gmail.com>
Thu, 16 Jul 2026 16:55:15 +0000 (18:55 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 16 Jul 2026 21:11:13 +0000 (14:11 -0700)
commit36bd8a1e0d2cf6d7a6e35c4b1d895967500aee59
tree17ffc096285f2e7a5947854b2e92bac6844fbb2a
parent0892b3df6f40f798dfe9d9e4c000b027141a2cd6
fast-import: introduce 'struct fast_import_state'

"builtin/fast-import.c" uses a large number of global variables. This
makes it harder than necessary to reason about and improve. Especially
adding new features requires adding more global variables, while
modernizing and eventually libifying the code becomes more and more
difficult.

To start reverting the sad trend to more and more globals and to start
cleaning things up, let's introduce a 'struct fast_import_state' and
pass an instance of it as the first argument to many functions.

This is similar to what was done for "builtin/apply.c" by introducing a
'struct apply_state', see 07d7e290ff (apply: move 'struct apply_state'
to a header file, 2016-08-11) and related commits.

As a first step only the 'global_argc', 'global_argv' and
'global_prefix' variables are moved into the new struct. More variables
will be moved into it in the following commits.

Some functions receive the new 'state' parameter only to pass it
along or for future use, so they are marked with UNUSED for now to
satisfy '-Werror=unused-parameter'.

This is a mostly mechanical refactoring with no intended behavior
change.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/fast-import.c