mirror of
https://github.com/git/git.git
synced 2024-05-06 01:46:12 +02:00
notes-cache.c: remove the_repository references
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
363df5572c
commit
bd7ad45b64
|
@ -991,7 +991,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
|
||||||
if (!userdiff)
|
if (!userdiff)
|
||||||
userdiff = userdiff_find_by_name("default");
|
userdiff = userdiff_find_by_name("default");
|
||||||
if (opt->flags.allow_textconv)
|
if (opt->flags.allow_textconv)
|
||||||
textconv = userdiff_get_textconv(userdiff);
|
textconv = userdiff_get_textconv(opt->repo, userdiff);
|
||||||
|
|
||||||
/* Read the result of merge first */
|
/* Read the result of merge first */
|
||||||
if (!working_tree_file)
|
if (!working_tree_file)
|
||||||
|
|
12
diff.c
12
diff.c
|
@ -3312,14 +3312,14 @@ void diff_set_mnemonic_prefix(struct diff_options *options, const char *a, const
|
||||||
options->b_prefix = b;
|
options->b_prefix = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct userdiff_driver *get_textconv(struct index_state *istate,
|
struct userdiff_driver *get_textconv(struct repository *r,
|
||||||
struct diff_filespec *one)
|
struct diff_filespec *one)
|
||||||
{
|
{
|
||||||
if (!DIFF_FILE_VALID(one))
|
if (!DIFF_FILE_VALID(one))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
diff_filespec_load_driver(one, istate);
|
diff_filespec_load_driver(one, r->index);
|
||||||
return userdiff_get_textconv(one->driver);
|
return userdiff_get_textconv(r, one->driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void builtin_diff(const char *name_a,
|
static void builtin_diff(const char *name_a,
|
||||||
|
@ -3368,8 +3368,8 @@ static void builtin_diff(const char *name_a,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (o->flags.allow_textconv) {
|
if (o->flags.allow_textconv) {
|
||||||
textconv_one = get_textconv(o->repo->index, one);
|
textconv_one = get_textconv(o->repo, one);
|
||||||
textconv_two = get_textconv(o->repo->index, two);
|
textconv_two = get_textconv(o->repo, two);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Never use a non-valid filename anywhere if at all possible */
|
/* Never use a non-valid filename anywhere if at all possible */
|
||||||
|
@ -6436,7 +6436,7 @@ int textconv_object(struct repository *r,
|
||||||
|
|
||||||
df = alloc_filespec(path);
|
df = alloc_filespec(path);
|
||||||
fill_filespec(df, oid, oid_valid, mode);
|
fill_filespec(df, oid, oid_valid, mode);
|
||||||
textconv = get_textconv(r->index, df);
|
textconv = get_textconv(r, df);
|
||||||
if (!textconv) {
|
if (!textconv) {
|
||||||
free_filespec(df);
|
free_filespec(df);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
2
diff.h
2
diff.h
|
@ -461,7 +461,7 @@ size_t fill_textconv(struct repository *r,
|
||||||
* and only if it has textconv enabled (otherwise return NULL). The result
|
* and only if it has textconv enabled (otherwise return NULL). The result
|
||||||
* can be passed to fill_textconv().
|
* can be passed to fill_textconv().
|
||||||
*/
|
*/
|
||||||
struct userdiff_driver *get_textconv(struct index_state *istate,
|
struct userdiff_driver *get_textconv(struct repository *r,
|
||||||
struct diff_filespec *one);
|
struct diff_filespec *one);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -139,8 +139,8 @@ static int pickaxe_match(struct diff_filepair *p, struct diff_options *o,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (o->flags.allow_textconv) {
|
if (o->flags.allow_textconv) {
|
||||||
textconv_one = get_textconv(o->repo->index, p->one);
|
textconv_one = get_textconv(o->repo, p->one);
|
||||||
textconv_two = get_textconv(o->repo->index, p->two);
|
textconv_two = get_textconv(o->repo, p->two);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
2
grep.c
2
grep.c
|
@ -1811,7 +1811,7 @@ static int grep_source_1(struct grep_opt *opt, struct grep_source *gs, int colle
|
||||||
* is not thread-safe.
|
* is not thread-safe.
|
||||||
*/
|
*/
|
||||||
grep_attr_lock();
|
grep_attr_lock();
|
||||||
textconv = userdiff_get_textconv(gs->driver);
|
textconv = userdiff_get_textconv(opt->repo, gs->driver);
|
||||||
grep_attr_unlock();
|
grep_attr_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,9 @@
|
||||||
#include "commit.h"
|
#include "commit.h"
|
||||||
#include "refs.h"
|
#include "refs.h"
|
||||||
|
|
||||||
static int notes_cache_match_validity(const char *ref, const char *validity)
|
static int notes_cache_match_validity(struct repository *r,
|
||||||
|
const char *ref,
|
||||||
|
const char *validity)
|
||||||
{
|
{
|
||||||
struct object_id oid;
|
struct object_id oid;
|
||||||
struct commit *commit;
|
struct commit *commit;
|
||||||
|
@ -16,7 +18,7 @@ static int notes_cache_match_validity(const char *ref, const char *validity)
|
||||||
if (read_ref(ref, &oid) < 0)
|
if (read_ref(ref, &oid) < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
commit = lookup_commit_reference_gently(the_repository, &oid, 1);
|
commit = lookup_commit_reference_gently(r, &oid, 1);
|
||||||
if (!commit)
|
if (!commit)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -30,8 +32,8 @@ static int notes_cache_match_validity(const char *ref, const char *validity)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void notes_cache_init(struct notes_cache *c, const char *name,
|
void notes_cache_init(struct repository *r, struct notes_cache *c,
|
||||||
const char *validity)
|
const char *name, const char *validity)
|
||||||
{
|
{
|
||||||
struct strbuf ref = STRBUF_INIT;
|
struct strbuf ref = STRBUF_INIT;
|
||||||
int flags = NOTES_INIT_WRITABLE;
|
int flags = NOTES_INIT_WRITABLE;
|
||||||
|
@ -40,7 +42,7 @@ void notes_cache_init(struct notes_cache *c, const char *name,
|
||||||
c->validity = xstrdup(validity);
|
c->validity = xstrdup(validity);
|
||||||
|
|
||||||
strbuf_addf(&ref, "refs/notes/%s", name);
|
strbuf_addf(&ref, "refs/notes/%s", name);
|
||||||
if (!notes_cache_match_validity(ref.buf, validity))
|
if (!notes_cache_match_validity(r, ref.buf, validity))
|
||||||
flags |= NOTES_INIT_EMPTY;
|
flags |= NOTES_INIT_EMPTY;
|
||||||
init_notes(&c->tree, ref.buf, combine_notes_overwrite, flags);
|
init_notes(&c->tree, ref.buf, combine_notes_overwrite, flags);
|
||||||
strbuf_release(&ref);
|
strbuf_release(&ref);
|
||||||
|
|
|
@ -3,13 +3,15 @@
|
||||||
|
|
||||||
#include "notes.h"
|
#include "notes.h"
|
||||||
|
|
||||||
|
struct repository;
|
||||||
|
|
||||||
struct notes_cache {
|
struct notes_cache {
|
||||||
struct notes_tree tree;
|
struct notes_tree tree;
|
||||||
char *validity;
|
char *validity;
|
||||||
};
|
};
|
||||||
|
|
||||||
void notes_cache_init(struct notes_cache *c, const char *name,
|
void notes_cache_init(struct repository *r, struct notes_cache *c,
|
||||||
const char *validity);
|
const char *name, const char *validity);
|
||||||
int notes_cache_write(struct notes_cache *c);
|
int notes_cache_write(struct notes_cache *c);
|
||||||
|
|
||||||
char *notes_cache_get(struct notes_cache *c, struct object_id *oid, size_t
|
char *notes_cache_get(struct notes_cache *c, struct object_id *oid, size_t
|
||||||
|
|
|
@ -290,7 +290,8 @@ struct userdiff_driver *userdiff_find_by_path(struct index_state *istate,
|
||||||
return userdiff_find_by_name(check->items[0].value);
|
return userdiff_find_by_name(check->items[0].value);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct userdiff_driver *userdiff_get_textconv(struct userdiff_driver *driver)
|
struct userdiff_driver *userdiff_get_textconv(struct repository *r,
|
||||||
|
struct userdiff_driver *driver)
|
||||||
{
|
{
|
||||||
if (!driver->textconv)
|
if (!driver->textconv)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -300,7 +301,7 @@ struct userdiff_driver *userdiff_get_textconv(struct userdiff_driver *driver)
|
||||||
struct strbuf name = STRBUF_INIT;
|
struct strbuf name = STRBUF_INIT;
|
||||||
|
|
||||||
strbuf_addf(&name, "textconv/%s", driver->name);
|
strbuf_addf(&name, "textconv/%s", driver->name);
|
||||||
notes_cache_init(c, name.buf, driver->textconv);
|
notes_cache_init(r, c, name.buf, driver->textconv);
|
||||||
driver->textconv_cache = c;
|
driver->textconv_cache = c;
|
||||||
strbuf_release(&name);
|
strbuf_release(&name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "notes-cache.h"
|
#include "notes-cache.h"
|
||||||
|
|
||||||
struct index_state;
|
struct index_state;
|
||||||
|
struct repository;
|
||||||
|
|
||||||
struct userdiff_funcname {
|
struct userdiff_funcname {
|
||||||
const char *pattern;
|
const char *pattern;
|
||||||
|
@ -30,6 +31,7 @@ struct userdiff_driver *userdiff_find_by_path(struct index_state *istate,
|
||||||
* Initialize any textconv-related fields in the driver and return it, or NULL
|
* Initialize any textconv-related fields in the driver and return it, or NULL
|
||||||
* if it does not have textconv enabled at all.
|
* if it does not have textconv enabled at all.
|
||||||
*/
|
*/
|
||||||
struct userdiff_driver *userdiff_get_textconv(struct userdiff_driver *driver);
|
struct userdiff_driver *userdiff_get_textconv(struct repository *r,
|
||||||
|
struct userdiff_driver *driver);
|
||||||
|
|
||||||
#endif /* USERDIFF */
|
#endif /* USERDIFF */
|
||||||
|
|
Loading…
Reference in New Issue