mirror of
https://github.com/git/git.git
synced 2024-04-27 16:25:10 +02:00
rerere.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
7c14112741
commit
55e6b3547d
|
@ -2033,7 +2033,7 @@ static int clean_index(const struct object_id *head, const struct object_id *rem
|
||||||
static void am_rerere_clear(void)
|
static void am_rerere_clear(void)
|
||||||
{
|
{
|
||||||
struct string_list merge_rr = STRING_LIST_INIT_DUP;
|
struct string_list merge_rr = STRING_LIST_INIT_DUP;
|
||||||
rerere_clear(&merge_rr);
|
rerere_clear(the_repository, &merge_rr);
|
||||||
string_list_clear(&merge_rr, 1);
|
string_list_clear(&merge_rr, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -233,7 +233,7 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
|
||||||
case SKIP: {
|
case SKIP: {
|
||||||
struct string_list merge_rr = STRING_LIST_INIT_DUP;
|
struct string_list merge_rr = STRING_LIST_INIT_DUP;
|
||||||
|
|
||||||
rerere_clear(&merge_rr);
|
rerere_clear(the_repository, &merge_rr);
|
||||||
/* fallthrough */
|
/* fallthrough */
|
||||||
case CONTINUE:
|
case CONTINUE:
|
||||||
ret = sequencer_continue(the_repository, &opts);
|
ret = sequencer_continue(the_repository, &opts);
|
||||||
|
|
|
@ -997,7 +997,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
|
||||||
|
|
||||||
options.action = "skip";
|
options.action = "skip";
|
||||||
|
|
||||||
rerere_clear(&merge_rr);
|
rerere_clear(the_repository, &merge_rr);
|
||||||
string_list_clear(&merge_rr, 1);
|
string_list_clear(&merge_rr, 1);
|
||||||
|
|
||||||
if (reset_head(NULL, "reset", NULL, 0, NULL, NULL) < 0)
|
if (reset_head(NULL, "reset", NULL, 0, NULL, NULL) < 0)
|
||||||
|
@ -1010,7 +1010,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
|
||||||
struct string_list merge_rr = STRING_LIST_INIT_DUP;
|
struct string_list merge_rr = STRING_LIST_INIT_DUP;
|
||||||
options.action = "abort";
|
options.action = "abort";
|
||||||
|
|
||||||
rerere_clear(&merge_rr);
|
rerere_clear(the_repository, &merge_rr);
|
||||||
string_list_clear(&merge_rr, 1);
|
string_list_clear(&merge_rr, 1);
|
||||||
|
|
||||||
if (read_basic_state(&options))
|
if (read_basic_state(&options))
|
||||||
|
|
|
@ -82,11 +82,12 @@ int cmd_rerere(int argc, const char **argv, const char *prefix)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(argv[0], "clear")) {
|
if (!strcmp(argv[0], "clear")) {
|
||||||
rerere_clear(&merge_rr);
|
rerere_clear(the_repository, &merge_rr);
|
||||||
} else if (!strcmp(argv[0], "gc"))
|
} else if (!strcmp(argv[0], "gc"))
|
||||||
rerere_gc(&merge_rr);
|
rerere_gc(the_repository, &merge_rr);
|
||||||
else if (!strcmp(argv[0], "status")) {
|
else if (!strcmp(argv[0], "status")) {
|
||||||
if (setup_rerere(&merge_rr, flags | RERERE_READONLY) < 0)
|
if (setup_rerere(the_repository, &merge_rr,
|
||||||
|
flags | RERERE_READONLY) < 0)
|
||||||
return 0;
|
return 0;
|
||||||
for (i = 0; i < merge_rr.nr; i++)
|
for (i = 0; i < merge_rr.nr; i++)
|
||||||
printf("%s\n", merge_rr.items[i].string);
|
printf("%s\n", merge_rr.items[i].string);
|
||||||
|
@ -101,7 +102,8 @@ int cmd_rerere(int argc, const char **argv, const char *prefix)
|
||||||
merge_rr.items[i].util = NULL;
|
merge_rr.items[i].util = NULL;
|
||||||
}
|
}
|
||||||
} else if (!strcmp(argv[0], "diff")) {
|
} else if (!strcmp(argv[0], "diff")) {
|
||||||
if (setup_rerere(&merge_rr, flags | RERERE_READONLY) < 0)
|
if (setup_rerere(the_repository, &merge_rr,
|
||||||
|
flags | RERERE_READONLY) < 0)
|
||||||
return 0;
|
return 0;
|
||||||
for (i = 0; i < merge_rr.nr; i++) {
|
for (i = 0; i < merge_rr.nr; i++) {
|
||||||
const char *path = merge_rr.items[i].string;
|
const char *path = merge_rr.items[i].string;
|
||||||
|
|
26
rerere.c
26
rerere.c
|
@ -198,10 +198,10 @@ static struct rerere_id *new_rerere_id(unsigned char *sha1)
|
||||||
* work on (i.e. what is left by the previous invocation of "git
|
* work on (i.e. what is left by the previous invocation of "git
|
||||||
* rerere" during the current conflict resolution session).
|
* rerere" during the current conflict resolution session).
|
||||||
*/
|
*/
|
||||||
static void read_rr(struct string_list *rr)
|
static void read_rr(struct repository *r, struct string_list *rr)
|
||||||
{
|
{
|
||||||
struct strbuf buf = STRBUF_INIT;
|
struct strbuf buf = STRBUF_INIT;
|
||||||
FILE *in = fopen_or_warn(git_path_merge_rr(the_repository), "r");
|
FILE *in = fopen_or_warn(git_path_merge_rr(r), "r");
|
||||||
|
|
||||||
if (!in)
|
if (!in)
|
||||||
return;
|
return;
|
||||||
|
@ -593,7 +593,7 @@ int rerere_remaining(struct repository *r, struct string_list *merge_rr)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (setup_rerere(merge_rr, RERERE_READONLY))
|
if (setup_rerere(r, merge_rr, RERERE_READONLY))
|
||||||
return 0;
|
return 0;
|
||||||
if (read_index(r->index) < 0)
|
if (read_index(r->index) < 0)
|
||||||
return error(_("index file corrupt"));
|
return error(_("index file corrupt"));
|
||||||
|
@ -882,7 +882,7 @@ static int is_rerere_enabled(void)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int setup_rerere(struct string_list *merge_rr, int flags)
|
int setup_rerere(struct repository *r, struct string_list *merge_rr, int flags)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
|
@ -896,9 +896,9 @@ int setup_rerere(struct string_list *merge_rr, int flags)
|
||||||
fd = 0;
|
fd = 0;
|
||||||
else
|
else
|
||||||
fd = hold_lock_file_for_update(&write_lock,
|
fd = hold_lock_file_for_update(&write_lock,
|
||||||
git_path_merge_rr(the_repository),
|
git_path_merge_rr(r),
|
||||||
LOCK_DIE_ON_ERROR);
|
LOCK_DIE_ON_ERROR);
|
||||||
read_rr(merge_rr);
|
read_rr(r, merge_rr);
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -912,7 +912,7 @@ int repo_rerere(struct repository *r, int flags)
|
||||||
struct string_list merge_rr = STRING_LIST_INIT_DUP;
|
struct string_list merge_rr = STRING_LIST_INIT_DUP;
|
||||||
int fd, status;
|
int fd, status;
|
||||||
|
|
||||||
fd = setup_rerere(&merge_rr, flags);
|
fd = setup_rerere(r, &merge_rr, flags);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return 0;
|
return 0;
|
||||||
status = do_plain_rerere(r, &merge_rr, fd);
|
status = do_plain_rerere(r, &merge_rr, fd);
|
||||||
|
@ -1110,7 +1110,7 @@ int rerere_forget(struct repository *r, struct pathspec *pathspec)
|
||||||
if (read_index(r->index) < 0)
|
if (read_index(r->index) < 0)
|
||||||
return error(_("index file corrupt"));
|
return error(_("index file corrupt"));
|
||||||
|
|
||||||
fd = setup_rerere(&merge_rr, RERERE_NOAUTOUPDATE);
|
fd = setup_rerere(r, &merge_rr, RERERE_NOAUTOUPDATE);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -1178,7 +1178,7 @@ static void prune_one(struct rerere_id *id,
|
||||||
unlink_rr_item(id);
|
unlink_rr_item(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rerere_gc(struct string_list *rr)
|
void rerere_gc(struct repository *r, struct string_list *rr)
|
||||||
{
|
{
|
||||||
struct string_list to_remove = STRING_LIST_INIT_DUP;
|
struct string_list to_remove = STRING_LIST_INIT_DUP;
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
|
@ -1188,7 +1188,7 @@ void rerere_gc(struct string_list *rr)
|
||||||
timestamp_t cutoff_noresolve = now - 15 * 86400;
|
timestamp_t cutoff_noresolve = now - 15 * 86400;
|
||||||
timestamp_t cutoff_resolve = now - 60 * 86400;
|
timestamp_t cutoff_resolve = now - 60 * 86400;
|
||||||
|
|
||||||
if (setup_rerere(rr, 0) < 0)
|
if (setup_rerere(r, rr, 0) < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
git_config_get_expiry_in_days("gc.rerereresolved", &cutoff_resolve, now);
|
git_config_get_expiry_in_days("gc.rerereresolved", &cutoff_resolve, now);
|
||||||
|
@ -1236,11 +1236,11 @@ void rerere_gc(struct string_list *rr)
|
||||||
*
|
*
|
||||||
* NEEDSWORK: shouldn't we be calling this from "reset --hard"?
|
* NEEDSWORK: shouldn't we be calling this from "reset --hard"?
|
||||||
*/
|
*/
|
||||||
void rerere_clear(struct string_list *merge_rr)
|
void rerere_clear(struct repository *r, struct string_list *merge_rr)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (setup_rerere(merge_rr, 0) < 0)
|
if (setup_rerere(r, merge_rr, 0) < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i < merge_rr->nr; i++) {
|
for (i = 0; i < merge_rr->nr; i++) {
|
||||||
|
@ -1250,6 +1250,6 @@ void rerere_clear(struct string_list *merge_rr)
|
||||||
rmdir(rerere_path(id, NULL));
|
rmdir(rerere_path(id, NULL));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unlink_or_warn(git_path_merge_rr(the_repository));
|
unlink_or_warn(git_path_merge_rr(r));
|
||||||
rollback_lock_file(&write_lock);
|
rollback_lock_file(&write_lock);
|
||||||
}
|
}
|
||||||
|
|
6
rerere.h
6
rerere.h
|
@ -23,7 +23,7 @@ struct rerere_id {
|
||||||
int variant;
|
int variant;
|
||||||
};
|
};
|
||||||
|
|
||||||
int setup_rerere(struct string_list *, int);
|
int setup_rerere(struct repository *,struct string_list *, int);
|
||||||
#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
|
#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
|
||||||
#define rerere(flags) repo_rerere(the_repository, flags)
|
#define rerere(flags) repo_rerere(the_repository, flags)
|
||||||
#endif
|
#endif
|
||||||
|
@ -37,8 +37,8 @@ int repo_rerere(struct repository *, int);
|
||||||
const char *rerere_path(const struct rerere_id *, const char *file);
|
const char *rerere_path(const struct rerere_id *, const char *file);
|
||||||
int rerere_forget(struct repository *, struct pathspec *);
|
int rerere_forget(struct repository *, struct pathspec *);
|
||||||
int rerere_remaining(struct repository *, struct string_list *);
|
int rerere_remaining(struct repository *, struct string_list *);
|
||||||
void rerere_clear(struct string_list *);
|
void rerere_clear(struct repository *, struct string_list *);
|
||||||
void rerere_gc(struct string_list *);
|
void rerere_gc(struct repository *, struct string_list *);
|
||||||
|
|
||||||
#define OPT_RERERE_AUTOUPDATE(v) OPT_UYN(0, "rerere-autoupdate", (v), \
|
#define OPT_RERERE_AUTOUPDATE(v) OPT_UYN(0, "rerere-autoupdate", (v), \
|
||||||
N_("update the index with reused conflict resolution if possible"))
|
N_("update the index with reused conflict resolution if possible"))
|
||||||
|
|
Loading…
Reference in New Issue