зеркало из https://github.com/microsoft/git.git
Merge branch 'hn/create-reflog-simplify'
A small simplification of API. * hn/create-reflog-simplify: refs: drop force_create argument of create_reflog API
This commit is contained in:
Коммит
b8148376a2
|
@ -885,7 +885,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);
|
||||
|
|
13
refs.c
13
refs.c
|
@ -2373,16 +2373,15 @@ int reflog_exists(const char *refname)
|
|||
}
|
||||
|
||||
int refs_create_reflog(struct ref_store *refs, const char *refname,
|
||||
int force_create, struct strbuf *err)
|
||||
{
|
||||
return refs->be->create_reflog(refs, refname, force_create, err);
|
||||
}
|
||||
|
||||
int safe_create_reflog(const char *refname, int force_create,
|
||||
struct strbuf *err)
|
||||
{
|
||||
return refs->be->create_reflog(refs, refname, 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)
|
||||
|
|
4
refs.h
4
refs.h
|
@ -417,8 +417,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,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -1671,15 +1671,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)
|
||||
|
|
|
@ -1629,8 +1629,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");
|
||||
}
|
||||
|
|
|
@ -592,7 +592,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,
|
||||
|
|
|
@ -182,11 +182,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;
|
||||
|
|
|
@ -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
|
||||
'
|
||||
|
||||
|
|
|
@ -93,7 +93,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
|
||||
|
|
Загрузка…
Ссылка в новой задаче