1 From 5f0a31143d8e1c3740e81ad948c8ae670a322dcc Mon Sep 17 00:00:00 2001
2 From: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 Date: Fri, 4 Nov 2016 17:40:49 +0000
4 Subject: [PATCH 4/5] check-ref-format: New --report-errors option
6 Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
8 Documentation/git-check-ref-format.txt | 8 ++++++--
9 builtin/check-ref-format.c | 10 ++++++++--
10 2 files changed, 14 insertions(+), 4 deletions(-)
12 diff --git a/Documentation/git-check-ref-format.txt b/Documentation/git-check-ref-format.txt
13 index 8611a99..e9a2657 100644
14 --- a/Documentation/git-check-ref-format.txt
15 +++ b/Documentation/git-check-ref-format.txt
16 @@ -8,10 +8,10 @@ git-check-ref-format - Ensures that a reference name is well formed
20 -'git check-ref-format' [--normalize]
21 +'git check-ref-format' [--report-errors] [--normalize]
22 [--[no-]allow-onelevel] [--refspec-pattern]
24 -'git check-ref-format' --branch <branchname-shorthand>
25 +'git check-ref-format' [--report-errors] --branch <branchname-shorthand>
29 @@ -105,6 +105,10 @@ OPTIONS
30 with a status of 0. (`--print` is a deprecated way to spell
34 + If any ref does not check OK, print a message to stderr.
35 + (By default, git check-ref-format is silent.)
40 diff --git a/builtin/check-ref-format.c b/builtin/check-ref-format.c
41 index 020ebe8..559d5c2 100644
42 --- a/builtin/check-ref-format.c
43 +++ b/builtin/check-ref-format.c
46 static const char builtin_check_ref_format_usage[] =
47 "git check-ref-format [--normalize] [<options>] <refname>\n"
48 -" or: git check-ref-format --branch <branchname-shorthand>";
49 +" or: git check-ref-format [<options>] --branch <branchname-shorthand>";
52 * Return a copy of refname but with leading slashes removed and runs
53 @@ -51,6 +51,7 @@ static int check_ref_format_branch(const char *arg)
54 static int normalize = 0;
55 static int check_branch = 0;
57 +static int report_errors = 0;
59 static int check_one_ref_format(const char *refname)
61 @@ -61,8 +62,11 @@ static int check_one_ref_format(const char *refname)
63 ? check_ref_format_branch(refname)
64 : check_refname_format(refname, flags);
68 + fprintf(stderr, "bad ref format: %s\n", refname);
72 printf("%s\n", refname);
74 @@ -87,6 +91,8 @@ int cmd_check_ref_format(int argc, const char **argv, const char *prefix)
75 flags |= REFNAME_REFSPEC_PATTERN;
76 else if (!strcmp(argv[i], "--branch"))
78 + else if (!strcmp(argv[i], "--report-errors"))
81 usage(builtin_check_ref_format_usage);