From: Junio C Hamano <gitster@pobox.com>
To: cornelius.weig@tngtech.com
Cc: peff@peff.net, git@vger.kernel.org
Subject: Re: [PATCH v2 2/3] refs: add option core.logAllRefUpdates = always
Date: Thu, 26 Jan 2017 15:39:37 -0800 [thread overview]
Message-ID: <xmqqr33p1jd2.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20170126223159.16439-2-cornelius.weig@tngtech.com> (cornelius weig's message of "Thu, 26 Jan 2017 23:31:58 +0100")
cornelius.weig@tngtech.com writes:
> From: Cornelius Weig <cornelius.weig@tngtech.com>
>
> When core.logallrefupdates is true, we only create a new reflog for refs
> that are under certain well-known hierarchies. The reason is that we
> know that some hierarchies (like refs/tags) do not typically change, and
s/do not typically/are not meant to/;
> that unknown hierarchies might not want reflogs at all (e.g., a
> hypothetical refs/foo might be meant to change often and drop old
> history immediately).
>
> However, sometimes it is useful to override this decision and simply log
> for all refs, because the safety and audit trail is more important than
> the performance implications of keeping the log around.
>
> This patch introduces a new "always" mode for the core.logallrefupdates
> option which will log updates to everything under refs/, regardless
> where in the hierarchy it is (we still will not log things like
> ORIG_HEAD and FETCH_HEAD, which are known to be transient).
OK.
> diff --git a/Documentation/config.txt b/Documentation/config.txt
> index 3cd8030..2117616 100644
> --- a/Documentation/config.txt
> +++ b/Documentation/config.txt
> @@ -522,6 +522,8 @@ core.logAllRefUpdates::
> refs/heads/), remote refs (i.e. under refs/remotes/),
> `refs/heads/`), remote refs (i.e. under `refs/remotes/`),
Ahh, the answer to my question on 1/3 is "no, the commit that the
patch was taken out of was already wrong, still having the old line
in front of its rewrite".
> note refs (i.e. under `refs/notes/`), and the symbolic ref `HEAD`.
> + If it is set to `always`, then a missing reflog is automatically
> + created for any ref under `refs/`.
> +
OK.
> diff --git a/Documentation/git-tag.txt b/Documentation/git-tag.txt
> index 5055a96..2ac25a9 100644
> --- a/Documentation/git-tag.txt
> +++ b/Documentation/git-tag.txt
> @@ -150,7 +150,8 @@ This option is only applicable when listing tags without annotation lines.
> 'strip' removes both whitespace and commentary.
>
> --create-reflog::
> - Create a reflog for the tag.
> + Create a reflog for the tag. To globally enable reflogs for tags, see
> + `core.logAllRefUpdates` in linkgit:git-config[1].
OK.
> diff --git a/builtin/checkout.c b/builtin/checkout.c
> index bfe685c..1db0b44 100644
> --- a/builtin/checkout.c
> +++ b/builtin/checkout.c
> @@ -612,7 +612,7 @@ 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) {
> + if (opts->new_branch_log && should_autocreate_reflog("refs/heads/")) {
This is inviting a maintenance nightmare. The helper function is
defined to take the final refname, not a leading directory name.
That is why you named the parameter "refname" in your patch like
this:
--- a/refs.h
+++ b/refs.h
@@ -64,6 +64,8 @@ int read_ref(const char *refname, unsigned char *sha1);
int ref_exists(const char *refname);
+int should_autocreate_reflog(const char *refname);
+
int is_branch(const char *refname);
The callers are not supposed to know that its current implementation
happens to only use the leading prefix. When the definition of this
helper function is changed (e.g. imagine a future where this
"log.allrefupdate" is further enhanced to take glob patterns to
match the refname against), this may break and nobody would notice
for a few weeks, and we will get a regression report after a release
is made.
Don't we have the refname for the branch already in this codepath?
> diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh
> index d4fb977..b9084ca 100755
> --- a/t/t1400-update-ref.sh
> +++ b/t/t1400-update-ref.sh
> @@ -93,6 +93,42 @@ test_expect_success 'update-ref creates reflogs with --create-reflog' '
> git reflog exists $outside
> '
>
> +test_expect_success 'core.logAllRefUpdates=true does not create reflog by default' '
> + test_config core.logAllRefUpdates true &&
> + test_when_finished "git update-ref -d $outside" &&
> + git update-ref $outside $A &&
> + git rev-parse $A >expect &&
> + git rev-parse $outside >actual &&
> + test_cmp expect actual &&
> + test_must_fail git reflog exists $outside
> +'
> +
> +test_expect_success 'core.logAllRefUpdates=always creates reflog by default' '
> + test_config core.logAllRefUpdates always &&
> + test_when_finished "git update-ref -d $outside" &&
> + git update-ref $outside $A &&
> + git rev-parse $A >expect &&
> + git rev-parse $outside >actual &&
> + test_cmp expect actual &&
> + git reflog exists $outside
> +'
You might want to add two tests for your original motivation, i.e.
test_config core.logAllRefUpdates always &&
git tag a-tag &&
git reflog exists refs/tags/a-tag
and the other one that does not give reflog for a tag.
Other than that, looks good to me.
next prev parent reply other threads:[~2017-01-26 23:41 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 [this message]
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
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=xmqqr33p1jd2.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).