1#include"cache.h" 2#include"commit.h" 3#include"rebase-interactive.h" 4#include"sequencer.h" 5#include"strbuf.h" 6 7intappend_todo_help(unsigned edit_todo,unsigned keep_empty) 8{ 9struct strbuf buf = STRBUF_INIT; 10FILE*todo; 11int ret; 12const 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"); 30if(!todo) 31return1; 32 33strbuf_add_commented_lines(&buf, msg,strlen(msg)); 34 35if(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"); 38else 39 msg =_("\nIf you remove a line here " 40"THAT COMMIT WILL BE LOST.\n"); 41 42strbuf_add_commented_lines(&buf, msg,strlen(msg)); 43 44if(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"); 49else 50 msg =_("\nHowever, if you remove everything, " 51"the rebase will be aborted.\n\n"); 52 53strbuf_add_commented_lines(&buf, msg,strlen(msg)); 54 55if(!keep_empty) { 56 msg =_("Note that empty commits are commented out"); 57strbuf_add_commented_lines(&buf, msg,strlen(msg)); 58} 59 60 ret =fputs(buf.buf, todo); 61if(ret <0) 62error_errno(_("could not append help text to '%s'"),rebase_path_todo()); 63 64fclose(todo); 65strbuf_release(&buf); 66 67return ret; 68} 69 70intedit_todo_list(unsigned flags) 71{ 72struct strbuf buf = STRBUF_INIT; 73const char*todo_file =rebase_path_todo(); 74 75if(strbuf_read_file(&buf, todo_file,0) <0) 76returnerror_errno(_("could not read '%s'."), todo_file); 77 78strbuf_stripspace(&buf,1); 79if(write_message(buf.buf, buf.len, todo_file,0)) { 80strbuf_release(&buf); 81return-1; 82} 83 84strbuf_release(&buf); 85 86transform_todos(flags | TODO_LIST_SHORTEN_IDS); 87append_todo_help(1,0); 88 89if(launch_sequence_editor(todo_file, NULL, NULL)) 90return-1; 91 92transform_todos(flags & ~(TODO_LIST_SHORTEN_IDS)); 93 94return0; 95}