Re: [RFC PATCH v1 02/17] merge-one-file: rewrite in C

From
Chris Torek <hidden>
Date
2020-06-25 14:55:38
Reply to
Alban Gruin, 2020-06-25
much snippage below, keeping just enough context to see which file,
function, etc:

On Thu, Jun 25, 2020 at 5:49 AM Alban Gruin [off-list ref] wrote:
quoted hunk ↗ jump to hunk
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 @@
quoted hunk ↗ jump to hunk
+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;
quoted hunk ↗ jump to hunk
+       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
Thread (185 messages) 185 messages, 9 authors, last reply 2022-12-15
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help