Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
sequencer (rebase -i): allow fast-forwarding for edit/reword
author
Johannes Schindelin
<johannes.schindelin@gmx.de>
Mon, 2 Jan 2017 15:28:05 +0000
(16:28 +0100)
committer
Junio C Hamano
<gitster@pobox.com>
Mon, 9 Jan 2017 22:57:30 +0000
(14:57 -0800)
The sequencer already knew how to fast-forward instead of
cherry-picking, if possible.
We want to continue to do this, of course, but in case of the 'reword'
command, we will need to call `git commit` after fast-forwarding.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sequencer.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
04efc8b
)
diff --git
a/sequencer.c
b/sequencer.c
index 50e998acc4c5749fbd37b1dfbcf73dc495a7f233..23161f593e2ce90486a939dd8612843a08c74003 100644
(file)
--- a/
sequencer.c
+++ b/
sequencer.c
@@
-860,7
+860,7
@@
static int do_pick_commit(enum todo_command command, struct commit *commit,
const char *base_label, *next_label;
struct commit_message msg = { NULL, NULL, NULL, NULL };
struct strbuf msgbuf = STRBUF_INIT;
const char *base_label, *next_label;
struct commit_message msg = { NULL, NULL, NULL, NULL };
struct strbuf msgbuf = STRBUF_INIT;
- int res, unborn = 0, amend = 0, allow;
+ int res, unborn = 0, amend = 0, allow
= 0
;
if (opts->no_commit) {
/*
if (opts->no_commit) {
/*
@@
-905,11
+905,23
@@
static int do_pick_commit(enum todo_command command, struct commit *commit,
else
parent = commit->parents->item;
else
parent = commit->parents->item;
+ if (get_message(commit, &msg) != 0)
+ return error(_("cannot get commit message for %s"),
+ oid_to_hex(&commit->object.oid));
+
if (opts->allow_ff && !is_fixup(command) &&
((parent && !hashcmp(parent->object.oid.hash, head)) ||
if (opts->allow_ff && !is_fixup(command) &&
((parent && !hashcmp(parent->object.oid.hash, head)) ||
- (!parent && unborn)))
- return fast_forward_to(commit->object.oid.hash, head, unborn, opts);
-
+ (!parent && unborn))) {
+ if (is_rebase_i(opts))
+ write_author_script(msg.message);
+ res = fast_forward_to(commit->object.oid.hash, head, unborn,
+ opts);
+ if (res || command != TODO_REWORD)
+ goto leave;
+ edit = amend = 1;
+ msg_file = NULL;
+ goto fast_forward_edit;
+ }
if (parent && parse_commit(parent) < 0)
/* TRANSLATORS: The first %s will be a "todo" command like
"revert" or "pick", the second %s a SHA1. */
if (parent && parse_commit(parent) < 0)
/* TRANSLATORS: The first %s will be a "todo" command like
"revert" or "pick", the second %s a SHA1. */
@@
-917,10
+929,6
@@
static int do_pick_commit(enum todo_command command, struct commit *commit,
command_to_string(command),
oid_to_hex(&parent->object.oid));
command_to_string(command),
oid_to_hex(&parent->object.oid));
- if (get_message(commit, &msg) != 0)
- return error(_("cannot get commit message for %s"),
- oid_to_hex(&commit->object.oid));
-
/*
* "commit" is an existing commit. We would want to apply
* the difference it introduces since its first parent "prev"
/*
* "commit" is an existing commit. We would want to apply
* the difference it introduces since its first parent "prev"
@@
-1044,6
+1052,7
@@
static int do_pick_commit(enum todo_command command, struct commit *commit,
goto leave;
}
if (!opts->no_commit)
goto leave;
}
if (!opts->no_commit)
+fast_forward_edit:
res = run_git_commit(msg_file, opts, allow, edit, amend,
cleanup_commit_message);
res = run_git_commit(msg_file, opts, allow, edit, amend,
cleanup_commit_message);