Skip to content

Commit

Permalink
show-ref: fix --exclude-existing
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano committed Dec 18, 2006
1 parent 0c7a97f commit d8285af
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions builtin-show-ref.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "tag.h"
#include "path-list.h"

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";
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";

static int deref_tags = 0, show_head = 0, tags_only = 0, heads_only = 0,
found_match = 0, verify = 0, quiet = 0, hash_only = 0, abbrev = 0;
Expand Down Expand Up @@ -116,11 +116,12 @@ static int exclude_existing(const char *match)

for_each_ref(add_existing, &existing_refs);
while (fgets(buf, sizeof(buf), stdin)) {
int len = strlen(buf);
char *ref;
int len = strlen(buf);

if (len > 0 && buf[len - 1] == '\n')
buf[--len] = '\0';
if (!strcmp(buf + len - 3, "^{}")) {
if (3 <= len && !strcmp(buf + len - 3, "^{}")) {
len -= 3;
buf[len] = '\0';
}
Expand Down

0 comments on commit d8285af

Please sign in to comment.