Always ensure the pack.keep file is removed by git-fetch
If we are using a native transport and the transport chose to save the packfile it may have created a .keep file to protect the packfile from a concurrently running git-repack process. In such a case the git-fetch process should make sure it will unlink the .keep file even if it fails to update any refs as otherwise the newly downloaded packfile's diskspace will never be reclaimed if the objects are not actually referenced. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Shawn O. Pearce committed
Sep 14, 2007 at 03:31 UTC
e4022ed2c85825f238661e3e532b0bb108b5e318
1 file changed
+16
-1
builtin-fetch.c
+16
-1
@@ -13,6 +13,20 @@ static const char fetch_usage[] = "git-fetch [-a | --append] [--upload-pack <upl
13
14
static int append, force, tags, no_tags, update_head_ok, verbose, quiet;
15
static char *default_rla = NULL;
16
+static struct transport *transport;
17
+
18
+static void unlock_pack(void)
19
+{
20
+ if (transport)
21
+ transport_unlock_pack(transport);
22
+}
23
+
24
+static void unlock_pack_on_signal(int signo)
25
+{
26
+ unlock_pack();
27
+ signal(SIGINT, SIG_DFL);
28
+ raise(signo);
29
+}
30
31
static void find_merge_config(struct ref *ref_map, struct remote *remote)
32
{
@@ -396,7 +410,6 @@ static int do_fetch(struct transport *transport,
410
int cmd_fetch(int argc, const char **argv, const char *prefix)
411
{
412
struct remote *remote;
399
- struct transport *transport;
413
int i, j, rla_offset;
414
static const char **refs = NULL;
415
int ref_nr = 0;
@@ -520,5 +533,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
533
printf("ref: %s\n", refs[j]);
534
}
535
536
+ signal(SIGINT, unlock_pack_on_signal);
537
+ atexit(unlock_pack);
538
return do_fetch(transport, parse_ref_spec(ref_nr, refs), ref_nr);
539
}