show-ref: fix --exclude-existing
Do not falsely document --filter-invalid which does not even exist. Also make sure the line is long enough to have ^{} suffix before checking for it. Pointed out by Dscho. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Dec 18, 2006 at 13:33 UTC
d8285af4810f655e28a0ae0e71a28a920bb6871f
1 file changed
+4
-3
builtin-show-ref.c
+4
-3
@@ -4,7 +4,7 @@
4
#include "tag.h"
5
#include "path-list.h"
6
7
-static const char show_ref_usage[] = "git show-ref [-q|--quiet] [--verify] [-h|--head] [-d|--dereference] [-s|--hash[=<length>]] [--abbrev[=<length>]] [--tags] [--heads] [--] [pattern*] | --filter-invalid < ref-list";
7
+static const char show_ref_usage[] = "git show-ref [-q|--quiet] [--verify] [-h|--head] [-d|--dereference] [-s|--hash[=<length>]] [--abbrev[=<length>]] [--tags] [--heads] [--] [pattern*] < ref-list";
8
9
static int deref_tags = 0, show_head = 0, tags_only = 0, heads_only = 0,
10
found_match = 0, verify = 0, quiet = 0, hash_only = 0, abbrev = 0;
@@ -116,11 +116,12 @@ static int exclude_existing(const char *match)
116
117
for_each_ref(add_existing, &existing_refs);
118
while (fgets(buf, sizeof(buf), stdin)) {
119
- int len = strlen(buf);
119
char *ref;
120
+ int len = strlen(buf);
121
+
122
if (len > 0 && buf[len - 1] == '\n')
123
buf[--len] = '\0';
123
- if (!strcmp(buf + len - 3, "^{}")) {
124
+ if (3 <= len && !strcmp(buf + len - 3, "^{}")) {
125
len -= 3;
126
buf[len] = '\0';
127
}