Re: [PATCH 18/22] sequencer: support amending commits
- From
Jakub Narębski <jnareb@gmail.com>
- Date
- Aug 31, 2016, 21:08 UTC
- Message-ID
- <dd7e4c82-cedb-6cde-a186-8b52bac3a5b8@gmail.com>
- In-Reply-To
- <c4e474af8e6237522f4c452ca90c2e2670059e60.1472457609.git.johannes.schindelin@gmx.de>
W dniu 29.08.2016 o 10:06, Johannes Schindelin pisze:
Show 9 quoted lines
> This teaches the sequencer_commit() function to take an argument that
> will allow us to implement "todo" commands that need to amend the commit
> messages ("fixup", "squash" and "reword").
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
> sequencer.c | 6 ++++--
> sequencer.h | 2 +-
> 2 files changed, 5 insertions(+), 3 deletions(-)Nice and small addition of a new feature, a scaffolding for implementing rebase -i using the sequencer.
Show 11 quoted lines
> > diff --git a/sequencer.c b/sequencer.c > index 7e17d14..20f7590 100644 > --- a/sequencer.c > +++ b/sequencer.c > @@ -478,7 +478,7 @@ static char **read_author_script(void) > * (except, of course, while running an interactive rebase). > */ > int sequencer_commit(const char *defmsg, struct replay_opts *opts, > - int allow_empty, int edit) > + int allow_empty, int edit, int amend)
I guess we won't get much more parameters; it would get unwieldy (and hard to remember). Five is all right.
Show 18 quoted lines
> {
> char **env = NULL;
> struct argv_array array;
> @@ -507,6 +507,8 @@ int sequencer_commit(const char *defmsg, struct replay_opts *opts,
> argv_array_push(&array, "commit");
> argv_array_push(&array, "-n");
>
> + if (amend)
> + argv_array_push(&array, "--amend");
> if (opts->gpg_sign)
> argv_array_pushf(&array, "-S%s", opts->gpg_sign);
> if (opts->signoff)
> @@ -779,7 +781,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
> }
> if (!opts->no_commit)
> res = sequencer_commit(opts->edit ? NULL : git_path_merge_msg(),
> - opts, allow, opts->edit);
> + opts, allow, opts->edit, 0);... even of this makes one need to check the calling convention, what does this 0 mean.
Show 17 quoted lines
> > leave: > free_message(commit, &msg); > diff --git a/sequencer.h b/sequencer.h > index fd02baf..2106c0d 100644 > --- a/sequencer.h > +++ b/sequencer.h > @@ -50,7 +50,7 @@ int sequencer_rollback(struct replay_opts *opts); > int sequencer_remove_state(struct replay_opts *opts); > > int sequencer_commit(const char *defmsg, struct replay_opts *opts, > - int allow_empty, int edit); > + int allow_empty, int edit, int amend); > > extern const char sign_off_header[]; > >