]> git.ipfire.org Git - thirdparty/git.git/commitdiff
refs: drop force_create argument of create_reflog API
authorHan-Wen Nienhuys <hanwen@google.com>
Mon, 22 Nov 2021 14:19:08 +0000 (14:19 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 22 Nov 2021 19:01:25 +0000 (11:01 -0800)
There is only one caller, builtin/checkout.c, and it hardcodes
force_create=1.

This argument was introduced in abd0cd3a301 (refs: new public ref function:
safe_create_reflog, 2015-07-21), which promised to immediately use it in a
follow-on commit, but that never happened.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/checkout.c
refs.c
refs.h
refs/debug.c
refs/files-backend.c
refs/packed-backend.c
refs/refs-internal.h
t/helper/test-ref-store.c
t/t1405-main-ref-store.sh
t/t1406-submodule-ref-store.sh

index cbf73b8c9f65ae2fdd1d96265bd4972aeaa9bd68..19d752847f8e54c0789a792bbd51a34d6002c933 100644 (file)
@@ -874,7 +874,7 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
                                int ret;
                                struct strbuf err = STRBUF_INIT;
 
-                               ret = safe_create_reflog(refname, 1, &err);
+                               ret = safe_create_reflog(refname, &err);
                                if (ret) {
                                        fprintf(stderr, _("Can not do reflog for '%s': %s\n"),
                                                opts->new_orphan_branch, err.buf);
diff --git a/refs.c b/refs.c
index d7cc0a23a3b65502242650cce698179e3cca27d4..cc291ee49fc1c6a4e1ea98655a9fb4858f867c30 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -2358,16 +2358,15 @@ int reflog_exists(const char *refname)
 }
 
 int refs_create_reflog(struct ref_store *refs, const char *refname,
-                      int force_create, struct strbuf *err)
+                      struct strbuf *err)
 {
-       return refs->be->create_reflog(refs, refname, force_create, err);
+       return refs->be->create_reflog(refs, refname, err);
 }
 
-int safe_create_reflog(const char *refname, int force_create,
-                      struct strbuf *err)
+int safe_create_reflog(const char *refname, struct strbuf *err)
 {
        return refs_create_reflog(get_main_ref_store(the_repository), refname,
-                                 force_create, err);
+                                 err);
 }
 
 int refs_delete_reflog(struct ref_store *refs, const char *refname)
diff --git a/refs.h b/refs.h
index d5099d4984ef9c9fe248897528344ab9019eba65..bd3836c97efc6fd893bd61dbf9a276512c235a0b 100644 (file)
--- a/refs.h
+++ b/refs.h
@@ -413,8 +413,8 @@ int refs_pack_refs(struct ref_store *refs, unsigned int flags);
  * Setup reflog before using. Fill in err and return -1 on failure.
  */
 int refs_create_reflog(struct ref_store *refs, const char *refname,
-                      int force_create, struct strbuf *err);
-int safe_create_reflog(const char *refname, int force_create, struct strbuf *err);
+                      struct strbuf *err);
+int safe_create_reflog(const char *refname, struct strbuf *err);
 
 /** Reads log for the value of ref during at_time. **/
 int read_ref_at(struct ref_store *refs,
index 8667c64023784051169451517d55f4055e3919aa..756d07c72475fcc4c23d3067611ba94d53adeb64 100644 (file)
@@ -339,11 +339,10 @@ static int debug_reflog_exists(struct ref_store *ref_store, const char *refname)
 }
 
 static int debug_create_reflog(struct ref_store *ref_store, const char *refname,
-                              int force_create, struct strbuf *err)
+                              struct strbuf *err)
 {
        struct debug_ref_store *drefs = (struct debug_ref_store *)ref_store;
-       int res = drefs->refs->be->create_reflog(drefs->refs, refname,
-                                                force_create, err);
+       int res = drefs->refs->be->create_reflog(drefs->refs, refname, err);
        trace_printf_key(&trace_refs, "create_reflog: %s: %d\n", refname, res);
        return res;
 }
index 151b0056fe57d41acdacdcf4e8dfc16a43d82b96..00f596dd68c7f6891de3538a8458c3423584738f 100644 (file)
@@ -1639,15 +1639,14 @@ error:
        return -1;
 }
 
-static int files_create_reflog(struct ref_store *ref_store,
-                              const char *refname, int force_create,
+static int files_create_reflog(struct ref_store *ref_store, const char *refname,
                               struct strbuf *err)
 {
        struct files_ref_store *refs =
                files_downcast(ref_store, REF_STORE_WRITE, "create_reflog");
        int fd;
 
-       if (log_ref_setup(refs, refname, force_create, &fd, err))
+       if (log_ref_setup(refs, refname, 1, &fd, err))
                return -1;
 
        if (fd >= 0)
index 1c5211b03e48cf23fd3a4d02e8aa6278b24ce26f..472458b844e14462e963210ccc04adf098ff969d 100644 (file)
@@ -1628,8 +1628,7 @@ static int packed_reflog_exists(struct ref_store *ref_store,
 }
 
 static int packed_create_reflog(struct ref_store *ref_store,
-                              const char *refname, int force_create,
-                              struct strbuf *err)
+                               const char *refname, struct strbuf *err)
 {
        BUG("packed reference store does not support reflogs");
 }
index 12224742ede8f01d4f8d88ceaaa2e326413bf674..5b40b3bbbf81ed1bc682c72bb737f125391c6a58 100644 (file)
@@ -606,7 +606,7 @@ typedef int for_each_reflog_ent_reverse_fn(struct ref_store *ref_store,
                                           void *cb_data);
 typedef int reflog_exists_fn(struct ref_store *ref_store, const char *refname);
 typedef int create_reflog_fn(struct ref_store *ref_store, const char *refname,
-                            int force_create, struct strbuf *err);
+                            struct strbuf *err);
 typedef int delete_reflog_fn(struct ref_store *ref_store, const char *refname);
 typedef int reflog_expire_fn(struct ref_store *ref_store,
                             const char *refname,
index b314b81a45b27cac548e1c5628f3dd96685ceb09..98f827edfb734114aa126ff5ce37f722cec9d391 100644 (file)
@@ -181,11 +181,10 @@ static int cmd_reflog_exists(struct ref_store *refs, const char **argv)
 static int cmd_create_reflog(struct ref_store *refs, const char **argv)
 {
        const char *refname = notnull(*argv++, "refname");
-       int force_create = arg_flags(*argv++, "force-create");
        struct strbuf err = STRBUF_INIT;
        int ret;
 
-       ret = refs_create_reflog(refs, refname, force_create, &err);
+       ret = refs_create_reflog(refs, refname, &err);
        if (err.len)
                puts(err.buf);
        return ret;
index 49718b7ea7fe7df85b6e2bd4c9833ee443825632..c89cef2d26be9252c075b58767919f4186259305 100755 (executable)
@@ -108,7 +108,7 @@ test_expect_success 'delete_reflog(HEAD)' '
 '
 
 test_expect_success 'create-reflog(HEAD)' '
-       $RUN create-reflog HEAD &&
+       $RUN create-reflog HEAD &&
        git reflog exists HEAD
 '
 
index 0a87058971ee3f601f928a1d3078c25ac0a60ce2..f1e57a9c0519d74f247e6b2e038698359fad8ad9 100755 (executable)
@@ -92,7 +92,7 @@ test_expect_success 'delete_reflog() not allowed' '
 '
 
 test_expect_success 'create-reflog() not allowed' '
-       test_must_fail $RUN create-reflog HEAD 1
+       test_must_fail $RUN create-reflog HEAD
 '
 
 test_done