Skip to content

Commit

Permalink
show: --ignore-missing
Browse files Browse the repository at this point in the history
Instead of barfing, simply ignore bad object names seen in the
input. This is useful when reading from "git notes list" output
that may refer to objects that have already been garbage collected.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed May 19, 2011
1 parent 4653801 commit cc243c3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions Documentation/git-rev-list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ SYNOPSIS
[ \--tags[=<pattern>] ]
[ \--remotes[=<pattern>] ]
[ \--glob=<glob-pattern> ]
[ \--ignore-missing ]
[ \--stdin ]
[ \--quiet ]
[ \--topo-order ]
Expand Down
4 changes: 4 additions & 0 deletions Documentation/rev-list-options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ parents) and `--max-parents=-1` (negative numbers denote no upper limit).
is automatically prepended if missing. If pattern lacks '?', '*',
or '[', '/*' at the end is implied.

--ignore-missing::

Upon seeing an invalid object name in the input, pretend as if
the bad input was not given.

ifndef::git-rev-list[]
--bisect::
Expand Down
1 change: 1 addition & 0 deletions builtin/rev-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ static int is_rev_argument(const char *arg)
"--branches=",
"--branches",
"--header",
"--ignore-missing",
"--max-age=",
"--max-count=",
"--min-age=",
Expand Down
15 changes: 13 additions & 2 deletions revision.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ void mark_parents_uninteresting(struct commit *commit)

static void add_pending_object_with_mode(struct rev_info *revs, struct object *obj, const char *name, unsigned mode)
{
if (!obj)
return;
if (revs->no_walk && (obj->flags & UNINTERESTING))
revs->no_walk = 0;
if (revs->reflog_info && obj->type == OBJ_COMMIT) {
Expand Down Expand Up @@ -174,8 +176,11 @@ static struct object *get_reference(struct rev_info *revs, const char *name, con
struct object *object;

object = parse_object(sha1);
if (!object)
if (!object) {
if (revs->ignore_missing)
return object;
die("bad object %s", name);
}
object->flags |= flags;
return object;
}
Expand Down Expand Up @@ -906,6 +911,8 @@ static int add_parents_only(struct rev_info *revs, const char *arg, int flags)
return 0;
while (1) {
it = get_reference(revs, arg, sha1, 0);
if (!it && revs->ignore_missing)
return 0;
if (it->type != OBJ_TAG)
break;
if (!((struct tag*)it)->tagged)
Expand Down Expand Up @@ -1044,6 +1051,8 @@ int handle_revision_arg(const char *arg, struct rev_info *revs,
a = lookup_commit_reference(from_sha1);
b = lookup_commit_reference(sha1);
if (!a || !b) {
if (revs->ignore_missing)
return 0;
die(symmetric ?
"Invalid symmetric difference expression %s...%s" :
"Invalid revision range %s..%s",
Expand Down Expand Up @@ -1090,7 +1099,7 @@ int handle_revision_arg(const char *arg, struct rev_info *revs,
arg++;
}
if (get_sha1_with_mode(arg, sha1, &mode))
return -1;
return revs->ignore_missing ? 0 : -1;
if (!cant_be_filename)
verify_non_filename(revs->prefix, arg);
object = get_reference(revs, arg, sha1, flags ^ local_flags);
Expand Down Expand Up @@ -1475,6 +1484,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
} else if (!strcmp(arg, "--children")) {
revs->children.name = "children";
revs->limited = 1;
} else if (!strcmp(arg, "--ignore-missing")) {
revs->ignore_missing = 1;
} else {
int opts = diff_opt_parse(&revs->diffopt, argv, argc);
if (!opts)
Expand Down
3 changes: 2 additions & 1 deletion revision.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ struct rev_info {
const char *prefix;
const char *def;
struct pathspec prune_data;
unsigned int early_output;
unsigned int early_output:1,
ignore_missing:1;

/* Traversal flags */
unsigned int dense:1,
Expand Down

0 comments on commit cc243c3

Please sign in to comment.