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

Function batch_objects_command

builtin/cat-file.c:756–820  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

754};
755
756static void batch_objects_command(struct batch_options *opt,
757 struct strbuf *output,
758 struct expand_data *data)
759{
760 struct strbuf input = STRBUF_INIT;
761 struct queued_cmd *queued_cmd = NULL;
762 size_t alloc = 0, nr = 0;
763
764 while (strbuf_getdelim_strip_crlf(&input, stdin, opt->input_delim) != EOF) {
765 int i;
766 const struct parse_cmd *cmd = NULL;
767 const char *p = NULL, *cmd_end;
768 struct queued_cmd call = {0};
769
770 if (!input.len)
771 die(_("empty command in input"));
772 if (isspace(*input.buf))
773 die(_("whitespace before command: '%s'"), input.buf);
774
775 for (i = 0; i < ARRAY_SIZE(commands); i++) {
776 if (!skip_prefix(input.buf, commands[i].name, &cmd_end))
777 continue;
778
779 cmd = &commands[i];
780 if (cmd->takes_args) {
781 if (*cmd_end != ' ')
782 die(_("%s requires arguments"),
783 commands[i].name);
784
785 p = cmd_end + 1;
786 } else if (*cmd_end) {
787 die(_("%s takes no arguments"),
788 commands[i].name);
789 }
790
791 break;
792 }
793
794 if (!cmd)
795 die(_("unknown command: '%s'"), input.buf);
796
797 if (!strcmp(cmd->name, "flush")) {
798 dispatch_calls(opt, output, data, queued_cmd, nr);
799 free_cmds(queued_cmd, &nr);
800 } else if (!opt->buffer_output) {
801 cmd->fn(opt, p, output, data);
802 } else {
803 ALLOC_GROW(queued_cmd, nr + 1, alloc);
804 call.fn = cmd->fn;
805 call.line = xstrdup_or_null(p);
806 queued_cmd[nr++] = call;
807 }
808 }
809
810 if (opt->buffer_output &&
811 nr &&
812 !git_env_bool("GIT_TEST_CAT_FILE_NO_FLUSH_ON_EXIT", 0)) {
813 dispatch_calls(opt, output, data, queued_cmd, nr);

Callers 1

batch_objectsFunction · 0.85

Calls 7

dispatch_callsFunction · 0.85
free_cmdsFunction · 0.85
xstrdup_or_nullFunction · 0.85
git_env_boolFunction · 0.85
strbuf_releaseFunction · 0.85
dieFunction · 0.50

Tested by

no test coverage detected