diff options
author | Jonathan Nieder <jrnieder@gmail.com> | 2010-01-26 10:08:44 -0600 |
---|---|---|
committer | Jonathan Nieder <jrnieder@gmail.com> | 2010-01-26 10:08:44 -0600 |
commit | 225f78c817755bebff91629cc525a258cf60eaea (patch) | |
tree | fc8146efeb2e2165d5427854f7f36d78fa59e168 /builtin-pack-objects.c | |
parent | Makefile: drop dependency on $(wildcard */*.h) (diff) | |
parent | am: fix patch format detection for Thunderbird "Save As" emails (diff) | |
download | tgif-225f78c817755bebff91629cc525a258cf60eaea.tar.xz |
Merge branch 'master' of git://repo.or.cz/alt-git into jn/autodep
* 'master' of git://repo.or.cz/alt-git: (384 commits)
am: fix patch format detection for Thunderbird "Save As" emails
t0022: replace non-portable literal CR
tests: consolidate CR removal/addition functions
commit-tree: remove unused #define
t5541-http-push: make grep expression check for one line only
rebase: replace antiquated sed invocation
Add test-run-command to .gitignore
git_connect: use use_shell instead of explicit "sh", "-c"
gitweb.js: Workaround for IE8 bug
Make test numbers unique
Windows: Remove dependency on pthreadGC2.dll
Documentation: move away misplaced 'push --upstream' description
Documentation: add missing :: in config.txt
pull: re-fix command line generation
Documentation: merge: use MERGE_HEAD to refer to the remote branch
Documentation: simplify How Merge Works
Documentation: merge: add a section about fast-forward
Documentation: emphasize when git merge terminates early
Documentation: merge: add an overview
Documentation: merge: move merge strategy list to end
...
Conflicts:
Makefile
Diffstat (limited to 'builtin-pack-objects.c')
-rw-r--r-- | builtin-pack-objects.c | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c index 4429d53a1e..b0887d759d 100644 --- a/builtin-pack-objects.c +++ b/builtin-pack-objects.c @@ -525,7 +525,8 @@ static void write_pack_file(void) if (!pack_to_stdout) { mode_t mode = umask(0); struct stat st; - char *idx_tmp_name, tmpname[PATH_MAX]; + const char *idx_tmp_name; + char tmpname[PATH_MAX]; umask(mode); mode = 0444 & ~mode; @@ -569,7 +570,7 @@ static void write_pack_file(void) if (rename(idx_tmp_name, tmpname)) die_errno("unable to rename temporary index file"); - free(idx_tmp_name); + free((void *) idx_tmp_name); free(pack_tmp_name); puts(sha1_to_hex(sha1)); } @@ -673,7 +674,7 @@ static void setup_delta_attr_check(struct git_attr_check *check) static struct git_attr *attr_delta; if (!attr_delta) - attr_delta = git_attr("delta", 5); + attr_delta = git_attr("delta"); check[0].attr = attr_delta; } @@ -1256,15 +1257,15 @@ static int delta_cacheable(unsigned long src_size, unsigned long trg_size, #ifdef THREADED_DELTA_SEARCH -static pthread_mutex_t read_mutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t read_mutex; #define read_lock() pthread_mutex_lock(&read_mutex) #define read_unlock() pthread_mutex_unlock(&read_mutex) -static pthread_mutex_t cache_mutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t cache_mutex; #define cache_lock() pthread_mutex_lock(&cache_mutex) #define cache_unlock() pthread_mutex_unlock(&cache_mutex) -static pthread_mutex_t progress_mutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t progress_mutex; #define progress_lock() pthread_mutex_lock(&progress_mutex) #define progress_unlock() pthread_mutex_unlock(&progress_mutex) @@ -1591,7 +1592,26 @@ struct thread_params { unsigned *processed; }; -static pthread_cond_t progress_cond = PTHREAD_COND_INITIALIZER; +static pthread_cond_t progress_cond; + +/* + * Mutex and conditional variable can't be statically-initialized on Windows. + */ +static void init_threaded_search(void) +{ + pthread_mutex_init(&read_mutex, NULL); + pthread_mutex_init(&cache_mutex, NULL); + pthread_mutex_init(&progress_mutex, NULL); + pthread_cond_init(&progress_cond, NULL); +} + +static void cleanup_threaded_search(void) +{ + pthread_cond_destroy(&progress_cond); + pthread_mutex_destroy(&read_mutex); + pthread_mutex_destroy(&cache_mutex); + pthread_mutex_destroy(&progress_mutex); +} static void *threaded_find_deltas(void *arg) { @@ -1630,10 +1650,13 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size, struct thread_params *p; int i, ret, active_threads = 0; + init_threaded_search(); + if (!delta_search_threads) /* --threads=0 means autodetect */ delta_search_threads = online_cpus(); if (delta_search_threads <= 1) { find_deltas(list, &list_size, window, depth, processed); + cleanup_threaded_search(); return; } if (progress > pack_to_stdout) @@ -1748,6 +1771,7 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size, active_threads--; } } + cleanup_threaded_search(); free(p); } |