summaryrefslogtreecommitdiff
path: root/cache.h
AgeCommit message (Collapse)Author
2005-07-03Add "has_sha1_pack()" function to query whether the object is available in a ↵Linus Torvalds
pack We'll want this for incremental packing.
2005-07-01[PATCH] Show more details of packfile with verify-pack -v.Junio C Hamano
This implements show_pack_info() function used in verify-pack command when -v flag is used to obtain something like unpack-objects used to give when it was first written. It shows the following for each non-deltified object found in the pack: SHA1 type size offset For deltified objects, it shows this instead: SHA1 type size offset depth base_sha1 In order to get the output in the order that appear in the pack file for debugging purposes, you can do this: $ git-verify-pack -v packfile | sort -n -k 4,4 Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-07-01[PATCH] verify-pack updates.Junio C Hamano
Nico pointed out that having verify_pack.c and verify-pack.c was confusing. Rename verify_pack.c to pack-check.c as suggested, and enhances the verification done quite a bit. - Built-in sha1_file unpacking knows that a base object of a deltified object _must_ be in the same pack, and takes advantage of that fact. - Earlier verify-pack command only checked the SHA1 sum for the entire pack file and did not look into its contents. It now checks everything idx file claims to have unpacks correctly. - It now has a hook to give more detailed information for objects contained in the pack under -v flag. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-06-30Add first cut at "git-receive-pack"Linus Torvalds
It's not working yet, but it's at the point where I want to be able to track my changes. The theory of operation is that this is the "remote" side of a "git push". It can tell us what references the remote side has, receives out reference update commands and a pack-file, and can execute the unpacking command.
2005-06-29[PATCH] Add git-verify-pack command.Junio C Hamano
Given a list of <pack>.idx files, this command validates the index file and the corresponding .pack file for consistency. This patch also uses the same validation mechanism in fsck-cache when the --full flag is used. During normal operation, sha1_file.c verifies that a given .idx file matches the .pack file by comparing the SHA1 checksum stored in .idx file and .pack file as a minimum sanity check. We may further want to check the pack signature and version when we map the pack, but that would be a separate patch. Earlier, errors to map a pack file was not flagged fatal but led to a random fatal error later. This version explicitly die()s when such an error is detected. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-06-28[PATCH] Expose packed_git and alt_odb.Junio C Hamano
The commands git-fsck-cache and probably git-*-pull needs to have a way to enumerate objects contained in packed GIT archives and alternate object pools. This commit exposes the data structure used to keep track of them from sha1_file.c, and adds a couple of accessor interface functions for use by the enhanced git-fsck-cache command. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-06-27[PATCH] Enhance sha1_file_size() into sha1_object_info()Junio C Hamano
This lets us eliminate one use of map_sha1_file() outside sha1_file.c, to bring us one step closer to the packed GIT. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-06-27[PATCH] Remove "delta" object representation.Junio C Hamano
Packed delta files created by git-pack-objects seems to be the way to go, and existing "delta" object handling code has exposed the object representation details to too many places. Remove it while we refactor code to come up with a proper interface in sha1_file.c. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-06-25[PATCH] Fix oversimplified optimization for add_cache_entry().Junio C Hamano
An earlier change to optimize directory-file conflict check broke what "read-tree --emu23" expects. This is fixed by this commit. (1) Introduces an explicit flag to tell add_cache_entry() not to check for conflicts and use it when reading an existing tree into an empty stage --- by definition this case can never introduce such conflicts. (2) Makes read-cache.c:has_file_name() and read-cache.c:has_dir_name() aware of the cache stages, and flag conflict only with paths in the same stage. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-06-08[PATCH] Anal retentive 'const unsigned char *sha1'Jason McMullan
Make 'sha1' parameters const where possible Signed-off-by: Jason McMullan <jason.mcmullan@timesys.com> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-06-07[PATCH] Operations on refsDaniel Barkalow
This patch adds code to read a hash out of a specified file under {GIT_DIR}/refs/, and to write such files atomically and optionally with an compare and lock. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-06-06Add "__noreturn__" attribute to die() and usage()Linus Torvalds
Only with gcc. It fixes some warnings for certain versions of gcc, but not apparently all.
2005-06-06More work on merging with git-read-tree..Linus Torvalds
Add a "-u" flag to update the tree as a result of a merge. Right now this code is way too anal about things, and fails merges it shouldn't, but let me fix up the different cases and this will allow for much smoother merging even in the presense of dirty data in the working tree.
2005-06-06Make fiel checkout function available to the git libraryLinus Torvalds
The merge stuff will want it soon, and we don't want to duplicate all the work..
2005-06-02[PATCH] Find size of SHA1 object without inflating everything.Junio C Hamano
This adds sha1_file_size() helper function and uses it in the rename/copy similarity estimator. The helper function handles deltified object as well. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-06-02[PATCH] Handle deltified object correctly in git-*-pull family.Junio C Hamano
When a remote repository is deltified, we need to get the objects that a deltified object we want to obtain is based upon. The initial parts of each retrieved SHA1 file is inflated and inspected to see if it is deltified, and its base object is asked from the remote side when it is. Since this partial inflation and inspection has a small performance hit, it can optionally be skipped by giving -d flag to git-*-pull commands. This flag should be used only when the remote repository is known to have no deltified objects. Rsync transport does not have this problem since it fetches everything the remote side has. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-06-02Split up unpack_sha1_file() some moreLinus Torvalds
Make a separate helper for parsing the header of an object file (really carefully) and for unpacking the rest. This means that anybody who uses the "unpack_sha1_header()" interface can easily look at the header and decide to unpack the rest too, without doing any extra work.
2005-06-02Add "unpack_sha1_header()" helper functionLinus Torvalds
It's for people who aren't necessarily interested in the whole unpacked file, but do want to know the header information (size, type, etc..) For example, the delta code can use this to figure out whether an object is already a delta object, and what it is a delta against, without actually bothering to unpack all of the actual data in the delta.
2005-05-22Include file cleanups..Linus Torvalds
Add <limits.h> to the include files handled by "cache.h", and remove extraneous #include directives from various .c files. The rule is that "cache.h" gets all the basic stuff, so that we'll have as few system dependencies as possible.
2005-05-20Introduce "base_name_compare()" helper functionLinus Torvalds
This one compares two pathnames that may be partial basenames, not full paths. We need to get the path sorting right, since a directory name will sort as if it had the final '/' at the end.
2005-05-19[PATCH] Implement git-checkout-cache -u to update stat information in the cache.Junio C Hamano
With -u flag, git-checkout-cache picks up the stat information from newly created file and updates the cache. This removes the need to run git-update-cache --refresh immediately after running git-checkout-cache. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-05-18[PATCH] Kill a bunch of pointer sign warnings for gcc4Brian Gerst
- Raw hashes should be unsigned char. - String functions want signed char. - Hash and compress functions want unsigned char. Signed-off By: Brian Gerst <bgerst@didntduck.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-05-15Remove obsolete note about native CPU byte formatPetr Baudis
Comment in entry.h said that the cache contents is in the native CPU byte format, which is really not true anymore for quite some time.
2005-05-15Rename some more cache-related functionsBrad Roberts
same_name -> ce_same_name() remove_entry_at() -> remove_cache_entry_at() Signed-off-by: Brad Roberts <braddr@puremagic.com> Signed-off-by: Petr Baudis <pasky@ucw.cz>
2005-05-15Rename cache_match_stat() to ce_match_stat()Brad Roberts
Signed-off-by: Brad Roberts <braddr@puremagic.com> Signed-off-by: Petr Baudis <pasky@ucw.cz>
2005-05-15Cleanup the x-allocation functionsBrad Roberts
xmalloc() and xrealloc() now take their sizes as size_t-type arguments. Introduced complementary xcalloc(). Signed-off-by: Brad Roberts <braddr@puremagic.com> Signed-off-by: Petr Baudis <pasky@ucw.cz>
2005-05-13[PATCH 2/3] Support symlinks in git-ls-files --others.Junio C Hamano
It is kind of surprising that this was missed in the last round, but the work tree scanner in git-ls-files was still deliberately ignoring symlinks. This patch fixes it, so that --others will correctly report unregistered symlinks. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Petr Baudis <pasky@ucw.cz>
2005-05-11Merge with http://members.cox.net/junkio/git-jc.gitPetr Baudis
2005-05-10Mark the variable declarations in .h files as externPetr Baudis
This allows git to be built even with linkers which are not smart enough to join those symbols, and makes this correct C. Pointed out by several people.
2005-05-10Introduce GIT_DIR environment variable.Junio C Hamano
During the mailing list discussion on renaming GIT_ environment variables, people felt that having one environment that lets the user (or Porcelain) specify both SHA1_FILE_DIRECTORY (now GIT_OBJECT_DIRECTORY) and GIT_INDEX_FILE for the default layout would be handy. This change introduces GIT_DIR environment variable, from which the defaults for GIT_INDEX_FILE and GIT_OBJECT_DIRECTORY are derived. When GIT_DIR is not defined, it defaults to ".git". GIT_INDEX_FILE defaults to "$GIT_DIR/index" and GIT_OBJECT_DIRECTORY defaults to "$GIT_DIR/objects". Special thanks for ideas and discussions go to Petr Baudis and Daniel Barkalow. Bugs are mine ;-) Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-05-10Rename environment variables.Junio C Hamano
H. Peter Anvin mentioned that using SHA1_whatever as an environment variable name is not nice and we should instead use names starting with "GIT_" prefix to avoid conflicts. Here is what this patch does: * Renames the following environment variables: New name Old Name GIT_AUTHOR_DATE AUTHOR_DATE GIT_AUTHOR_EMAIL AUTHOR_EMAIL GIT_AUTHOR_NAME AUTHOR_NAME GIT_COMMITTER_EMAIL COMMIT_AUTHOR_EMAIL GIT_COMMITTER_NAME COMMIT_AUTHOR_NAME GIT_ALTERNATE_OBJECT_DIRECTORIES SHA1_FILE_DIRECTORIES GIT_OBJECT_DIRECTORY SHA1_FILE_DIRECTORY * Introduces a compatibility macro, gitenv(), which does an getenv() and if it fails calls gitenv_bc(), which in turn picks up the value from old name while giving a warning about using an old name. * Changes all users of the environment variable to fetch environment variable with the new name using gitenv(). * Updates the documentation and scripts shipped with Linus GIT distribution. The transition plan is as follows: * We will keep the backward compatibility list used by gitenv() for now, so the current scripts and user environments continue to work as before. The users will get warnings when they have old name but not new name in their environment to the stderr. * The Porcelain layers should start using new names. However, just in case it ends up calling old Plumbing layer implementation, they should also export old names, taking values from the corresponding new names, during the transition period. * After a transition period, we would drop the compatibility support and drop gitenv(). Revert the callers to directly call getenv() but keep using the new names. The last part is probably optional and the transition duration needs to be set to a reasonable value. Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-05-08Add git-update-cache --replace option.Junio C Hamano
When "path" exists as a file or a symlink in the index, an attempt to add "path/file" is refused because it results in file vs directory conflict. Similarly when "path/file1", "path/file2", etc. exist, an attempt to add "path" as a file or a symlink is refused. With git-update-cache --replace, these existing entries that conflict with the entry being added are automatically removed from the cache, with warning messages. Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-05-07Introduce SHA1_FILE_DIRECTORIES to support multiple object databases.Junio C Hamano
SHA1_FILE_DIRECTORIES environment variable is a colon separated paths used when looking for SHA1 files not found in the usual place for reading. Creating a new SHA1 file does not use this alternate object database location mechanism. This is useful to archive older, rarely used objects into separate directories. Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-05-07[PATCH] Remove unused sha1_file_directory variable.Junio C Hamano
Now all the users have gone. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-05-06Revert bogus optimization that avoids index file writesLinus Torvalds
It didn't properly mark all cache updates as being dirty, and causes merge errors due to that. In particular, it didn't notice when a file was force-removed. Besides, it was ugly as hell. I've put in place a slightly cleaner version, but I've not enabled the optimization because I don't want to be burned again.
2005-05-06date.c: add "show_date()" function.Linus Torvalds
Kind of like ctime(), but not as broken.
2005-05-05Fix symlink handlingLinus Torvalds
We really always want to have S_IFREG there for non-symlinks, otherwise we create corrupt index files.
2005-05-05[PATCH] git and symlinks as tracked contentKay Sievers
Allow to store and track symlink in the repository. A symlink is stored the same way as a regular file, only with the appropriate mode bits set. The symlink target is therefore stored in a blob object. This will hopefully make our udev repository fully functional. :) Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-05-03Improve sha1 object file writing.Linus Torvalds
Make it much safer: we write to a temporary file, and then link that temporary file to the final destination. This avoids all the nasty races if several people write the same object at the same time. It should also result in nicer on-disk layout, since it means that objects all get created in the same subdirectory. That makes a lot of block allocation algorithms happier, since the objects will now be allocated from the same zone.
2005-05-02Add git-write-blob.Junio C Hamano
A new command, git-write-blob, is introduced. This registers the contents of any file on the filesystem as a blob in the object database and reports its SHA1 to the standard output. To implement it, the patch promotes index_fd() from a static function in update-cache.c to extern and moves it to a library source, sha1_file.c. This command is used to update git-merge-one-file-script so that it does not smudge the work tree. Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-05-01Add "get_sha1()" helper function.Linus Torvalds
This allows the programs to use various simplified versions of the SHA1 names, eg just say "HEAD" for the SHA1 pointed to by the .git/HEAD file etc. For example, this commit has been done with git-commit-tree $(git-write-tree) -p HEAD instead of the traditional "$(cat .git/HEAD)" syntax.
2005-04-30[PATCH] compat: missing dirent.d_type fieldEdgar Toernig
Not everybody has "d_type".
2005-04-30[PATCH] compat: support pre-1.2 zlibEdgar Toernig
Older zlib's don't have deflateBound()
2005-04-30[PATCH] Do date parsing by hand...Edgar Toernig
...since everything out there is either strange (libc mktime has issues with timezones) or introduces unnecessary dependencies for people (libcurl). This goes back to the old date parsing, but moves it out into a file of its own, and does the "struct tm" to "seconds since epoch" handling by hand. I grepped through the tz-database and it seems there's one "country" left that has non-60-minute DST: Lord Howe Island. All others dropped that before 1970.
2005-04-28[PATCH] Rename and extend read_tree_with_tree_or_commit_sha1Junio C Hamano
This patch renames read_tree_with_tree_or_commit_sha1() to read_object_with_reference() and extends it to automatically dereference not just "commit" objects but "tag" objects. With this patch, you can say e.g.: ls-tree $tag read-tree -m $(merge-base $tag $HEAD) $tag $HEAD diff-cache $tag diff-tree $tag $HEAD Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-26[PATCH] introduce xmalloc and xreallocChristopher Li
Introduce xmalloc and xrealloc to die gracefully with a descriptive message when out of memory, rather than taking a SIGSEGV. Signed-off-by: Christopher Li<chrislgit@chrisli.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-25Fix up the types in write_sha1_fileLinus Torvalds
Use "unsigned long" for the size, like we do everywhere else.
2005-04-25Simplify "write_sha1_file()" interfacesLinus Torvalds
The write function now adds the header to the file by itself, so there is no reason to duplicate it among all the users any more.
2005-04-24[PATCH] Additional functions for the objects databaseDaniel Barkalow
This adds two functions: one to check if an object is present in the local database, and one to add an object to the local database by reading it from a file descriptor and checking its hash. Signed-Off-By: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-23New "diff-cache" implementation.Linus Torvalds
This one is about a million times simpler, and much more likely to be correct too. Instead of trying to match up a tree object against the index, we just read in the tree object side-by-side into the index, and just walk the resulting index file. This was what all the read-tree cleanups were all getting to.