diff options
Diffstat (limited to 'builtin/pack-objects.c')
| -rw-r--r-- | builtin/pack-objects.c | 50 | 
1 files changed, 43 insertions, 7 deletions
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index a27de5b323..a2f8cfdec0 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -44,6 +44,7 @@ static int non_empty;  static int reuse_delta = 1, reuse_object = 1;  static int keep_unreachable, unpack_unreachable, include_tag;  static unsigned long unpack_unreachable_expiration; +static int pack_loose_unreachable;  static int local;  static int incremental;  static int ignore_packed_keep; @@ -759,6 +760,10 @@ static off_t write_reused_pack(struct sha1file *f)  	return reuse_packfile_offset - sizeof(struct pack_header);  } +static const char no_split_warning[] = N_( +"disabling bitmap writing, packs are split due to pack.packSizeLimit" +); +  static void write_pack_file(void)  {  	uint32_t i = 0, j; @@ -813,7 +818,10 @@ static void write_pack_file(void)  			fixup_pack_header_footer(fd, sha1, pack_tmp_name,  						 nr_written, sha1, offset);  			close(fd); -			write_bitmap_index = 0; +			if (write_bitmap_index) { +				warning(_(no_split_warning)); +				write_bitmap_index = 0; +			}  		}  		if (!pack_to_stdout) { @@ -828,8 +836,7 @@ static void write_pack_file(void)  			 * to preserve this property.  			 */  			if (stat(pack_tmp_name, &st) < 0) { -				warning("failed to stat %s: %s", -					pack_tmp_name, strerror(errno)); +				warning_errno("failed to stat %s", pack_tmp_name);  			} else if (!last_mtime) {  				last_mtime = st.st_mtime;  			} else { @@ -837,8 +844,7 @@ static void write_pack_file(void)  				utb.actime = st.st_atime;  				utb.modtime = --last_mtime;  				if (utime(pack_tmp_name, &utb) < 0) -					warning("failed utime() on %s: %s", -						pack_tmp_name, strerror(errno)); +					warning_errno("failed utime() on %s", pack_tmp_name);  			}  			strbuf_addf(&tmpname, "%s-", base_name); @@ -1186,7 +1192,7 @@ static void add_pbase_object(struct tree_desc *tree,  		if (cmp < 0)  			return;  		if (name[cmplen] != '/') { -			add_object_entry(entry.sha1, +			add_object_entry(entry.oid->hash,  					 object_type(entry.mode),  					 fullname, 1);  			return; @@ -1197,7 +1203,7 @@ static void add_pbase_object(struct tree_desc *tree,  			const char *down = name+cmplen+1;  			int downlen = name_cmp_len(down); -			tree = pbase_tree_get(entry.sha1); +			tree = pbase_tree_get(entry.oid->hash);  			if (!tree)  				return;  			init_tree_desc(&sub, tree->tree_data, tree->tree_size); @@ -2373,6 +2379,32 @@ static void add_objects_in_unpacked_packs(struct rev_info *revs)  	free(in_pack.array);  } +static int add_loose_object(const unsigned char *sha1, const char *path, +			    void *data) +{ +	enum object_type type = sha1_object_info(sha1, NULL); + +	if (type < 0) { +		warning("loose object at %s could not be examined", path); +		return 0; +	} + +	add_object_entry(sha1, type, "", 0); +	return 0; +} + +/* + * We actually don't even have to worry about reachability here. + * add_object_entry will weed out duplicates, so we just add every + * loose object we find. + */ +static void add_unreachable_loose_objects(void) +{ +	for_each_loose_file_in_objdir(get_object_directory(), +				      add_loose_object, +				      NULL, NULL, NULL); +} +  static int has_sha1_pack_kept_or_nonlocal(const unsigned char *sha1)  {  	static struct packed_git *last_found = (void *)1; @@ -2542,6 +2574,8 @@ static void get_object_list(int ac, const char **av)  	if (keep_unreachable)  		add_objects_in_unpacked_packs(&revs); +	if (pack_loose_unreachable) +		add_unreachable_loose_objects();  	if (unpack_unreachable)  		loosen_unused_packed_objects(&revs); @@ -2642,6 +2676,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)  			 N_("include tag objects that refer to objects to be packed")),  		OPT_BOOL(0, "keep-unreachable", &keep_unreachable,  			 N_("keep unreachable objects")), +		OPT_BOOL(0, "pack-loose-unreachable", &pack_loose_unreachable, +			 N_("pack loose unreachable objects")),  		{ OPTION_CALLBACK, 0, "unpack-unreachable", NULL, N_("time"),  		  N_("unpack unreachable objects newer than <time>"),  		  PARSE_OPT_OPTARG, option_parse_unpack_unreachable },  | 
