| 1032 | } |
| 1033 | |
| 1034 | static int remove_cmd(int argc, const char **argv, const char *prefix, |
| 1035 | struct repository *repo UNUSED) |
| 1036 | { |
| 1037 | unsigned flag = 0; |
| 1038 | int from_stdin = 0; |
| 1039 | struct option options[] = { |
| 1040 | OPT_BIT(0, "ignore-missing", &flag, |
| 1041 | N_("attempt to remove non-existent note is not an error"), |
| 1042 | IGNORE_MISSING), |
| 1043 | OPT_BOOL(0, "stdin", &from_stdin, |
| 1044 | N_("read object names from the standard input")), |
| 1045 | OPT_END() |
| 1046 | }; |
| 1047 | struct notes_tree *t; |
| 1048 | int retval = 0; |
| 1049 | |
| 1050 | argc = parse_options(argc, argv, prefix, options, |
| 1051 | git_notes_remove_usage, 0); |
| 1052 | |
| 1053 | t = init_notes_check("remove", NOTES_INIT_WRITABLE); |
| 1054 | |
| 1055 | if (!argc && !from_stdin) { |
| 1056 | retval = remove_one_note(t, "HEAD", flag); |
| 1057 | } else { |
| 1058 | while (*argv) { |
| 1059 | retval |= remove_one_note(t, *argv, flag); |
| 1060 | argv++; |
| 1061 | } |
| 1062 | } |
| 1063 | if (from_stdin) { |
| 1064 | struct strbuf sb = STRBUF_INIT; |
| 1065 | while (strbuf_getwholeline(&sb, stdin, '\n') != EOF) { |
| 1066 | strbuf_rtrim(&sb); |
| 1067 | retval |= remove_one_note(t, sb.buf, flag); |
| 1068 | } |
| 1069 | strbuf_release(&sb); |
| 1070 | } |
| 1071 | if (!retval) |
| 1072 | commit_notes(the_repository, t, |
| 1073 | "Notes removed by 'git notes remove'"); |
| 1074 | free_notes(t); |
| 1075 | return retval; |
| 1076 | } |
| 1077 | |
| 1078 | static int prune(int argc, const char **argv, const char *prefix, |
| 1079 | struct repository *repo UNUSED) |
nothing calls this directly
no test coverage detected