git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Han-Wen Nienhuys via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Han-Wen Nienhuys <hanwen@google.com>,
	Han-Wen Nienhuys <hanwenn@gmail.com>,
	Han-Wen Nienhuys <hanwen@google.com>
Subject: [PATCH v2] refs: print errno for read_raw_ref if GIT_TRACE_REFS is set
Date: Tue, 13 Apr 2021 12:10:38 +0000	[thread overview]
Message-ID: <pull.1002.v2.git.git.1618315838582.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1002.git.git.1618255954484.gitgitgadget@gmail.com>

From: Han-Wen Nienhuys <hanwen@google.com>

The ref backend API uses errno as a sideband error channel.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
---
    refs: print errno for read_raw_ref if GIT_TRACE_REFS is set
    
    The ref backend API uses errno as a sideband error channel.
    
    Signed-off-by: Han-Wen Nienhuys hanwen@google.com

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1002%2Fhanwen%2Ferrno-debug-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1002/hanwen/errno-debug-v2
Pull-Request: https://github.com/git/git/pull/1002

Range-diff vs v1:

 1:  9b150c5563f9 ! 1:  1e9a8990e7f2 refs: print errno for read_raw_ref if GIT_TRACE_REFS is set
     @@ Commit message
      
       ## refs/debug.c ##
      @@ refs/debug.c: static int debug_read_raw_ref(struct ref_store *ref_store, const char *refname,
     + {
     + 	struct debug_ref_store *drefs = (struct debug_ref_store *)ref_store;
       	int res = 0;
     ++	int saved_errno = 0;
       
       	oidcpy(oid, &null_oid);
      +	errno = 0;
       	res = drefs->refs->be->read_raw_ref(drefs->refs, refname, oid, referent,
       					    type);
     ++	saved_errno = errno;
       
     -@@ refs/debug.c: static int debug_read_raw_ref(struct ref_store *ref_store, const char *refname,
     + 	if (res == 0) {
       		trace_printf_key(&trace_refs, "read_raw_ref: %s: %s (=> %s) type %x: %d\n",
       			refname, oid_to_hex(oid), referent->buf, *type, res);
       	} else {
      -		trace_printf_key(&trace_refs, "read_raw_ref: %s: %d\n", refname, res);
      +		trace_printf_key(&trace_refs,
      +				 "read_raw_ref: %s: %d (errno %d)\n", refname,
     -+				 res, errno);
     ++				 res, saved_errno);
       	}
       	return res;
       }


 refs/debug.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/refs/debug.c b/refs/debug.c
index 922e64fa6ad9..286987b72166 100644
--- a/refs/debug.c
+++ b/refs/debug.c
@@ -242,16 +242,21 @@ static int debug_read_raw_ref(struct ref_store *ref_store, const char *refname,
 {
 	struct debug_ref_store *drefs = (struct debug_ref_store *)ref_store;
 	int res = 0;
+	int saved_errno = 0;
 
 	oidcpy(oid, &null_oid);
+	errno = 0;
 	res = drefs->refs->be->read_raw_ref(drefs->refs, refname, oid, referent,
 					    type);
+	saved_errno = errno;
 
 	if (res == 0) {
 		trace_printf_key(&trace_refs, "read_raw_ref: %s: %s (=> %s) type %x: %d\n",
 			refname, oid_to_hex(oid), referent->buf, *type, res);
 	} else {
-		trace_printf_key(&trace_refs, "read_raw_ref: %s: %d\n", refname, res);
+		trace_printf_key(&trace_refs,
+				 "read_raw_ref: %s: %d (errno %d)\n", refname,
+				 res, saved_errno);
 	}
 	return res;
 }

base-commit: 89b43f80a514aee58b662ad606e6352e03eaeee4
-- 
gitgitgadget

      parent reply	other threads:[~2021-04-13 12:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-12 19:32 [PATCH] refs: print errno for read_raw_ref if GIT_TRACE_REFS is set Han-Wen Nienhuys via GitGitGadget
2021-04-12 21:45 ` Junio C Hamano
2021-04-13 11:58   ` Han-Wen Nienhuys
2021-04-13 12:02     ` Han-Wen Nienhuys
2021-04-13 20:08     ` Junio C Hamano
2021-04-23  8:34       ` Han-Wen Nienhuys
2021-04-13 12:10 ` Han-Wen Nienhuys via GitGitGadget [this message]

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=pull.1002.v2.git.git.1618315838582.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=hanwen@google.com \
    --cc=hanwenn@gmail.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).