refs: use same lock_file object for both ref-packing functions

Use a single struct lock_file for both pack_refs() and repack_without_ref(). Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Haggerty committed Apr 22, 2013 at 21:52 UTC d9470330379f5899dd117b7c720e67d278fed9e2
1 file changed +4 -6
refs.c
+4 -6
@@ -2092,7 +2092,7 @@ static void prune_refs(struct ref_to_prune *r)
2092 }
2093 }
2094
2095 -static struct lock_file packed;
2095 +static struct lock_file packlock;
2096
2097 int pack_refs(unsigned int flags)
2098 {
@@ -2102,7 +2102,7 @@ int pack_refs(unsigned int flags)
2102 memset(&cbdata, 0, sizeof(cbdata));
2103 cbdata.flags = flags;
2104
2105 - fd = hold_lock_file_for_update(&packed, git_path("packed-refs"),
2105 + fd = hold_lock_file_for_update(&packlock, git_path("packed-refs"),
2106 LOCK_DIE_ON_ERROR);
2107 cbdata.refs_file = fdopen(fd, "w");
2108 if (!cbdata.refs_file)
@@ -2121,8 +2121,8 @@ int pack_refs(unsigned int flags)
2121 * assign -1 to the lock file descriptor so that commit_lock_file()
2122 * won't try to close() it.
2123 */
2124 - packed.fd = -1;
2125 - if (commit_lock_file(&packed) < 0)
2124 + packlock.fd = -1;
2125 + if (commit_lock_file(&packlock) < 0)
2126 die_errno("unable to overwrite old ref-pack file");
2127 prune_refs(cbdata.ref_to_prune);
2128 return 0;
@@ -2176,8 +2176,6 @@ static int repack_ref_fn(struct ref_entry *entry, void *cb_data)
2176 return 0;
2177 }
2178
2179 -static struct lock_file packlock;
2180 -
2179 static int repack_without_ref(const char *refname)
2180 {
2181 int fd;