summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4653801)
raw | patch | inline | side by side (parent: 4653801)
author | Junio C Hamano <gitster@pobox.com> | |
Thu, 19 May 2011 01:08:09 +0000 (18:08 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 19 May 2011 17:55:54 +0000 (10:55 -0700) |
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>
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>
index 415f4f0b303da22e9eec19c1b9e24732a74ecf67..38fafcaa6b4173ad7f900c71efaa8ea25470072f 100644 (file)
[ \--tags[=<pattern>] ]
[ \--remotes[=<pattern>] ]
[ \--glob=<glob-pattern> ]
+ [ \--ignore-missing ]
[ \--stdin ]
[ \--quiet ]
[ \--topo-order ]
index 52bae31fcb7f741c34911d94a9253a2a546ee2c2..7e7ba68781f98b55f4189fe0fb4dd6e96c47c0af 100644 (file)
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::
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index adb1cae4f27ad3993aa2418f7b0fd355d19cdab9..4c19f844a977b6413afcd5df6b4f8bc0875775a8 100644 (file)
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
"--branches=",
"--branches",
"--header",
+ "--ignore-missing",
"--max-age=",
"--max-count=",
"--min-age=",
diff --git a/revision.c b/revision.c
index a7cf79bf2ed3f348f211878005899bebd96629f2..5cb3a75f8572f0c0f0e56cfbff63008fe07b78c3 100644 (file)
--- a/revision.c
+++ b/revision.c
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) {
@@ -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;
}
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)
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",
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);
@@ -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)
diff --git a/revision.h b/revision.h
index bca9947977c50d151b0fed90931ec52112e72bae..93f338d6a747a0181240304ef0dea4ddddd50c05 100644 (file)
--- a/revision.h
+++ b/revision.h
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,