# [PATCH] New commit option --fixup.

4 messages from 2010-10-06 to 2010-10-07. Participants: Rodolfo Borges, Pat Notz, Sverre Rabbelier, Ævar Arnfjörð Bjarmason.
Thread: https://gitlist.dev/t/25372

## Rodolfo Borges, 2010-10-06 22:58

Subject: [PATCH] New commit option --fixup.
Message-ID: <1286405901-13586-1-git-send-email-rodolfo.borges@gmail.com>
URL: https://gitlist.dev/e/1286405901-13586-1-git-send-email-rodolfo.borges%40gmail.com

```
Equivalent of '-C HEAD --amend'.
Inspired by new 'fixup' rebase -i action.

Signed-off-by: Rodolfo Borges <rodolfo.borges@gmail.com>
---
 Documentation/git-commit.txt |    4 ++++
 builtin/commit.c             |    8 +++++++-
 2 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index 42fb1f5..faba634 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -180,6 +180,10 @@ You should understand the implications of rewriting history if you
 amend a commit that has already been published.  (See the "RECOVERING
 FROM UPSTREAM REBASE" section in linkgit:git-rebase[1].)
 
+--fixup::
+	Like '--amend', but use previous commit message.
+	(Equivalent to `--amend -C HEAD`.)
+
 -i::
 --include::
 	Before making a commit out of staged contents so far,
diff --git a/builtin/commit.c b/builtin/commit.c
index 66fdd22..fd7c145 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -70,7 +70,7 @@ static const char *logfile, *force_author;
 static const char *template_file;
 static char *edit_message, *use_message;
 static char *author_name, *author_email, *author_date;
-static int all, edit_flag, also, interactive, only, amend, signoff;
+static int all, edit_flag, also, interactive, only, amend, fixup, signoff;
 static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship;
 static int no_post_rewrite, allow_empty_message;
 static char *untracked_files_arg, *force_date, *ignore_submodule_arg;
@@ -147,6 +147,7 @@ static struct option builtin_commit_options[] = {
 	OPT_BOOLEAN('z', "null", &null_termination,
 		    "terminate entries with NUL"),
 	OPT_BOOLEAN(0, "amend", &amend, "amend previous commit"),
+	OPT_BOOLEAN(0, "fixup", &fixup, "fixup previous commit"),
 	OPT_BOOLEAN(0, "no-post-rewrite", &no_post_rewrite, "bypass post-rewrite hook"),
 	{ OPTION_STRING, 'u', "untracked-files", &untracked_files_arg, "mode", "show untracked files, optional modes: all, normal, no (Default: all)", PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },
 	/* end commit contents options */
@@ -863,6 +864,11 @@ static int parse_and_validate_options(int argc, const char *argv[],
 	if (force_author && renew_authorship)
 		die("Using both --reset-author and --author does not make sense");
 
+	if (fixup) {
+		amend = 1;
+		use_message = "HEAD";
+	}
+
 	if (logfile || message.len || use_message)
 		use_editor = 0;
 	if (edit_flag)
-- 
1.7.2.3

```

## Pat Notz, 2010-10-07 00:38

Subject: Re: [PATCH] New commit option --fixup.
Message-ID: <AANLkTimHz3sCDh-aicw1agi_mrL8pUztfi32vWv1pXUM@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTimHz3sCDh-aicw1agi_mrL8pUztfi32vWv1pXUM%40mail.gmail.com
In-Reply-To: <1286405901-13586-1-git-send-email-rodolfo.borges@gmail.com>

