diff options
author | Junio C Hamano <gitster@pobox.com> | 2015-08-03 11:01:29 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-08-03 11:01:29 -0700 |
commit | b6d323f1646d7204fc6693071e5be84377ece70b (patch) | |
tree | bb917f3763b586c34dc8fb03fb4bc9c8132e4632 /builtin/checkout.c | |
parent | Merge branch 'as/sparse-checkout-removal' (diff) | |
parent | git-stash: use update-ref --create-reflog instead of creating files (diff) | |
download | tgif-b6d323f1646d7204fc6693071e5be84377ece70b.tar.xz |
Merge branch 'dt/refs-backend-preamble'
In preparation for allowing different "backends" to store the refs
in a way different from the traditional "one ref per file in $GIT_DIR
or in a $GIT_DIR/packed-refs file" filesystem storage, reduce
direct filesystem access to ref-like things like CHERRY_PICK_HEAD
from scripts and programs.
* dt/refs-backend-preamble:
git-stash: use update-ref --create-reflog instead of creating files
update-ref and tag: add --create-reflog arg
refs: add REF_FORCE_CREATE_REFLOG flag
git-reflog: add exists command
refs: new public ref function: safe_create_reflog
refs: break out check for reflog autocreation
refs.c: add err arguments to reflog functions
Diffstat (limited to 'builtin/checkout.c')
-rw-r--r-- | builtin/checkout.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c index f71844a23a..9ff5ca4cbe 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -612,22 +612,20 @@ static void update_refs_for_switch(const struct checkout_opts *opts, if (opts->new_branch) { if (opts->new_orphan_branch) { if (opts->new_branch_log && !log_all_ref_updates) { - int temp; - struct strbuf log_file = STRBUF_INIT; int ret; - const char *ref_name; - - ref_name = mkpath("refs/heads/%s", opts->new_orphan_branch); - temp = log_all_ref_updates; - log_all_ref_updates = 1; - ret = log_ref_setup(ref_name, &log_file); - log_all_ref_updates = temp; - strbuf_release(&log_file); + 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'\n"), - opts->new_orphan_branch); + fprintf(stderr, _("Can not do reflog for '%s': %s\n"), + opts->new_orphan_branch, err.buf); + strbuf_release(&err); return; } + strbuf_release(&err); } } else |