git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Wishlist: git commit --no-edit
@ 2012-11-02  9:26 Niels Möller
  2012-11-02  9:42 ` Matthieu Moy
  0 siblings, 1 reply; 9+ messages in thread
From: Niels Möller @ 2012-11-02  9:26 UTC (permalink / raw)
  To: git

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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Wishlist: git commit --no-edit
  2012-11-02  9:26 Wishlist: git commit --no-edit Niels Möller
@ 2012-11-02  9:42 ` Matthieu Moy
  2012-11-02  9:59   ` Jeff King
  2012-11-02 10:07   ` Niels Möller
  0 siblings, 2 replies; 9+ messages in thread
From: Matthieu Moy @ 2012-11-02  9:42 UTC (permalink / raw)
  To: Niels Möller; +Cc: git

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/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Wishlist: git commit --no-edit
  2012-11-02  9:42 ` Matthieu Moy
@ 2012-11-02  9:59   ` Jeff King
       [not found]     ` <CACnwZYe-za3Q0qvkfQ=qatB1-8eLUFA6ZzfS41yeqrV=8rVzGA@mail.gmail.com>
  2012-11-02 10:07   ` Niels Möller
  1 sibling, 1 reply; 9+ messages in thread
From: Jeff King @ 2012-11-02  9:59 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: Niels Möller, git

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Wishlist: git commit --no-edit
  2012-11-02  9:42 ` Matthieu Moy
  2012-11-02  9:59   ` Jeff King
@ 2012-11-02 10:07   ` Niels Möller
  2012-11-02 10:39     ` [PATCH] Document 'git commit --no-edit' explicitly Matthieu Moy
  1 sibling, 1 reply; 9+ messages in thread
From: Niels Möller @ 2012-11-02 10:07 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: git

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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH] Document 'git commit --no-edit' explicitly
  2012-11-02 10:07   ` Niels Möller
@ 2012-11-02 10:39     ` Matthieu Moy
  2012-11-02 11:24       ` Niels Möller
  2012-11-02 11:53       ` Jeff King
  0 siblings, 2 replies; 9+ messages in thread
From: Matthieu Moy @ 2012-11-02 10:39 UTC (permalink / raw)
  To: git; +Cc: peff, nisse, Matthieu Moy


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

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] Document 'git commit --no-edit' explicitly
  2012-11-02 10:39     ` [PATCH] Document 'git commit --no-edit' explicitly Matthieu Moy
@ 2012-11-02 11:24       ` Niels Möller
  2012-11-02 11:29         ` Matthieu Moy
  2012-11-02 11:53       ` Jeff King
  1 sibling, 1 reply; 9+ messages in thread
From: Niels Möller @ 2012-11-02 11:24 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: git, peff

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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Document 'git commit --no-edit' explicitly
  2012-11-02 11:24       ` Niels Möller
@ 2012-11-02 11:29         ` Matthieu Moy
  0 siblings, 0 replies; 9+ messages in thread
From: Matthieu Moy @ 2012-11-02 11:29 UTC (permalink / raw)
  To: Niels Möller; +Cc: git, peff

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/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Document 'git commit --no-edit' explicitly
  2012-11-02 10:39     ` [PATCH] Document 'git commit --no-edit' explicitly Matthieu Moy
  2012-11-02 11:24       ` Niels Möller
@ 2012-11-02 11:53       ` Jeff King
  1 sibling, 0 replies; 9+ messages in thread
From: Jeff King @ 2012-11-02 11:53 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: git, nisse

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Wishlist: git commit --no-edit
       [not found]     ` <CACnwZYe-za3Q0qvkfQ=qatB1-8eLUFA6ZzfS41yeqrV=8rVzGA@mail.gmail.com>
@ 2012-11-02 12:45       ` Jeff King
  0 siblings, 0 replies; 9+ messages in thread
From: Jeff King @ 2012-11-02 12:45 UTC (permalink / raw)
  To: Thiago Farina; +Cc: git

[+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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-11-02 12:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-02  9:26 Wishlist: git commit --no-edit Niels Möller
2012-11-02  9:42 ` Matthieu Moy
2012-11-02  9:59   ` Jeff King
     [not found]     ` <CACnwZYe-za3Q0qvkfQ=qatB1-8eLUFA6ZzfS41yeqrV=8rVzGA@mail.gmail.com>
2012-11-02 12:45       ` Jeff King
2012-11-02 10:07   ` Niels Möller
2012-11-02 10:39     ` [PATCH] Document 'git commit --no-edit' explicitly Matthieu Moy
2012-11-02 11:24       ` Niels Möller
2012-11-02 11:29         ` Matthieu Moy
2012-11-02 11:53       ` Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).