Will be useful for the next commits. Signed-off-by: Felipe Contreras <felipe.contreras@xxxxxxxxx> --- sequencer.c | 22 +++++++++++++++++++++- sequencer.h | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/sequencer.c b/sequencer.c index a258627..426fddd 100644 --- a/sequencer.c +++ b/sequencer.c @@ -14,11 +14,13 @@ #include "merge-recursive.h" #include "refs.h" #include "argv-array.h" +#include "rewrite.h" #define GIT_REFLOG_ACTION "GIT_REFLOG_ACTION" const char sign_off_header[] = "Signed-off-by: "; static const char cherry_picked_prefix[] = "(cherry picked from commit "; +static struct rewritten rewritten; static int is_rfc2822_line(const char *buf, int len) { @@ -651,6 +653,14 @@ static int do_pick_commit(struct commit *commit, struct replay_opts *opts) if (!opts->no_commit) res = run_git_commit(defmsg, opts, allow); + if (!res && opts->action == REPLAY_PICK) { + unsigned char to[20]; + + if (read_ref("HEAD", to)) + goto leave; + + add_rewritten(&rewritten, commit->object.sha1, to); + } leave: free_message(&msg); free(defmsg); @@ -1021,8 +1031,11 @@ static int pick_commits(struct commit_list *todo_list, struct replay_opts *opts) for (cur = todo_list; cur; cur = cur->next) { save_todo(cur, opts); res = do_pick_commit(cur->item, opts); - if (res) + if (res) { + if (opts->action == REPLAY_PICK) + store_rewritten(&rewritten, git_path(SEQ_REWR_FILE)); return res; + } } /* @@ -1051,6 +1064,8 @@ static int sequencer_continue(struct replay_opts *opts) return continue_single_pick(); read_populate_opts(&opts); read_populate_todo(&todo_list, opts); + if (opts->action == REPLAY_PICK) + load_rewritten(&rewritten, git_path(SEQ_REWR_FILE)); /* Verify that the conflict has been resolved */ if (file_exists(git_path("CHERRY_PICK_HEAD")) || @@ -1061,6 +1076,11 @@ static int sequencer_continue(struct replay_opts *opts) } if (index_differs_from("HEAD", 0)) return error_dirty_index(opts); + if (opts->action == REPLAY_PICK) { + unsigned char to[20]; + if (!read_ref("HEAD", to)) + add_rewritten(&rewritten, todo_list->item->object.sha1, to); + } todo_list = todo_list->next; return pick_commits(todo_list, opts); } diff --git a/sequencer.h b/sequencer.h index 74d592a..efec1b5 100644 --- a/sequencer.h +++ b/sequencer.h @@ -5,6 +5,7 @@ #define SEQ_HEAD_FILE "sequencer/head" #define SEQ_TODO_FILE "sequencer/todo" #define SEQ_OPTS_FILE "sequencer/opts" +#define SEQ_REWR_FILE "sequencer/rewritten" #define APPEND_SIGNOFF_DEDUP (1u << 0) -- 1.9.2+fc1.2.gfbaae8c -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html