aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2007-09-14 03:31:25 -0400
committerJunio C Hamano <gitster@pobox.com>2007-09-19 03:22:31 -0700
commite4022ed2c85825f238661e3e532b0bb108b5e318 (patch)
tree662dca9a9593db9183f71eea44985693a669ae4d
parent1788c39cd0742439b9bedc28bc10bc4d105b6c0f (diff)
downloadgit-e4022ed2c85825f238661e3e532b0bb108b5e318.tar.gz
git-e4022ed2c85825f238661e3e532b0bb108b5e318.tar.xz
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>
-rw-r--r--builtin-fetch.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/builtin-fetch.c b/builtin-fetch.c
index 8e433d1bf..8b0fdbe90 100644
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
@@ -13,6 +13,20 @@ static const char fetch_usage[] = "git-fetch [-a | --append] [--upload-pack <upl
static int append, force, tags, no_tags, update_head_ok, verbose, quiet;
static char *default_rla = NULL;
+static struct transport *transport;
+
+static void unlock_pack(void)
+{
+ if (transport)
+ transport_unlock_pack(transport);
+}
+
+static void unlock_pack_on_signal(int signo)
+{
+ unlock_pack();
+ signal(SIGINT, SIG_DFL);
+ raise(signo);
+}
static void find_merge_config(struct ref *ref_map, struct remote *remote)
{
@@ -396,7 +410,6 @@ static int do_fetch(struct transport *transport,
int cmd_fetch(int argc, const char **argv, const char *prefix)
{
struct remote *remote;
- struct transport *transport;
int i, j, rla_offset;
static const char **refs = NULL;
int ref_nr = 0;
@@ -520,5 +533,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
printf("ref: %s\n", refs[j]);
}
+ signal(SIGINT, unlock_pack_on_signal);
+ atexit(unlock_pack);
return do_fetch(transport, parse_ref_spec(ref_nr, refs), ref_nr);
}