{"thread":{"id":"63845","subject":"[PATCH v6 1/1] test-delta: Replaced space-based indentation with tabs to follow Git coding style.","startedAt":"2025-07-25T06:10:52Z","lastAt":"2025-07-25T06:10:52Z","messageCount":1,"participants":["Hoyoung Lee"],"isPatch":true,"patchVersion":6,"patchTotal":1},"messages":[{"id":"522721","messageId":"20250725061038.3130912-1-lhywkd22@gmail.com","threadId":"63845","inReplyTo":null,"subject":"[PATCH v6 1/1] test-delta: Replaced space-based indentation with tabs to follow Git coding style.","fromName":"Hoyoung Lee","fromEmail":"lhywkd22@gmail.com","sentAt":"2025-07-25T06:10:38Z","receivedAt":"2025-07-25T06:10:52Z","isPatch":true,"sender":{"key":"lhywkd22@gmail.com","avatar":"https://avatars.githubusercontent.com/u/204378075?v=4"},"body":"Replaced space-based indentation with tabs to follow Git coding style.\nNo functional changes.\n\nSigned-off-by: Hoyoung Lee <lhywkd22@gmail.com>\n---\n t/helper/test-delta.c | 78 ++++++++++++++-----------------------------\n 1 file changed, 25 insertions(+), 53 deletions(-)\n\ndiff --git a/t/helper/test-delta.c b/t/helper/test-delta.c\nindex 6bc787a474..4977ee4eaf 100644\n--- a/t/helper/test-delta.c\n+++ b/t/helper/test-delta.c\n@@ -11,6 +11,7 @@\n #include \"test-tool.h\"\n #include \"git-compat-util.h\"\n #include \"delta.h\"\n+#include \"strbuf.h\"\n \n static const char usage_str[] =\n \t\"test-tool delta (-d|-p) <from_file> <data_file> <out_file>\";\n@@ -18,68 +19,39 @@ static const char usage_str[] =\n int cmd__delta(int argc, const char **argv)\n {\n \tint fd;\n-\tstruct stat st;\n-\tvoid *from_buf = NULL, *data_buf = NULL, *out_buf = NULL;\n-\tunsigned long from_size, data_size, out_size;\n-\tint ret = 1;\n+\tstruct strbuf from = STRBUF_INIT, data = STRBUF_INIT;\n+\tchar *out_buf;\n+\tunsigned long out_size;\n \n-\tif (argc != 5 || (strcmp(argv[1], \"-d\") && strcmp(argv[1], \"-p\"))) {\n-\t\tfprintf(stderr, \"usage: %s\\n\", usage_str);\n-\t\treturn 1;\n-\t}\n+\tif (argc != 5 || (strcmp(argv[1], \"-d\") && strcmp(argv[1], \"-p\")))\n+        \tusage(usage_str);\n \n-\tfd = open(argv[2], O_RDONLY);\n-\tif (fd < 0 || fstat(fd, &st)) {\n-\t\tperror(argv[2]);\n-\t\treturn 1;\n-\t}\n-\tfrom_size = st.st_size;\n-\tfrom_buf = xmalloc(from_size);\n-\tif (read_in_full(fd, from_buf, from_size) < 0) {\n-\t\tperror(argv[2]);\n-\t\tclose(fd);\n-\t\tgoto cleanup;\n-\t}\n-\tclose(fd);\n-\n-\tfd = open(argv[3], O_RDONLY);\n-\tif (fd < 0 || fstat(fd, &st)) {\n-\t\tperror(argv[3]);\n-\t\tgoto cleanup;\n-\t}\n-\tdata_size = st.st_size;\n-\tdata_buf = xmalloc(data_size);\n-\tif (read_in_full(fd, data_buf, data_size) < 0) {\n-\t\tperror(argv[3]);\n-\t\tclose(fd);\n-\t\tgoto cleanup;\n-\t}\n-\tclose(fd);\n+\tif (strbuf_read_file(&from, argv[2], 0) < 0)\n+        \tdie_errno(\"unable to read '%s'\", argv[2]);\n+\tif (strbuf_read_file(&data, argv[3], 0) < 0)\n+        \tdie_errno(\"unable to read '%s'\", argv[3]);\n \n \tif (argv[1][1] == 'd')\n-\t\tout_buf = diff_delta(from_buf, from_size,\n-\t\t\t\t     data_buf, data_size,\n+        \tout_buf = diff_delta(from.buf, from.len,\n+\t\t\t\t     data.buf, data.len,\n \t\t\t\t     &out_size, 0);\n \telse\n-\t\tout_buf = patch_delta(from_buf, from_size,\n-\t\t\t\t      data_buf, data_size,\n+        \tout_buf = patch_delta(from.buf, from.len,\n+\t\t\t\t      data.buf, data.len,\n \t\t\t\t      &out_size);\n-\tif (!out_buf) {\n-\t\tfprintf(stderr, \"delta operation failed (returned NULL)\\n\");\n-\t\tgoto cleanup;\n-\t}\n \n-\tfd = open (argv[4], O_WRONLY|O_CREAT|O_TRUNC, 0666);\n-\tif (fd < 0 || write_in_full(fd, out_buf, out_size) < 0) {\n-\t\tperror(argv[4]);\n-\t\tgoto cleanup;\n-\t}\n+\tif (!out_buf)\n+        \tdie(\"delta operation failed (returned NULL)\");\n+\n+\tfd = xopen(argv[4], O_WRONLY | O_CREAT | O_TRUNC, 0666);\n+\tif (write_in_full(fd, out_buf, out_size) < 0)\n+        \tdie_errno(\"write(%s)\", argv[4]);\n+\tif (close(fd) < 0)\n+        \tdie_errno(\"close(%s)\", argv[4]);\n \n-\tret = 0;\n-cleanup:\n-\tfree(from_buf);\n-\tfree(data_buf);\n+\tstrbuf_release(&from);\n+\tstrbuf_release(&data);\n \tfree(out_buf);\n \n-\treturn ret;\n+\treturn 0;\n }\n-- \n2.34.1\n\n"}]}