Skip to content

Commit b84be55

Browse files
larsxschneidergitster
authored andcommitted
convert: make apply_filter() adhere to standard Git error handling
apply_filter() returns a boolean that tells the caller if it "did convert or did not convert". The variable `ret` was used throughout the function to track errors whereas `1` denoted success and `0` failure. This is unusual for the Git source where `0` denotes success. Rename the variable and flip its value to make the function easier readable for Git developers. Signed-off-by: Lars Schneider <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bb643d8 commit b84be55

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

convert.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ static int apply_filter(const char *path, const char *src, size_t len, int fd,
451451
*
452452
* (child --> cmd) --> us
453453
*/
454-
int ret = 1;
454+
int err = 0;
455455
struct strbuf nbuf = STRBUF_INIT;
456456
struct async async;
457457
struct filter_params params;
@@ -477,23 +477,20 @@ static int apply_filter(const char *path, const char *src, size_t len, int fd,
477477
return 0; /* error was already reported */
478478

479479
if (strbuf_read(&nbuf, async.out, len) < 0) {
480-
error("read from external filter '%s' failed", cmd);
481-
ret = 0;
480+
err = error("read from external filter '%s' failed", cmd);
482481
}
483482
if (close(async.out)) {
484-
error("read from external filter '%s' failed", cmd);
485-
ret = 0;
483+
err = error("read from external filter '%s' failed", cmd);
486484
}
487485
if (finish_async(&async)) {
488-
error("external filter '%s' failed", cmd);
489-
ret = 0;
486+
err = error("external filter '%s' failed", cmd);
490487
}
491488

492-
if (ret) {
489+
if (!err) {
493490
strbuf_swap(dst, &nbuf);
494491
}
495492
strbuf_release(&nbuf);
496-
return ret;
493+
return !err;
497494
}
498495

499496
static struct convert_driver {

0 commit comments

Comments
 (0)