# Wishlist: git commit --no-edit

9 messages from 2012-11-02 to 2012-11-02. Participants: Niels Möller, Matthieu Moy, Jeff King.
Thread: https://gitlist.dev/t/31999

## Niels Möller, 2012-11-02 09:26

Subject: Wishlist: git commit --no-edit
Message-ID: <nntxt8ice9.fsf@stalhein.lysator.liu.se>
URL: https://gitlist.dev/e/nntxt8ice9.fsf%40stalhein.lysator.liu.se

```
I'd like to have a git commit option which is the opposite of --edit, to
use the selected commit message as is, without invoking any editor.

Main use case I see would be

  git commit --amend --no-edit

(say you fix a typo in the previous commit which doesn't affect the
commit message). Today, one can get the same effect more clumsily as

  EDITOR=touch git commit --amend

Or maybe as

  git commit --amend -C HEAD

But I'd really prefer a --no-edit option over those alternatives. And it
might be useful also in combination with other options, e.g., it would
make the -C option equivalent to -c --no-edit, if I understand it
correctly.

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.

```

## Matthieu Moy, 2012-11-02 09:42

Subject: Re: Wishlist: git commit --no-edit
Message-ID: <vpqfw4sgx33.fsf@grenoble-inp.fr>
URL: https://gitlist.dev/e/vpqfw4sgx33.fsf%40grenoble-inp.fr
In-Reply-To: <nntxt8ice9.fsf@stalhein.lysator.liu.se>

```
nisse@lysator.liu.se (Niels Möller) writes:

> I'd like to have a git commit option which is the opposite of --edit, to
> use the selected commit message as is, without invoking any editor.
>
> Main use case I see would be
>
>   git commit --amend --no-edit

Err, isn't this already working? (maybe your version of Git is too old,
but my 1.7.9.5 does this at least)

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

```

## Jeff King, 2012-11-02 09:59

Subject: Re: Wishlist: git commit --no-edit
Message-ID: <20121102095954.GB30221@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20121102095954.GB30221%40sigill.intra.peff.net
In-Reply-To: <vpqfw4sgx33.fsf@grenoble-inp.fr>

```
On Fri, Nov 02, 2012 at 10:42:24AM +0100, Matthieu Moy wrote:

> nisse@lysator.liu.se (Niels Möller) writes:
> 
> > I'd like to have a git commit option which is the opposite of --edit, to
> > use the selected commit message as is, without invoking any editor.
> >
> > Main use case I see would be
> >
> >   git commit --amend --no-edit
> 
> Err, isn't this already working? (maybe your version of Git is too old,
> but my 1.7.9.5 does this at least)

Yup, should be working since 1.7.9.

  $ git tag --contains ':/commit: honour --no-edit' |
    sort -V |
    head -1
  v1.7.9

-Peff

```

## Niels Möller, 2012-11-02 10:07

Subject: Re: Wishlist: git commit --no-edit
Message-ID: <nnpq3wiaha.fsf@stalhein.lysator.liu.se>
URL: https://gitlist.dev/e/nnpq3wiaha.fsf%40stalhein.lysator.liu.se
In-Reply-To: <vpqfw4sgx33.fsf@grenoble-inp.fr>

```
Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:

> Err, isn't this already working? (maybe your version of Git is too old,
> but my 1.7.9.5 does this at least)

It may be that I'm confused.

It doesn't work in the version I have (1.7.2.5, debian packaged).

And then I also had a quick look in the source code (of a fresh pull
from https://github.com/git/git.git). In builtin/commit.c, I didn't see
any no-edit flag (but I maybe it's in the OPT_BOOL magic (which is
different from OPT_BOOLEAN?)).

And it's also not mentioned in Documentation/git-commit.txt or on
http://kernel.org/pub/software/scm/git/docs/git-commit.html.

If commit --no-edit does work in recent versions, then all is fine,
except possibly the documentation of it. Thanks.

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.

```

## Matthieu Moy, 2012-11-02 10:39

Subject: [PATCH] Document 'git commit --no-edit' explicitly
Message-ID: <1351852770-13897-1-git-send-email-Matthieu.Moy@imag.fr>
URL: https://gitlist.dev/e/1351852770-13897-1-git-send-email-Matthieu.Moy%40imag.fr
In-Reply-To: <nnpq3wiaha.fsf@stalhein.lysator.liu.se>

```

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
I was tempted to merge the paragraph with --edit::, but I thought this
may add confusion. The use-cases for --edit and --no-edit are really
different so I went for a separate paragraph, right below the --edit one.

 Documentation/git-commit.txt | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index 3acf2e7..44b4347 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -188,6 +188,11 @@ OPTIONS
 	commit log message unmodified.  This option lets you
 	further edit the message taken from these sources.
 
+--no-edit::
+	Use the selected commit message without launching an editor.
+	For example, `git commit --amend --no-edit` amends a commit
+	without changing its commit message.
+
 --amend::
 	Used to amend the tip of the current branch. Prepare the tree
 	object you would want to replace the latest commit as usual
-- 
1.8.0.319.g8abfee4

```

