Re: [RFC PATCH v1 02/17] merge-one-file: rewrite in C
- From
Chris Torek <chris.torek@gmail.com>
- Date
- Jun 25, 2020, 14:55 UTC
- Message-ID
- <CAPx1GvdoVf-yFmbCuFc3ZtPvQ=PjuFrum_mijsQ9u8uf61SOHQ@mail.gmail.com>
- In-Reply-To
- <20200625121953.16991-3-alban.gruin@gmail.com>
much snippage below, keeping just enough context to see which file, function, etc:
On Thu, Jun 25, 2020 at 5:49 AM Alban Gruin <alban.gruin@gmail.com> wrote:
Show 6 quoted lines
> diff --git a/builtin/merge-one-file.c b/builtin/merge-one-file.c > new file mode 100644 > index 0000000000..4992a6cd30 > --- /dev/null > +++ b/builtin/merge-one-file.c > @@ -0,0 +1,275 @@
Show 6 quoted lines
> +static int do_merge_one_file(const struct object_id *orig_blob,
> + const struct object_id *our_blob,
> + const struct object_id *their_blob, const char *path,
> + unsigned int orig_mode, unsigned int our_mode, unsigned int their_mode)
> +{
> + int ret, source, dest;Show 11 quoted lines
> + source = open(src1.buf, O_RDONLY); > + dest = open(path, O_WRONLY | O_TRUNC); > + > + copy_fd(source, dest); > + > + close(source); > + close(dest); > + > + unlink(orig.buf); > + unlink(src1.buf); > + unlink(src2.buf);
Some of this goes away in subsequent patches, but most of these calls should be checked for error returns, especially the two `open`s in case someone has messed with permissions.
Chris