git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] commit -c/-C/--amend: reset timestamp and authorship to committer with --reset-author

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 4, 2009, 01:12 UTC
Message-ID
<7vd43znldw.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20091104073822.6117@nanako3.lavabit.com>
Nanako Shiraishi <nanako3@lavabit.com> writes:
> I think it is much better to replace "--mine" in gmane/131893 
> with "--reset-author" and make no other change to the test.

Heh, I would not claim my tests were perfect, even though I agree with most of the suggestions and comments, including the parts I did not quote that are not about the test script.

My first test did not check the message contents, but all the other ones (except the last one that we expect the command to fail) check output from both author_header and message_body, so that not just "--mine affects the authorship" but also "--mine does not mangle the message contents" are checked.

One thing you did not mention was that I made sure that the command failed when given both --mine and --author options; I think Erick's last round fails to test this condition.

    Side note.  When writing tests for their shiny new toy, people often
    forget to test "the other side".
    It is just human nature.  It is more fun to demonstrate what your new
    feature does, than making sure that the new feature does not kick in
    when it is not supposed to, nor it does not change what it is not
    supposed to change.
    Negative tests are not particularly hard to write.  The harder part is
    to force the habit of writing them on yourself.  Right after designing
    and implementing a new feature, the list of things it is supposed to
    do and when it is supposed to kick in are pretty clear in your mind,
    and that is what makes writing positive tests psychologically a lot
    easier.
    On the other hand, it takes concious effort to list what it is _not_
    supposed to do or when it is _not_ supposed to kick in.  That is why
    people often fail to write negative tests.

I think in addition to the obvious "s/--mine/--reset-author/g" replacements, we would need this patch on top of mine.

 t/t7509-commit.sh |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/t/t7509-commit.sh b/t/t7509-commit.sh
index ec13cea..1dad228 100755
--- a/t/t7509-commit.sh
+++ b/t/t7509-commit.sh
@@ -28,6 +28,10 @@ test_expect_success '-C option copies authorship and message' '
 	git commit -a -C Initial &&
 	author_header Initial >expect &&
 	author_header HEAD >actual &&
+	test_cmp expect actual &&
+
+	message_body Initial >expect &&
+	message_body HEAD >actual &&
 	test_cmp expect actual
 '
 
Previous: Erick Mattos
Message 6 of 6 in “commit -c/-C/--amend: reset timestamp and authorship to committer with --reset-author”
  1. commit -c/-C/--amend: reset timestamp and authorship to committer with --reset-authorErick Mattos, Nov 3, 2009
  2. Nanako ShiraishiNov 3, 2009
  3. Erick MattosNov 3, 2009
  4. Junio C HamanoNov 4, 2009
  5. Erick MattosNov 4, 2009
  6. Junio C HamanoNov 4, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.