Skip to content

Commit c7a25d3

Browse files
committed
rerere: further de-dent do_plain_rerere()
It's just easier to follow this way. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8e7768b commit c7a25d3

File tree

1 file changed

+33
-32
lines changed

1 file changed

+33
-32
lines changed

rerere.c

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -682,42 +682,43 @@ static int do_plain_rerere(struct string_list *rr, int fd)
682682
* initial run would catch all and register their preimages.
683683
*/
684684
for (i = 0; i < conflict.nr; i++) {
685+
unsigned char sha1[20];
686+
char *hex;
687+
int ret;
685688
const char *path = conflict.items[i].string;
686-
if (!string_list_has_string(rr, path)) {
687-
unsigned char sha1[20];
688-
char *hex;
689-
int ret;
690689

691-
/*
692-
* Ask handle_file() to scan and assign a
693-
* conflict ID. No need to write anything out
694-
* yet.
695-
*/
696-
ret = handle_file(path, sha1, NULL);
697-
if (ret < 1)
698-
continue;
699-
hex = xstrdup(sha1_to_hex(sha1));
700-
string_list_insert(rr, path)->util = hex;
690+
if (string_list_has_string(rr, path))
691+
continue;
701692

702-
/*
703-
* If the directory does not exist, create
704-
* it. mkdir_in_gitdir() will fail with
705-
* EEXIST if there already is one.
706-
*
707-
* NEEDSWORK: make sure "gc" does not remove
708-
* preimage without removing the directory.
709-
*/
710-
if (mkdir_in_gitdir(git_path("rr-cache/%s", hex)))
711-
continue;
693+
/*
694+
* Ask handle_file() to scan and assign a
695+
* conflict ID. No need to write anything out
696+
* yet.
697+
*/
698+
ret = handle_file(path, sha1, NULL);
699+
if (ret < 1)
700+
continue;
701+
hex = xstrdup(sha1_to_hex(sha1));
702+
string_list_insert(rr, path)->util = hex;
712703

713-
/*
714-
* We are the first to encounter this
715-
* conflict. Ask handle_file() to write the
716-
* normalized contents to the "preimage" file.
717-
*/
718-
handle_file(path, NULL, rerere_path(hex, "preimage"));
719-
fprintf(stderr, "Recorded preimage for '%s'\n", path);
720-
}
704+
/*
705+
* If the directory does not exist, create
706+
* it. mkdir_in_gitdir() will fail with
707+
* EEXIST if there already is one.
708+
*
709+
* NEEDSWORK: make sure "gc" does not remove
710+
* preimage without removing the directory.
711+
*/
712+
if (mkdir_in_gitdir(git_path("rr-cache/%s", hex)))
713+
continue;
714+
715+
/*
716+
* We are the first to encounter this
717+
* conflict. Ask handle_file() to write the
718+
* normalized contents to the "preimage" file.
719+
*/
720+
handle_file(path, NULL, rerere_path(hex, "preimage"));
721+
fprintf(stderr, "Recorded preimage for '%s'\n", path);
721722
}
722723

723724
for (i = 0; i < rr->nr; i++)

0 commit comments

Comments
 (0)