X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin-rerere.c;h=5c811423cc1234d933cff013f9923b45f19dc6fa;hb=d3a7b8f5c5ed2a073936e09aa80c8a0b0cf10f5c;hp=74493237c9ca129cd7398963ace747a04a6bf6fd;hpb=1ab58e8d6f728cdde0057f7ee88daab3a1c2d06f;p=git.git diff --git a/builtin-rerere.c b/builtin-rerere.c index 74493237c..5c811423c 100644 --- a/builtin-rerere.c +++ b/builtin-rerere.c @@ -61,9 +61,9 @@ static int write_rr(struct path_list *rr, int out_fd) write_in_full(out_fd, path, length) != length) die("unable to write rerere record"); } - if (close(out_fd) != 0) + if (commit_lock_file(&write_lock) != 0) die("unable to write rerere record"); - return commit_lock_file(&write_lock); + return 0; } static int handle_file(const char *path, @@ -149,8 +149,8 @@ static int find_conflict(struct path_list *conflict) if (ce_stage(e2) == 2 && ce_stage(e3) == 3 && ce_same_name(e2, e3) && - S_ISREG(ntohl(e2->ce_mode)) && - S_ISREG(ntohl(e3->ce_mode))) { + S_ISREG(e2->ce_mode) && + S_ISREG(e3->ce_mode)) { path_list_insert((const char *)e2->name, conflict); i++; /* skip over both #2 and #3 */ } @@ -260,30 +260,13 @@ static int diff_two(const char *file1, const char *label1, memset(&xecfg, 0, sizeof(xecfg)); xecfg.ctxlen = 3; ecb.outf = outf; - xdl_diff(&minus, &plus, &xpp, &xecfg, &ecb); + xdi_diff(&minus, &plus, &xpp, &xecfg, &ecb); free(minus.ptr); free(plus.ptr); return 0; } -static int copy_file(const char *src, const char *dest) -{ - FILE *in, *out; - char buffer[32768]; - int count; - - if (!(in = fopen(src, "r"))) - return error("Could not open %s", src); - if (!(out = fopen(dest, "w"))) - return error("Could not open %s", dest); - while ((count = fread(buffer, 1, sizeof(buffer), in))) - fwrite(buffer, 1, count, out); - fclose(in); - fclose(out); - return 0; -} - static int do_plain_rerere(struct path_list *rr, int fd) { struct path_list conflict = { NULL, 0, 0, 1 }; @@ -343,7 +326,7 @@ static int do_plain_rerere(struct path_list *rr, int fd) continue; fprintf(stderr, "Recorded resolution for '%s'.\n", path); - copy_file(path, rr_path(name, "postimage")); + copy_file(rr_path(name, "postimage"), path, 0666); tail_optimization: if (i < rr->nr - 1) memmove(rr->items + i, @@ -356,7 +339,7 @@ tail_optimization: return write_rr(rr, fd); } -static int git_rerere_config(const char *var, const char *value) +static int git_rerere_config(const char *var, const char *value, void *cb) { if (!strcmp(var, "gc.rerereresolved")) cutoff_resolve = git_config_int(var, value); @@ -365,7 +348,7 @@ static int git_rerere_config(const char *var, const char *value) else if (!strcmp(var, "rerere.enabled")) rerere_enabled = git_config_bool(var, value); else - return git_default_config(var, value); + return git_default_config(var, value, cb); return 0; } @@ -393,7 +376,7 @@ static int setup_rerere(struct path_list *merge_rr) { int fd; - git_config(git_rerere_config); + git_config(git_rerere_config, NULL); if (!is_rerere_enabled()) return -1;