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

Function run_add_i

add-interactive.c:1064–1163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1062}
1063
1064int run_add_i(struct repository *r, const struct pathspec *ps,
1065 struct interactive_options *interactive_opts)
1066{
1067 struct add_i_state s = { NULL };
1068 struct print_command_item_data data = { "[", "]" };
1069 struct list_and_choose_options main_loop_opts = {
1070 { 4, N_("*** Commands ***"), print_command_item, &data },
1071 N_("What now"), SINGLETON | IMMEDIATE, command_prompt_help
1072 };
1073 struct {
1074 const char *string;
1075 command_t command;
1076 } command_list[] = {
1077 { "status", run_status },
1078 { "update", run_update },
1079 { "revert", run_revert },
1080 { "add untracked", run_add_untracked },
1081 { "patch", run_patch },
1082 { "diff", run_diff },
1083 { "quit", NULL },
1084 { "help", run_help },
1085 };
1086 struct prefix_item_list commands = PREFIX_ITEM_LIST_INIT;
1087
1088 struct print_file_item_data print_file_item_data = {
1089 "%12s %12s %s", NULL, NULL,
1090 STRBUF_INIT, STRBUF_INIT, STRBUF_INIT, STRBUF_INIT
1091 };
1092 struct list_and_choose_options opts = {
1093 { 0, NULL, print_file_item, &print_file_item_data },
1094 NULL, 0, choose_prompt_help
1095 };
1096 struct strbuf header = STRBUF_INIT;
1097 struct prefix_item_list files = PREFIX_ITEM_LIST_INIT;
1098 ssize_t i;
1099 int res = 0;
1100
1101 for (i = 0; i < ARRAY_SIZE(command_list); i++) {
1102 struct command_item *util = xcalloc(1, sizeof(*util));
1103 util->command = command_list[i].command;
1104 string_list_append(&commands.items, command_list[i].string)
1105 ->util = util;
1106 }
1107
1108 init_add_i_state(&s, r, interactive_opts);
1109
1110 /*
1111 * When color was asked for, use the prompt color for
1112 * highlighting, otherwise use square brackets.
1113 */
1114 if (want_color(s.cfg.use_color_interactive)) {
1115 data.color = s.cfg.prompt_color;
1116 data.reset = s.cfg.reset_color_interactive;
1117 }
1118 print_file_item_data.color = data.color;
1119 print_file_item_data.reset = data.reset;
1120
1121 strbuf_addstr(&header, " ");

Callers 1

interactive_addFunction · 0.85

Calls 14

xcallocFunction · 0.85
init_add_i_stateFunction · 0.85
strbuf_addstrFunction · 0.85
strbuf_addfFunction · 0.85
discard_indexFunction · 0.85
repo_read_indexFunction · 0.85
warningFunction · 0.85
prefix_item_list_clearFunction · 0.85
strbuf_releaseFunction · 0.85
clear_add_i_stateFunction · 0.85
string_list_appendFunction · 0.70

Tested by

no test coverage detected