summaryrefslogtreecommitdiff
path: root/rebase-interactive.c
diff options
context:
space:
mode:
Diffstat (limited to 'rebase-interactive.c')
-rw-r--r--rebase-interactive.c68
1 files changed, 27 insertions, 41 deletions
diff --git a/rebase-interactive.c b/rebase-interactive.c
index b6cbd16..c343e16 100644
--- a/rebase-interactive.c
+++ b/rebase-interactive.c
@@ -1,11 +1,16 @@
-#include "cache.h"
+#include "git-compat-util.h"
#include "commit.h"
+#include "editor.h"
+#include "environment.h"
+#include "gettext.h"
#include "sequencer.h"
#include "rebase-interactive.h"
+#include "repository.h"
#include "strbuf.h"
#include "commit-slab.h"
#include "config.h"
#include "dir.h"
+#include "object-name.h"
static const char edit_todo_list_advice[] =
N_("You can fix this with 'git rebase --edit-todo' "
@@ -54,22 +59,26 @@ void append_todo_help(int command_count,
"l, label <label> = label current HEAD with a name\n"
"t, reset <label> = reset HEAD to a label\n"
"m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]\n"
-". create a merge commit using the original merge commit's\n"
-". message (or the oneline, if no original merge commit was\n"
-". specified); use -c <commit> to reword the commit message\n"
+" create a merge commit using the original merge commit's\n"
+" message (or the oneline, if no original merge commit was\n"
+" specified); use -c <commit> to reword the commit message\n"
+"u, update-ref <ref> = track a placeholder for the <ref> to be updated\n"
+" to this position in the new commits. The <ref> is\n"
+" updated at the end of the rebase\n"
"\n"
"These lines can be re-ordered; they are executed from top to bottom.\n");
unsigned edit_todo = !(shortrevisions && shortonto);
if (!edit_todo) {
strbuf_addch(buf, '\n');
- strbuf_commented_addf(buf, Q_("Rebase %s onto %s (%d command)",
- "Rebase %s onto %s (%d commands)",
- command_count),
+ strbuf_commented_addf(buf, comment_line_str,
+ Q_("Rebase %s onto %s (%d command)",
+ "Rebase %s onto %s (%d commands)",
+ command_count),
shortrevisions, shortonto, command_count);
}
- strbuf_add_commented_lines(buf, msg, strlen(msg));
+ strbuf_add_commented_lines(buf, msg, strlen(msg), comment_line_str);
if (get_missing_commit_check_level() == MISSING_COMMIT_CHECK_ERROR)
msg = _("\nDo not remove any line. Use 'drop' "
@@ -78,7 +87,7 @@ void append_todo_help(int command_count,
msg = _("\nIf you remove a line here "
"THAT COMMIT WILL BE LOST.\n");
- strbuf_add_commented_lines(buf, msg, strlen(msg));
+ strbuf_add_commented_lines(buf, msg, strlen(msg), comment_line_str);
if (edit_todo)
msg = _("\nYou are editing the todo file "
@@ -89,7 +98,7 @@ void append_todo_help(int command_count,
msg = _("\nHowever, if you remove everything, "
"the rebase will be aborted.\n\n");
- strbuf_add_commented_lines(buf, msg, strlen(msg));
+ strbuf_add_commented_lines(buf, msg, strlen(msg), comment_line_str);
}
int edit_todo_list(struct repository *r, struct todo_list *todo_list,
@@ -121,7 +130,7 @@ int edit_todo_list(struct repository *r, struct todo_list *todo_list,
if (launch_sequence_editor(todo_file, &new_todo->buf, NULL))
return -2;
- strbuf_stripspace(&new_todo->buf, 1);
+ strbuf_stripspace(&new_todo->buf, comment_line_str);
if (initial && new_todo->buf.len == 0)
return -3;
@@ -143,6 +152,12 @@ int edit_todo_list(struct repository *r, struct todo_list *todo_list,
return -4;
}
+ /*
+ * See if branches need to be added or removed from the update-refs
+ * file based on the new todo list.
+ */
+ todo_list_filter_update_refs(r, new_todo);
+
return 0;
}
@@ -178,7 +193,7 @@ int todo_list_check(struct todo_list *old_todo, struct todo_list *new_todo)
struct commit *commit = item->commit;
if (commit && !*commit_seen_at(&commit_seen, commit)) {
strbuf_addf(&missing, " - %s %.*s\n",
- find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV),
+ repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV),
item->arg_len,
todo_item_get_arg(old_todo, item));
*commit_seen_at(&commit_seen, commit) = 1;
@@ -226,32 +241,3 @@ int todo_list_check_against_backup(struct repository *r, struct todo_list *todo_
todo_list_release(&backup);
return res;
}
-
-int check_todo_list_from_file(struct repository *r)
-{
- struct todo_list old_todo = TODO_LIST_INIT, new_todo = TODO_LIST_INIT;
- int res = 0;
-
- if (strbuf_read_file(&new_todo.buf, rebase_path_todo(), 0) < 0) {
- res = error(_("could not read '%s'."), rebase_path_todo());
- goto out;
- }
-
- if (strbuf_read_file(&old_todo.buf, rebase_path_todo_backup(), 0) < 0) {
- res = error(_("could not read '%s'."), rebase_path_todo_backup());
- goto out;
- }
-
- res = todo_list_parse_insn_buffer(r, old_todo.buf.buf, &old_todo);
- if (!res)
- res = todo_list_parse_insn_buffer(r, new_todo.buf.buf, &new_todo);
- if (res)
- fprintf(stderr, _(edit_todo_list_advice));
- if (!res)
- res = todo_list_check(&old_todo, &new_todo);
-out:
- todo_list_release(&old_todo);
- todo_list_release(&new_todo);
-
- return res;
-}