git-commit-vandalism/t/helper
Jeff King 517fe807d6 assert NOARG/NONEG behavior of parse-options callbacks
When we define a parse-options callback, the flags we put in the option
struct must match what the callback expects. For example, a callback
which does not handle the "unset" parameter should only be used with
PARSE_OPT_NONEG. But since the callback and the option struct are not
defined next to each other, it's easy to get this wrong (as earlier
patches in this series show).

Fortunately, the compiler can help us here: compiling with
-Wunused-parameters can show us which callbacks ignore their "unset"
parameters (and likewise, ones that ignore "arg" expect to be triggered
with PARSE_OPT_NOARG).

But after we've inspected a callback and determined that all of its
callers use the right flags, what do we do next? We'd like to silence
the compiler warning, but do so in a way that will catch any wrong calls
in the future.

We can do that by actually checking those variables and asserting that
they match our expectations. Because this is such a common pattern,
we'll introduce some helper macros. The resulting messages aren't
as descriptive as we could make them, but the file/line information from
BUG() is enough to identify the problem (and anyway, the point is that
these should never be seen).

Each of the annotated callbacks in this patch triggers
-Wunused-parameters, and was manually inspected to make sure all callers
use the correct options (so none of these BUGs should be triggerable).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-11-06 12:56:29 +09:00
..
.gitignore
test-chmtime.c Merge branch 'ps/test-chmtime-get' 2018-04-25 13:29:00 +09:00
test-config.c
test-ctype.c
test-date.c
test-delta.c test-delta: read input into a heap buffer 2018-08-30 10:30:21 -07:00
test-drop-caches.c handle lower case drive letters on Windows 2018-07-12 12:11:05 -07:00
test-dump-cache-tree.c convert "oidcmp() != 0" to "!oideq()" 2018-08-29 11:32:49 -07:00
test-dump-fsmonitor.c t/helper: merge test-dump-fsmonitor into test-tool 2018-09-11 10:54:19 -07:00
test-dump-split-index.c Update struct index_state to use struct object_id 2018-05-02 13:59:50 +09:00
test-dump-untracked-cache.c t/helper: merge test-dump-untracked-cache into test-tool 2018-09-11 10:54:19 -07:00
test-example-decorate.c Replace all die("BUG: ...") calls by BUG() ones 2018-05-06 19:06:13 +09:00
test-fake-ssh.c
test-genrandom.c
test-hashmap.c
test-index-version.c
test-json-writer.c json_writer: new routines to create JSON data 2018-07-16 13:55:39 -07:00
test-lazy-init-name-hash.c
test-line-buffer.c
test-match-trees.c
test-mergesort.c
test-mktemp.c t/helper: merge test-mktemp into test-tool 2018-03-27 08:45:47 -07:00
test-online-cpus.c
test-parse-options.c assert NOARG/NONEG behavior of parse-options callbacks 2018-11-06 12:56:29 +09:00
test-path-utils.c Sync with Git 2.17.1 2018-05-29 17:10:05 +09:00
test-pkt-line.c t/helper: merge test-pkt-line into test-tool 2018-09-11 10:54:19 -07:00
test-prio-queue.c
test-reach.c commit-reach: properly peel tags 2018-09-21 11:36:27 -07:00
test-read-cache.c
test-read-midx.c multi-pack-index: store local property 2018-08-20 15:31:39 -07:00
test-ref-store.c refs: add repository argument to get_main_ref_store 2018-04-12 11:38:56 +09:00
test-regex.c
test-repository.c test-repository: properly init repo 2018-08-21 10:22:50 -07:00
test-revision-walking.c revision.c: remove implicit dependency on the_index 2018-09-21 09:51:19 -07:00
test-run-command.c
test-scrap-cache-tree.c Merge branch 'ma/lockfile-cleanup' 2018-05-30 14:04:05 +09:00
test-sha1-array.c
test-sha1.c
test-sha1.sh
test-sigchain.c
test-strcmp-offset.c
test-string-list.c
test-submodule-config.c Merge branch 'sb/submodule-move-nested' 2018-05-08 15:59:17 +09:00
test-subprocess.c
test-svn-fe.c
test-tool.c test-tool: show tool list on error 2018-10-18 12:27:39 +09:00
test-tool.h headers: normalize the spelling of some header guards 2018-10-18 13:39:35 +09:00
test-urlmatch-normalization.c
test-wildmatch.c t/helper: merge test-wildmatch into test-tool 2018-03-27 08:45:47 -07:00
test-windows-named-pipe.c t0051: test GIT_TRACE to a windows named pipe 2018-09-11 13:54:25 -07:00
test-write-cache.c Merge branch 'ma/lockfile-cleanup' 2018-05-30 14:04:05 +09:00