summaryrefslogtreecommitdiff
path: root/parse-options.h
diff options
context:
space:
mode:
authorBrandon Richardson <brandon1024.br@gmail.com>2019-03-07 15:44:09 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-03-08 01:31:24 (GMT)
commitcbdeab98e871bfbb45cf5095cc804ebb07054eba (patch)
tree6fedd900986b19cd48fe78e15c4a64cb3a8bbdf2 /parse-options.h
parent8104ec994ea3849a968b4667d072fedd1e688642 (diff)
downloadgit-cbdeab98e871bfbb45cf5095cc804ebb07054eba.zip
git-cbdeab98e871bfbb45cf5095cc804ebb07054eba.tar.gz
git-cbdeab98e871bfbb45cf5095cc804ebb07054eba.tar.bz2
commit-tree: utilize parse-options api
Rather than parse options manually, which is both difficult to read and error prone, parse options supplied to commit-tree using the parse-options api. It was discovered that the --no-gpg-sign option was documented but not implemented in commit 70ddbd7767 (commit-tree: add missing --gpg-sign flag, 2019-01-19), and the existing implementation would attempt to translate the option as a tree oid. It was also suggested earlier in commit 55ca3f99ae (commit-tree: add and document --no-gpg-sign, 2013-12-13) that commit-tree should be migrated to utilize the parse-options api, which could help prevent mistakes like this in the future. Hence this change. Also update the documentation to better describe that mixing `-m` and `-F` options will correctly compose commit log messages in the order in which the options are given. In the process, mark various strings for translation. Signed-off-by: Brandon Richardson <brandon1024.br@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'parse-options.h')
-rw-r--r--parse-options.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/parse-options.h b/parse-options.h
index 14fe324..3a442ee 100644
--- a/parse-options.h
+++ b/parse-options.h
@@ -202,6 +202,17 @@ const char *optname(const struct option *opt, int flags);
BUG("option callback does not expect an argument"); \
} while (0)
+/*
+ * Similar to the assertions above, but checks that "arg" is always non-NULL.
+ * This assertion also implies BUG_ON_OPT_NEG(), letting you declare both
+ * assertions in a single line.
+ */
+#define BUG_ON_OPT_NEG_NOARG(unset, arg) do { \
+ BUG_ON_OPT_NEG(unset); \
+ if(!(arg)) \
+ BUG("option callback expects an argument"); \
+} while(0)
+
/*----- incremental advanced APIs -----*/
enum {