From: Junio C Hamano Date: Fri, 2 Nov 2007 23:27:37 +0000 (-0700) Subject: Merge branch 'np/progress' X-Git-Tag: v1.5.4-rc0~286 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/265ae188267fda441f92e513fb89641f78e982fd?ds=inline;hp=-c Merge branch 'np/progress' * np/progress: Show total transferred as part of throughput progress make sure throughput display gets updated even if progress doesn't move return the prune-packed progress display to the inner loop add throughput display to git-push add some copyright notice to the progress display code add throughput display to index-pack add throughput to progress display relax usage of the progress API make struct progress an opaque type prune-packed: don't call display_progress() for every file Stop displaying "Pack pack-$ID created." during git-gc Teach prune-packed to use the standard progress meter Change 'Deltifying objects' to 'Compressing objects' fix for more minor memory leaks fix const issues with some functions pack-objects.c: fix some global variable abuse and memory leaks pack-objects: no delta possible with only one object in the list cope with multiple line breaks within sideband progress messages more compact progress display --- 265ae188267fda441f92e513fb89641f78e982fd diff --combined pack-write.c index 979bdfff7c,d1ed3abe21..665e2b29b8 --- a/pack-write.c +++ b/pack-write.c @@@ -17,7 -17,8 +17,8 @@@ static int sha1_compare(const void *_a * the SHA1 hash of sorted object names. The objects array passed in * will be sorted by SHA1 on exit. */ - const char *write_idx_file(const char *index_name, struct pack_idx_entry **objects, int nr_objects, unsigned char *sha1) + char *write_idx_file(char *index_name, struct pack_idx_entry **objects, + int nr_objects, unsigned char *sha1) { struct sha1file *f; struct pack_idx_entry **sorted_by_sha, **list, **last; @@@ -179,29 -180,3 +180,29 @@@ void fixup_pack_header_footer(int pack_ SHA1_Final(pack_file_sha1, &c); write_or_die(pack_fd, pack_file_sha1, 20); } + +char *index_pack_lockfile(int ip_out) +{ + int len, s; + char packname[46]; + + /* + * The first thing we expects from index-pack's output + * is "pack\t%40s\n" or "keep\t%40s\n" (46 bytes) where + * %40s is the newly created pack SHA1 name. In the "keep" + * case, we need it to remove the corresponding .keep file + * later on. If we don't get that then tough luck with it. + */ + for (len = 0; + len < 46 && (s = xread(ip_out, packname+len, 46-len)) > 0; + len += s); + if (len == 46 && packname[45] == '\n' && + memcmp(packname, "keep\t", 5) == 0) { + char path[PATH_MAX]; + packname[45] = 0; + snprintf(path, sizeof(path), "%s/pack/pack-%s.keep", + get_object_directory(), packname + 5); + return xstrdup(path); + } + return NULL; +} diff --combined pack.h index b57ba2d9ed,cab4aa8381..b31b37608d --- a/pack.h +++ b/pack.h @@@ -55,11 -55,10 +55,11 @@@ struct pack_idx_entry off_t offset; }; - extern const char *write_idx_file(const char *index_name, struct pack_idx_entry **objects, int nr_objects, unsigned char *sha1); + extern char *write_idx_file(char *index_name, struct pack_idx_entry **objects, int nr_objects, unsigned char *sha1); extern int verify_pack(struct packed_git *, int); extern void fixup_pack_header_footer(int, unsigned char *, const char *, uint32_t); +extern char *index_pack_lockfile(int fd); #define PH_ERROR_EOF (-1) #define PH_ERROR_PACK_SIGNATURE (-2)