]> git.ipfire.org Git - thirdparty/git.git/commit - builtin/notes.c
Use OPT_CALLBACK and OPT_CALLBACK_F
authorDenton Liu <liu.denton@gmail.com>
Tue, 28 Apr 2020 08:36:28 +0000 (04:36 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 28 Apr 2020 17:47:10 +0000 (10:47 -0700)
commit203c85339fb51bb8b83aae8f0adde44d6e55e018
tree177514cadc9a148394749b130ed168ccff57c7d8
parente870325ee8575d5c3d7afe0ba2c9be072c692b65
Use OPT_CALLBACK and OPT_CALLBACK_F

In the codebase, there are many options which use OPTION_CALLBACK in a
plain ol' struct definition. However, we have the OPT_CALLBACK and
OPT_CALLBACK_F macros which are meant to abstract these plain struct
definitions away. These macros are useful as they semantically signal to
developers that these are just normal callback option with nothing fancy
happening.

Replace plain struct definitions of OPTION_CALLBACK with OPT_CALLBACK or
OPT_CALLBACK_F where applicable. The heavy lifting was done using the
following (disgusting) shell script:

#!/bin/sh

do_replacement () {
tr '\n' '\r' |
sed -e 's/{\s*OPTION_CALLBACK,\s*\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\),\s*0,\(\s*[^[:space:]}]*\)\s*}/OPT_CALLBACK(\1,\2,\3,\4,\5,\6)/g' |
sed -e 's/{\s*OPTION_CALLBACK,\s*\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\),\(\s*[^[:space:]}]*\)\s*}/OPT_CALLBACK_F(\1,\2,\3,\4,\5,\6,\7)/g' |
tr '\r' '\n'
}

for f in $(git ls-files \*.c)
do
do_replacement <"$f" >"$f.tmp"
mv "$f.tmp" "$f"
done

The result was manually inspected and then reformatted to match the
style of the surrounding code. Finally, using
`git grep OPTION_CALLBACK \*.c`, leftover results which were not handled
by the script were manually transformed.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
31 files changed:
apply.c
builtin/add.c
builtin/blame.c
builtin/branch.c
builtin/cat-file.c
builtin/checkout-index.c
builtin/checkout.c
builtin/clean.c
builtin/commit-tree.c
builtin/commit.c
builtin/fetch.c
builtin/grep.c
builtin/interpret-trailers.c
builtin/log.c
builtin/ls-files.c
builtin/merge.c
builtin/notes.c
builtin/pack-objects.c
builtin/pull.c
builtin/push.c
builtin/read-tree.c
builtin/rebase.c
builtin/remote.c
builtin/reset.c
builtin/send-pack.c
builtin/shortlog.c
builtin/show-branch.c
builtin/show-ref.c
builtin/tag.c
builtin/update-index.c
list-objects-filter-options.h