On Fri, Jul 08, 2016 at 08:37:35AM +0200, Johannes Schindelin wrote: > > We have two forms of write_file(): one that dies, and one > > that returns an error. However, the latter has only a single > > caller, which immediately dies anyway (after producing a > > message that is not really any more informative than > > write_file's generic die(), and arguably worse because it > > does not give the actual filename). > > This is more an illustration of unnecessarily duplicated code, isn't it? > There are *tons* of instances in Git's code where writing to a file is > implemented separately (and differently). > > It would make tons of sense to consolidate all of these instances, > methinks. The diffstat should look *very* pleasing.
I grepped for O_WRONLY, and there are fewer instances than I would have thought. Most of the obvious write_file() candidates are in the merge code, which is probably why you saw so many of them. :) I started at converting a few sites, but it's actually a little awkward because they all have strbufs (with a ptr/len combo that _could_ contain NULs, but probably doesn't), and write_file() wants to take a format string. I think we can clean that up, though. I'll hopefully have a series in a few minutes. -Peff -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html