@@ -393,12 +393,13 @@ static int is_cmarker(char *buf, int marker_char, int marker_size)
393393 * one side of the conflict, NUL, the other side of the conflict,
394394 * and NUL concatenated together.
395395 *
396- * Return the number of conflict hunks found.
396+ * Return 1 if conflict hunks are found, 0 if there are no conflict
397+ * hunks and -1 if an error occured.
397398 */
398399static int handle_path (unsigned char * sha1 , struct rerere_io * io , int marker_size )
399400{
400401 git_SHA_CTX ctx ;
401- int hunk_no = 0 ;
402+ int has_conflicts = 0 ;
402403 enum {
403404 RR_CONTEXT = 0 , RR_SIDE_1 , RR_SIDE_2 , RR_ORIGINAL
404405 } hunk = RR_CONTEXT ;
@@ -426,7 +427,7 @@ static int handle_path(unsigned char *sha1, struct rerere_io *io, int marker_siz
426427 goto bad ;
427428 if (strbuf_cmp (& one , & two ) > 0 )
428429 strbuf_swap (& one , & two );
429- hunk_no ++ ;
430+ has_conflicts = 1 ;
430431 hunk = RR_CONTEXT ;
431432 rerere_io_putconflict ('<' , marker_size , io );
432433 rerere_io_putmem (one .buf , one .len , io );
@@ -462,7 +463,7 @@ static int handle_path(unsigned char *sha1, struct rerere_io *io, int marker_siz
462463 git_SHA1_Final (sha1 , & ctx );
463464 if (hunk != RR_CONTEXT )
464465 return -1 ;
465- return hunk_no ;
466+ return has_conflicts ;
466467}
467468
468469/*
@@ -471,7 +472,7 @@ static int handle_path(unsigned char *sha1, struct rerere_io *io, int marker_siz
471472 */
472473static int handle_file (const char * path , unsigned char * sha1 , const char * output )
473474{
474- int hunk_no = 0 ;
475+ int has_conflicts = 0 ;
475476 struct rerere_io_file io ;
476477 int marker_size = ll_merge_marker_size (path );
477478
@@ -491,7 +492,7 @@ static int handle_file(const char *path, unsigned char *sha1, const char *output
491492 }
492493 }
493494
494- hunk_no = handle_path (sha1 , (struct rerere_io * )& io , marker_size );
495+ has_conflicts = handle_path (sha1 , (struct rerere_io * )& io , marker_size );
495496
496497 fclose (io .input );
497498 if (io .io .wrerror )
@@ -500,14 +501,14 @@ static int handle_file(const char *path, unsigned char *sha1, const char *output
500501 if (io .io .output && fclose (io .io .output ))
501502 io .io .wrerror = error_errno (_ ("failed to flush '%s'" ), path );
502503
503- if (hunk_no < 0 ) {
504+ if (has_conflicts < 0 ) {
504505 if (output )
505506 unlink_or_warn (output );
506507 return error (_ ("could not parse conflict hunks in '%s'" ), path );
507508 }
508509 if (io .io .wrerror )
509510 return -1 ;
510- return hunk_no ;
511+ return has_conflicts ;
511512}
512513
513514/*
@@ -954,7 +955,7 @@ static int handle_cache(const char *path, unsigned char *sha1, const char *outpu
954955 mmfile_t mmfile [3 ] = {{NULL }};
955956 mmbuffer_t result = {NULL , 0 };
956957 const struct cache_entry * ce ;
957- int pos , len , i , hunk_no ;
958+ int pos , len , i , has_conflicts ;
958959 struct rerere_io_mem io ;
959960 int marker_size = ll_merge_marker_size (path );
960961
@@ -1008,11 +1009,11 @@ static int handle_cache(const char *path, unsigned char *sha1, const char *outpu
10081009 * Grab the conflict ID and optionally write the original
10091010 * contents with conflict markers out.
10101011 */
1011- hunk_no = handle_path (sha1 , (struct rerere_io * )& io , marker_size );
1012+ has_conflicts = handle_path (sha1 , (struct rerere_io * )& io , marker_size );
10121013 strbuf_release (& io .input );
10131014 if (io .io .output )
10141015 fclose (io .io .output );
1015- return hunk_no ;
1016+ return has_conflicts ;
10161017}
10171018
10181019static int rerere_forget_one_path (const char * path , struct string_list * rr )
0 commit comments