All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Neeraj K. Singh via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: "Neeraj K. Singh" <neerajsi@microsoft.com>,
	Neeraj Singh <neerajsi@microsoft.com>
Subject: [PATCH] object-file: pass filename to fsync_or_die
Date: Wed, 30 Mar 2022 18:14:15 +0000	[thread overview]
Message-ID: <pull.1194.git.1648664055986.gitgitgadget@gmail.com> (raw)

From: Neeraj Singh <neerajsi@microsoft.com>

If we die while trying to fsync a loose object file, pass the actual
filename we're trying to sync. This is likely to be more helpful for a
user trying to diagnose the cause of the failure than the former
'loose object file' string. It also sidesteps any concerns about
translating the die message differently for loose objects versus
something else that has a real path.

Reported-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Neeraj Singh <neerajsi@microsoft.com>
---
    object-file: pass filename to fsync_or_die
    
    If we die while trying to fsync a loose object file, pass the actual
    filename we're trying to sync. This is likely to be more helpful for a
    user trying to diagnose the cause of the failure than the former 'loose
    object file' string. It also sidesteps any concerns about translating
    the die message differently for loose objects versus something else that
    has a real path.
    
    Reported-by: Ævar Arnfjörð Bjarmason avarab@gmail.com Signed-off-by:
    Neeraj Singh neerajsi@microsoft.com
    
    ------------------------------------------------------------------------
    
    This is in response to:
    https://lore.kernel.org/git/220321.861qyv9rjr.gmgdl@evledraar.gmail.com/
    
    > Unrelated nit: this API is producing sentence lego unfriendly to
    > translators.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1194%2Fneerajsi-msft%2Fns%2Ffsync-die-filename-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1194/neerajsi-msft/ns/fsync-die-filename-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1194

 object-file.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/object-file.c b/object-file.c
index b254bc50d70..5ffbf3d4fd4 100644
--- a/object-file.c
+++ b/object-file.c
@@ -1888,16 +1888,16 @@ void hash_object_file(const struct git_hash_algo *algo, const void *buf,
 }
 
 /* Finalize a file on disk, and close it. */
-static void close_loose_object(int fd)
+static void close_loose_object(int fd, const char *filename)
 {
 	if (the_repository->objects->odb->will_destroy)
 		goto out;
 
 	if (fsync_object_files > 0)
-		fsync_or_die(fd, "loose object file");
+		fsync_or_die(fd, filename);
 	else
 		fsync_component_or_die(FSYNC_COMPONENT_LOOSE_OBJECT, fd,
-				       "loose object file");
+				       filename);
 
 out:
 	if (close(fd) != 0)
@@ -2011,7 +2011,7 @@ static int write_loose_object(const struct object_id *oid, char *hdr,
 		die(_("confused by unstable object source data for %s"),
 		    oid_to_hex(oid));
 
-	close_loose_object(fd);
+	close_loose_object(fd, tmp_file.buf);
 
 	if (mtime) {
 		struct utimbuf utb;

base-commit: 805e0a68082a217f0112db9ee86a022227a9c81b
-- 
gitgitgadget

                 reply	other threads:[~2022-03-30 18:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=pull.1194.git.1648664055986.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=neerajsi@microsoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.