MCPcopy Index your code
hub / github.com/git/git / append_edit

Function append_edit

builtin/notes.c:656–758  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

654}
655
656static int append_edit(int argc, const char **argv, const char *prefix,
657 struct repository *repo UNUSED)
658{
659 int allow_empty = 0;
660 const char *object_ref;
661 struct notes_tree *t;
662 struct object_id object, new_note;
663 const struct object_id *note;
664 char *logmsg;
665 const char * const *usage;
666 struct note_data d = { .buf = STRBUF_INIT, .stripspace = UNSPECIFIED };
667 struct option options[] = {
668 OPT_CALLBACK_F('m', "message", &d, N_("message"),
669 N_("note contents as a string"), PARSE_OPT_NONEG,
670 parse_msg_arg),
671 OPT_CALLBACK_F('F', "file", &d, N_("file"),
672 N_("note contents in a file"), PARSE_OPT_NONEG,
673 parse_file_arg),
674 OPT_CALLBACK_F('c', "reedit-message", &d, N_("object"),
675 N_("reuse and edit specified note object"), PARSE_OPT_NONEG,
676 parse_reedit_arg),
677 OPT_CALLBACK_F('C', "reuse-message", &d, N_("object"),
678 N_("reuse specified note object"), PARSE_OPT_NONEG,
679 parse_reuse_arg),
680 OPT_BOOL('e', "edit", &d.use_editor,
681 N_("edit note message in editor")),
682 OPT_BOOL(0, "allow-empty", &allow_empty,
683 N_("allow storing empty note")),
684 OPT_CALLBACK_F(0, "separator", &separator,
685 N_("<paragraph-break>"),
686 N_("insert <paragraph-break> between paragraphs"),
687 PARSE_OPT_OPTARG, parse_separator_arg),
688 OPT_BOOL(0, "stripspace", &d.stripspace,
689 N_("remove unnecessary whitespace")),
690 OPT_END()
691 };
692 int edit = !strcmp(argv[0], "edit");
693
694 usage = edit ? git_notes_edit_usage : git_notes_append_usage;
695 argc = parse_options(argc, argv, prefix, options, usage,
696 PARSE_OPT_KEEP_ARGV0);
697
698 if (2 < argc) {
699 error(_("too many arguments"));
700 usage_with_options(usage, options);
701 }
702
703 if (d.msg_nr) {
704 concat_messages(&d);
705 if (edit)
706 fprintf(stderr, _("The -m/-F/-c/-C options have been "
707 "deprecated for the 'edit' subcommand.\n"
708 "Please use 'git notes add -f -m/-F/-c/-C' "
709 "instead.\n"));
710 }
711
712 object_ref = 1 < argc ? argv[1] : "HEAD";
713

Callers 1

addFunction · 0.85

Calls 15

parse_optionsFunction · 0.85
errorFunction · 0.85
usage_with_optionsFunction · 0.85
concat_messagesFunction · 0.85
repo_get_oidFunction · 0.85
init_notes_checkFunction · 0.85
get_noteFunction · 0.85
prepare_note_dataFunction · 0.85
odb_read_objectFunction · 0.85
oid_to_hexFunction · 0.85
strbuf_addFunction · 0.85
append_separatorFunction · 0.85

Tested by

no test coverage detected