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
This commit is contained in:
@ -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;
|
||||
char *refname;
|
||||
struct strbuf err = STRBUF_INIT;
|
||||
|
||||
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);
|
||||
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
|
||||
|
Reference in New Issue
Block a user