| 6152 | } |
| 6153 | |
| 6154 | int sequencer_make_script(struct repository *r, struct strbuf *out, |
| 6155 | struct strvec *argv, unsigned flags) |
| 6156 | { |
| 6157 | char *format = NULL; |
| 6158 | struct pretty_print_context pp = {0}; |
| 6159 | struct rev_info revs; |
| 6160 | struct commit *commit; |
| 6161 | int keep_empty = flags & TODO_LIST_KEEP_EMPTY; |
| 6162 | const char *insn = flags & TODO_LIST_ABBREVIATE_CMDS ? "p" : "pick"; |
| 6163 | int rebase_merges = flags & TODO_LIST_REBASE_MERGES; |
| 6164 | int reapply_cherry_picks = flags & TODO_LIST_REAPPLY_CHERRY_PICKS; |
| 6165 | int skipped_commit = 0; |
| 6166 | int ret = 0; |
| 6167 | |
| 6168 | repo_init_revisions(r, &revs, NULL); |
| 6169 | revs.verbose_header = 1; |
| 6170 | if (!rebase_merges) |
| 6171 | revs.max_parents = 1; |
| 6172 | revs.cherry_mark = !reapply_cherry_picks; |
| 6173 | revs.limited = 1; |
| 6174 | revs.reverse = 1; |
| 6175 | revs.right_only = 1; |
| 6176 | revs.sort_order = REV_SORT_IN_GRAPH_ORDER; |
| 6177 | revs.topo_order = 1; |
| 6178 | |
| 6179 | revs.pretty_given = 1; |
| 6180 | repo_config_get_string(the_repository, "rebase.instructionFormat", &format); |
| 6181 | if (!format || !*format) { |
| 6182 | free(format); |
| 6183 | format = xstrdup("# %s"); |
| 6184 | } |
| 6185 | if (*format != '#') { |
| 6186 | char *temp = format; |
| 6187 | format = xstrfmt("# %s", temp); |
| 6188 | free(temp); |
| 6189 | } |
| 6190 | |
| 6191 | get_commit_format(format, &revs); |
| 6192 | free(format); |
| 6193 | pp.fmt = revs.commit_format; |
| 6194 | pp.output_encoding = get_log_output_encoding(); |
| 6195 | |
| 6196 | setup_revisions_from_strvec(argv, &revs, NULL); |
| 6197 | if (argv->nr > 1) { |
| 6198 | ret = error(_("make_script: unhandled options")); |
| 6199 | goto cleanup; |
| 6200 | } |
| 6201 | |
| 6202 | if (prepare_revision_walk(&revs) < 0) { |
| 6203 | ret = error(_("make_script: error preparing revisions")); |
| 6204 | goto cleanup; |
| 6205 | } |
| 6206 | |
| 6207 | if (rebase_merges) { |
| 6208 | ret = make_script_with_merges(&pp, &revs, out, flags); |
| 6209 | goto cleanup; |
| 6210 | } |
| 6211 |
no test coverage detected