write_file: drop "gently" form

There are no callers left of write_file_gently(). Let's drop it, as it doesn't seem likely for new callers to be added (since its inception, the only callers who wanted the gentle form generally just died immediately themselves, and have since been converted). While we're there, let's also drop the "int" return from write_file, as it is never meaningful (in the non-gentle form, we always either die or return 0). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Jul 8, 2016 at 05:09 UTC ef22318cff51244cd0047b11ee7accfded522782
2 files changed +12 -45
cache.h
+1 -2
@@ -1734,8 +1734,7 @@ static inline ssize_t write_str_in_full(int fd, const char *str)
1734 return write_in_full(fd, str, strlen(str));
1735 }
1736
1737 -extern int write_file(const char *path, const char *fmt, ...);
1738 -extern int write_file_gently(const char *path, const char *fmt, ...);
1737 +extern void write_file(const char *path, const char *fmt, ...);
1738
1739 /* pager.c */
1740 extern void setup_pager(void);
wrapper.c
+11 -43
@@ -640,56 +640,24 @@ int xsnprintf(char *dst, size_t max, const char *fmt, ...)
640 return len;
641 }
642
643 -static int write_file_v(const char *path, int fatal,
644 - const char *fmt, va_list params)
643 +void write_file(const char *path, const char *fmt, ...)
644 {
645 + va_list params;
646 struct strbuf sb = STRBUF_INIT;
647 int fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0666);
648 - if (fd < 0) {
649 - if (fatal)
650 - die_errno(_("could not open %s for writing"), path);
651 - return -1;
652 - }
653 - strbuf_vaddf(&sb, fmt, params);
654 - strbuf_complete_line(&sb);
655 - if (write_in_full(fd, sb.buf, sb.len) != sb.len) {
656 - int err = errno;
657 - close(fd);
658 - strbuf_release(&sb);
659 - errno = err;
660 - if (fatal)
661 - die_errno(_("could not write to %s"), path);
662 - return -1;
663 - }
664 - strbuf_release(&sb);
665 - if (close(fd)) {
666 - if (fatal)
667 - die_errno(_("could not close %s"), path);
668 - return -1;
669 - }
670 - return 0;
671 -}
672 -
673 -int write_file(const char *path, const char *fmt, ...)
674 -{
675 - int status;
676 - va_list params;
648 + if (fd < 0)
649 + die_errno(_("could not open %s for writing"), path);
650
651 va_start(params, fmt);
679 - status = write_file_v(path, 1, fmt, params);
652 + strbuf_vaddf(&sb, fmt, params);
653 va_end(params);
681 - return status;
682 -}
683 -
684 -int write_file_gently(const char *path, const char *fmt, ...)
685 -{
686 - int status;
687 - va_list params;
654
689 - va_start(params, fmt);
690 - status = write_file_v(path, 0, fmt, params);
691 - va_end(params);
692 - return status;
655 + strbuf_complete_line(&sb);
656 + if (write_in_full(fd, sb.buf, sb.len) != sb.len)
657 + die_errno(_("could not write to %s"), path);
658 + strbuf_release(&sb);
659 + if (close(fd))
660 + die_errno(_("could not close %s"), path);
661 }
662
663 void sleep_millisec(int millisec)