From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Paul Tan <pyokagan@gmail.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] reset cached ident date before creating objects
Date: Mon, 1 Aug 2016 14:12:34 -0400 [thread overview]
Message-ID: <20160801181233.wycskha3mrribx7s@sigill.intra.peff.net> (raw)
In-Reply-To: <xmqq7fc0l6aw.fsf@gitster.mtv.corp.google.com>
On Mon, Aug 01, 2016 at 10:58:47AM -0700, Junio C Hamano wrote:
> diff --git a/commit.c b/commit.c
> index b02f3c4..db24013 100644
> --- a/commit.c
> +++ b/commit.c
> @@ -1543,7 +1543,6 @@ int commit_tree_extended(const char *msg, size_t msg_len,
> }
>
> /* Person/date information */
> - reset_ident_date();
> if (!author)
> author = git_author_info(IDENT_STRICT);
> strbuf_addf(&buffer, "author %s\n", author);
> @@ -1564,11 +1563,21 @@ int commit_tree_extended(const char *msg, size_t msg_len,
> if (encoding_is_utf8 && !verify_utf8(&buffer))
> fprintf(stderr, commit_utf8_warn);
>
> - if (sign_commit && do_sign_commit(&buffer, sign_commit))
> - return -1;
> + if (sign_commit && do_sign_commit(&buffer, sign_commit)) {
> + result = -1;
> + goto out;
> + }
>
> result = write_sha1_file(buffer.buf, buffer.len, commit_type, ret);
> +
> +out:
> strbuf_release(&buffer);
> +
> + /*
> + * Reset the default timestamp for the next call to create tag/commit
> + * object, so that they get their own fresh timestamp.
> + */
> + reset_ident_date();
> return result;
> }
Before I switched to "reset at the beginning" in my original patch, I
also noticed this issue, but decided the other way: to only reset after
a successful creation.
I think in most cases it wouldn't matter anyway, because the caller will
generally abort as soon as this returns failure anyway. But I wondered
about something like:
author = prepare_author_info();
if (commit_tree_extended(..., author, ...) < 0) {
/* oops, we failed. Do a thing and try again. */
possible_fix();
if (commit_tree_extended(..., author, ...) < 0)
die("giving up");
}
In the second call (but only the second call!) the committer and author
can diverge.
-Peff
next prev parent reply other threads:[~2016-08-01 18:14 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-28 23:35 Small trivial annoyance with the nice new builtin "git am" Linus Torvalds
2016-07-28 23:47 ` Junio C Hamano
2016-07-29 0:29 ` Jeff King
2016-07-29 0:37 ` Linus Torvalds
2016-07-29 15:50 ` Jeff King
2016-07-29 17:15 ` Junio C Hamano
2016-07-29 18:05 ` [PATCH] reset cached ident date before creating objects Jeff King
2016-07-29 18:12 ` Linus Torvalds
2016-07-29 18:15 ` Junio C Hamano
2016-07-29 18:25 ` Jeff King
2016-07-30 2:11 ` Paul Tan
2016-07-30 2:41 ` Jeff King
2016-08-01 17:49 ` Junio C Hamano
2016-08-01 17:58 ` Junio C Hamano
2016-08-01 18:12 ` Jeff King [this message]
2016-08-01 18:17 ` Jeff King
2016-08-01 18:00 ` Jeff King
2016-08-01 19:37 ` Jeff King
2016-08-01 21:54 ` Junio C Hamano
2016-08-01 22:00 ` Jeff King
2016-07-29 18:10 ` Small trivial annoyance with the nice new builtin "git am" Junio C Hamano
2016-07-29 17:06 ` Junio C Hamano
2016-07-29 0:21 ` Jeff King
2016-07-29 0:32 ` Linus Torvalds
2016-07-29 8:19 ` Christian Couder
2016-07-29 17:18 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160801181233.wycskha3mrribx7s@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=pyokagan@gmail.com \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).