]> asedeno.scripts.mit.edu Git - git.git/blobdiff - builtin/notes.c
Merge branch 'rr/needs-clean-work-tree'
[git.git] / builtin / notes.c
index fbc347c9f09e0da4ba43982a5f7b29882080f150..c85cbf5a4758c8c08ef43dd65d9f85669c0063f2 100644 (file)
@@ -538,7 +538,7 @@ static int add(int argc, const char **argv, const char *prefix)
                { OPTION_CALLBACK, 'C', "reuse-message", &msg, "OBJECT",
                        "reuse specified note object", PARSE_OPT_NONEG,
                        parse_reuse_arg},
-               OPT_BOOLEAN('f', "force", &force, "replace existing notes"),
+               OPT__FORCE(&force, "replace existing notes"),
                OPT_END()
        };
 
@@ -594,7 +594,7 @@ static int copy(int argc, const char **argv, const char *prefix)
        struct notes_tree *t;
        const char *rewrite_cmd = NULL;
        struct option options[] = {
-               OPT_BOOLEAN('f', "force", &force, "replace existing notes"),
+               OPT__FORCE(&force, "replace existing notes"),
                OPT_BOOLEAN(0, "stdin", &from_stdin, "read objects from stdin"),
                OPT_STRING(0, "for-rewrite", &rewrite_cmd, "command",
                           "load rewriting config for <command> (implies "
@@ -769,6 +769,7 @@ static int remove_cmd(int argc, const char **argv, const char *prefix)
        const char *object_ref;
        struct notes_tree *t;
        unsigned char object[20];
+       int retval;
 
        argc = parse_options(argc, argv, prefix, options,
                             git_notes_remove_usage, 0);
@@ -785,12 +786,17 @@ static int remove_cmd(int argc, const char **argv, const char *prefix)
 
        t = init_notes_check("remove");
 
-       fprintf(stderr, "Removing note for object %s\n", sha1_to_hex(object));
-       remove_note(t, object);
+       retval = remove_note(t, object);
+       if (retval)
+               fprintf(stderr, "Object %s has no note\n", sha1_to_hex(object));
+       else {
+               fprintf(stderr, "Removing note for object %s\n",
+                       sha1_to_hex(object));
 
-       commit_notes(t, "Notes removed by 'git notes remove'");
+               commit_notes(t, "Notes removed by 'git notes remove'");
+       }
        free_notes(t);
-       return 0;
+       return retval;
 }
 
 static int prune(int argc, const char **argv, const char *prefix)
@@ -798,9 +804,8 @@ static int prune(int argc, const char **argv, const char *prefix)
        struct notes_tree *t;
        int show_only = 0, verbose = 0;
        struct option options[] = {
-               OPT_BOOLEAN('n', "dry-run", &show_only,
-                           "do not remove, show only"),
-               OPT_BOOLEAN('v', "verbose", &verbose, "report pruned notes"),
+               OPT__DRY_RUN(&show_only, "do not remove, show only"),
+               OPT__VERBOSE(&verbose, "report pruned notes"),
                OPT_END()
        };