From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Haggerty Subject: [PATCH v3 11/19] refs: remove some functions from the module's public interface Date: Mon, 22 Jun 2015 16:03:02 +0200 Message-ID: <5413233024b7efc9081f25ccc983988d48c76c45.1434980615.git.mhagger@alum.mit.edu> References: Cc: Stefan Beller , Jeff King , git@vger.kernel.org, Michael Haggerty To: Junio C Hamano X-From: git-owner@vger.kernel.org Mon Jun 22 16:04:09 2015 Return-path: Envelope-to: gcvg-git-2@plane.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Z72KN-0005gX-Ah for gcvg-git-2@plane.gmane.org; Mon, 22 Jun 2015 16:03:59 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933690AbbFVODz (ORCPT ); Mon, 22 Jun 2015 10:03:55 -0400 Received: from alum-mailsec-scanner-6.mit.edu ([18.7.68.18]:52843 "EHLO alum-mailsec-scanner-6.mit.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933443AbbFVODn (ORCPT ); Mon, 22 Jun 2015 10:03:43 -0400 X-AuditID: 12074412-f79a76d000007c8b-85-558815b14c2f Received: from outgoing-alum.mit.edu (OUTGOING-ALUM.MIT.EDU [18.7.68.33]) by alum-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP id 9E.21.31883.1B518855; Mon, 22 Jun 2015 10:03:29 -0400 (EDT) Received: from michael.fritz.box (p4FC977DB.dip0.t-ipconnect.de [79.201.119.219]) (authenticated bits=0) (User authenticated as mhagger@ALUM.MIT.EDU) by outgoing-alum.mit.edu (8.13.8/8.12.4) with ESMTP id t5ME3Cc9030627 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT); Mon, 22 Jun 2015 10:03:28 -0400 X-Mailer: git-send-email 2.1.4 In-Reply-To: X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrDIsWRmVeSWpSXmKPExsUixO6iqLtRtCPU4N9WMYuuK91MFg29V5gt bq+Yz2zxo6WH2WLz5nYWB1aPv+8/MHks2FTq8ax3D6PHxUvKHp83yQWwRnHbJCWWlAVnpufp 2yVwZ6zeNZel4I9SxYE7/9gaGPfIdDFycEgImEh8/qfWxcgJZIpJXLi3nq2LkYtDSOAyo8Sc FReYIZyTTBJdu1azglSxCehKLOppZgKxRQTUJCa2HWIBKWIW6GCUuLB8GztIQlggQuLF5Vds IDaLgKrEzd9HwGxegSiJT5OvMEGsk5M4f/wnM4jNKWAhMX/ff7BeIQFziYkzH7FMYORdwMiw ilEuMac0Vzc3MTOnODVZtzg5MS8vtUjXTC83s0QvNaV0EyMkpIR2MK4/KXeIUYCDUYmH18G2 PVSINbGsuDL3EKMkB5OSKO+B10AhvqT8lMqMxOKM+KLSnNTiQ4wSHMxKIrwtZ4FyvCmJlVWp RfkwKWkOFiVx3p+L1f2EBNITS1KzU1MLUotgsjIcHEoSvH4iHaFCgkWp6akVaZk5JQhpJg5O kOFcUiLFqXkpqUWJpSUZ8aDYiC8GRgdIigdo71KQdt7igsRcoChE6ylGRSlx3skgCQGQREZp HtxYWKJ4xSgO9KUw70uQKh5gkoHrfgU0mAlo8JfcNpDBJYkIKakGxk3GM5ZyJt7/aKIexG6w 2aGme+okcxGL5rlzZ5QWhu09H6PlPdlS9pT2B/34aPllBUWta0pfdaq4hW38Wmn7fL6Wgs9m oXT3yzlp7ZPPPPu8NtGy+TVrt3rtpFo9De7kZds9mLaUhlnFx5icK/PwnbVjWbl0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: The following functions are no longer used from outside the refs module: * lock_packed_refs() * add_packed_ref() * commit_packed_refs() * rollback_packed_refs() So make these functions private. This is an important step, because it means that nobody outside of the refs module needs to know the difference between loose and packed references. Signed-off-by: Michael Haggerty --- refs.c | 31 ++++++++++++++++++++++++------- refs.h | 30 ------------------------------ 2 files changed, 24 insertions(+), 37 deletions(-) diff --git a/refs.c b/refs.c index 2367572..31661c7 100644 --- a/refs.c +++ b/refs.c @@ -1314,7 +1314,13 @@ static struct ref_dir *get_packed_refs(struct ref_cache *refs) return get_packed_ref_dir(get_packed_ref_cache(refs)); } -void add_packed_ref(const char *refname, const unsigned char *sha1) +/* + * Add a reference to the in-memory packed reference cache. This may + * only be called while the packed-refs file is locked (see + * lock_packed_refs()). To actually write the packed-refs file, call + * commit_packed_refs(). + */ +static void add_packed_ref(const char *refname, const unsigned char *sha1) { struct packed_ref_cache *packed_ref_cache = get_packed_ref_cache(&ref_cache); @@ -2503,8 +2509,12 @@ static int write_packed_entry_fn(struct ref_entry *entry, void *cb_data) return 0; } -/* This should return a meaningful errno on failure */ -int lock_packed_refs(int flags) +/* + * Lock the packed-refs file for writing. Flags is passed to + * hold_lock_file_for_update(). Return 0 on success. On errors, set + * errno appropriately and return a nonzero value. + */ +static int lock_packed_refs(int flags) { static int timeout_configured = 0; static int timeout_value = 1000; @@ -2534,10 +2544,12 @@ int lock_packed_refs(int flags) } /* - * Commit the packed refs changes. - * On error we must make sure that errno contains a meaningful value. + * Write the current version of the packed refs cache from memory to + * disk. The packed-refs file must already be locked for writing (see + * lock_packed_refs()). Return zero on success. On errors, set errno + * and return a nonzero value */ -int commit_packed_refs(void) +static int commit_packed_refs(void) { struct packed_ref_cache *packed_ref_cache = get_packed_ref_cache(&ref_cache); @@ -2566,7 +2578,12 @@ int commit_packed_refs(void) return error; } -void rollback_packed_refs(void) +/* + * Rollback the lockfile for the packed-refs file, and discard the + * in-memory packed reference cache. (The packed-refs file will be + * read anew if it is needed again after this function is called.) + */ +static void rollback_packed_refs(void) { struct packed_ref_cache *packed_ref_cache = get_packed_ref_cache(&ref_cache); diff --git a/refs.h b/refs.h index 9602889..cd87f2f 100644 --- a/refs.h +++ b/refs.h @@ -111,36 +111,6 @@ extern void warn_dangling_symref(FILE *fp, const char *msg_fmt, const char *refn extern void warn_dangling_symrefs(FILE *fp, const char *msg_fmt, const struct string_list *refnames); /* - * Lock the packed-refs file for writing. Flags is passed to - * hold_lock_file_for_update(). Return 0 on success. - * Errno is set to something meaningful on error. - */ -extern int lock_packed_refs(int flags); - -/* - * Add a reference to the in-memory packed reference cache. This may - * only be called while the packed-refs file is locked (see - * lock_packed_refs()). To actually write the packed-refs file, call - * commit_packed_refs(). - */ -extern void add_packed_ref(const char *refname, const unsigned char *sha1); - -/* - * Write the current version of the packed refs cache from memory to - * disk. The packed-refs file must already be locked for writing (see - * lock_packed_refs()). Return zero on success. - * Sets errno to something meaningful on error. - */ -extern int commit_packed_refs(void); - -/* - * Rollback the lockfile for the packed-refs file, and discard the - * in-memory packed reference cache. (The packed-refs file will be - * read anew if it is needed again after this function is called.) - */ -extern void rollback_packed_refs(void); - -/* * Flags for controlling behaviour of pack_refs() * PACK_REFS_PRUNE: Prune loose refs after packing * PACK_REFS_ALL: Pack _all_ refs, not just tags and already packed refs -- 2.1.4