From: Junio C Hamano <gitster@pobox.com>
To: cornelius.weig@tngtech.com
Cc: peff@peff.net, git@vger.kernel.org
Subject: Re: [PATCH v3 2/3] refs: add option core.logAllRefUpdates = always
Date: Mon, 30 Jan 2017 13:58:10 -0800 [thread overview]
Message-ID: <xmqq37g0us5p.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20170127100948.29408-2-cornelius.weig@tngtech.com> (cornelius weig's message of "Fri, 27 Jan 2017 11:09:47 +0100")
cornelius.weig@tngtech.com writes:
> Notes:
> Changes wrt v2:
>
> - change wording in commit message s/do not typically/are not meant to/;
> - in update_refs_for_switch move refname to the enclosing block, so that
> should_autocreate_reflog has access. Thanks Junio for spotting this
> potential bug early :)
> - add test that asserts reflogs are created for tags if
> logAllRefUpdates=always. The case with logAllRefUpdates=true is IMHO already
> covered by the default case. To make that clearer, I explicitly added
> logAllRefUpdates=true.
These look all sensible. Especially thanks for reordering the code
to feed the real refname for the new branch in the "checkout"
codepath.
> When writing the test for git-tag, I realized that the option
> --no-create-reflog to git-tag does not take precedence over
> logAllRefUpdate=always. IOW the setting cannot be overridden on the command
> line. Do you think this is a defect or would it not be desirable to have this
> feature anyway?
"--no-create-reflog" should override the configuration set to "true"
or "always". Also "--create-reflog" should override the
configuration set to "false".
If the problem was inherited from the original code before your
change (e.g. you set logAllRefUpdates to true and then did
"update-ref --no-create-reflog refs/heads/foo". Does the code
before your change ignore the command lne option and create a reflog
for the branch?), then it would be ideal to fix the bug before this
series as a preparatory fix. If the problem was introduced by this
patch set, then we would need a fix not to introduce it ;-)
> diff --git a/builtin/checkout.c b/builtin/checkout.c
> index bfe685c..81ea2ed 100644
> --- a/builtin/checkout.c
> +++ b/builtin/checkout.c
> @@ -612,14 +612,12 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
> const char *old_desc, *reflog_msg;
> if (opts->new_branch) {
> if (opts->new_orphan_branch) {
> - if (opts->new_branch_log && !log_all_ref_updates) {
> + const char *refname = mkpathdup("refs/heads/%s", opts->new_orphan_branch);
> + if (opts->new_branch_log && should_autocreate_reflog(refname)) {
> int ret;
> - char *refname;
> struct strbuf err = STRBUF_INIT;
>
> - refname = mkpathdup("refs/heads/%s", opts->new_orphan_branch);
> ret = safe_create_reflog(refname, 1, &err);
> - free(refname);
> if (ret) {
> fprintf(stderr, _("Can not do reflog for '%s': %s\n"),
> opts->new_orphan_branch, err.buf);
Here you need to have another free(), as this block makes an early
return and you end up leaking refname.
> diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
> index 1cfa8a2..1bf622d 100755
> --- a/t/t7004-tag.sh
> +++ b/t/t7004-tag.sh
> @@ -71,6 +71,7 @@ test_expect_success 'creating a tag for an unknown revision should fail' '
>
> # commit used in the tests, test_tick is also called here to freeze the date:
> test_expect_success 'creating a tag using default HEAD should succeed' '
> + test_config core.logAllRefUpdates true &&
> test_tick &&
> echo foo >foo &&
> git add foo &&
This change is to make sure that 'true' does not affect tags (but
'always' does as seen in the later new test)? I am just double
checking, not objecting.
Thanks.
next prev parent reply other threads:[~2017-01-30 21:58 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-25 0:19 [PATCH] tag: add tag.createReflog option cornelius.weig
2017-01-25 5:06 ` Pranit Bauva
2017-01-25 18:00 ` Jeff King
2017-01-25 18:10 ` Junio C Hamano
2017-01-25 21:21 ` Cornelius Weig
2017-01-25 21:33 ` Jeff King
2017-01-25 21:43 ` Junio C Hamano
2017-01-25 22:56 ` Junio C Hamano
2017-01-25 23:40 ` Cornelius Weig
2017-01-26 1:16 ` [PATCH] refs: add option core.logAllRefUpdates = always cornelius.weig
2017-01-26 1:16 ` cornelius.weig
2017-01-26 3:35 ` Jeff King
2017-01-26 14:06 ` Cornelius Weig
2017-01-26 14:46 ` Jeff King
2017-01-26 22:31 ` [PATCH v2 1/3] config: add markup to core.logAllRefUpdates doc cornelius.weig
2017-01-26 22:31 ` [PATCH v2 2/3] refs: add option core.logAllRefUpdates = always cornelius.weig
2017-01-26 23:39 ` Junio C Hamano
2017-01-26 22:31 ` [PATCH v2 3/3] update-ref: add test cases for bare repository cornelius.weig
2017-01-26 23:41 ` Junio C Hamano
2017-01-26 23:24 ` [PATCH v2 1/3] config: add markup to core.logAllRefUpdates doc Junio C Hamano
2017-01-27 10:09 ` [PATCH v3 " cornelius.weig
2017-01-27 10:09 ` [PATCH v3 2/3] refs: add option core.logAllRefUpdates = always cornelius.weig
2017-01-30 21:58 ` Junio C Hamano [this message]
2017-01-30 22:57 ` Junio C Hamano
2017-01-31 13:16 ` Cornelius Weig
2017-01-31 17:11 ` Junio C Hamano
2017-01-30 23:37 ` Jeff King
2017-01-31 14:00 ` Cornelius Weig
2017-01-31 18:21 ` Jeff King
2017-01-31 17:08 ` Junio C Hamano
2017-01-31 20:28 ` Cornelius Weig
2017-01-31 22:02 ` Junio C Hamano
2017-01-27 10:09 ` [PATCH v3 3/3] update-ref: add test cases for bare repository cornelius.weig
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=xmqq37g0us5p.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=cornelius.weig@tngtech.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
/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).