git-reflog: add exists command
[gitweb.git] / builtin / checkout.c
index 8faa2d141dc8760457137805bcc6e73c76da88f7..3eaa73b983f8b209ccfa94f7d436fc7296856c87 100644 (file)
@@ -619,24 +619,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, &err);
-                               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': %s\n"),
                                                opts->new_orphan_branch, err.buf);
                                        strbuf_release(&err);
                                        return;
                                }
+                               strbuf_release(&err);
                        }
                }
                else