git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Query on git commit amend
@ 2011-12-06  8:23 Viresh Kumar
  2011-12-06  9:01 ` Konstantin Khomoutov
                   ` (2 more replies)
  0 siblings, 3 replies; 27+ messages in thread
From: Viresh Kumar @ 2011-12-06  8:23 UTC (permalink / raw
  To: git@vger.kernel.org; +Cc: Shiraz HASHIM


Hello,

Suppose i want to add few new changes to my last commit (HEAD).
The way i do it is
$ git add all_changed_files
$ git commit --amend

OR
$ git commit --amend -a

With both these ways, i get a screen to edit the message too.

I want to know if there is a way to skip this screen.

i.e.
$ git commit --amend -a -some_other_option

which simply adds new changes to existing commit, without asking to change
message.

If there is no such way, then can we add a patch for this, if it looks a valid
case.

-- 
viresh

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

* Re: Query on git commit amend
  2011-12-06  8:23 Query on git commit amend Viresh Kumar
@ 2011-12-06  9:01 ` Konstantin Khomoutov
  2011-12-06 19:09   ` Dirk Süsserott
  2011-12-06  9:11 ` Johannes Sixt
  2011-12-06 15:46 ` Vijay Lakshminarayanan
  2 siblings, 1 reply; 27+ messages in thread
From: Konstantin Khomoutov @ 2011-12-06  9:01 UTC (permalink / raw
  To: Viresh Kumar; +Cc: git@vger.kernel.org, Shiraz HASHIM

On Tue, 6 Dec 2011 13:53:00 +0530
Viresh Kumar <viresh.kumar@st.com> wrote:

> Suppose i want to add few new changes to my last commit (HEAD).
> The way i do it is
> $ git add all_changed_files
> $ git commit --amend
> 
> OR
> $ git commit --amend -a
> 
> With both these ways, i get a screen to edit the message too.
> 
> I want to know if there is a way to skip this screen.
> 
> i.e.
> $ git commit --amend -a -some_other_option
> 
> which simply adds new changes to existing commit, without asking to
> change message.
> 
> If there is no such way, then can we add a patch for this, if it
> looks a valid case.
git commit --amend -C HEAD

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

* Re: Query on git commit amend
  2011-12-06  8:23 Query on git commit amend Viresh Kumar
  2011-12-06  9:01 ` Konstantin Khomoutov
@ 2011-12-06  9:11 ` Johannes Sixt
  2011-12-06  9:20   ` Viresh Kumar
  2011-12-06 15:46 ` Vijay Lakshminarayanan
  2 siblings, 1 reply; 27+ messages in thread
From: Johannes Sixt @ 2011-12-06  9:11 UTC (permalink / raw
  To: Viresh Kumar; +Cc: git@vger.kernel.org, Shiraz HASHIM

Am 12/6/2011 9:23, schrieb Viresh Kumar:
> 
> Hello,
> 
> Suppose i want to add few new changes to my last commit (HEAD).
> The way i do it is
> $ git add all_changed_files
> $ git commit --amend
> 
> OR
> $ git commit --amend -a
> 
> With both these ways, i get a screen to edit the message too.
> 
> I want to know if there is a way to skip this screen.
> 
> i.e.
> $ git commit --amend -a -some_other_option
> 
> which simply adds new changes to existing commit, without asking to change
> message.

$ git commit --amend -a -C HEAD

But let's count keystrokes (after -a):

<BLANK>-<SHIFT>C<BLANK>HEAD<ENTER>
10 keystrokes (more if you release SHIFT before D)

But if vi pops up you have:

<ENTER><SHIFT>ZZ
4 keystrokes

Where is the advantage of the option?

-- Hannes

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

* Re: Query on git commit amend
  2011-12-06  9:11 ` Johannes Sixt
@ 2011-12-06  9:20   ` Viresh Kumar
  2011-12-06  9:22     ` Viresh Kumar
  0 siblings, 1 reply; 27+ messages in thread
From: Viresh Kumar @ 2011-12-06  9:20 UTC (permalink / raw
  To: Johannes Sixt, flatworm; +Cc: git@vger.kernel.org, Shiraz HASHIM

On 12/6/2011 2:41 PM, Johannes Sixt wrote:
> Am 12/6/2011 9:23, schrieb Viresh Kumar:
> $ git commit --amend -a -C HEAD
> 
> But let's count keystrokes (after -a):
> 
> <BLANK>-<SHIFT>C<BLANK>HEAD<ENTER>
> 10 keystrokes (more if you release SHIFT before D)
> 
> But if vi pops up you have:
> 
> <ENTER><SHIFT>ZZ
> 4 keystrokes
> 
> Where is the advantage of the option?
> 

Thanks guys.

@Johannes: You are right but, i will make an alias for the entire command.
So keystrokes are same for me. :)

-- 
viresh

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

* Re: Query on git commit amend
  2011-12-06  9:20   ` Viresh Kumar
@ 2011-12-06  9:22     ` Viresh Kumar
  0 siblings, 0 replies; 27+ messages in thread
From: Viresh Kumar @ 2011-12-06  9:22 UTC (permalink / raw
  To: Johannes Sixt; +Cc: flatworm, git@vger.kernel.org, Shiraz HASHIM

On 12/6/2011 2:50 PM, Viresh Kumar wrote:
> On 12/6/2011 2:41 PM, Johannes Sixt wrote:
>> Am 12/6/2011 9:23, schrieb Viresh Kumar:
>> $ git commit --amend -a -C HEAD
>>
>> But let's count keystrokes (after -a):
>>
>> <BLANK>-<SHIFT>C<BLANK>HEAD<ENTER>
>> 10 keystrokes (more if you release SHIFT before D)
>>
>> But if vi pops up you have:
>>
>> <ENTER><SHIFT>ZZ
>> 4 keystrokes
>>
>> Where is the advantage of the option?
>>
> 
> Thanks guys.
> 
> @Johannes: You are right but, i will make an alias for the entire command.
> So keystrokes are same for me. :)
> 

There is one more benefit, we don't have to wait for git. We can simply switch to
some other window and work. And can write further command on the same window, in
the time git processes commit --amend.

-- 
viresh

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

* Re: Query on git commit amend
  2011-12-06  8:23 Query on git commit amend Viresh Kumar
  2011-12-06  9:01 ` Konstantin Khomoutov
  2011-12-06  9:11 ` Johannes Sixt
@ 2011-12-06 15:46 ` Vijay Lakshminarayanan
  2011-12-06 19:11   ` Jeff King
                     ` (2 more replies)
  2 siblings, 3 replies; 27+ messages in thread
From: Vijay Lakshminarayanan @ 2011-12-06 15:46 UTC (permalink / raw
  To: Viresh Kumar; +Cc: git@vger.kernel.org, Shiraz HASHIM

Viresh Kumar <viresh.kumar@st.com> writes:

> Hello,
>
> Suppose i want to add few new changes to my last commit (HEAD).
> The way i do it is
> $ git add all_changed_files
> $ git commit --amend
>
> OR
> $ git commit --amend -a
>
> With both these ways, i get a screen to edit the message too.
>
> I want to know if there is a way to skip this screen.
>
> i.e.
> $ git commit --amend -a -some_other_option
>
> which simply adds new changes to existing commit, without asking to change
> message.
>
> If there is no such way, then can we add a patch for this, if it looks a valid
> case.

I've found 

$ GIT_EDITOR=cat git commit --amend

useful.

The benefit of this technique is that it even works for git-rebase -i.

In my typical git usage, I do a lot of git-commit --fixup's.  After
reaching a level of stability, I change the history with:

GIT_EDITOR=cat git rebase -i --autosquash

and my history is adjusted without requiring manual intervention.

-- 
Cheers
~vijay

Gnus should be more complicated.

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

* Re: Query on git commit amend
  2011-12-06  9:01 ` Konstantin Khomoutov
@ 2011-12-06 19:09   ` Dirk Süsserott
  0 siblings, 0 replies; 27+ messages in thread
From: Dirk Süsserott @ 2011-12-06 19:09 UTC (permalink / raw
  To: Konstantin Khomoutov; +Cc: Viresh Kumar, git@vger.kernel.org, Shiraz HASHIM

Am 06.12.2011 10:01 schrieb Konstantin Khomoutov:
> On Tue, 6 Dec 2011 13:53:00 +0530
> Viresh Kumar <viresh.kumar@st.com> wrote:
> 
>> Suppose i want to add few new changes to my last commit (HEAD).
>> The way i do it is
>> $ git add all_changed_files
>> $ git commit --amend
>>
>> OR
>> $ git commit --amend -a
>>
>> With both these ways, i get a screen to edit the message too.
>>
>> I want to know if there is a way to skip this screen.
>>
>> i.e.
>> $ git commit --amend -a -some_other_option
>>
>> which simply adds new changes to existing commit, without asking to
>> change message.
>>
>> If there is no such way, then can we add a patch for this, if it
>> looks a valid case.
> git commit --amend -C HEAD

$ git commit --amend -C HEAD

works fine but will keep the authorship (name _and_ date). To change the
date to the current timestamp, use

$ git commit --amend -C HEAD --reset-author

Note that this will also change the author's name to yours, so it
depends on your case. The commiter's name and timestamp are always
updated to "you/now", independently of that option. To change only the
author's date, use --date=<date>.

Cheers,
    Dirk

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

* Re: Query on git commit amend
  2011-12-06 15:46 ` Vijay Lakshminarayanan
@ 2011-12-06 19:11   ` Jeff King
  2011-12-07  2:18     ` Vijay Lakshminarayanan
  2011-12-06 20:03   ` Junio C Hamano
  2011-12-08  5:26   ` Viresh Kumar
  2 siblings, 1 reply; 27+ messages in thread
From: Jeff King @ 2011-12-06 19:11 UTC (permalink / raw
  To: Vijay Lakshminarayanan; +Cc: Viresh Kumar, git@vger.kernel.org, Shiraz HASHIM

On Tue, Dec 06, 2011 at 09:16:18PM +0530, Vijay Lakshminarayanan wrote:

> I've found 
> 
> $ GIT_EDITOR=cat git commit --amend
> 
> useful.
> 
> The benefit of this technique is that it even works for git-rebase -i.

I sometimes do a similar thing, but I don't use "cat". That will dump
all of the log message (including the generated template) to stdout
(i.e., the terminal), which is quite noisy. Instead, I use:

  GIT_EDITOR=true git commit --amend

which silently leaves the file untouched.

-Peff

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

* Re: Query on git commit amend
  2011-12-06 15:46 ` Vijay Lakshminarayanan
  2011-12-06 19:11   ` Jeff King
@ 2011-12-06 20:03   ` Junio C Hamano
  2011-12-06 21:00     ` Junio C Hamano
  2011-12-07  2:28     ` Query on git commit amend Vijay Lakshminarayanan
  2011-12-08  5:26   ` Viresh Kumar
  2 siblings, 2 replies; 27+ messages in thread
From: Junio C Hamano @ 2011-12-06 20:03 UTC (permalink / raw
  To: Vijay Lakshminarayanan; +Cc: Viresh Kumar, git@vger.kernel.org, Shiraz HASHIM

Vijay Lakshminarayanan <laksvij@gmail.com> writes:

> I've found 
>
> $ GIT_EDITOR=cat git commit --amend
>
> useful.

Are you sure it is a cat?

I almost always use

    $ EDITOR=: git commit --amend

when rewriting the contents without updating the message, but I think
we should allow people to say:

    $ git commit --amend --no-edit

which is accepted from the command line but is not honoured.

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

* Re: Query on git commit amend
  2011-12-06 20:03   ` Junio C Hamano
@ 2011-12-06 21:00     ` Junio C Hamano
  2011-12-07 14:42       ` [PATCH/RFC 0/4] Re: commit: honor --no-edit Jonathan Nieder
  2011-12-07  2:28     ` Query on git commit amend Vijay Lakshminarayanan
  1 sibling, 1 reply; 27+ messages in thread
From: Junio C Hamano @ 2011-12-06 21:00 UTC (permalink / raw
  To: git; +Cc: Vijay Lakshminarayanan, Viresh Kumar, Shiraz HASHIM

Junio C Hamano <gitster@pobox.com> writes:

> I almost always use
>
>     $ EDITOR=: git commit --amend
>
> when rewriting the contents without updating the message, but I think
> we should allow people to say:
>
>     $ git commit --amend --no-edit
>
> which is accepted from the command line but is not honoured.

And this should fix it (only lightly tested).

-- >8 --
Subject: [PATCH] commit: honor --no-edit

After making fixes to the contents to be committed, it is not unusual to
update the current commit without rewording the message. Idioms to do
tell "commit --amend" that we do not need an editor have been:

    $ EDITOR=: git commit --amend
    $ git commit --amend -C HEAD

but that was only because a more natural

    $ git commit --amend --no-edit

did not honour "--no-edit" option.    

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin/commit.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/builtin/commit.c b/builtin/commit.c
index 8f2bebe..48bea8f 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -81,7 +81,8 @@ static const char *template_file;
 static const char *author_message, *author_message_buffer;
 static char *edit_message, *use_message;
 static char *fixup_message, *squash_message;
-static int all, edit_flag, also, interactive, patch_interactive, only, amend, signoff;
+static int all, also, interactive, patch_interactive, only, amend, signoff;
+static int edit_flag = -1; /* unspecified */
 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;
@@ -141,7 +142,7 @@ static struct option builtin_commit_options[] = {
 	OPT_BOOLEAN(0, "reset-author", &renew_authorship, "the commit is authored by me now (used with -C-c/--amend)"),
 	OPT_BOOLEAN('s', "signoff", &signoff, "add Signed-off-by:"),
 	OPT_FILENAME('t', "template", &template_file, "use specified template file"),
-	OPT_BOOLEAN('e', "edit", &edit_flag, "force edit of commit"),
+	OPT_BOOL('e', "edit", &edit_flag, "force edit of commit"),
 	OPT_STRING(0, "cleanup", &cleanup_arg, "default", "how to strip spaces and #comments from message"),
 	OPT_BOOLEAN(0, "status", &include_status, "include status in commit message template"),
 	/* end commit message options */
@@ -1020,8 +1021,8 @@ static int parse_and_validate_options(int argc, const char *argv[],
 
 	if (logfile || message.len || use_message || fixup_message)
 		use_editor = 0;
-	if (edit_flag)
-		use_editor = 1;
+	if (0 <= edit_flag)
+		use_editor = edit_flag;
 	if (!use_editor)
 		setenv("GIT_EDITOR", ":", 1);
 
-- 
1.7.8.157.g03e55

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

* Re: Query on git commit amend
  2011-12-06 19:11   ` Jeff King
@ 2011-12-07  2:18     ` Vijay Lakshminarayanan
  0 siblings, 0 replies; 27+ messages in thread
From: Vijay Lakshminarayanan @ 2011-12-07  2:18 UTC (permalink / raw
  To: Jeff King; +Cc: Viresh Kumar, git@vger.kernel.org, Shiraz HASHIM

Jeff King <peff@peff.net> writes:

> On Tue, Dec 06, 2011 at 09:16:18PM +0530, Vijay Lakshminarayanan wrote:
>
>> I've found 
>> 
>> $ GIT_EDITOR=cat git commit --amend
>> 
>> useful.
>> 
>> The benefit of this technique is that it even works for git-rebase -i.
>
> I sometimes do a similar thing, but I don't use "cat". That will dump
> all of the log message (including the generated template) to stdout
> (i.e., the terminal), which is quite noisy. Instead, I use:
>
>   GIT_EDITOR=true git commit --amend
>
> which silently leaves the file untouched.

Thanks Peff.  I didn't know about true.  I will use it when rebasing.
cat's noisiness is useful as a review of the output.

> -Peff

-- 
Cheers
~vijay

Gnus should be more complicated.

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

* Re: Query on git commit amend
  2011-12-06 20:03   ` Junio C Hamano
  2011-12-06 21:00     ` Junio C Hamano
@ 2011-12-07  2:28     ` Vijay Lakshminarayanan
  2011-12-07  4:20       ` Viresh Kumar
  1 sibling, 1 reply; 27+ messages in thread
From: Vijay Lakshminarayanan @ 2011-12-07  2:28 UTC (permalink / raw
  To: Junio C Hamano; +Cc: Viresh Kumar, git@vger.kernel.org, Shiraz HASHIM

Junio C Hamano <gitster@pobox.com> writes:

> Vijay Lakshminarayanan <laksvij@gmail.com> writes:
>
>> I've found 
>>
>> $ GIT_EDITOR=cat git commit --amend
>>
>> useful.
>
> Are you sure it is a cat?

Yes.

Did you mean something else by your question?

> I almost always use
>
>     $ EDITOR=: git commit --amend

I just tried this out.  This and Peff's GIT_EDITOR=true silently dwiw
but cat is useful to review the commit.

-- 
Cheers
~vijay

Gnus should be more complicated.

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

* Re: Query on git commit amend
  2011-12-07  2:28     ` Query on git commit amend Vijay Lakshminarayanan
@ 2011-12-07  4:20       ` Viresh Kumar
  2011-12-07  4:53         ` Björn Steinbrink
  0 siblings, 1 reply; 27+ messages in thread
From: Viresh Kumar @ 2011-12-07  4:20 UTC (permalink / raw
  To: Vijay Lakshminarayanan, Junio C Hamano
  Cc: git@vger.kernel.org, Shiraz HASHIM, Vipin KUMAR


Thanks guys. This whole session was new to me.

On 12/7/2011 7:58 AM, Vijay Lakshminarayanan wrote:
> Junio C Hamano <gitster@pobox.com> writes:
> 
>> > Vijay Lakshminarayanan <laksvij@gmail.com> writes:
>> >
>>> >> I've found 
>>> >>
>>> >> $ GIT_EDITOR=cat git commit --amend
>>> >>
>>> >> useful.
>> >
>> > Are you sure it is a cat?
> Yes.

This didn't worked for me. Got following error:

cat: unrecognized option `--amend'
Try `cat --help' for more information.
error: There was a problem with the editor 'cat git commit --amend'.
Please supply the message using either -m or -F option.
Could not commit staged changes.

>> > I almost always use
>> >
>> >     $ EDITOR=: git commit --amend

Even this didn't worked for me:

error: pathspec '.git/COMMIT_EDITMSG' did not match any file(s) known to git.
error: There was a problem with the editor 'git commit --amend'.
Please supply the message using either -m or -F option.
Could not commit staged changes.

Only "true" worked for me.

Probably, i have an older version of git (version 1.7.2.2)

One more thing. I couldn't get completely how this worked. Maybe any pointers to
earlier discussions.

The way i am testing it is:
- Stop after a commit in middle of rebase using "edit" or "e" option
- set EDITOR or GIT_EDITOR
- change files
- git add changed_files
- git rebase --continue

-- 
viresh

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

* Re: Query on git commit amend
  2011-12-07  4:20       ` Viresh Kumar
@ 2011-12-07  4:53         ` Björn Steinbrink
  2011-12-07  5:45           ` Viresh Kumar
  0 siblings, 1 reply; 27+ messages in thread
From: Björn Steinbrink @ 2011-12-07  4:53 UTC (permalink / raw
  To: Viresh Kumar
  Cc: Vijay Lakshminarayanan, Junio C Hamano, git@vger.kernel.org,
	Shiraz HASHIM, Vipin KUMAR

On 2011.12.07 09:50:24 +0530, Viresh Kumar wrote:
> 
> Thanks guys. This whole session was new to me.
> 
> On 12/7/2011 7:58 AM, Vijay Lakshminarayanan wrote:
> > Junio C Hamano <gitster@pobox.com> writes:
> > 
> >> > Vijay Lakshminarayanan <laksvij@gmail.com> writes:
> >> >
> >>> >> I've found 
> >>> >>
> >>> >> $ GIT_EDITOR=cat git commit --amend
> >>> >>
> >>> >> useful.
> >> >
> >> > Are you sure it is a cat?
> > Yes.
> 
> This didn't worked for me. Got following error:
> 
> cat: unrecognized option `--amend'
> Try `cat --help' for more information.
> error: There was a problem with the editor 'cat git commit --amend'.
> Please supply the message using either -m or -F option.
> Could not commit staged changes.

That looks like you did something like:
export GIT_EDITOR="cat git commit --amend"

But the original command was:
  GIT_EDITOR=cat git commit --amend

Notice that there are no quotes and no escaped spaces. This is a
shortcut to set GIT_EDITOR to "cat" for just this one command (git
commit --amend).

If you want to set the editor in the environment, use just "export
GIT_EDITOR=cat" or something like that.

HTH
Björn

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

* Re: Query on git commit amend
  2011-12-07  4:53         ` Björn Steinbrink
@ 2011-12-07  5:45           ` Viresh Kumar
  2011-12-07 15:06             ` Vijay Lakshminarayanan
  2011-12-08 17:52             ` Junio C Hamano
  0 siblings, 2 replies; 27+ messages in thread
From: Viresh Kumar @ 2011-12-07  5:45 UTC (permalink / raw
  To: Björn Steinbrink
  Cc: Vijay Lakshminarayanan, Junio C Hamano, git@vger.kernel.org,
	Shiraz HASHIM, Vipin KUMAR

On 12/7/2011 10:23 AM, Björn Steinbrink wrote:
> That looks like you did something like:
> export GIT_EDITOR="cat git commit --amend"
> 
> But the original command was:
>   GIT_EDITOR=cat git commit --amend
> 
> Notice that there are no quotes and no escaped spaces. This is a
> shortcut to set GIT_EDITOR to "cat" for just this one command (git
> commit --amend).
> 
> If you want to set the editor in the environment, use just "export
> GIT_EDITOR=cat" or something like that.

Ok. Got it now.

Now, whats the benefit of 

GIT_EDITOR=cat git commit --amend

over

git commit --amend -C HEAD

?

Obviously if we have more than one commit to handle during a rebase then,
setting editor to cat once, would be good. As now we don't really need to
do git commit --amend. We can add commits and continue rebase.
But for single commit probably second one looks easier. Isn't it?
Or maybe the latest patch from Junio is even better.

-- 
viresh

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

* [PATCH/RFC 0/4] Re: commit: honor --no-edit
  2011-12-06 21:00     ` Junio C Hamano
@ 2011-12-07 14:42       ` Jonathan Nieder
  2011-12-07 14:45         ` [PATCH 1/4] test: add missing "&&" after echo command Jonathan Nieder
                           ` (3 more replies)
  0 siblings, 4 replies; 27+ messages in thread
From: Jonathan Nieder @ 2011-12-07 14:42 UTC (permalink / raw
  To: Junio C Hamano; +Cc: git, Vijay Lakshminarayanan, Viresh Kumar, Shiraz HASHIM

Junio C Hamano wrote:

> And this should fix it (only lightly tested).
>
> -- >8 --
> Subject: [PATCH] commit: honor --no-edit
>
> After making fixes to the contents to be committed, it is not unusual to
> update the current commit without rewording the message. Idioms to do
> tell "commit --amend" that we do not need an editor have been:
>
>     $ EDITOR=: git commit --amend
>     $ git commit --amend -C HEAD
>
> but that was only because a more natural
>
>     $ git commit --amend --no-edit
>
> did not honour "--no-edit" option.    

I like it.

Here are a couple of tests.  The three patches before are just to make
it less frightening to add to the relevant test script.

Jonathan Nieder (4):
  test: add missing "&&" after echo command
  test: remove a test of porcelain that hardcodes commit ids
  t7501 (commit): modernize style
  test: commit --amend should honor --no-edit

 t/t7501-commit.sh |  335 ++++++++++++++++++++++++++++-------------------------
 1 files changed, 175 insertions(+), 160 deletions(-)

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

* [PATCH 1/4] test: add missing "&&" after echo command
  2011-12-07 14:42       ` [PATCH/RFC 0/4] Re: commit: honor --no-edit Jonathan Nieder
@ 2011-12-07 14:45         ` Jonathan Nieder
  2011-12-07 23:10           ` Jeff King
  2011-12-07 14:49         ` [PATCH 2/4] test: remove a porcelain test that hard-codes commit names Jonathan Nieder
                           ` (2 subsequent siblings)
  3 siblings, 1 reply; 27+ messages in thread
From: Jonathan Nieder @ 2011-12-07 14:45 UTC (permalink / raw
  To: Junio C Hamano; +Cc: git, Vijay Lakshminarayanan, Viresh Kumar, Shiraz HASHIM

This test wants to modify a file and commit the change, but because of
a missing separator between commands it is parsed as a single "echo"
command.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 t/t7501-commit.sh |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh
index 3ad04363..da75abc1 100755
--- a/t/t7501-commit.sh
+++ b/t/t7501-commit.sh
@@ -60,7 +60,7 @@ test_expect_success \
 
 test_expect_success \
 	"next commit" \
-	"echo 'bongo bongo bongo' >file \
+	"echo 'bongo bongo bongo' >file && \
 	 git commit -m next -a"
 
 test_expect_success \
@@ -172,11 +172,12 @@ test_expect_success \
 # easier to isolate bugs.
 
 cat >expected <<\EOF
-72c0dc9855b0c9dadcbfd5a31cab072e0cb774ca
-9b88fc14ce6b32e3d9ee021531a54f18a5cf38a2
-3536bbb352c3a1ef9a420f5b4242d48578b92aa7
-d381ac431806e53f3dd7ac2f1ae0534f36d738b9
-4fd44095ad6334f3ef72e4c5ec8ddf108174b54a
+285fcf7ec0d61b14249dfdb4c1e1fe03eaf15ee0
+0b8148b9afce917b87d71199b900466dc8ea8b6e
+43fb8826314939ce79a856face7953557fdca3d1
+eaa04bc3ae0f0b003f7f1d86bf869ec5d73eaf3e
+ee1963b250ee0f02a3fe37be0e4a02bb5af6a1ad
+b49f306003c627361a0304d151a6b4c8b26af6a1
 402702b49136e7587daa9280e91e4bb7cb2179f7
 EOF
 
-- 
1.7.8.rc3

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

* [PATCH 2/4] test: remove a porcelain test that hard-codes commit names
  2011-12-07 14:42       ` [PATCH/RFC 0/4] Re: commit: honor --no-edit Jonathan Nieder
  2011-12-07 14:45         ` [PATCH 1/4] test: add missing "&&" after echo command Jonathan Nieder
@ 2011-12-07 14:49         ` Jonathan Nieder
  2011-12-07 14:50         ` [PATCH 3/4] t7501 (commit): modernize style Jonathan Nieder
  2011-12-07 14:54         ` [PATCH 4/4] test: commit --amend should honor --no-edit Jonathan Nieder
  3 siblings, 0 replies; 27+ messages in thread
From: Jonathan Nieder @ 2011-12-07 14:49 UTC (permalink / raw
  To: Junio C Hamano; +Cc: git, Vijay Lakshminarayanan, Viresh Kumar, Shiraz HASHIM

The rev-list output in this test depends on the details of test_tick's
dummy dates and the choice of hash function.  Worse, it depends on the
order and nature of commits made in the earlier tests, so adding new
tests or rearranging existing ones breaks it.

It would be nice to check that "git commit" and commit-tree name
objects consistently and that commit objects' text is as documented,
but this particular test checks everything at once and hence is not a
robust test for that.  Remove it.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Hence the odd hunk in the previous patch.

Maybe this doesn't belong in this series, but it's the kind of thing
that drives me batty when writing new tests.

 t/t7501-commit.sh |   20 --------------------
 1 files changed, 0 insertions(+), 20 deletions(-)

diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh
index da75abc1..9c507b08 100755
--- a/t/t7501-commit.sh
+++ b/t/t7501-commit.sh
@@ -144,10 +144,6 @@ test_expect_success PERL \
 	git diff >diff2 &&
 	test_cmp diff1 diff2"
 
-test_expect_success \
-	"showing committed revisions" \
-	"git rev-list HEAD >current"
-
 cat >editor <<\EOF
 #!/bin/sh
 sed -e "s/good/bad/g" < "$1" > "$1-"
@@ -168,22 +164,6 @@ test_expect_success \
 	 echo "Another good message." | EDITOR=./editor git commit -a -F - &&
 	 git show -s --pretty=format:"%s" | grep -q good
 	 '
-# We could just check the head sha1, but checking each commit makes it
-# easier to isolate bugs.
-
-cat >expected <<\EOF
-285fcf7ec0d61b14249dfdb4c1e1fe03eaf15ee0
-0b8148b9afce917b87d71199b900466dc8ea8b6e
-43fb8826314939ce79a856face7953557fdca3d1
-eaa04bc3ae0f0b003f7f1d86bf869ec5d73eaf3e
-ee1963b250ee0f02a3fe37be0e4a02bb5af6a1ad
-b49f306003c627361a0304d151a6b4c8b26af6a1
-402702b49136e7587daa9280e91e4bb7cb2179f7
-EOF
-
-test_expect_success \
-    'validate git rev-list output.' \
-    'test_cmp expected current'
 
 test_expect_success 'partial commit that involves removal (1)' '
 
-- 
1.7.8.rc3

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

* [PATCH 3/4] t7501 (commit): modernize style
  2011-12-07 14:42       ` [PATCH/RFC 0/4] Re: commit: honor --no-edit Jonathan Nieder
  2011-12-07 14:45         ` [PATCH 1/4] test: add missing "&&" after echo command Jonathan Nieder
  2011-12-07 14:49         ` [PATCH 2/4] test: remove a porcelain test that hard-codes commit names Jonathan Nieder
@ 2011-12-07 14:50         ` Jonathan Nieder
  2011-12-07 14:54         ` [PATCH 4/4] test: commit --amend should honor --no-edit Jonathan Nieder
  3 siblings, 0 replies; 27+ messages in thread
From: Jonathan Nieder @ 2011-12-07 14:50 UTC (permalink / raw
  To: Junio C Hamano; +Cc: git, Vijay Lakshminarayanan, Viresh Kumar, Shiraz HASHIM

Put the opening quote starting each test on the same line as the
test_expect_* invocation.  While at it:

- guard commands that prepare test input for individual tests in
  the same test_expect_success, so their scope is clearer and
  errors at that stage can be caught;
- use the compare_diff_patch helper function when comparing patches;
- use single-quotes in preference to double-quotes and <<\EOF in
  preference to <<EOF, to save readers the trouble of looking for
  variable interpolations;
- lift the setting of the $author variable used throughout the
  test script to the top of the test script;
- include "setup" in the titles of test assertions that prepare for
  later ones to make it more obvious which tests can be skipped;
- use test_must_fail instead of "if ...; then:; else false; fi",
  for clarity and to catch segfaults when they happen;
- break up some pipelines into separate commands that read and write
  to ordinary files, and test the exit status at each stage;
- chain commands with &&.  Breaks in a test assertion's && chain can
  potentially hide failures from earlier commands in the chain;
- combine two initial tests that do not make as much sense alone.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Miscellaneous cleanups.

 t/t7501-commit.sh |  278 ++++++++++++++++++++++++++---------------------------
 1 files changed, 136 insertions(+), 142 deletions(-)

diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh
index 9c507b08..bf025df6 100755
--- a/t/t7501-commit.sh
+++ b/t/t7501-commit.sh
@@ -8,39 +8,39 @@
 
 test_description='git commit'
 . ./test-lib.sh
+. "$TEST_DIRECTORY/diff-lib.sh"
+
+author='The Real Author <someguy@his.email.org>'
 
 test_tick
 
-test_expect_success \
-	"initial status" \
-	"echo 'bongo bongo' >file &&
-	 git add file"
-
-test_expect_success "Constructing initial commit" '
+test_expect_success 'initial status' '
+	echo bongo bongo >file &&
+	git add file &&
 	git status >actual &&
 	test_i18ngrep "Initial commit" actual
 '
 
-test_expect_success \
-	"fail initial amend" \
-	"test_must_fail git commit --amend"
+test_expect_success 'fail initial amend' '
+	test_must_fail git commit --amend
+'
 
-test_expect_success \
-	"initial commit" \
-	"git commit -m initial"
+test_expect_success 'setup: initial commit' '
+	git commit -m initial
+'
 
-test_expect_success \
-	"invalid options 1" \
-	"test_must_fail git commit -m foo -m bar -F file"
+test_expect_success '-m and -F do not mix' '
+	test_must_fail git commit -m foo -m bar -F file
+'
 
-test_expect_success \
-	"invalid options 2" \
-	"test_must_fail git commit -C HEAD -m illegal"
+test_expect_success '-m and -C do not mix' '
+	test_must_fail git commit -C HEAD -m illegal
+'
 
-test_expect_success \
-	"using paths with -a" \
-	"echo King of the bongo >file &&
-	test_must_fail git commit -m foo -a file"
+test_expect_success 'paths and -a do not mix' '
+	echo King of the bongo >file &&
+	test_must_fail git commit -m foo -a file
+'
 
 test_expect_success PERL 'can use paths with --interactive' '
 	echo bong-o-bong >file &&
@@ -50,120 +50,123 @@ test_expect_success PERL 'can use paths with --interactive' '
 	git reset --hard HEAD^
 '
 
-test_expect_success \
-	"using invalid commit with -C" \
-	"test_must_fail git commit -C bogus"
-
-test_expect_success \
-	"testing nothing to commit" \
-	"test_must_fail git commit -m initial"
-
-test_expect_success \
-	"next commit" \
-	"echo 'bongo bongo bongo' >file && \
-	 git commit -m next -a"
-
-test_expect_success \
-	"commit message from non-existing file" \
-	"echo 'more bongo: bongo bongo bongo bongo' >file && \
-	 test_must_fail git commit -F gah -a"
-
-# Empty except stray tabs and spaces on a few lines.
-sed -e 's/@$//' >msg <<EOF
-		@
-
-  @
-Signed-off-by: hula
-EOF
-test_expect_success \
-	"empty commit message" \
-	"test_must_fail git commit -F msg -a"
-
-test_expect_success \
-	"commit message from file" \
-	"echo 'this is the commit message, coming from a file' >msg && \
-	 git commit -F msg -a"
-
-cat >editor <<\EOF
-#!/bin/sh
-sed -e "s/a file/an amend commit/g" < "$1" > "$1-"
-mv "$1-" "$1"
-EOF
-chmod 755 editor
-
-test_expect_success \
-	"amend commit" \
-	"EDITOR=./editor git commit --amend"
-
-test_expect_success \
-	"passing -m and -F" \
-	"echo 'enough with the bongos' >file && \
-	 test_must_fail git commit -F msg -m amending ."
-
-test_expect_success \
-	"using message from other commit" \
-	"git commit -C HEAD^ ."
-
-cat >editor <<\EOF
-#!/bin/sh
-sed -e "s/amend/older/g"  < "$1" > "$1-"
-mv "$1-" "$1"
-EOF
-chmod 755 editor
-
-test_expect_success \
-	"editing message from other commit" \
-	"echo 'hula hula' >file && \
-	 EDITOR=./editor git commit -c HEAD^ -a"
-
-test_expect_success \
-	"message from stdin" \
-	"echo 'silly new contents' >file && \
-	 echo commit message from stdin | git commit -F - -a"
-
-test_expect_success \
-	"overriding author from command line" \
-	"echo 'gak' >file && \
-	 git commit -m 'author' --author 'Rubber Duck <rduck@convoy.org>' -a >output 2>&1"
-
-test_expect_success \
-	"commit --author output mentions author" \
-	"grep Rubber.Duck output"
-
-test_expect_success PERL \
-	"interactive add" \
-	"echo 7 | git commit --interactive | grep 'What now'"
-
-test_expect_success PERL \
-	"commit --interactive doesn't change index if editor aborts" \
-	"echo zoo >file &&
+test_expect_success 'using invalid commit with -C' '
+	test_must_fail git commit -C bogus
+'
+
+test_expect_success 'nothing to commit' '
+	test_must_fail git commit -m initial
+'
+
+test_expect_success 'setup: non-initial commit' '
+	echo bongo bongo bongo >file &&
+	git commit -m next -a
+'
+
+test_expect_success 'commit message from non-existing file' '
+	echo more bongo: bongo bongo bongo bongo >file &&
+	test_must_fail git commit -F gah -a
+'
+
+test_expect_success 'empty commit message' '
+	# Empty except stray tabs and spaces on a few lines.
+	sed -e "s/@//g" >msg <<-\EOF &&
+		@		@
+		@@
+		@  @
+		@Signed-off-by: hula@
+	EOF
+	test_must_fail git commit -F msg -a
+'
+
+test_expect_success 'setup: commit message from file' '
+	echo this is the commit message, coming from a file >msg &&
+	git commit -F msg -a
+'
+
+test_expect_success 'amend commit' '
+	cat >editor <<-\EOF &&
+	#!/bin/sh
+	sed -e "s/a file/an amend commit/g" < "$1" > "$1-"
+	mv "$1-" "$1"
+	EOF
+	chmod 755 editor &&
+	EDITOR=./editor git commit --amend
+'
+
+test_expect_success '-m and -F do not mix' '
+	echo enough with the bongos >file &&
+	test_must_fail git commit -F msg -m amending .
+'
+
+test_expect_success 'using message from other commit' '
+	git commit -C HEAD^ .
+'
+
+test_expect_success 'editing message from other commit' '
+	cat >editor <<-\EOF &&
+	#!/bin/sh
+	sed -e "s/amend/older/g"  < "$1" > "$1-"
+	mv "$1-" "$1"
+	EOF
+	chmod 755 editor &&
+	echo hula hula >file &&
+	EDITOR=./editor git commit -c HEAD^ -a
+'
+
+test_expect_success 'message from stdin' '
+	echo silly new contents >file &&
+	echo commit message from stdin |
+	git commit -F - -a
+'
+
+test_expect_success 'overriding author from command line' '
+	echo gak >file &&
+	git commit -m author \
+		--author "Rubber Duck <rduck@convoy.org>" -a >output 2>&1 &&
+	grep Rubber.Duck output
+'
+
+test_expect_success PERL 'interactive add' '
+	echo 7 |
+	git commit --interactive |
+	grep "What now"
+'
+
+test_expect_success PERL "commit --interactive doesn't change index if editor aborts" '
+	echo zoo >file &&
 	test_must_fail git diff --exit-code >diff1 &&
-	(echo u ; echo '*' ; echo q) |
-	(EDITOR=: && export EDITOR &&
-	 test_must_fail git commit --interactive) &&
+	(echo u ; echo "*" ; echo q) |
+	(
+		EDITOR=: &&
+		export EDITOR &&
+		test_must_fail git commit --interactive
+	) &&
 	git diff >diff2 &&
-	test_cmp diff1 diff2"
+	compare_diff_patch diff1 diff2
+'
 
-cat >editor <<\EOF
-#!/bin/sh
-sed -e "s/good/bad/g" < "$1" > "$1-"
-mv "$1-" "$1"
-EOF
-chmod 755 editor
+test_expect_success 'editor not invoked if -F is given' '
+	cat >editor <<-\EOF &&
+	#!/bin/sh
+	sed -e s/good/bad/g <"$1" >"$1-"
+	mv "$1-" "$1"
+	EOF
+	chmod 755 editor &&
 
-cat >msg <<EOF
-A good commit message.
-EOF
+	echo A good commit message. >msg &&
+	echo moo >file &&
 
-test_expect_success \
-	'editor not invoked if -F is given' '
-	 echo "moo" >file &&
-	 EDITOR=./editor git commit -a -F msg &&
-	 git show -s --pretty=format:"%s" | grep -q good &&
-	 echo "quack" >file &&
-	 echo "Another good message." | EDITOR=./editor git commit -a -F - &&
-	 git show -s --pretty=format:"%s" | grep -q good
-	 '
+	EDITOR=./editor git commit -a -F msg &&
+	git show -s --pretty=format:%s >subject &&
+	grep -q good subject &&
+
+	echo quack >file &&
+	echo Another good message. |
+	EDITOR=./editor git commit -a -F - &&
+	git show -s --pretty=format:%s >subject &&
+	grep -q good subject
+'
 
 test_expect_success 'partial commit that involves removal (1)' '
 
@@ -197,7 +200,6 @@ test_expect_success 'partial commit that involves removal (3)' '
 
 '
 
-author="The Real Author <someguy@his.email.org>"
 test_expect_success 'amend commit to fix author' '
 
 	oldtick=$GIT_AUTHOR_DATE &&
@@ -326,7 +328,6 @@ test_expect_success 'multiple -m' '
 
 '
 
-author="The Real Author <someguy@his.email.org>"
 test_expect_success 'amend commit to fix author' '
 
 	oldtick=$GIT_AUTHOR_DATE &&
@@ -353,15 +354,8 @@ test_expect_success 'git commit <file> with dirty index' '
 
 test_expect_success 'same tree (single parent)' '
 
-	git reset --hard
-
-	if git commit -m empty
-	then
-		echo oops -- should have complained
-		false
-	else
-		: happy
-	fi
+	git reset --hard &&
+	test_must_fail git commit -m empty
 
 '
 
-- 
1.7.8.rc3

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

* [PATCH 4/4] test: commit --amend should honor --no-edit
  2011-12-07 14:42       ` [PATCH/RFC 0/4] Re: commit: honor --no-edit Jonathan Nieder
                           ` (2 preceding siblings ...)
  2011-12-07 14:50         ` [PATCH 3/4] t7501 (commit): modernize style Jonathan Nieder
@ 2011-12-07 14:54         ` Jonathan Nieder
  3 siblings, 0 replies; 27+ messages in thread
From: Jonathan Nieder @ 2011-12-07 14:54 UTC (permalink / raw
  To: Junio C Hamano; +Cc: git, Vijay Lakshminarayanan, Viresh Kumar, Shiraz HASHIM

A quick test to make sure git doesn't lose the functionality added by
the recent patch "commit: honor --no-edit", plus another test to check
the classical --edit use case (use with "-m").

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 t/t7501-commit.sh |   40 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh
index bf025df6..c462bf3b 100755
--- a/t/t7501-commit.sh
+++ b/t/t7501-commit.sh
@@ -94,6 +94,46 @@ test_expect_success 'amend commit' '
 	EDITOR=./editor git commit --amend
 '
 
+test_expect_success 'set up editor' '
+	cat >editor <<-\EOF &&
+	#!/bin/sh
+	sed -e "s/unamended/amended/g" <"$1" >"$1-"
+	mv "$1-" "$1"
+	EOF
+	chmod 755 editor
+'
+
+test_expect_success 'amend without launching editor' '
+	echo unamended >expect &&
+	git commit --allow-empty -m "unamended" &&
+	echo needs more bongo >file &&
+	git add file &&
+	EDITOR=./editor git commit --no-edit --amend &&
+	git diff --exit-code HEAD -- file &&
+	git diff-tree -s --format=%s HEAD >msg &&
+	test_cmp expect msg
+'
+
+test_expect_success '--amend --edit' '
+	echo amended >expect &&
+	git commit --allow-empty -m "unamended" &&
+	echo bongo again >file &&
+	git add file &&
+	EDITOR=./editor git commit --edit --amend &&
+	git diff-tree -s --format=%s HEAD >msg &&
+	test_cmp expect msg
+'
+
+test_expect_success '-m --edit' '
+	echo amended >expect &&
+	git commit --allow-empty -m buffer &&
+	echo bongo bongo >file &&
+	git add file &&
+	EDITOR=./editor git commit -m unamended --edit &&
+	git diff-tree -s  --format=%s HEAD >msg &&
+	test_cmp expect msg
+'
+
 test_expect_success '-m and -F do not mix' '
 	echo enough with the bongos >file &&
 	test_must_fail git commit -F msg -m amending .
-- 
1.7.8.rc3

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

* Re: Query on git commit amend
  2011-12-07  5:45           ` Viresh Kumar
@ 2011-12-07 15:06             ` Vijay Lakshminarayanan
  2011-12-08 17:52             ` Junio C Hamano
  1 sibling, 0 replies; 27+ messages in thread
From: Vijay Lakshminarayanan @ 2011-12-07 15:06 UTC (permalink / raw
  To: Viresh Kumar
  Cc: Björn Steinbrink, Junio C Hamano, git@vger.kernel.org,
	Shiraz HASHIM, Vipin KUMAR

Viresh Kumar <viresh.kumar@st.com> writes:

[snip]

> Now, whats the benefit of 
>
> GIT_EDITOR=cat git commit --amend
>
> over
>
> git commit --amend -C HEAD
>
> ?

The latter preserves the original timestamp of the commit and other
environment variables like GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL
whereas GIT_EDITOR=cat (or true or :) are equivalent to opening up the
commit in an editor and so consider these variables during execution.

For instance, you could say

$ GIT_EDITOR=cat GIT_COMMITTER_EMAIL=foo@bar.baz git commit --amend

and the commiter email would be set to foo@bar.baz

-- 
Cheers
~vijay

Gnus should be more complicated.

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

* Re: [PATCH 1/4] test: add missing "&&" after echo command
  2011-12-07 14:45         ` [PATCH 1/4] test: add missing "&&" after echo command Jonathan Nieder
@ 2011-12-07 23:10           ` Jeff King
  2011-12-07 23:11             ` Jeff King
  0 siblings, 1 reply; 27+ messages in thread
From: Jeff King @ 2011-12-07 23:10 UTC (permalink / raw
  To: Jonathan Nieder
  Cc: Junio C Hamano, git, Vijay Lakshminarayanan, Viresh Kumar,
	Shiraz HASHIM

On Wed, Dec 07, 2011 at 08:45:40AM -0600, Jonathan Nieder wrote:

> diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh
> index 3ad04363..da75abc1 100755
> --- a/t/t7501-commit.sh
> +++ b/t/t7501-commit.sh
> @@ -60,7 +60,7 @@ test_expect_success \
>  
>  test_expect_success \
>  	"next commit" \
> -	"echo 'bongo bongo bongo' >file \
> +	"echo 'bongo bongo bongo' >file && \
>  	 git commit -m next -a"

Patch is obviously correct, but isn't the "\" here just superfluous and
error-prone? Maybe it should just be dropped from the new version (and
possibly from other tests in t7501).

-Peff

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

* Re: [PATCH 1/4] test: add missing "&&" after echo command
  2011-12-07 23:10           ` Jeff King
@ 2011-12-07 23:11             ` Jeff King
  0 siblings, 0 replies; 27+ messages in thread
From: Jeff King @ 2011-12-07 23:11 UTC (permalink / raw
  To: Jonathan Nieder
  Cc: Junio C Hamano, git, Vijay Lakshminarayanan, Viresh Kumar,
	Shiraz HASHIM

On Wed, Dec 07, 2011 at 06:10:03PM -0500, Jeff King wrote:

> On Wed, Dec 07, 2011 at 08:45:40AM -0600, Jonathan Nieder wrote:
> 
> > diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh
> > index 3ad04363..da75abc1 100755
> > --- a/t/t7501-commit.sh
> > +++ b/t/t7501-commit.sh
> > @@ -60,7 +60,7 @@ test_expect_success \
> >  
> >  test_expect_success \
> >  	"next commit" \
> > -	"echo 'bongo bongo bongo' >file \
> > +	"echo 'bongo bongo bongo' >file && \
> >  	 git commit -m next -a"
> 
> Patch is obviously correct, but isn't the "\" here just superfluous and
> error-prone? Maybe it should just be dropped from the new version (and
> possibly from other tests in t7501).

Oh, nevermind. I just read your patch 3, which does that and much more.
I approve.

-Peff

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

* Re: Query on git commit amend
  2011-12-06 15:46 ` Vijay Lakshminarayanan
  2011-12-06 19:11   ` Jeff King
  2011-12-06 20:03   ` Junio C Hamano
@ 2011-12-08  5:26   ` Viresh Kumar
  2011-12-08  5:30     ` Viresh Kumar
  2 siblings, 1 reply; 27+ messages in thread
From: Viresh Kumar @ 2011-12-08  5:26 UTC (permalink / raw
  To: Junio C Hamano, Vipin KUMAR
  Cc: Vijay Lakshminarayanan, git@vger.kernel.org, Shiraz HASHIM

On 12/6/2011 9:16 PM, Vijay Lakshminarayanan wrote:
> I've found 
> 
> $ GIT_EDITOR=cat git commit --amend
> 
> useful.
> 
> The benefit of this technique is that it even works for git-rebase -i.
> 
> In my typical git usage, I do a lot of git-commit --fixup's.  After
> reaching a level of stability, I change the history with:
> 
> GIT_EDITOR=cat git rebase -i --autosquash
> 
> and my history is adjusted without requiring manual intervention.

Hi Junio,

After going through autosquash option for rebase, i was wondering
if there is a way to create a new commit easily for autosquash.

For autosquash to work, we need to keep the same commit log/title,
prefixed with squash! or Fixup! etc. What about adding another option
in commit amend which adds squash! or Fixup! automatically. So, manual
intervention at all. :)

I don't know if it already exist.

-- 
viresh

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

* Re: Query on git commit amend
  2011-12-08  5:26   ` Viresh Kumar
@ 2011-12-08  5:30     ` Viresh Kumar
  0 siblings, 0 replies; 27+ messages in thread
From: Viresh Kumar @ 2011-12-08  5:30 UTC (permalink / raw
  To: Junio C Hamano
  Cc: Vipin KUMAR, Vijay Lakshminarayanan, git@vger.kernel.org,
	Shiraz HASHIM

On 12/8/2011 10:56 AM, Viresh Kumar wrote:
> For autosquash to work, we need to keep the same commit log/title,
> prefixed with squash! or Fixup! etc. What about adding another option
> in commit amend which adds squash! or Fixup! automatically. So, manual
> intervention at all. :)

Done. It is already there in git commit.

-- 
viresh

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

* Re: Query on git commit amend
  2011-12-07  5:45           ` Viresh Kumar
  2011-12-07 15:06             ` Vijay Lakshminarayanan
@ 2011-12-08 17:52             ` Junio C Hamano
  2011-12-09  4:49               ` Viresh Kumar
  1 sibling, 1 reply; 27+ messages in thread
From: Junio C Hamano @ 2011-12-08 17:52 UTC (permalink / raw
  To: Viresh Kumar
  Cc: Björn Steinbrink, Vijay Lakshminarayanan,
	git@vger.kernel.org, Shiraz HASHIM, Vipin KUMAR

Viresh Kumar <viresh.kumar@st.com> writes:

> GIT_EDITOR=cat git commit --amend
>
> over
>
> git commit --amend -C HEAD
>
> ?
>
> ...
> But for single commit probably second one looks easier. Isn't it?

I saw "--amend -C HEAD" mentioned in some newbie-guide webpages, and I
think you just copy/learned from one of them, so it is not entirely your
fault, but the combination of --amend and "-C HEAD" is an idiotic thing
that happens to work, if you think about what exactly you are telling to
the command.

The point of --amend is twofold. One is to let you tweak the contents of
what is committed, which is not the topic of this thread, and the other is
to allow the user to reuse the log message from the commit being amended,
instead of typing the message from scratch.

The "-c <commit>" and its cousin "-C <commit>" options are about telling
Git that the user does _not_ want the other usual logic to come up with
the initial commit template (e.g. when committing anew, it may read the
log template file, when committing a merge, it may read the MERGE_MSG
prepared by fmt-merge-msg, and most importantly in this context, when
amending, the one that is prepared by the --amend logic is used) kick in
at all, and instead wants to start from the log message of the named
commit.

So by saying "--amend -C HEAD" you are saying "I want to reuse the log
message of the commit I am amending,... eh, scratch that, I instead want
to use the log message of the HEAD commit", as if the commit you are
amending and HEAD are two different things. That is idiotic.

And you say that only for the side effect that capital "-C" stops the
editor.

Compared to that idiotic statement, "EDITOR=: git commit --amend" is a lot
saner way to say the same thing in a more direct and straightforward
way. "I want to reuse the log message of the commit I am amending, and the
editor to use it while running that commit is the command 'true', i.e. the
one that does not really touch any line in the text file and successfully
exits, because I am not going to change anything".

Of course, if "git commit --amend" honoured "--no-edit", that is even more
direct, straightforward and intuitive way to say so ;-)

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

* Re: Query on git commit amend
  2011-12-08 17:52             ` Junio C Hamano
@ 2011-12-09  4:49               ` Viresh Kumar
  0 siblings, 0 replies; 27+ messages in thread
From: Viresh Kumar @ 2011-12-09  4:49 UTC (permalink / raw
  To: Junio C Hamano
  Cc: Björn Steinbrink, Vijay Lakshminarayanan,
	git@vger.kernel.org, Shiraz HASHIM, Vipin KUMAR

On 12/8/2011 11:22 PM, Junio C Hamano wrote:
> So by saying "--amend -C HEAD" you are saying "I want to reuse the log
> message of the commit I am amending,... eh, scratch that, I instead want
> to use the log message of the HEAD commit", as if the commit you are
> amending and HEAD are two different things. That is idiotic.
> 
> Of course, if "git commit --amend" honoured "--no-edit", that is even more
> direct, straightforward and intuitive way to say so ;-)

Got your point. That's correct.

-- 
viresh

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

end of thread, other threads:[~2011-12-09  4:49 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-06  8:23 Query on git commit amend Viresh Kumar
2011-12-06  9:01 ` Konstantin Khomoutov
2011-12-06 19:09   ` Dirk Süsserott
2011-12-06  9:11 ` Johannes Sixt
2011-12-06  9:20   ` Viresh Kumar
2011-12-06  9:22     ` Viresh Kumar
2011-12-06 15:46 ` Vijay Lakshminarayanan
2011-12-06 19:11   ` Jeff King
2011-12-07  2:18     ` Vijay Lakshminarayanan
2011-12-06 20:03   ` Junio C Hamano
2011-12-06 21:00     ` Junio C Hamano
2011-12-07 14:42       ` [PATCH/RFC 0/4] Re: commit: honor --no-edit Jonathan Nieder
2011-12-07 14:45         ` [PATCH 1/4] test: add missing "&&" after echo command Jonathan Nieder
2011-12-07 23:10           ` Jeff King
2011-12-07 23:11             ` Jeff King
2011-12-07 14:49         ` [PATCH 2/4] test: remove a porcelain test that hard-codes commit names Jonathan Nieder
2011-12-07 14:50         ` [PATCH 3/4] t7501 (commit): modernize style Jonathan Nieder
2011-12-07 14:54         ` [PATCH 4/4] test: commit --amend should honor --no-edit Jonathan Nieder
2011-12-07  2:28     ` Query on git commit amend Vijay Lakshminarayanan
2011-12-07  4:20       ` Viresh Kumar
2011-12-07  4:53         ` Björn Steinbrink
2011-12-07  5:45           ` Viresh Kumar
2011-12-07 15:06             ` Vijay Lakshminarayanan
2011-12-08 17:52             ` Junio C Hamano
2011-12-09  4:49               ` Viresh Kumar
2011-12-08  5:26   ` Viresh Kumar
2011-12-08  5:30     ` Viresh Kumar

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).