mirror of
https://github.com/git/git.git
synced 2024-11-16 14:04:52 +01:00
0c8151b6ff
Given a request for command-line usage information rather than some more substantial action, the only friendly thing to do is to report the usage information as soon as possible and exit. Without this change, as "git gc" glances over the repository, it can be distracted by the desire to report a malformed configuration file. Noticed while working through reports from Duy's repository access checker. [jn: with rewritten log message and tests] Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
28 lines
499 B
Bash
Executable file
28 lines
499 B
Bash
Executable file
#!/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
|