Skip to content

Commit 18bb993

Browse files
committed
rerere: call conflict-ids IDs
Most places we call conflict IDs "name" and some others we call them "hex"; update all of them to "id". Signed-off-by: Junio C Hamano <[email protected]>
1 parent 925d73c commit 18bb993

File tree

3 files changed

+41
-41
lines changed

3 files changed

+41
-41
lines changed

builtin/rerere.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ int cmd_rerere(int argc, const char **argv, const char *prefix)
103103
} else if (!strcmp(argv[0], "diff"))
104104
for (i = 0; i < merge_rr.nr; i++) {
105105
const char *path = merge_rr.items[i].string;
106-
const char *name = (const char *)merge_rr.items[i].util;
107-
diff_two(rerere_path(name, "preimage"), path, path, path);
106+
const char *id = (const char *)merge_rr.items[i].util;
107+
diff_two(rerere_path(id, "preimage"), path, path, path);
108108
}
109109
else
110110
usage_with_options(rerere_usage, options);

rerere.c

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ static int rerere_autoupdate;
2222

2323
static char *merge_rr_path;
2424

25-
const char *rerere_path(const char *hex, const char *file)
25+
const char *rerere_path(const char *id, const char *file)
2626
{
27-
return git_path("rr-cache/%s/%s", hex, file);
27+
return git_path("rr-cache/%s/%s", id, file);
2828
}
2929

30-
static int has_rerere_resolution(const char *hex)
30+
static int has_rerere_resolution(const char *id)
3131
{
3232
struct stat st;
33-
return !stat(rerere_path(hex, "postimage"), &st);
33+
return !stat(rerere_path(id, "postimage"), &st);
3434
}
3535

