]>
Commit | Line | Data |
---|---|---|
1 | #include "cache.h" | |
2 | #include "commit.h" | |
3 | #include "rebase-interactive.h" | |
4 | #include "sequencer.h" | |
5 | #include "strbuf.h" | |
6 | ||
7 | int append_todo_help(unsigned edit_todo, unsigned keep_empty) | |
8 | { | |
9 | struct strbuf buf = STRBUF_INIT; | |
10 | FILE *todo; | |
11 | int ret; | |
12 | const char *msg = _("\nCommands:\n" | |
13 | "p, pick <commit> = use commit\n" | |
14 | "r, reword <commit> = use commit, but edit the commit message\n" | |
15 | "e, edit <commit> = use commit, but stop for amending\n" | |
16 | "s, squash <commit> = use commit, but meld into previous commit\n" | |
17 | "f, fixup <commit> = like \"squash\", but discard this commit's log message\n" | |
18 | "x, exec <command> = run command (the rest of the line) using shell\n" | |
19 | "d, drop <commit> = remove commit\n" | |
20 | "l, label <label> = label current HEAD with a name\n" | |
21 | "t, reset <label> = reset HEAD to a label\n" | |
22 | "m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]\n" | |
23 | ". create a merge commit using the original merge commit's\n" | |
24 | ". message (or the oneline, if no original merge commit was\n" | |
25 | ". specified). Use -c <commit> to reword the commit message.\n" | |
26 | "\n" | |
27 | "These lines can be re-ordered; they are executed from top to bottom.\n"); | |
28 | ||
29 | todo = fopen_or_warn(rebase_path_todo(), "a"); | |
30 | if (!todo) | |
31 | return 1; | |
32 | ||
33 | strbuf_add_commented_lines(&buf, msg, strlen(msg)); | |
34 | ||
35 | if (get_missing_commit_check_level() == MISSING_COMMIT_CHECK_ERROR) | |
36 | msg = _("\nDo not remove any line. Use 'drop' " | |
37 | "explicitly to remove a commit.\n"); | |
38 | else | |
39 | msg = _("\nIf you remove a line here " | |
40 | "THAT COMMIT WILL BE LOST.\n"); | |
41 | ||
42 | strbuf_add_commented_lines(&buf, msg, strlen(msg)); | |
43 | ||
44 | if (edit_todo) | |
45 | msg = _("\nYou are editing the todo file " | |
46 | "of an ongoing interactive rebase.\n" | |
47 | "To continue rebase after editing, run:\n" | |
48 | " git rebase --continue\n\n"); | |
49 | else | |
50 | msg = _("\nHowever, if you remove everything, " | |
51 | "the rebase will be aborted.\n\n"); | |
52 | ||
53 | strbuf_add_commented_lines(&buf, msg, strlen(msg)); | |
54 | ||
55 | if (!keep_empty) { | |
56 | msg = _("Note that empty commits are commented out"); | |
57 | strbuf_add_commented_lines(&buf, msg, strlen(msg)); | |
58 | } | |
59 | ||
60 | ret = fputs(buf.buf, todo); | |
61 | if (ret < 0) | |
62 | error_errno(_("could not append help text to '%s'"), rebase_path_todo()); | |
63 | ||
64 | fclose(todo); | |
65 | strbuf_release(&buf); | |
66 | ||
67 | return ret; | |
68 | } |