Merge branch 'jn/git-cmd-h-bypass-setup'
* jn/git-cmd-h-bypass-setup: update-index -h: show usage even with corrupt index merge -h: show usage even with corrupt index ls-files -h: show usage even with corrupt index gc -h: show usage even with broken configuration commit/status -h: show usage even with broken configuration checkout-index -h: show usage even in an invalid repository branch -h: show usage even in an invalid repository Conflicts: builtin/merge.c
This commit is contained in:
commit
6758af89e4
@ -668,6 +668,9 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
|
||||
OPT_END(),
|
||||
};
|
||||
|
||||
if (argc == 2 && !strcmp(argv[1], "-h"))
|
||||
usage_with_options(builtin_branch_usage, options);
|
||||
|
||||
git_config(git_branch_config, NULL);
|
||||
|
||||
if (branch_use_color == -1)
|
||||
|
@ -241,6 +241,9 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
|
||||
OPT_END()
|
||||
};
|
||||
|
||||
if (argc == 2 && !strcmp(argv[1], "-h"))
|
||||
usage_with_options(builtin_checkout_index_usage,
|
||||
builtin_checkout_index_options);
|
||||
git_config(git_default_config, NULL);
|
||||
state.base_dir = "";
|
||||
prefix_length = prefix ? strlen(prefix) : 0;
|
||||
|
@ -1097,6 +1097,9 @@ int cmd_status(int argc, const char **argv, const char *prefix)
|
||||
OPT_END(),
|
||||
};
|
||||
|
||||
if (argc == 2 && !strcmp(argv[1], "-h"))
|
||||
usage_with_options(builtin_status_usage, builtin_status_options);
|
||||
|
||||
if (null_termination && status_format == STATUS_FORMAT_LONG)
|
||||
status_format = STATUS_FORMAT_PORCELAIN;
|
||||
|
||||
@ -1282,6 +1285,9 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
|
||||
int allow_fast_forward = 1;
|
||||
struct wt_status s;
|
||||
|
||||
if (argc == 2 && !strcmp(argv[1], "-h"))
|
||||
usage_with_options(builtin_commit_usage, builtin_commit_options);
|
||||
|
||||
wt_status_prepare(&s);
|
||||
git_config(git_commit_config, &s);
|
||||
in_merge = file_exists(git_path("MERGE_HEAD"));
|
||||
|
@ -189,6 +189,9 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
|
||||
OPT_END()
|
||||
};
|
||||
|
||||
if (argc == 2 && !strcmp(argv[1], "-h"))
|
||||
usage_with_options(builtin_gc_usage, builtin_gc_options);
|
||||
|
||||
git_config(gc_config, NULL);
|
||||
|
||||
if (pack_refs < 0)
|
||||
|
@ -530,6 +530,9 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
|
||||
OPT_END()
|
||||
};
|
||||
|
||||
if (argc == 2 && !strcmp(argv[1], "-h"))
|
||||
usage_with_options(ls_files_usage, builtin_ls_files_options);
|
||||
|
||||
memset(&dir, 0, sizeof(dir));
|
||||
prefix = cmd_prefix;
|
||||
if (prefix)
|
||||
|
@ -922,6 +922,9 @@ 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);
|
||||
|
||||
/*
|
||||
* Check if we are _not_ on a detached HEAD, i.e. if there is a
|
||||
* current branch.
|
||||
|
@ -589,6 +589,9 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
|
||||
int lock_error = 0;
|
||||
struct lock_file *lock_file;
|
||||
|
||||
if (argc == 2 && !strcmp(argv[1], "-h"))
|
||||
usage(update_index_usage);
|
||||
|
||||
git_config(git_default_config, NULL);
|
||||
|
||||
/* We can't free this memory, it becomes part of a linked list parsed atexit() */
|
||||
|
24
t/t2006-checkout-index-basic.sh
Executable file
24
t/t2006-checkout-index-basic.sh
Executable file
@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
|
||||
test_description='basic checkout-index tests
|
||||
'
|
||||
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success 'checkout-index --gobbledegook' '
|
||||
test_expect_code 129 git checkout-index --gobbledegook 2>err &&
|
||||
grep "[Uu]sage" err
|
||||
'
|
||||
|
||||
test_expect_success 'checkout-index -h in broken repository' '
|
||||
mkdir broken &&
|
||||
(
|
||||
cd broken &&
|
||||
git init &&
|
||||
>.git/index &&
|
||||
test_expect_code 129 git checkout-index -h >usage 2>&1
|
||||
) &&
|
||||
grep "[Uu]sage" broken/usage
|
||||
'
|
||||
|
||||
test_done
|
32
t/t2107-update-index-basic.sh
Executable file
32
t/t2107-update-index-basic.sh
Executable file
@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
test_description='basic update-index tests
|
||||
|
||||
Tests for command-line parsing and basic operation.
|
||||
'
|
||||
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success 'update-index --nonsense fails' '
|
||||
test_must_fail git update-index --nonsense 2>msg &&
|
||||
cat msg &&
|
||||
test -s msg
|
||||
'
|
||||
|
||||
test_expect_failure 'update-index --nonsense dumps usage' '
|
||||
test_expect_code 129 git update-index --nonsense 2>err &&
|
||||
grep "[Uu]sage: git update-index" err
|
||||
'
|
||||
|
||||
test_expect_success 'update-index -h with corrupt index' '
|
||||
mkdir broken &&
|
||||
(
|
||||
cd broken &&
|
||||
git init &&
|
||||
>.git/index &&
|
||||
test_expect_code 129 git update-index -h >usage 2>&1
|
||||
) &&
|
||||
grep "[Uu]sage: git update-index" broken/usage
|
||||
'
|
||||
|
||||
test_done
|
39
t/t3004-ls-files-basic.sh
Executable file
39
t/t3004-ls-files-basic.sh
Executable file
@ -0,0 +1,39 @@
|
||||
#!/bin/sh
|
||||
|
||||
test_description='basic ls-files tests
|
||||
|
||||
This test runs git ls-files with various unusual or malformed
|
||||
command-line arguments.
|
||||
'
|
||||
|
||||
. ./test-lib.sh
|
||||
|
||||
>empty
|
||||
|
||||
test_expect_success 'ls-files in empty repository' '
|
||||
git ls-files >actual &&
|
||||
test_cmp empty actual
|
||||
'
|
||||
|
||||
test_expect_success 'ls-files with nonexistent path' '
|
||||
git ls-files doesnotexist >actual &&
|
||||
test_cmp empty actual
|
||||
'
|
||||
|
||||
test_expect_success 'ls-files with nonsense option' '
|
||||
test_expect_code 129 git ls-files --nonsense 2>actual &&
|
||||
grep "[Uu]sage: git ls-files" actual
|
||||
'
|
||||
|
||||
test_expect_success 'ls-files -h in corrupt repository' '
|
||||
mkdir broken &&
|
||||
(
|
||||
cd broken &&
|
||||
git init &&
|
||||
>.git/index &&
|
||||
test_expect_code 129 git ls-files -h >usage 2>&1
|
||||
) &&
|
||||
grep "[Uu]sage: git ls-files " broken/usage
|
||||
'
|
||||
|
||||
test_done
|
@ -26,6 +26,17 @@ test_expect_success \
|
||||
! test -f .git/refs/heads/--help
|
||||
'
|
||||
|
||||
test_expect_success 'branch -h in broken repository' '
|
||||
mkdir broken &&
|
||||
(
|
||||
cd broken &&
|
||||
git init &&
|
||||
>.git/refs/heads/master &&
|
||||
test_expect_code 129 git branch -h >usage 2>&1
|
||||
) &&
|
||||
grep "[Uu]sage" broken/usage
|
||||
'
|
||||
|
||||
test_expect_success \
|
||||
'git branch abc should create a branch' \
|
||||
'git branch abc && test -f .git/refs/heads/abc'
|
||||
|
28
t/t6500-gc.sh
Executable file
28
t/t6500-gc.sh
Executable file
@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
test_description='basic git gc tests
|
||||
'
|
||||
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success 'gc empty repository' '
|
||||
git gc
|
||||
'
|
||||
|
||||
test_expect_success 'gc --gobbledegook' '
|
||||
test_expect_code 129 git gc --nonsense 2>err &&
|
||||
grep "[Uu]sage: git gc" err
|
||||
'
|
||||
|
||||
test_expect_success 'gc -h with invalid configuration' '
|
||||
mkdir broken &&
|
||||
(
|
||||
cd broken &&
|
||||
git init &&
|
||||
echo "[gc] pruneexpire = CORRUPT" >>.git/config &&
|
||||
test_expect_code 129 git gc -h >usage 2>&1
|
||||
) &&
|
||||
grep "[Uu]sage" broken/usage
|
||||
'
|
||||
|
||||
test_done
|
@ -7,6 +7,30 @@ test_description='git status'
|
||||
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success 'status -h in broken repository' '
|
||||
mkdir broken &&
|
||||
test_when_finished "rm -fr broken" &&
|
||||
(
|
||||
cd broken &&
|
||||
git init &&
|
||||
echo "[status] showuntrackedfiles = CORRUPT" >>.git/config &&
|
||||
test_expect_code 129 git status -h >usage 2>&1
|
||||
) &&
|
||||
grep "[Uu]sage" broken/usage
|
||||
'
|
||||
|
||||
test_expect_success 'commit -h in broken repository' '
|
||||
mkdir broken &&
|
||||
test_when_finished "rm -fr broken" &&
|
||||
(
|
||||
cd broken &&
|
||||
git init &&
|
||||
echo "[status] showuntrackedfiles = CORRUPT" >>.git/config &&
|
||||
test_expect_code 129 git commit -h >usage 2>&1
|
||||
) &&
|
||||
grep "[Uu]sage" broken/usage
|
||||
'
|
||||
|
||||
test_expect_success 'setup' '
|
||||
: >tracked &&
|
||||
: >modified &&
|
||||
|
@ -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
|
||||
'
|
||||
|
Loading…
Reference in New Issue
Block a user