3636
/*
@@ -539,7 +539,7 @@ int rerere_remaining(struct string_list *merge_rr)
539539
}
540540

541541
/*
542-
* Find the conflict identified by "name"; the change between its
542+
* Find the conflict identified by "id"; the change between its
543543
* "preimage" (i.e. a previous contents with conflict markers) and its
544544
* "postimage" (i.e. the corresponding contents with conflicts
545545
* resolved) may apply cleanly to the contents stored in "path", i.e.
@@ -548,7 +548,7 @@ int rerere_remaining(struct string_list *merge_rr)
548548
* Returns 0 for successful replay of recorded resolution, or non-zero
549549
* for failure.
550550
*/
551-
static int merge(const char *name, const char *path)
551+
static int merge(const char *id, const char *path)
552552
{
553553
int ret;
554554
mmfile_t cur = {NULL, 0}, base = {NULL, 0}, other = {NULL, 0};
@@ -558,12 +558,12 @@ static int merge(const char *name, const char *path)
558558
* Normalize the conflicts in path and write it out to
559559
* "thisimage" temporary file.
560560
*/
561-
if (handle_file(path, NULL, rerere_path(name, "thisimage")) < 0)
561+
if (handle_file(path, NULL, rerere_path(id, "thisimage")) < 0)
562562
return 1;
563563

564-
if (read_mmfile(&cur, rerere_path(name, "thisimage")) ||
565-
read_mmfile(&base, rerere_path(name, "preimage")) ||
566-
read_mmfile(&other, rerere_path(name, "postimage"))) {
564+
if (read_mmfile(&cur, rerere_path(id, "thisimage")) ||
565+
read_mmfile(&base, rerere_path(id, "preimage")) ||
566+
read_mmfile(&other, rerere_path(id, "postimage"))) {
567567
ret = 1;
568568
goto out;
569569
}
@@ -580,9 +580,9 @@ static int merge(const char *name, const char *path)
580580
* A successful replay of recorded resolution.
581581
* Mark that "postimage" was used to help gc.
582582
*/
583-
if (utime(rerere_path(name, "postimage"), NULL) < 0)
583+
if (utime(rerere_path(id, "postimage"), NULL) < 0)
584584
warning("failed utime() on %s: %s",
585-
rerere_path(name, "postimage"),
585+
rerere_path(id, "postimage"),
586586
strerror(errno));
587587

588588
/* Update "path" with the resolution */
@@ -640,11 +640,11 @@ static void do_rerere_one_path(struct string_list_item *rr_item,
640640
struct string_list *update)
641641
{
642642
const char *path = rr_item->string;
643-
const char *name = (const char *)rr_item->util;
643+
const char *id = (const char *)rr_item->util;
644644

645645
/* Is there a recorded resolution we could attempt to apply? */
646-
if (has_rerere_resolution(name)) {
647-
if (merge(name, path))
646+
if (has_rerere_resolution(id)) {
647+
if (merge(id, path))
648648
return; /* failed to replay */
649649

650650
if (rerere_autoupdate)
@@ -655,7 +655,7 @@ static void do_rerere_one_path(struct string_list_item *rr_item,
655655
path);
656656
} else if (!handle_file(path, NULL, NULL)) {
657657
/* The user has resolved it. */
658-
copy_file(rerere_path(name, "postimage"), path, 0666);
658+
copy_file(rerere_path(id, "postimage"), path, 0666);
659659
fprintf(stderr, "Recorded resolution for '%s'.\n", path);
660660
} else {
661661
return;
@@ -680,7 +680,7 @@ static int do_plain_rerere(struct string_list *rr, int fd)
680680
*/
681681
for (i = 0; i < conflict.nr; i++) {
682682
unsigned char sha1[20];
683-
char *hex;
683+
char *id;
684684
int ret;
685685
const char *path = conflict.items[i].string;
686686

@@ -695,8 +695,8 @@ static int do_plain_rerere(struct string_list *rr, int fd)
695695
ret = handle_file(path, sha1, NULL);
696696
if (ret < 1)
697697
continue;
698-
hex = xstrdup(sha1_to_hex(sha1));
699-
string_list_insert(rr, path)->util = hex;
698+
id = xstrdup(sha1_to_hex(sha1));
699+
string_list_insert(rr, path)->util = id;
700700

701701
/*
702702
* If the directory does not exist, create
@@ -706,15 +706,15 @@ static int do_plain_rerere(struct string_list *rr, int fd)
706706
* NEEDSWORK: make sure "gc" does not remove
707707
* preimage without removing the directory.
708708
*/
709-
if (mkdir_in_gitdir(git_path("rr-cache/%s", hex)))
709+
if (mkdir_in_gitdir(git_path("rr-cache/%s", id)))
710710
continue;
711711

712712
/*
713713
* We are the first to encounter this
714714
* conflict. Ask handle_file() to write the
715715
* normalized contents to the "preimage" file.
716716
*/
717-
handle_file(path, NULL, rerere_path(hex, "preimage"));
717+
handle_file(path, NULL, rerere_path(id, "preimage"));
718718
fprintf(stderr, "Recorded preimage for '%s'\n", path);
719719
}
720720

@@ -788,7 +788,7 @@ int rerere(int flags)
788788
static int rerere_forget_one_path(const char *path, struct string_list *rr)
789789
{
790790
const char *filename;
791-
char *hex;
791+
char *id;
792792
unsigned char sha1[20];
793793
int ret;
794794
struct string_list_item *item;
@@ -802,8 +802,8 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)
802802
return error("Could not parse conflict hunks in '%s'", path);
803803

804804
/* Nuke the recorded resolution for the conflict */
805-
hex = xstrdup(sha1_to_hex(sha1));
806-
filename = rerere_path(hex, "postimage");
805+
id = xstrdup(sha1_to_hex(sha1));
806+
filename = rerere_path(id, "postimage");
807807
if (unlink(filename))
808808
return (errno == ENOENT
809809
? error("no remembered resolution for %s", path)
@@ -814,7 +814,7 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)
814814
* conflict in the working tree, run us again to record
815815
* the postimage.
816816
*/
817-
handle_cache(path, sha1, rerere_path(hex, "preimage"));
817+
handle_cache(path, sha1, rerere_path(id, "preimage"));
818818
fprintf(stderr, "Updated preimage for '%s'\n", path);
819819

820820
/*
@@ -823,7 +823,7 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)
823823
*/
824824
item = string_list_insert(rr, path);
825825
free(item->util);
826-
item->util = hex;
826+
item->util = id;
827827
fprintf(stderr, "Forgot resolution for %s\n", path);
828828
return 0;
829829
}
@@ -859,32 +859,32 @@ int rerere_forget(struct pathspec *pathspec)
859859
/*
860860
* Garbage collection support
861861
*/
862-
static time_t rerere_created_at(const char *name)
862+
static time_t rerere_created_at(const char *id)
863863
{
864864
struct stat st;
865-
return stat(rerere_path(name, "preimage"), &st) ? (time_t) 0 : st.st_mtime;
865+
return stat(rerere_path(id, "preimage"), &st) ? (time_t) 0 : st.st_mtime;
866866
}
867867

868-
static time_t rerere_last_used_at(const char *name)
868+
static time_t rerere_last_used_at(const char *id)
869869
{
870870
struct stat st;
871-
return stat(rerere_path(name, "postimage"), &st) ? (time_t) 0 : st.st_mtime;
871+
return stat(rerere_path(id, "postimage"), &st) ? (time_t) 0 : st.st_mtime;
872872
}
873873

874874
/*
875875
* Remove the recorded resolution for a given conflict ID
876876
*/
877-
static void unlink_rr_item(const char *name)
877+
static void unlink_rr_item(const char *id)
878878
{
879-
unlink(rerere_path(name, "thisimage"));
880-
unlink(rerere_path(name, "preimage"));
881-
unlink(rerere_path(name, "postimage"));
879+
unlink(rerere_path(id, "thisimage"));
880+
unlink(rerere_path(id, "preimage"));
881+
unlink(rerere_path(id, "postimage"));
882882
/*
883883
* NEEDSWORK: what if this rmdir() fails? Wouldn't we then
884884
* assume that we already have preimage recorded in
885885
* do_plain_rerere()?
886886
*/
887-
rmdir(git_path("rr-cache/%s", name));
887+
rmdir(git_path("rr-cache/%s", id));
888888
}
889889

890890
void rerere_gc(struct string_list *rr)
@@ -939,9 +939,9 @@ void rerere_clear(struct string_list *merge_rr)
939939
int i;
940940

941941
for (i = 0; i < merge_rr->nr; i++) {
942-
const char *name = (const char *)merge_rr->items[i].util;
943-
if (!has_rerere_resolution(name))
944-
unlink_rr_item(name);
942+
const char *id = (const char *)merge_rr->items[i].util;
943+
if (!has_rerere_resolution(id))
944+
unlink_rr_item(id);
945945
}
946946
unlink_or_warn(git_path("MERGE_RR"));
947947
}

rerere.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ extern void *RERERE_RESOLVED;
1717

1818
extern int setup_rerere(struct string_list *, int);
1919
extern int rerere(int);
20-
extern const char *rerere_path(const char *hex, const char *file);
20+
extern const char *rerere_path(const char *id, const char *file);
2121
extern int rerere_forget(struct pathspec *);
2222
extern int rerere_remaining(struct string_list *);
2323
extern void rerere_clear(struct string_list *);

0 commit comments

Comments
 (0)