```
On Wed, Oct 6, 2010 at 4:58 PM, Rodolfo Borges <rodolfo.borges@gmail.com> wrote:
> Equivalent of '-C HEAD --amend'.
> Inspired by new 'fixup' rebase -i action.
>
> Signed-off-by: Rodolfo Borges <rodolfo.borges@gmail.com>
> ---
>  Documentation/git-commit.txt |    4 ++++
>  builtin/commit.c             |    8 +++++++-
>  2 files changed, 11 insertions(+), 1 deletions(-)
>
> diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
> index 42fb1f5..faba634 100644
> --- a/Documentation/git-commit.txt
> +++ b/Documentation/git-commit.txt
> @@ -180,6 +180,10 @@ You should understand the implications of rewriting history if you
>  amend a commit that has already been published.  (See the "RECOVERING
>  FROM UPSTREAM REBASE" section in linkgit:git-rebase[1].)
>
> +--fixup::
> +       Like '--amend', but use previous commit message.
> +       (Equivalent to `--amend -C HEAD`.)
> +

Why not just use an alias for this?  I do:

git config alias.fixup "commit --amend -C HEAD"

Also, I've been working on --fixup and --squash options for commit,
under the same inspiration.  See,
http://thread.gmane.org/gmane.comp.version-control.git/156883

I'm hoping to submit v5 patch series tomorrow night.

>  -i::
>  --include::
>        Before making a commit out of staged contents so far,
> diff --git a/builtin/commit.c b/builtin/commit.c
> index 66fdd22..fd7c145 100644
> --- a/builtin/commit.c
> +++ b/builtin/commit.c
> @@ -70,7 +70,7 @@ static const char *logfile, *force_author;
>  static const char *template_file;
>  static char *edit_message, *use_message;
>  static char *author_name, *author_email, *author_date;
> -static int all, edit_flag, also, interactive, only, amend, signoff;
> +static int all, edit_flag, also, interactive, only, amend, fixup, signoff;
>  static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship;
>  static int no_post_rewrite, allow_empty_message;
>  static char *untracked_files_arg, *force_date, *ignore_submodule_arg;
> @@ -147,6 +147,7 @@ static struct option builtin_commit_options[] = {
>        OPT_BOOLEAN('z', "null", &null_termination,
>                    "terminate entries with NUL"),
>        OPT_BOOLEAN(0, "amend", &amend, "amend previous commit"),
> +       OPT_BOOLEAN(0, "fixup", &fixup, "fixup previous commit"),
>        OPT_BOOLEAN(0, "no-post-rewrite", &no_post_rewrite, "bypass post-rewrite hook"),
>        { OPTION_STRING, 'u', "untracked-files", &untracked_files_arg, "mode", "show untracked files, optional modes: all, normal, no (Default: all)", PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },
>        /* end commit contents options */
> @@ -863,6 +864,11 @@ static int parse_and_validate_options(int argc, const char *argv[],
>        if (force_author && renew_authorship)
>                die("Using both --reset-author and --author does not make sense");
>
> +       if (fixup) {
> +               amend = 1;
> +               use_message = "HEAD";
> +       }
> +
>        if (logfile || message.len || use_message)
>                use_editor = 0;
>        if (edit_flag)
> --
> 1.7.2.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

```

## Sverre Rabbelier, 2010-10-07 08:09

Subject: Re: [PATCH] New commit option --fixup.
Message-ID: <AANLkTi=c9zCKUnZp3B=m9C99FKOTtz+hY5-GvSXjozHD@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTi%3Dc9zCKUnZp3B%3Dm9C99FKOTtz%2BhY5-GvSXjozHD%40mail.gmail.com
In-Reply-To: <AANLkTimHz3sCDh-aicw1agi_mrL8pUztfi32vWv1pXUM@mail.gmail.com>

```
Heya,

On Thu, Oct 7, 2010 at 02:38, Pat Notz <patnotz@gmail.com> wrote:
> Why not just use an alias for this?  I do:
>
> git config alias.fixup "commit --amend -C HEAD"

I have a similar alias:

git config alias.amendall "commit --amend -a -C HEAD"

I don't think we need a command to do this, but I'm starting to think
we really should have a list of aliases either ship with git itself,
or with the git documentation.

-- 
Cheers,

Sverre Rabbelier

```

## Ævar Arnfjörð Bjarmason, 2010-10-07 08:35

Subject: Re: [PATCH] New commit option --fixup.
Message-ID: <AANLkTimQbYi=MmodFuyDdgeoYXQ42j2Jq4a+BmohGG0W@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTimQbYi%3DMmodFuyDdgeoYXQ42j2Jq4a%2BBmohGG0W%40mail.gmail.com
In-Reply-To: <AANLkTi=c9zCKUnZp3B=m9C99FKOTtz+hY5-GvSXjozHD@mail.gmail.com>

```
On Thu, Oct 7, 2010 at 08:09, Sverre Rabbelier <srabbelier@gmail.com> wrote:
> Heya,
>
> On Thu, Oct 7, 2010 at 02:38, Pat Notz <patnotz@gmail.com> wrote:
>> Why not just use an alias for this?  I do:
>>
>> git config alias.fixup "commit --amend -C HEAD"
>
> I have a similar alias:
>
> git config alias.amendall "commit --amend -a -C HEAD"
>
> I don't think we need a command to do this, but I'm starting to think
> we really should have a list of aliases either ship with git itself,
> or with the git documentation.

FWIW that's one of the things I want to do if I pick up my .gitconfig
inclusion patch again. Have aliases files that ship with Git itself
that you can include in ~/.gitconfig.

```
