MCPcopy Create free account
hub / github.com/git/git / remove_cmd

Function remove_cmd

builtin/notes.c:1034–1076  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1032}
1033
1034static 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
1078static int prune(int argc, const char **argv, const char *prefix,
1079 struct repository *repo UNUSED)

Callers

nothing calls this directly

Calls 8

parse_optionsFunction · 0.85
init_notes_checkFunction · 0.85
remove_one_noteFunction · 0.85
strbuf_getwholelineFunction · 0.85
strbuf_rtrimFunction · 0.85
strbuf_releaseFunction · 0.85
commit_notesFunction · 0.85
free_notesFunction · 0.85

Tested by

no test coverage detected