summaryrefslogtreecommitdiff
path: root/cache.h
AgeCommit message (Collapse)Author
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.
2005-04-22Move "read_tree()" to "tree.c" to be used as a generic helper function.Linus Torvalds
Next step: make "diff-cache" use it.
2005-04-21Add support for alternate SHA1 library implementations.Linus Torvalds
This one includes the Mozilla SHA1 implementation sent in by Edgar Toernig. It's dual-licenced under MPL-1.1 or GPL, so in the context of git, we obviously use the GPL version. Side note: the Mozilla SHA1 implementation is about twice as fast as the default openssl one on my G5, but the default openssl one has optimized x86 assembly language on x86. So choose wisely.
2005-04-21Add support for a "GIT_INDEX_FILE" environment variable.Linus Torvalds
We use that to specify alternative index files, which can be useful if you want to (for example) generate a temporary index file to do some specific operation that you don't want to mess with your main one with. It defaults to the regular ".git/index" if it hasn't been specified.
2005-04-21[PATCH] Accept commit in some places when tree is needed.Junio C Hamano
This patch implements read_tree_with_tree_or_commit_sha1(), which can be used when you are interested in reading an unpacked raw tree data but you do not know nor care if the SHA1 you obtained your user is a tree ID or a commit ID. Before this function's introduction, you would have called read_sha1_file(), examined its type, parsed it to call read_sha1_file() again if it is a commit, and verified that the resulting object is a tree. Instead, this function does that for you. It returns NULL if the given SHA1 is not either a tree or a commit. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-20Improve build: add <unistd.h> and use -O2 instead of -O3Linus Torvalds
(Nobody should use -O3. It just makes bad inlining decisions).
2005-04-20Make the sha1 of the index file go at the very end of the file.Linus Torvalds
This allows us to both calculate it and verify it faster.
2005-04-20Do SHA1 hash _before_ compression.Linus Torvalds
And add a "convert-cache" program to convert from old-style to new-style.
2005-04-17Be much more liberal about the file mode bits.Linus Torvalds
We only really care about the difference between a file being executable or not (by its owner). Everything else we leave for the user umask to decide.
2005-04-16[PATCH] Add --stage to show-files for new stage dircache.Junio C Hamano
This adds --stage option to show-files command. It shows file-mode, SHA1, stage and pathname. Record separator follows the usual convention of -z option as before. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-16[PATCH] Byteorder fix for read-tree, new -m semantics version.Junio C Hamano
The ce_namelen field has been renamed to ce_flags and split into the top 2-bit unused, next 2-bit stage number and the lowest 12-bit name-length, stored in the network byte order. A new macro create_ce_flags() is defined to synthesize this value from length and stage, but it forgets to turn the value into the network byte order. Here is a fix. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-16Make cache entry comparison take the new "state" flag into account.Linus Torvalds
This is what allows us to have multiple states of the same file in the index, and what makes it always sort correctly.
2005-04-16Encode a few extra flags per index entry.Linus Torvalds
This will allow us to have the same name in different "states" in the index at the same time. Which in turn seems to be a very simple way to merge.
2005-04-15Convert the index file reading/writing to use network byte order.Linus Torvalds
This allows using a git tree over NFS with different byte order, and makes it possible to just copy a fully populated repository and have the end result immediately usable (needing just a refresh to update the stat information).
2005-04-13[PATCH] Consolidate the error handlingPetr Baudis
Now there is error() for "library" errors and die() for fatal "application" errors. usage() is now used strictly only for usage errors. Signed-off-by: Petr Baudis <pasky@ucw.cz>
2005-04-11Rename ".dircache" directory to ".git"Linus Torvalds
I started out calling the tool "dircache". That's clearly moronic.
2005-04-10Add "-R" flag to "diff-tree", so that it will recursively traverse a tree of ↵Linus Torvalds
trees as it diffs them. This makes diff-tree usable again in the new world order.
2005-04-10Make "update-cache" a bit friendlier to use (and harder to mis-use).Linus Torvalds
It now requires the "--add" flag before you add any new files, and a "--remove" file if you want to mark files for removal. And giving it the "--refresh" flag makes it just update all the files that it already knows about.
2005-04-10This implements the new "recursive tree" write-tree.Linus Torvalds
It's got some debugging printouts etc still in it, but testing on the kernel seems to show that it does indeed fix the issue with huge tree files for each commit.
2005-04-09Export "cache_name_compare()" helper function.Linus Torvalds
The "diff-tree" program needs it.
2005-04-09Make "write_cache()" and friends available as generic routines.Linus Torvalds
This is needed for the change to make "read-tree" just read into the cache (and then you do a "checkout-cache" to update your current dir contents).
2005-04-09Make the cache stat information comparator public.Linus Torvalds
Like the cache filename finder, it's a generically useful function, rather than something specific to the current "show-diff" thing.
2005-04-09Make "cache_name_pos()" available to others.Linus Torvalds
It finds the cache entry position for a given name, and is generally useful. Sure, everybody can just scan the active cache array, but since it's sorted, you actually want to search it with a binary search, so let's not duplicate that logic all over the place.
2005-04-09Fix missing return values and some error tests for empty index filesLinus Torvalds
Patches from Dave Jones and Ingo Molnar, but since I don't have any infrastructure in place to use the old patch applicator scripts I am trying to build up, I ended up fixing the thing by hand instead. Credit where credit is due, though. Nice to see that people are taking a look at the project even in this early stage.
2005-04-08Add "check_sha1_signature()" helper functionLinus Torvalds
And fix up header declarations.
2005-04-08Factor out "read_sha1_file" into mapping/inflating/unmapping.Linus Torvalds
This allows us to also actually check the sha1 hash using these routines. Needed for the "fsck" thing.
2005-04-08Make "cat-file" output the file contents to stdout.Linus Torvalds
New syntax: "cat-file -t <sha1>" shows the tag, while "cat-file <tag> <sha1>" outputs the file contents after checking that the supplied tag matches.