{"thread":{"id":"57637","subject":"[PATCH] object-file: pass filename to fsync_or_die","startedAt":"2022-03-30T18:14:33Z","lastAt":"2022-03-30T18:14:33Z","messageCount":1,"participants":["Neeraj K. Singh via GitGitGadget"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"452686","messageId":"pull.1194.git.1648664055986.gitgitgadget@gmail.com","threadId":"57637","inReplyTo":null,"subject":"[PATCH] object-file: pass filename to fsync_or_die","fromName":"Neeraj K. Singh via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-03-30T18:14:15Z","receivedAt":"2022-03-30T18:14:33Z","isPatch":true,"sender":{"key":"name:Neeraj K. Singh","avatar":null},"body":"From: Neeraj Singh <neerajsi@microsoft.com>\n\nIf we die while trying to fsync a loose object file, pass the actual\nfilename we're trying to sync. This is likely to be more helpful for a\nuser trying to diagnose the cause of the failure than the former\n'loose object file' string. It also sidesteps any concerns about\ntranslating the die message differently for loose objects versus\nsomething else that has a real path.\n\nReported-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\nSigned-off-by: Neeraj Singh <neerajsi@microsoft.com>\n---\n    object-file: pass filename to fsync_or_die\n    \n    If we die while trying to fsync a loose object file, pass the actual\n    filename we're trying to sync. This is likely to be more helpful for a\n    user trying to diagnose the cause of the failure than the former 'loose\n    object file' string. It also sidesteps any concerns about translating\n    the die message differently for loose objects versus something else that\n    has a real path.\n    \n    Reported-by: Ævar Arnfjörð Bjarmason avarab@gmail.com Signed-off-by:\n    Neeraj Singh neerajsi@microsoft.com\n    \n    ------------------------------------------------------------------------\n    \n    This is in response to:\n    https://lore.kernel.org/git/220321.861qyv9rjr.gmgdl@evledraar.gmail.com/\n    \n    > Unrelated nit: this API is producing sentence lego unfriendly to\n    > translators.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-1194%2Fneerajsi-msft%2Fns%2Ffsync-die-filename-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1194/neerajsi-msft/ns/fsync-die-filename-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/1194\n\n object-file.c | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/object-file.c b/object-file.c\nindex b254bc50d70..5ffbf3d4fd4 100644\n--- a/object-file.c\n+++ b/object-file.c\n@@ -1888,16 +1888,16 @@ void hash_object_file(const struct git_hash_algo *algo, const void *buf,\n }\n \n /* Finalize a file on disk, and close it. */\n-static void close_loose_object(int fd)\n+static void close_loose_object(int fd, const char *filename)\n {\n \tif (the_repository->objects->odb->will_destroy)\n \t\tgoto out;\n \n \tif (fsync_object_files > 0)\n-\t\tfsync_or_die(fd, \"loose object file\");\n+\t\tfsync_or_die(fd, filename);\n \telse\n \t\tfsync_component_or_die(FSYNC_COMPONENT_LOOSE_OBJECT, fd,\n-\t\t\t\t       \"loose object file\");\n+\t\t\t\t       filename);\n \n out:\n \tif (close(fd) != 0)\n@@ -2011,7 +2011,7 @@ static int write_loose_object(const struct object_id *oid, char *hdr,\n \t\tdie(_(\"confused by unstable object source data for %s\"),\n \t\t    oid_to_hex(oid));\n \n-\tclose_loose_object(fd);\n+\tclose_loose_object(fd, tmp_file.buf);\n \n \tif (mtime) {\n \t\tstruct utimbuf utb;\n\nbase-commit: 805e0a68082a217f0112db9ee86a022227a9c81b\n-- \ngitgitgadget\n"}]}