From: Ramkumar Ramachandra Date: Sat, 28 Aug 2010 10:35:32 GMT Subject: [PATCH] fmt-merge-msg: Disallow '--log', 'merge.log' < 0 Message-ID: <1282991734-3368-2-git-send-email-artagnon@gmail.com> In-Reply-To: <1282991734-3368-1-git-send-email-artagnon@gmail.com> Explicitly check for the case when '--log' or 'merge.log' is passed a negative integer argument. Handle the case by making it look as if such an argument was never parsed. Signed-off-by: Ramkumar Ramachandra --- builtin/fmt-merge-msg.c | 4 +++- builtin/merge.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c index d3b8297..0684179 100644 --- a/builtin/fmt-merge-msg.c +++ b/builtin/fmt-merge-msg.c @@ -18,7 +18,7 @@ static int fmt_merge_msg_config(const char *key, const char *value, void *cb) if (!strcmp(key, "merge.log") || !strcmp(key, "merge.summary")) { int is_bool; shortlog_len = git_config_bool_or_int(key, value, &is_bool); - if (is_bool && shortlog_len) + if ((is_bool && shortlog_len) || shortlog_len < 0) shortlog_len = DEFAULT_MERGE_LOG_LEN; } return 0; @@ -345,6 +345,8 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix) write_in_full(STDOUT_FILENO, &nl, 1); return 0; } + if (shortlog_len < 0) + shortlog_len = DEFAULT_MERGE_LOG_LEN; if (inpath && strcmp(inpath, "-")) { in = fopen(inpath, "r"); diff --git a/builtin/merge.c b/builtin/merge.c index 55dc571..affa197 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -510,7 +510,7 @@ static int git_merge_config(const char *k, const char *v, void *cb) else if (!strcmp(k, "merge.log") || !strcmp(k, "merge.summary")) { int is_bool; shortlog_len = git_config_bool_or_int(k, v, &is_bool); - if (is_bool && shortlog_len) + if ((is_bool && shortlog_len) || shortlog_len < 0) shortlog_len = DEFAULT_MERGE_LOG_LEN; return 0; } else if (!strcmp(k, "merge.renormalize")) -- 1.7.2.2.409.gdbb11.dirty