diff options
author | Cornelius Weig <cornelius.weig@tngtech.com> | 2017-01-27 11:09:47 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-01-31 10:01:24 -0800 |
commit | 341fb28621201c5e6c9d3fee5baf7c532fa8a618 (patch) | |
tree | 1968a421d74a50dcc53304dd0196af5cf76b8d14 /builtin/checkout.c | |
parent | config: add markup to core.logAllRefUpdates doc (diff) | |
download | tgif-341fb28621201c5e6c9d3fee5baf7c532fa8a618.tar.xz |
refs: add option core.logAllRefUpdates = always
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) are not meant to change, and
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).
Based-on-patch-by: Jeff King <peff@peff.net>
Signed-off-by: Cornelius Weig <cornelius.weig@tngtech.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/checkout.c')
-rw-r--r-- | builtin/checkout.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c index bfe685c198..569912c3ab 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -612,22 +612,25 @@ 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) { + char *refname; + + 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); strbuf_release(&err); + free(refname); return; } strbuf_release(&err); } + free(refname); } else create_branch(opts->new_branch, new->name, |