From: "Han-Wen Nienhuys via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: "Taylor Blau" <me@ttaylorr.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
"Han-Wen Nienhuys" <hanwenn@gmail.com>,
"Han-Wen Nienhuys" <hanwen@google.com>
Subject: [PATCH v3 5/7] refs: drop force_create argument of create_reflog API
Date: Tue, 07 Sep 2021 13:36:46 +0000 [thread overview]
Message-ID: <ce0047028dd4941c7b91d3299107651238b1431f.1631021808.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1067.v3.git.git.1631021808.gitgitgadget@gmail.com>
From: Han-Wen Nienhuys <hanwen@google.com>
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>
---
builtin/checkout.c | 2 +-
refs.c | 9 ++++-----
refs.h | 4 ++--
refs/debug.c | 5 ++---
refs/files-backend.c | 5 ++---
refs/packed-backend.c | 3 +--
refs/refs-internal.h | 2 +-
t/helper/test-ref-store.c | 3 +--
t/t1405-main-ref-store.sh | 2 +-
t/t1406-submodule-ref-store.sh | 2 +-
10 files changed, 16 insertions(+), 21 deletions(-)
diff --git a/builtin/checkout.c b/builtin/checkout.c
index b5d477919a7..3c6506e0595 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -876,7 +876,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 8b9f7c3a80a..ca59a7cc652 100644
--- a/refs.c
+++ b/refs.c
@@ -2347,16 +2347,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 48970dfc7e0..3c457bc19c8 100644
--- a/refs.h
+++ b/refs.h
@@ -416,8 +416,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,
diff --git a/refs/debug.c b/refs/debug.c
index 1a7a9e11cfa..f6b01b1eba0 100644
--- a/refs/debug.c
+++ b/refs/debug.c
@@ -340,11 +340,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;
}
diff --git a/refs/files-backend.c b/refs/files-backend.c
index 206c9f8b932..04d73b89c9c 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -1598,15 +1598,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)
diff --git a/refs/packed-backend.c b/refs/packed-backend.c
index f8aa97d7998..af7038de42d 100644
--- a/refs/packed-backend.c
+++ b/refs/packed-backend.c
@@ -1618,8 +1618,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");
}
diff --git a/refs/refs-internal.h b/refs/refs-internal.h
index 3155708345f..cc0e56e8c82 100644
--- a/refs/refs-internal.h
+++ b/refs/refs-internal.h
@@ -590,7 +590,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, const struct object_id *oid,
diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c
index 0fcad9b3812..a65fda66ddc 100644
--- a/t/helper/test-ref-store.c
+++ b/t/helper/test-ref-store.c
@@ -180,11 +180,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;
diff --git a/t/t1405-main-ref-store.sh b/t/t1405-main-ref-store.sh
index 76b15458409..3cb5e23d6db 100755
--- a/t/t1405-main-ref-store.sh
+++ b/t/t1405-main-ref-store.sh
@@ -108,7 +108,7 @@ test_expect_success 'delete_reflog(HEAD)' '
'
test_expect_success 'create-reflog(HEAD)' '
- $RUN create-reflog HEAD 1 &&
+ $RUN create-reflog HEAD &&
git reflog exists HEAD
'
diff --git a/t/t1406-submodule-ref-store.sh b/t/t1406-submodule-ref-store.sh
index b0365c1fee0..78d40bdcd8b 100755
--- a/t/t1406-submodule-ref-store.sh
+++ b/t/t1406-submodule-ref-store.sh
@@ -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
--
gitgitgadget
next prev parent reply other threads:[~2021-09-07 13:37 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-30 14:48 [PATCH 0/4] Gets rid of "if reflog exists, append to it regardless of config settings" Han-Wen Nienhuys via GitGitGadget
2021-08-30 14:48 ` [PATCH 1/4] test-ref-store: tweaks to for-each-reflog-ent format Han-Wen Nienhuys via GitGitGadget
2021-08-30 19:57 ` Taylor Blau
2021-08-30 20:23 ` Taylor Blau
2021-08-30 20:51 ` Junio C Hamano
2021-08-30 20:58 ` Taylor Blau
2021-08-30 21:59 ` Junio C Hamano
2021-08-30 14:48 ` [PATCH 2/4] t1400: use test-helper ref-store to inspect reflog contents Han-Wen Nienhuys via GitGitGadget
2021-08-30 20:55 ` Junio C Hamano
2021-08-30 14:48 ` [PATCH 3/4] refs: drop force_create argument of create_reflog API Han-Wen Nienhuys via GitGitGadget
2021-08-30 21:03 ` Junio C Hamano
2021-08-30 14:48 ` [PATCH 4/4] RFC: refs: reflog entries aren't written based on reflog existence Han-Wen Nienhuys via GitGitGadget
2021-08-30 21:10 ` Taylor Blau
2021-08-30 21:14 ` Junio C Hamano
2021-09-06 16:52 ` [PATCH v2 0/5] Gets rid of "if reflog exists, append to it regardless of config settings" Han-Wen Nienhuys via GitGitGadget
2021-09-06 16:52 ` [PATCH v2 1/5] refs: trim newline from reflog message Han-Wen Nienhuys via GitGitGadget
2021-09-06 22:38 ` Ævar Arnfjörð Bjarmason
2021-09-06 16:52 ` [PATCH v2 2/5] test-ref-store: tweaks to for-each-reflog-ent format Han-Wen Nienhuys via GitGitGadget
2021-09-06 22:34 ` Ævar Arnfjörð Bjarmason
2021-09-07 13:33 ` Han-Wen Nienhuys
2021-09-07 15:53 ` Ævar Arnfjörð Bjarmason
2021-09-06 16:52 ` [PATCH v2 3/5] t1400: use test-helper ref-store to inspect reflog contents Han-Wen Nienhuys via GitGitGadget
2021-09-06 16:52 ` [PATCH v2 4/5] refs: drop force_create argument of create_reflog API Han-Wen Nienhuys via GitGitGadget
2021-09-06 22:42 ` Ævar Arnfjörð Bjarmason
2021-09-06 16:52 ` [PATCH v2 5/5] RFC: refs: reflog entries aren't written based on reflog existence Han-Wen Nienhuys via GitGitGadget
2021-09-06 22:50 ` Ævar Arnfjörð Bjarmason
2021-09-07 13:36 ` [PATCH v3 0/7] Gets rid of "if reflog exists, append to it regardless of config settings" Han-Wen Nienhuys via GitGitGadget
2021-09-07 13:36 ` [PATCH v3 1/7] show-branch: show reflog message Han-Wen Nienhuys via GitGitGadget
2021-09-07 13:36 ` [PATCH v3 2/7] refs: trim newline from " Han-Wen Nienhuys via GitGitGadget
2021-09-07 13:36 ` [PATCH v3 3/7] test-ref-store: tweaks to for-each-reflog-ent format Han-Wen Nienhuys via GitGitGadget
2021-09-07 13:36 ` [PATCH v3 4/7] t1400: use test-helper ref-store to inspect reflog contents Han-Wen Nienhuys via GitGitGadget
2021-09-07 13:36 ` Han-Wen Nienhuys via GitGitGadget [this message]
2021-09-07 13:36 ` [PATCH v3 6/7] RFC: refs: reflog entries aren't written based on reflog existence Han-Wen Nienhuys via GitGitGadget
2021-09-07 13:36 ` [PATCH v3 7/7] refs: change log_ref_setup calling convention Han-Wen Nienhuys via GitGitGadget
2021-10-05 15:54 ` [PATCH v3 0/7] Gets rid of "if reflog exists, append to it regardless of config settings" Han-Wen Nienhuys
2021-10-06 18:20 ` Junio C Hamano
2021-10-06 18:27 ` Junio C Hamano
2021-10-07 17:38 ` Junio C Hamano
2021-11-11 11:46 ` Han-Wen Nienhuys
2021-11-11 14:38 ` Ævar Arnfjörð Bjarmason
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ce0047028dd4941c7b91d3299107651238b1431f.1631021808.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=hanwen@google.com \
--cc=hanwenn@gmail.com \
--cc=me@ttaylorr.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).