## Niels Möller, 2012-11-02 11:24

Subject: Re: [PATCH] Document 'git commit --no-edit' explicitly
Message-ID: <nnlieki6xs.fsf@stalhein.lysator.liu.se>
URL: https://gitlist.dev/e/nnlieki6xs.fsf%40stalhein.lysator.liu.se
In-Reply-To: <1351852770-13897-1-git-send-email-Matthieu.Moy@imag.fr>

```
Matthieu Moy <Matthieu.Moy@imag.fr> writes:

> +--no-edit::
> +	Use the selected commit message without launching an editor.
> +	For example, `git commit --amend --no-edit` amends a commit
> +	without changing its commit message.

Looks clear enough to me. Thanks for fixing.

Are -c --no-edit and -C really equivalent in all cases? If so, maybe you
want to say that in the documentation for -C. (And if not, maybe they
*ought* to be equivalent).

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.

```

## Matthieu Moy, 2012-11-02 11:29

Subject: Re: [PATCH] Document 'git commit --no-edit' explicitly
Message-ID: <vpqip9ofdjp.fsf@grenoble-inp.fr>
URL: https://gitlist.dev/e/vpqip9ofdjp.fsf%40grenoble-inp.fr
In-Reply-To: <nnlieki6xs.fsf@stalhein.lysator.liu.se>

```
nisse@lysator.liu.se (Niels Möller) writes:

> Matthieu Moy <Matthieu.Moy@imag.fr> writes:
>
>> +--no-edit::
>> +	Use the selected commit message without launching an editor.
>> +	For example, `git commit --amend --no-edit` amends a commit
>> +	without changing its commit message.
>
> Looks clear enough to me. Thanks for fixing.
>
> Are -c --no-edit and -C really equivalent in all cases?

I guess so, but I didn't check.

> If so, maybe you want to say that in the documentation for -C.

I don't think we should target exhaustivity in the documentation, so I'm
not in favor of *adding* it. But maybe we should replace the doc with
stg like:

-c <commit>::
--reedit-message=<commit>::
	Like '-C --edit'.

(it could even make sense to deprecate one of -C/-c)

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

```

## Jeff King, 2012-11-02 11:53

Subject: Re: [PATCH] Document 'git commit --no-edit' explicitly
Message-ID: <20121102115335.GA2598@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20121102115335.GA2598%40sigill.intra.peff.net
In-Reply-To: <1351852770-13897-1-git-send-email-Matthieu.Moy@imag.fr>

```
On Fri, Nov 02, 2012 at 11:39:30AM +0100, Matthieu Moy wrote:

> I was tempted to merge the paragraph with --edit::, but I thought this
> may add confusion. The use-cases for --edit and --no-edit are really
> different so I went for a separate paragraph, right below the --edit one.

Yeah, usually I think it would be better to keep the positive and
negative forms together, but the way you have done it does seem a lot
more clear to me. I think it is because the default flips based on other
options. So you would be stuck writing something like:

  -e, --edit::
          Edit the commit message using `$EDITOR`. This is the default
          unless the `-F`, `-m`, or `-C` options are used; in those
          cases, `-e` or `--edit` can be used to invoke the editor.
          Likewise, `--no-edit` can be used to suppress the editor when
          using an existing commit message. For example, `git commit
          --amend --no-edit` amends a commit without changing its commit
          message.

Your split reads much better, IMHO.

Thanks.

-Peff

```

## Jeff King, 2012-11-02 12:45

Subject: Re: Wishlist: git commit --no-edit
Message-ID: <20121102124522.GA6817@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20121102124522.GA6817%40sigill.intra.peff.net
In-Reply-To: <CACnwZYe-za3Q0qvkfQ=qatB1-8eLUFA6ZzfS41yeqrV=8rVzGA@mail.gmail.com>

```
[+cc git@vger; please keep discussion on list]

On Fri, Nov 02, 2012 at 10:37:27AM -0200, Thiago Farina wrote:

> >> >   git commit --amend --no-edit
> [...]
> > Yup, should be working since 1.7.9.
> [...]
> I doesn't appear in the help either:
> 
> $ git version
> git version 1.8.0.rc2
> 
> $ git commit -h 2>&1 | grep edit
>     -c, --reedit-message <commit>
>                           reuse and edit message from specified commit
>     -e, --edit            force edit of commit

Yeah, parse_options doesn't advertise negative forms of boolean options,
as they are implied. I don't think it's a big deal, especially now that
it is covered in more detail in the manpage.

I think changing it would probably involve adding "--no-edit" as a
separate entry in the options struct.

-Peff

```
