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

Function read_populate_todo

sequencer.c:3012–3066  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3010}
3011
3012static int read_populate_todo(struct repository *r,
3013 struct todo_list *todo_list,
3014 struct replay_opts *opts)
3015{
3016 const char *todo_file = get_todo_path(opts);
3017 int res;
3018
3019 strbuf_reset(&todo_list->buf);
3020 if (strbuf_read_file_or_whine(&todo_list->buf, todo_file) < 0)
3021 return -1;
3022
3023 res = todo_list_parse_insn_buffer(r, opts, todo_list->buf.buf, todo_list);
3024 if (res) {
3025 if (is_rebase_i(opts))
3026 return error(_("please fix this using "
3027 "'git rebase --edit-todo'."));
3028 return error(_("unusable instruction sheet: '%s'"), todo_file);
3029 }
3030
3031 if (!todo_list->nr &&
3032 (!is_rebase_i(opts) || !file_exists(rebase_path_done())))
3033 return error(_("no commits parsed."));
3034
3035 if (!is_rebase_i(opts)) {
3036 enum todo_command valid =
3037 opts->action == REPLAY_PICK ? TODO_PICK : TODO_REVERT;
3038 int i;
3039
3040 for (i = 0; i < todo_list->nr; i++)
3041 if (valid == todo_list->items[i].command)
3042 continue;
3043 else if (valid == TODO_PICK)
3044 return error(_("cannot cherry-pick during a revert."));
3045 else
3046 return error(_("cannot revert during a cherry-pick."));
3047 }
3048
3049 if (is_rebase_i(opts)) {
3050 struct todo_list done = TODO_LIST_INIT;
3051
3052 if (strbuf_read_file(&done.buf, rebase_path_done(), 0) > 0 &&
3053 !todo_list_parse_insn_buffer(r, opts, done.buf.buf, &done))
3054 todo_list->done_nr = count_commands(&done);
3055 else
3056 todo_list->done_nr = 0;
3057
3058 todo_list->total_nr = todo_list->done_nr
3059 + count_commands(todo_list);
3060 todo_list_release(&done);
3061
3062 todo_list_write_total_nr(todo_list);
3063 }
3064
3065 return 0;
3066}
3067
3068static int git_config_string_dup(char **dest,
3069 const char *var, const char *value)

Callers 2

reread_todo_if_changedFunction · 0.85
sequencer_continueFunction · 0.85

Calls 10

get_todo_pathFunction · 0.85
is_rebase_iFunction · 0.85
errorFunction · 0.85
file_existsFunction · 0.85
strbuf_read_fileFunction · 0.85
count_commandsFunction · 0.85
todo_list_releaseFunction · 0.85
todo_list_write_total_nrFunction · 0.85

Tested by

no test coverage detected