diff options
author | Junio C Hamano <gitster@pobox.com> | 2010-12-16 12:49:11 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-12-16 12:49:11 -0800 |
commit | f73c3e9704b80c8813b92392cced9328f81e91d6 (patch) | |
tree | 97f122c85e29c38f871fdfe90a9478b79c6d2dd0 | |
parent | 15368e1836970d87b5f29635b04c1d2144954f1f (diff) | |
parent | dc01f59d21fca9ade97f1433ca4cee17b5ce59a7 (diff) | |
download | git-f73c3e9704b80c8813b92392cced9328f81e91d6.tar.gz |
Merge branch 'jn/fast-import-ondemand-checkpoint'
* jn/fast-import-ondemand-checkpoint:
fast-import: treat SIGUSR1 as a request to access objects early
-rw-r--r-- | Documentation/git-fast-import.txt | 7 | ||||
-rw-r--r-- | fast-import.c | 41 |
2 files changed, 47 insertions, 1 deletions
diff --git a/Documentation/git-fast-import.txt b/Documentation/git-fast-import.txt index 5d0c245e38..9667e9aebc 100644 --- a/Documentation/git-fast-import.txt +++ b/Documentation/git-fast-import.txt @@ -1233,6 +1233,13 @@ and lazy loading of subtrees, allows fast-import to efficiently import projects with 2,000+ branches and 45,114+ files in a very limited memory footprint (less than 2.7 MiB per active branch). +Signals +------- +Sending *SIGUSR1* to the 'git fast-import' process ends the current +packfile early, simulating a `checkpoint` command. The impatient +operator can use this facility to peek at the objects and refs from an +import in progress, at the cost of some added running time and worse +compression. Author ------ diff --git a/fast-import.c b/fast-import.c index 534c68db6f..2b23635d60 100644 --- a/fast-import.c +++ b/fast-import.c @@ -362,6 +362,9 @@ static uintmax_t next_mark; static struct strbuf new_data = STRBUF_INIT; static int seen_data_command; +/* Signal handling */ +static volatile sig_atomic_t checkpoint_requested; + static void parse_argv(void); static void write_branch_report(FILE *rpt, struct branch *b) @@ -501,6 +504,32 @@ static NORETURN void die_nicely(const char *err, va_list params) exit(128); } +#ifndef SIGUSR1 /* Windows, for example */ + +static void set_checkpoint_signal(void) +{ +} + +#else + +static void checkpoint_signal(int signo) +{ + checkpoint_requested = 1; +} + +static void set_checkpoint_signal(void) +{ + struct sigaction sa; + + memset(&sa, 0, sizeof(sa)); + sa.sa_handler = checkpoint_signal; + sigemptyset(&sa.sa_mask); + sa.sa_flags = SA_RESTART; + sigaction(SIGUSR1, &sa, NULL); +} + +#endif + static void alloc_objects(unsigned int cnt) { struct object_entry_pool *b; @@ -2715,14 +2744,20 @@ static void parse_reset_branch(void) unread_command_buf = 1; } -static void parse_checkpoint(void) +static void checkpoint(void) { + checkpoint_requested = 0; if (object_count) { cycle_packfile(); dump_branches(); dump_tags(); dump_marks(); } +} + +static void parse_checkpoint(void) +{ + checkpoint_requested = 1; skip_optional_lf(); } @@ -2979,6 +3014,7 @@ int main(int argc, const char **argv) prepare_packed_git(); start_packfile(); set_die_routine(die_nicely); + set_checkpoint_signal(); while (read_next_command() != EOF) { if (!strcmp("blob", command_buf.buf)) parse_new_blob(); @@ -3000,6 +3036,9 @@ int main(int argc, const char **argv) /* ignore non-git options*/; else die("Unsupported command: %s", command_buf.buf); + + if (checkpoint_requested) + checkpoint(); } /* argv hasn't been parsed yet, do so */ |