refs: remove some functions from the module's public interface

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 <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Haggerty committed Jun 22, 2015 at 16:03 UTC 0a4b24ff146405fb636d74945c0fdf1afaef3fd6
2 files changed +24 -37
refs.c
+24 -7
@@ -1314,7 +1314,13 @@ static struct ref_dir *get_packed_refs(struct ref_cache *refs)
1314 return get_packed_ref_dir(get_packed_ref_cache(refs));
1315 }
1316
1317 -void add_packed_ref(const char *refname, const unsigned char *sha1)
1317 +/*
1318 + * Add a reference to the in-memory packed reference cache. This may
1319 + * only be called while the packed-refs file is locked (see
1320 + * lock_packed_refs()). To actually write the packed-refs file, call
1321 + * commit_packed_refs().
1322 + */
1323 +static void add_packed_ref(const char *refname, const unsigned char *sha1)
1324 {
1325 struct packed_ref_cache *packed_ref_cache =
1326 get_packed_ref_cache(&ref_cache);
@@ -2515,8 +2521,12 @@ static int write_packed_entry_fn(struct ref_entry *entry, void *cb_data)
2521 return 0;
2522 }
2523
2518 -/* This should return a meaningful errno on failure */
2519 -int lock_packed_refs(int flags)
2524 +/*
2525 + * Lock the packed-refs file for writing. Flags is passed to
2526 + * hold_lock_file_for_update(). Return 0 on success. On errors, set
2527 + * errno appropriately and return a nonzero value.
2528 + */
2529 +static int lock_packed_refs(int flags)
2530 {
2531 static int timeout_configured = 0;
2532 static int timeout_value = 1000;
@@ -2546,10 +2556,12 @@ int lock_packed_refs(int flags)
2556 }
2557
2558 /*
2549 - * Commit the packed refs changes.
2550 - * On error we must make sure that errno contains a meaningful value.
2559 + * Write the current version of the packed refs cache from memory to
2560 + * disk. The packed-refs file must already be locked for writing (see
2561 + * lock_packed_refs()). Return zero on success. On errors, set errno
2562 + * and return a nonzero value
2563 */
2552 -int commit_packed_refs(void)
2564 +static int commit_packed_refs(void)
2565 {
2566 struct packed_ref_cache *packed_ref_cache =
2567 get_packed_ref_cache(&ref_cache);
@@ -2578,7 +2590,12 @@ int commit_packed_refs(void)
2590 return error;
2591 }
2592
2581 -void rollback_packed_refs(void)
2593 +/*
2594 + * Rollback the lockfile for the packed-refs file, and discard the
2595 + * in-memory packed reference cache. (The packed-refs file will be
2596 + * read anew if it is needed again after this function is called.)
2597 + */
2598 +static void rollback_packed_refs(void)
2599 {
2600 struct packed_ref_cache *packed_ref_cache =
2601 get_packed_ref_cache(&ref_cache);
refs.h
-30
@@ -110,36 +110,6 @@ extern int for_each_rawref(each_ref_fn, void *);
110 extern void warn_dangling_symref(FILE *fp, const char *msg_fmt, const char *refname);
111 extern void warn_dangling_symrefs(FILE *fp, const char *msg_fmt, const struct string_list *refnames);
112
113 -/*
114 - * Lock the packed-refs file for writing. Flags is passed to
115 - * hold_lock_file_for_update(). Return 0 on success.
116 - * Errno is set to something meaningful on error.
117 - */
118 -extern int lock_packed_refs(int flags);
119 -
120 -/*
121 - * Add a reference to the in-memory packed reference cache. This may
122 - * only be called while the packed-refs file is locked (see
123 - * lock_packed_refs()). To actually write the packed-refs file, call
124 - * commit_packed_refs().
125 - */
126 -extern void add_packed_ref(const char *refname, const unsigned char *sha1);
127 -
128 -/*
129 - * Write the current version of the packed refs cache from memory to
130 - * disk. The packed-refs file must already be locked for writing (see
131 - * lock_packed_refs()). Return zero on success.
132 - * Sets errno to something meaningful on error.
133 - */
134 -extern int commit_packed_refs(void);
135 -
136 -/*
137 - * Rollback the lockfile for the packed-refs file, and discard the
138 - * in-memory packed reference cache. (The packed-refs file will be
139 - * read anew if it is needed again after this function is called.)
140 - */
141 -extern void rollback_packed_refs(void);
142 -
113 /*
114 * Flags for controlling behaviour of pack_refs()
115 * PACK_REFS_PRUNE: Prune loose refs after packing