提交 da53eec6 编写于 作者: N Nguyễn Thái Ngọc Duy 提交者: Junio C Hamano

merge -h: show usage even with corrupt index

Part of a campaign to make sure "git <command> -h" works correctly
when run from distractingly bad repositories.

[jn: with rewritten log message and tests]
Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 cbb3167e
......@@ -909,6 +909,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
const char *best_strategy = NULL, *wt_strategy = NULL;
struct commit_list **remotes = &remoteheads;
if (argc == 2 && !strcmp(argv[1], "-h"))
usage_with_options(builtin_merge_usage, builtin_merge_options);
if (read_cache_unmerged()) {
die_resolve_conflict("merge");
}
......
......@@ -144,6 +144,17 @@ test_expect_success 'test option parsing' '
test_must_fail git merge
'
test_expect_success 'merge -h with invalid index' '
mkdir broken &&
(
cd broken &&
git init &&
>.git/index &&
test_expect_code 129 git merge -h 2>usage
) &&
grep "[Uu]sage: git merge" broken/usage
'
test_expect_success 'reject non-strategy with a git-merge-foo name' '
test_must_fail git merge -s index c1
'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册