summaryrefslogtreecommitdiff
path: root/t/t6500-gc.sh
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2010-10-22 01:47:19 -0500
committerJunio C Hamano <gitster@pobox.com>2010-10-22 11:04:53 -0700
commit0c8151b6ff5b79e6638e4f8339d62b051998dc2f (patch)
treecccf62beaed093cfc43a601b9d8f1de6fb10d0ae /t/t6500-gc.sh
parent5d3dd915e64ea42ba6bf7646937784f6ddc71422 (diff)
downloadgit-0c8151b6ff5b79e6638e4f8339d62b051998dc2f.tar.gz
gc -h: show usage even with broken configuration
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>
Diffstat (limited to 't/t6500-gc.sh')
-rwxr-xr-xt/t6500-gc.sh28
1 files changed, 28 insertions, 0 deletions
diff --git a/t/t6500-gc.sh b/t/t6500-gc.sh
new file mode 100755
index 0000000000..82f3639937
--- /dev/null
+++ b/t/t6500-gc.sh
@@ -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