aboutsummaryrefslogtreecommitdiff
path: root/sha1_file.c
Commit message (Collapse)AuthorAge
* Make zlib compression level configurable, and change default.Joachim B Haga2006-07-03
| | | | | | | | | | | | | | | | With the change in default, "git add ." on kernel dir is about twice as fast as before, with only minimal (0.5%) change in object size. The speed difference is even more noticeable when committing large files, which is now up to 8 times faster. The configurability is through setting core.compression = [-1..9] which maps to the zlib constants; -1 is the default, 0 is no compression, and 1..9 are various speed/size tradeoffs, 9 being slowest. Signed-off-by: Joachim B Haga (cjhaga@fys.uio.no) Acked-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Make some strings constTimo Hirvonen2006-06-28
| | | | | Signed-off-by: Timo Hirvonen <tihirvon@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Remove all void-pointer arithmetic.Florian Forster2006-06-20
| | | | | | | | ANSI C99 doesn't allow void-pointer arithmetic. This patch fixes this in various ways. Usually the strategy that required the least changes was used. Signed-off-by: Florian Forster <octo@verplant.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* shared repository - add a few missing calls to adjust_shared_perm().Junio C Hamano2006-06-09
| | | | | | | | | | | | | | | | | | | | | | | | | | There were a few calls to adjust_shared_perm() that were missing: - init-db creates refs, refs/heads, and refs/tags before reading from templates that could specify sharedrepository in the config file; - updating config file created it under user's umask without adjusting; - updating refs created it under user's umask without adjusting; - switching branches created .git/HEAD under user's umask without adjusting. This moves adjust_shared_perm() from sha1_file.c to path.c, since a few SIMPLE_PROGRAM need to call repository configuration functions which in turn need to call adjust_shared_perm(). sha1_file.c needs to link with SHA1 computation library which is usually not linked to SIMPLE_PROGRAM. Signed-off-by: Junio C Hamano <junkio@cox.net>
* sha1_file: avoid re-preparing duplicate packsJeff King2006-06-02
| | | | | | | | When adding packs, skip the pack if we already have it in the packed_git list. This might happen if we are re-preparing our packs because of a missing object. Signed-off-by: Junio C Hamano <junkio@cox.net>
* handle concurrent pruning of packed objectsJeff King2006-06-02
| | | | | | | | | | | | | | This patch causes read_sha1_file and sha1_object_info to re-examine the list of packs if an object cannot be found. It works by re-running prepare_packed_git() after an object fails to be found. It does not attempt to clean up the old pack list. Old packs which are in use can continue to be used (until unused by lru selection). New packs are placed at the front of the list and will thus be examined before old packs. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Clean up sha1 file writingLinus Torvalds2006-05-24
| | | | | | | | | | | | | | | | This cleans up and future-proofs the sha1 file writing in sha1_file.c. In particular, instead of doing a simple "write()" call and just verifying that it succeeds (or - as in one place - just assuming it does), it uses "write_buffer()" to write data to the file descriptor while correctly checking for partial writes, EINTR etc. It also splits up write_sha1_to_fd() to be a lot more readable: if we need to re-create the compressed object, we do so in a separate helper function, making the logic a whole lot more modular and obvious. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* remove the artificial restriction tagsize < 8kbBjörn Engelmann2006-05-23
| | | | | Signed-off-by: Björn Engelmann <BjEngelmann@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Merge branch 'fix'Junio C Hamano2006-05-15
|\ | | | | | | | | | | | | | | | | | | * fix: Fix pack-index issue on 64-bit platforms a bit more portably. Install git-send-email by default Fix compilation on newer NetBSD systems git config syntax updates Another config file parsing fix. checkout: use --aggressive when running a 3-way merge (-m).
| * Fix pack-index issue on 64-bit platforms a bit more portably.v1.3.3Junio C Hamano2006-05-15
| | | | | | | | | | | | | | | | | | | | | | | | | | Apparently <stdint.h> is not enough for uint32_t on OpenBSD; use "unsigned int" -- hopefully that would stay 32-bit on every platform we care about, at least until we update the pack-index file format. Our sha1 routines optimized for architectures use uint32_t and expects '#include <stdint.h>' to be enough, so OpenBSD on arm or ppc might have similar issues down the road, I dunno. Signed-off-by: Junio C Hamano <junkio@cox.net>
* | Merge branch 'fix'Junio C Hamano2006-05-14
|\ \ | |/ | | | | | | * fix: include header to define uint32_t, necessary on Mac OS X
| * include header to define uint32_t, necessary on Mac OS XBen Clifford2006-05-14
| | | | | | | | Signed-off-by: Junio C Hamano <junkio@cox.net>
* | Merge branch 'fix'Junio C Hamano2006-05-13
|\ \ | |/ | | | | | | * fix: Fix git-pack-objects for 64-bit platforms
| * Fix git-pack-objects for 64-bit platformsDennis Stosberg2006-05-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The offset of an object in the pack is recorded as a 4-byte integer in the index file. When reading the offset from the mmap'ed index in prepare_pack_revindex(), the address is dereferenced as a long*. This works fine as long as the long type is four bytes wide. On NetBSD/sparc64, however, a long is 8 bytes wide and so dereferencing the offset produces garbage. [jc: taking suggestion by Linus to use uint32_t] Signed-off-by: Dennis Stosberg <dennis@stosberg.net> Signed-off-by: Junio C Hamano <junkio@cox.net>
* | Transitively read alternativesMartin Waitz2006-05-07
| | | | | | | | | | | | | | | | | | | | | | | | When adding an alternate object store then add entries from its info/alternates files, too. Relative entries are only allowed in the current repository. Loops and duplicate alternates through multiple repositories are ignored. Just to be sure that nothing breaks it is not allow to build deep nesting levels using info/alternates. Signed-off-by: Martin Waitz <tali@admingilde.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* | sha1_to_hex() usage cleanupLinus Torvalds2006-05-03
|/ | | | | | | | | | | | | Somebody on the #git channel complained that the sha1_to_hex() thing uses a static buffer which caused an error message to show the same hex output twice instead of showing two different ones. That's pretty easily rectified by making it uses a simple LRU of a few buffers, which also allows some other users (that were aware of the buffer re-use) to be written in a more straightforward manner. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* packed_object_info_detail(): check for corrupt packfile.Junio C Hamano2006-04-17
| | | | | | | Serge E. Hallyn noticed that we compute how many input bytes are still left, but did not use it for sanity checking. Signed-off-by: Junio C Hamano <junkio@cox.net>
* Merge branch 'maint'Junio C Hamano2006-04-07
|\ | | | | | | | | | | * maint: count-delta: match get_delta_hdr_size() changes. check patch_delta bounds more carefully
| * check patch_delta bounds more carefullyNicolas Pitre2006-04-07
| | | | | | | | | | | | | | Let's avoid going south with invalid delta data. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* | Use blob_, commit_, tag_, and tree_type throughout.Peter Eriksen2006-04-04
| | | | | | | | | | | | | | | | | | This replaces occurences of "blob", "commit", "tag", and "tree", where they're really used as type specifiers, which we already have defined global constants for. Signed-off-by: Peter Eriksen <s022018@student.dtu.dk> Signed-off-by: Junio C Hamano <junkio@cox.net>
* | unpack_delta_entry(): reduce memory footprint.Junio C Hamano2006-03-19
| | | | | | | | | | | | | | | | | | | | | | Currently we unpack the delta data from the pack and then unpack the base object to apply that delta data to it. When getting an object that is deeply deltified, we can reduce memory footprint by unpacking the base object first and then unpacking the delta data, because we will need to keep at most one delta data in memory that way. Signed-off-by: Junio C Hamano <junkio@cox.net>
* | Merge fixes early for next maint series.Junio C Hamano2006-02-23
|\ \ | |/
| * Give no terminating LF to error() function.Junio C Hamano2006-02-22
| | | | | | | | Signed-off-by: Junio C Hamano <junkio@cox.net>
* | Merge fixes up to GIT 1.2.3Junio C Hamano2006-02-22
|\ \ | |/
| * pack-objects: reuse data from existing packs.Junio C Hamano2006-02-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When generating a new pack, notice if we have already needed objects in existing packs. If an object is stored deltified, and its base object is also what we are going to pack, then reuse the existing deltified representation unconditionally, bypassing all the expensive find_deltas() and try_deltas() calls. Also, notice if what we are going to write out exactly match what is already in an existing pack (either deltified or just compressed). In such a case, we can just copy it instead of going through the usual uncompressing & recompressing cycle. Without this patch, in linux-2.6 repository with about 1500 loose objects and a single mega pack: $ git-rev-list --objects v2.6.16-rc3 >RL $ wc -l RL 184141 RL $ time git-pack-objects p <RL Generating pack... Done counting 184141 objects. Packing 184141 objects.................... a1fc7b3e537fcb9b3c46b7505df859f0a11e79d2 real 12m4.323s user 11m2.560s sys 0m55.950s With this patch, the same input: $ time ../git.junio/git-pack-objects q <RL Generating pack... Done counting 184141 objects. Packing 184141 objects..................... a1fc7b3e537fcb9b3c46b7505df859f0a11e79d2 Total 184141, written 184141, reused 182441 real 1m2.608s user 0m55.090s sys 0m1.830s Signed-off-by: Junio C Hamano <junkio@cox.net>
| * detect broken alternates.Junio C Hamano2006-02-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The real problem triggered an earlier fix was that an alternate entry was pointing at a removed directory. Complaining on object/pack directory that cannot be opendir-ed produces noise in an ancient repository that does not have object/pack directory and has never been packed. Detect the real user error and report it. Also if opendir failed for other reasons (e.g. no read permissions), report that as well. Spotted by Andrew Vasquez <andrew.vasquez@qlogic.com>. Signed-off-by: Junio C Hamano <junkio@cox.net>
* | Merge branch 'jc/pack-reuse'Junio C Hamano2006-02-21
|\ \ | | | | | | | | | | | | | | | | | | | | | * jc/pack-reuse: pack-objects: avoid delta chains that are too long. git-repack: allow passing a couple of flags to pack-objects. pack-objects: finishing touches. pack-objects: reuse data from existing packs.
| * | pack-objects: reuse data from existing packs.Junio C Hamano2006-02-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When generating a new pack, notice if we have already needed objects in existing packs. If an object is stored deltified, and its base object is also what we are going to pack, then reuse the existing deltified representation unconditionally, bypassing all the expensive find_deltas() and try_deltas() calls. Also, notice if what we are going to write out exactly match what is already in an existing pack (either deltified or just compressed). In such a case, we can just copy it instead of going through the usual uncompressing & recompressing cycle. Without this patch, in linux-2.6 repository with about 1500 loose objects and a single mega pack: $ git-rev-list --objects v2.6.16-rc3 >RL $ wc -l RL 184141 RL $ time git-pack-objects p <RL Generating pack... Done counting 184141 objects. Packing 184141 objects.................... a1fc7b3e537fcb9b3c46b7505df859f0a11e79d2 real 12m4.323s user 11m2.560s sys 0m55.950s With this patch, the same input: $ time ../git.junio/git-pack-objects q <RL Generating pack... Done counting 184141 objects. Packing 184141 objects..................... a1fc7b3e537fcb9b3c46b7505df859f0a11e79d2 Total 184141, written 184141, reused 182441 real 1m2.608s user 0m55.090s sys 0m1.830s Signed-off-by: Junio C Hamano <junkio@cox.net>
* | | Merge fixes up to GIT 1.2.2Junio C Hamano2006-02-18
|\ \ \ | |/ / |/| / | |/
| * Prevent git-upload-pack segfault if object cannot be foundCarl Worth2006-02-17
| | | | | | | | | | Signed-off-by: Carl Worth <cworth@cworth.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* | packed objects: minor cleanupJunio C Hamano2006-02-15
|/ | | | | | The delta depth is unsigned. Signed-off-by: Junio C Hamano <junkio@cox.net>
* stat() for existence in safe_create_leading_directories()Jason Riedy2006-02-09
| | | | | | | | | | | | | | | | | | | Use stat() to explicitly check for existence rather than relying on the non-portable EEXIST error in sha1_file.c's safe_create_leading_directories(). There certainly are optimizations possible, but then the code becomes almost the same as that in coreutil's lib/mkdir-p.c. Other uses of EEXIST seem ok. Tested on Solaris 8, AIX 5.2L, and a few Linux versions. AIX has some unrelated (I think) failures right now; I haven't tried many recent gits there. Anyone have an old Ultrix box to break everything? ;) Also remove extraneous #includes. Everything's already in git-compat-util.h, included through cache.h. Signed-off-by: Jason Riedy <ejr@cs.berkeley.edu> Signed-off-by: Junio C Hamano <junkio@cox.net>
* GIT 1.1.4v1.1.4Junio C Hamano2006-01-19
|\
| * Revert "check_packed_git_idx(): check integrity of the idx file itself."Junio C Hamano2006-01-19
| | | | | | | | | | | | | | | | | | | | | | This reverts c5ced64578a82b9d172aceb2f67c6fb9e639f6d9 commit. It turns out that doing this check every time we map the idx file is quite expensive. A corrupt idx file is caught by git-fsck-objects, so this check is not strictly necessary. In one unscientific test, 0.99.9m spent 10 seconds usertime for the same task 1.1.3 takes 37 seconds usertime. Reverting this gives us the performance of 0.99.9 back.
| * check_packed_git_idx(): check integrity of the idx file itself.Junio C Hamano2005-12-23
| | | | | | | | | | | | | | | | | | | | | | Although pack-check.c had routine to verify the checksum for the pack index file itself, the core did not check it before using it. This is stolen from the patch to tighten packname requirements. Signed-off-by: Junio C Hamano <junkio@cox.net> (cherry picked from 797bd6f490c91c07986382b9f268e0df712cb246 commit)
* | Introduce core.sharedrepositoryJohannes Schindelin2005-12-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the config variable 'core.sharedrepository' is set, the directories $GIT_DIR/objects/ $GIT_DIR/objects/?? $GIT_DIR/objects/pack $GIT_DIR/refs $GIT_DIR/refs/heads $GIT_DIR/refs/heads/tags are set group writable (and g+s, since the git group may be not the primary group of all users). Since all files are written as lock files first, and then moved to their destination, they do not have to be group writable. Indeed, if this leads to problems you found a bug. Note that -- as in my first attempt -- the config variable is set in the function which checks the repository format. If this were done in git_default_config instead, a lot of programs would need to be modified to call git_config(git_default_config) first. [jc: git variables should be in environment.c unless there is a compelling reason to do otherwise.] Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
* | check_packed_git_idx(): check integrity of the idx file itself.Junio C Hamano2005-12-22
|/ | | | | | | | | | Although pack-check.c had routine to verify the checksum for the pack index file itself, the core did not check it before using it. This is stolen from the patch to tighten packname requirements. Signed-off-by: Junio C Hamano <junkio@cox.net>
* sha1_to_hex: properly terminate the SHA1Johannes Schindelin2005-12-22
| | | | | | | | | | | | | sha1_to_hex() returns a pointer to a static buffer. Some of its users modify that buffer by appending a newline character. Other users rely on the fact that you can call printf("%s", sha1_to_hex(sha1)); Just to be on the safe side, terminate the SHA1 in sha1_to_hex(). Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
* \n usage in stderr outputAlex Riesen2005-12-21
| | | | | | | | fprintf and die sometimes have missing/excessive "\n" in their arguments, correct the strings where I think it would be appropriate. Signed-off-by: Alex Riesen <raa.lkml@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
* sanity check in add_packed_git()Pavel Roskin2005-12-21
| | | | | | | | add_packed_git() tries to get the pack SHA1 by parsing its name. It may access uninitialized memory for packs with short names. Signed-off-by: Pavel Roskin <proski@gnu.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Allow saving an object from a pipeDaniel Barkalow2005-12-10
| | | | | | | | In order to support getting data into git with scripts, this adds a --stdin option to git-hash-object, which will make it read from stdin. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* sha1_file.c: make sure packs in an alternate odb is named properly.Junio C Hamano2005-12-04
| | | | | | | | | | | | We somehow ended up registering packs in alternate object directories as "dir/object//pack/pack-*", which confusd the update-server-info code very badly. Also we did not attempt to detect a mistake of listing the object directory itself as one of the alternates. This does not lead to incorrect behaviour, but is simply wasteful, so try to do so when we are trivially able to. Signed-off-by: Junio C Hamano <junkio@cox.net>
* sha1_file.c::add_packed_git(): fix type mismatch.Junio C Hamano2005-11-15
| | | | | | An object name is 20-byte 'unsigned char', not 'char'. Signed-off-by: Junio C Hamano <junkio@cox.net>
* Add git-pack-intersectLukas_Sandström2005-11-11
| | | | | | | | This patch adds the program git-pack-intersect. It is used to find redundant packs in git repositories. Signed-off-by: Lukas Sandström <lukass@etek.chalmers.se> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Allow GIT_DIR to be an absolute pathJohannes Schindelin2005-11-06
| | | | | | | | This fixes a problem in safe_create_leading_directories() when the argument starts with a '/' (i.e. the path is absolute). Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Fix what to do and how to detect when hardlinking failsLinus Torvalds2005-10-26
| | | | | | | | | | | | | Recent FAT workaround caused compilation trouble on OpenBSD; different platforms use different error codes when we try to hardlink the temporary file to its final location. Existing Coda hack also checks its own error code, but the thing is, the case we care about is if link failed for a reason other than that the final file has already existed (which would be normal, or it could mean collision). So just check the error code against EEXIST. Signed-off-by: Junio C Hamano <junkio@cox.net>
* Work around missing hard links on FAT formatted mediaJohannes Schindelin2005-10-25
| | | | | | | | | FAT -- like Coda -- does not like cross-directory hard links. To be precise, FAT does not like links at all. But links are not needed either. So get rid of them. Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Keep track of whether a pack is local or notLinus Torvalds2005-10-13
| | | | | | | | If we want to re-pack just local packfiles, we need to know whether a particular object is local or not. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Use git config file for committer name and email infoLinus Torvalds2005-10-11
| | | | | | | | | | | | | | | | | | | | | | This starts using the "user.name" and "user.email" config variables if they exist as the default name and email when committing. This means that you don't have to use the GIT_COMMITTER_EMAIL environment variable to override your email - you can just edit the config file instead. The patch looks bigger than it is because it makes the default name and email information non-static and renames it appropriately. And it moves the common git environment variables into a new library file, so that you can link against libgit.a and get the git environment without having to link in zlib and libcrypt. In short, most of it is renaming and moving, the real change core is just a few new lines in "git_default_config()" that copies the user config values to the new base. It also changes "git-var -l" to list the config variables. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Use the same move_temp_to_file in git-http-fetch.Junio C Hamano2005-10-10
| | | | | | | | | | | | | | | | | The http commit walker cannot use the same temporary file creation code because it needs to use predictable temporary filename for partial fetch continuation purposes, but the code to move the temporary file to the final location should be usable from the ordinary object creation codepath. Export move_temp_to_file from sha1_file.c and use it, while losing the custom relink_or_rename function from http-fetch.c. Also the temporary object file creation part needs to make sure the leading path exists, in preparation of the really lazy fan-out directory creation. Signed-off-by: Junio C Hamano <junkio@cox.net>