Skip to content
Permalink
Browse files

fixup! builtin rebase: call `git am` directly

This fixes the reflog messages, as expected by t3406 in v2.20.0-rc2, as
well as fixing a compiler warning about "" being an invalid
printf()-style format. Also, while at it, ensure that
.git/rebased-patches is truncated if it already exists.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  • Loading branch information...
dscho committed Dec 1, 2018
1 parent fb6ad24 commit 96889860afc72a11e82b36aecb0b291c44d892ca
Showing with 17 additions and 9 deletions.
  1. +17 −9 builtin/rebase.c
@@ -253,7 +253,7 @@ static int write_basic_state(struct rebase_options *opts)
write_file(state_dir_path("quiet", opts), "%s",
opts->flags & REBASE_NO_QUIET ? "" : "t");
if (opts->flags & REBASE_VERBOSE)
write_file(state_dir_path("verbose", opts), "");
write_file(state_dir_path("verbose", opts), "%s", "");
if (opts->strategy)
write_file(state_dir_path("strategy", opts), "%s",
opts->strategy);
@@ -481,17 +481,24 @@ static int reset_head(struct object_id *oid, const char *action,

static int move_to_original_branch(struct rebase_options *opts)
{
struct strbuf buf = STRBUF_INIT;
struct strbuf orig_head_reflog = STRBUF_INIT, head_reflog = STRBUF_INIT;
int ret;

if (opts->head_name && opts->onto)
strbuf_addf(&buf, "rebase finished: %s onto %s",
opts->head_name,
oid_to_hex(&opts->onto->object.oid));
if (!opts->head_name)
return 0; /* nothing to move back to */

if (!opts->onto)
BUG("move_to_original_branch without onto");

strbuf_addf(&orig_head_reflog, "rebase finished: %s onto %s",
opts->head_name, oid_to_hex(&opts->onto->object.oid));
strbuf_addf(&head_reflog, "rebase finished: returning to %s",
opts->head_name);
ret = reset_head(NULL, "checkout", opts->head_name, 0,
"HEAD", buf.buf);
orig_head_reflog.buf, head_reflog.buf);

strbuf_release(&buf);
strbuf_release(&orig_head_reflog);
strbuf_release(&head_reflog);
return ret;
}

@@ -548,7 +555,8 @@ static int run_am(struct rebase_options *opts)
oid_to_hex(&opts->orig_head));

rebased_patches = xstrdup(git_path("rebased-patches"));
format_patch.out = open(rebased_patches, O_WRONLY | O_CREAT, 0666);
format_patch.out = open(rebased_patches,
O_WRONLY | O_CREAT | O_TRUNC, 0666);
if (format_patch.out < 0) {
status = error_errno(_("could not write '%s'"),
rebased_patches);

0 comments on commit 9688986

Please sign in to comment.
You can’t perform that action at this time.