summaryrefslogtreecommitdiff
path: root/builtin/notes.c
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/notes.c')
-rw-r--r--builtin/notes.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/builtin/notes.c b/builtin/notes.c
index 30cee0fd3c..541f776ebb 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -953,7 +953,9 @@ static int merge(int argc, const char **argv, const char *prefix)
return result < 0; /* return non-zero on conflicts */
}
-static int remove_one_note(struct notes_tree *t, const char *name)
+#define MISSING_OK 1
+
+static int remove_one_note(struct notes_tree *t, const char *name, unsigned flag)
{
int status;
unsigned char sha1[20];
@@ -964,12 +966,16 @@ static int remove_one_note(struct notes_tree *t, const char *name)
fprintf(stderr, _("Object %s has no note\n"), name);
else
fprintf(stderr, _("Removing note for object %s\n"), name);
- return status;
+ return (flag & MISSING_OK) ? 0 : status;
}
static int remove_cmd(int argc, const char **argv, const char *prefix)
{
+ unsigned flag = 0;
struct option options[] = {
+ OPT_BIT(0, "ignore-missing", &flag,
+ "attempt to remove non-existent note is not an error",
+ MISSING_OK),
OPT_END()
};
struct notes_tree *t;
@@ -981,10 +987,10 @@ static int remove_cmd(int argc, const char **argv, const char *prefix)
t = init_notes_check("remove");
if (!argc) {
- retval = remove_one_note(t, "HEAD");
+ retval = remove_one_note(t, "HEAD", flag);
} else {
while (*argv) {
- retval |= remove_one_note(t, *argv);
+ retval |= remove_one_note(t, *argv, flag);
argv++;
}
}