aboutsummaryrefslogtreecommitdiffstats
path: root/cache.h
AgeCommit message (Collapse)AuthorFilesLines
2005-10-01Add git-symbolic-refJunio C Hamano1-0/+2
This adds the counterpart of git-update-ref that lets you read and create "symbolic refs". By default it uses a symbolic link to represent ".git/HEAD -> refs/heads/master", but it can be compiled to use the textfile symbolic ref. The places that did 'readlink .git/HEAD' and 'ln -s refs/heads/blah .git/HEAD' have been converted to use new git-symbolic-ref command, so that they can deal with either implementation. Signed-off-by: Junio C Hamano <junio@twinsun.com>
2005-10-01Use resolve_ref() to implement read_ref().Junio C Hamano1-0/+1
Symbolic refs are understood by resolve_ref(), so existing read_ref() users will automatically understand them as well. Signed-off-by: Junio C Hamano <junio@twinsun.com>
2005-10-01[PATCH] Allow reading "symbolic refs" that point to other refsLinus Torvalds1-0/+1
This extends the ref reading to understand a "symbolic ref": a ref file that starts with "ref: " and points to another ref file, and thus introduces the notion of ref aliases. This is in preparation of allowing HEAD to eventually not be a symlink, but one of these symbolic refs instead. [jc: Linus originally required the prefix to be "ref: " five bytes and nothing else, but I changed it to allow and strip any number of leading whitespaces to match what update-ref.c does.] Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-09-30Consolidate null_sha1[].Junio C Hamano1-0/+1
Signed-off-by: Junio C Hamano <junio@twinsun.com>
2005-09-27[PATCH] Provide access to git_dir through get_git_dir().Sven Verdoolaege1-0/+1
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-09-24Diff clean-up.Junio C Hamano1-3/+3
This is a long overdue clean-up to the code for parsing and passing diff options. It also tightens some constness issues. Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-09-20[PATCH] Return proper error valud from "parse_date()"Linus Torvalds1-1/+1
Right now we don't return any error value at all from parse_date(), and if we can't parse it, we just silently leave the result buffer unchanged. That's fine for the current user, which will always default to the current date, but it's a crappy interface, and we might well be better off with an error message rather than just the default date. So let's change the thing to return a negative value if an error occurs, and the length of the result otherwise (snprintf behaviour: if the buffer is too small, it returns how big it _would_ have been). [ I started looking at this in case we could support date-based revision names. Looks ugly. Would have to parse relative dates.. ] Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-09-20Show modified files in git-ls-filesJunio C Hamano1-0/+1
Add -m/--modified to show files that have been modified wrt. the index. [jc: The original came from Brian Gerst on Sep 1st but it only checked if the paths were cache dirty without actually checking the files were modified. I also added the usage string and a new test.] Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-09-12[PATCH] Add note about IANA confirmationLinus Torvalds1-0/+11
The git port (9418) is officially listed by IANA now. So document it. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-09-09Retire support for old environment variables.Junio C Hamano1-11/+0
We have deprecated the old environment variable names for quite a while and now it's time to remove them. Gone are: SHA1_FILE_DIRECTORIES AUTHOR_DATE AUTHOR_EMAIL AUTHOR_NAME COMMIT_AUTHOR_EMAIL COMMIT_AUTHOR_NAME SHA1_FILE_DIRECTORY Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-09-04[PATCH] Possible cleanups for local-pull.cPeter Hagervall1-1/+1
Hi. This patch contains the following possible cleanups: * Make some needlessly global functions in local-pull.c static * Change 'char *' to 'const char *' where appropriate Signed-off-by: Peter Hagervall <hager@cs.umu.se> Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-08-29Revert "Replace zero-length array decls with []."Junio C Hamano1-4/+4
This reverts 6c5f9baa3bc0d63e141e0afc23110205379905a4 commit, whose change breaks gcc-2.95. Not that I ignore portability to compilers that are properly C99, but keeping compilation with GCC working is more important, at least for now. We would probably end up declaring with "name[1]" and teach the allocator to subtract one if we really aimed for portability, but that is left for later rounds. Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-08-28Merge refs/heads/portable from http://www.cs.berkeley.edu/~ejr/gits/git.git Junio C Hamano1-4/+8
2005-08-24Support +<src>:<dst> format in push as well.Junio C Hamano1-0/+1
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-08-23Fix ?: statements.Jason Riedy1-0/+4
Omitting the first branch in ?: is a GNU extension. Cute, but not supported by other compilers. Replaced mostly by explicit tests. Calls to getenv() simply are repeated on non-GNU compilers. Signed-off-by: Jason Riedy <ejr@cs.berkeley.edu>
2005-08-23Replace zero-length array decls with [].Jason Riedy1-4/+4
C99 denotes variable-sized members with [], not [0]. Signed-off-by: Jason Riedy <ejr@cs.berkeley.edu>
2005-08-19Fix __attribute__ changes.Junio C Hamano1-2/+1
It cannot be checked with #ifndef, if you really think about what it does which cannot be done only with the preprocessor. My thinko. Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-08-18[PATCH] Spell __attribute__ correctly in cache.h.Jason Riedy1-1/+1
Sun's cc doesn't know __attribute__. Signed-off-by: Jason Riedy <ejr@cs.berkeley.edu> Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-08-17[PATCH] Export relative path handling "prefix_path()" functionLinus Torvalds1-0/+1
Not all programs necessarily have a pathspec array of pathnames, some of them (like git-update-cache) want to do things one file at a time. So export the single-path interface too. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-08-16[PATCH] Make "git diff" work inside relative subdirectoriesLinus Torvalds1-0/+3
We always show the diff as an absolute path, but pathnames to diff are taken relative to the current working directory (and if no pathnames are given, the default ends up being all of the current working directory). Note that "../xyz" also works, so you can do cd linux/drivers/char git diff ../block and it will generate a diff of the linux/drivers/block changes. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-08-16[PATCH] Add function to read an index file from an arbitrary filename.Daniel Barkalow1-0/+2
Note that the pack file has to be in the usual location if it gets installed later. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-08-15Alternate object pool mechanism updates.Junio C Hamano1-2/+3
It was a mistake to use GIT_ALTERNATE_OBJECT_DIRECTORIES environment variable to specify what alternate object pools to look for missing objects when working with an object database. It is not a property of the process running the git commands, but a property of the object database that is partial and needs other object pools to complete the set of objects it lacks. This patch allows you to have $GIT_OBJECT_DIRECTORY/info/alternates whose contents is in exactly the same format as the environment variable, to let an object database name alternate object pools it depends on. Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-08-09[PATCH] -Werror fixesTimo Sirainen1-4/+8
GCC's format __attribute__ is good for checking errors, especially with -Wformat=2 parameter. This fixes most of the reported problems against 2005-08-09 snapshot.
2005-08-06Redo the templates generation and installation.Junio C Hamano1-4/+0
Per discussion with people interested in binary packaging, change the default template location from /etc/git-core to /usr/share/git-core hierarchy. If a user wants to run git before installing for whatever reason, in addition to adding $src to the PATH environment variable, git-init-db can be run with --template=$src/templates/blt/ parameter. Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-08-05[PATCH] git: add git_mkstemp()Holger Eitzenberger1-0/+3
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-08-03Renaming push.Junio C Hamano1-0/+3
This allows git-send-pack to push local refs to a destination repository under different names. Here is the name mapping rules for refs. * If there is no ref mapping on the command line: - if '--all' is specified, it is equivalent to specifying <local> ":" <local> for all the existing local refs on the command line - otherwise, it is equivalent to specifying <ref> ":" <ref> for all the refs that exist on both sides. * <name> is just a shorthand for <name> ":" <name> * <src> ":" <dst> push ref that matches <src> to ref that matches <dst>. - It is an error if <src> does not match exactly one of local refs. - It is an error if <dst> matches more than one remote refs. - If <dst> does not match any remote refs, either - it has to start with "refs/"; <dst> is used as the destination literally in this case. - <src> == <dst> and the ref that matched the <src> must not exist in the set of remote refs; the ref matched <src> locally is used as the name of the destination. For example, - "git-send-pack --all <remote>" works exactly as before; - "git-send-pack <remote> master:upstream" pushes local master to remote ref that matches "upstream". If there is no such ref, it is an error. - "git-send-pack <remote> master:refs/heads/upstream" pushes local master to remote refs/heads/upstream, even when refs/heads/upstream does not exist. - "git-send-pack <remote> master" into an empty remote repository pushes the local ref/heads/master to the remote ref/heads/master. Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-08-03Install sample hooksJunio C Hamano1-0/+4
A template mechanism to populate newly initialized repository with default set of files is introduced. Use it to ship example hooks that can be used for update and post update checks, as Josef Weidendorfer suggests. Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-08-02[PATCH] Parallelize pulling by sshbarkalow@iabervon.org1-1/+2
This causes ssh-pull to request objects in prefetch() and read then in fetch(), such that it reduces the unpipelined round-trip time. This also makes sha1_write_from_fd() support having a buffer of data which it accidentally read from the fd after the object; this was formerly not a problem, because it would always get a short read at the end of an object, because the next object had not been requested. This is no longer true. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-07-31[PATCH] Functions for managing the set of packs the library is using ↵barkalow@iabervon.org1-0/+13
(whitespace fixed) This adds support for reading an uninstalled index, and installing a pack file that was added while the program was running, as well as functions for determining where to put the file. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-07-31Teach parse_commit_buffer about grafting.Junio C Hamano1-0/+2
Introduce a new file $GIT_DIR/info/grafts (or $GIT_GRAFT_FILE) which is a list of "fake commit parent records". Each line of this file is a commit ID, followed by parent commit IDs, all 40-byte hex SHA1 separated by a single SP in between. The records override the parent information we would normally read from the commit objects, allowing both adding "fake" parents (i.e. grafting), and pretending as if a commit is not a child of some of its real parents (i.e. cauterizing). Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-07-23[PATCH] Add update-server-info.Junio C Hamano1-0/+3
The git-update-server-info command prepares informational files to help clients discover the contents of a repository, and pull from it via a dumb transport protocols. Currently, the following files are produced. - The $repo/info/refs file lists the name of heads and tags available in the $repo/refs/ directory, along with their SHA1. This can be used by git-ls-remote command running on the client side. - The $repo/info/rev-cache file describes the commit ancestry reachable from references in the $repo/refs/ directory. This file is in an append-only binary format to make the server side friendly to rsync mirroring scheme, and can be read by git-show-rev-cache command. - The $repo/objects/info/pack file lists the name of the packs available, the interdependencies among them, and the head commits and tags contained in them. Along with the other two files, this is designed to help clients to make smart pull decisions. The git-receive-pack command is changed to invoke it at the end, so just after a push to a public repository finishes via "git push", the server info is automatically updated. In addition, building of the rev-cache file can be done by a standalone git-build-rev-cache command separately. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-07-16Merge three separate "fetch refs" functionsLinus Torvalds1-0/+8
It really just boils down to one "get_remote_heads()" function, and a common "struct ref" structure definition.
2005-07-15[PATCH] Move git_author_info and git_commiter_info to ident.cEric W. Biederman1-0/+2
Moving these functions allows all of the logic for figuring out what these values are to be shared between programs. Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-07-14Make "ce_match_path()" a generic helper functionLinus Torvalds1-0/+1
... and make git-diff-files use it too. This all _should_ make the diffcore-pathspec.c phase unnecessary, since the diff'ers now all do the path matching early interally.
2005-07-14Fix up read_tree() pathspec matching to use "const char **"Linus Torvalds1-1/+1
The same way the other pathspecs work. Also fix missing success return from the matching - not that anything actually uses this yet ;)
2005-07-14Start adding interfaces to read in partial treesLinus Torvalds1-1/+1
The same way "git-diff-tree" can limit its output to just a set of matches, we can read in just a partial tree for comparison purposes.
2005-07-13Add first cut at "git protocol" connect logic.Linus Torvalds1-0/+10
Useful for pulling stuff off a dedicated server. Instead of connecting with ssh or just starting a local pipeline, we connect over TCP to the other side and try to see if there's a git server listening. Of course, since I haven't written the git server yet, that will never happen. But the server really just needs to listen on a port, and execute a "git-upload-pack" when somebody connects. (It should read one packet-line, which should be of the format "git-upload-pack directoryname\n" and eventually we migth have other commands the server might accept).
2005-07-12Abstract out the "name <email> date" handling of commit-tree.cLinus Torvalds1-0/+3
We'll want to use it for the tagging too.
2005-07-12parse_date(): allow const date stringLinus Torvalds1-1/+1
This is part of breaking up the tag ID patch by Eric Biederman.
2005-07-10[PATCH] Remove map_sha1_fileDaniel Barkalow1-1/+0
Remove map_sha1_file(), now unused. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-07-10[PATCH] write_sha1_to_fd()Daniel Barkalow1-0/+1
Add write_sha1_to_fd(), which writes an object to a file descriptor. This includes support for unpacking it and recompressing it. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-07-08[PATCH] Expose object ID computation functions.Bryan Larsen1-1/+7
This patch makes the first half of write_sha1_file() and index_fd() externally visible, to allow callers to compute the object ID without actually storing it in the object database. [JC demangled the whitespaces himself because he liked the patch so much, and reworked the interface to index_fd() slightly, taking suggestion from Linus and of his own.] Signed-off-by: Bryan Larsen <bryan.larsen@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-07-08Add "mkpath()" helper functionLinus Torvalds1-0/+1
I'm bored with doing it by hand all the time.
2005-07-06[PATCH] clone-pack.c:write_one_ref() - Create leading directories.Junio C Hamano1-0/+2
The function write_one_ref() is passed the list of refs received from the other end, which was obtained by directory traversal under $GIT_DIR/refs; this can contain paths other than what git-init-db prepares and would fail to clone when there is such. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-07-05Move "get_ack()" to common git_connect functionsLinus Torvalds1-0/+1
git-clone-pack will want it too. Soon.
2005-07-05Add "git_path()" and "head_ref()" helper functions.Linus Torvalds1-0/+1
"git_path()" returns a static pathname pointer into the git directory using a printf-like format specifier. "head_ref()" works like "for_each_ref()", except for just the HEAD.
2005-07-04Move ref path matching to connect.c libraryLinus Torvalds1-0/+1
It's a generic thing for matching refs from the other side.
2005-07-04Factor out the ssh connection stuff from send-pack.cLinus Torvalds1-0/+3
I want to use it for git-fetch-pack too.
2005-07-03Add "has_sha1_pack()" function to query whether the object is available in a ↵Linus Torvalds1-0/+1
pack We'll want this for incremental packing.
2005-06-30[PATCH] Show more details of packfile with verify-pack -v.Junio C Hamano1-0/+1
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-06-30[PATCH] verify-pack updates.Junio C Hamano1-0/+9
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-29Add first cut at "git-receive-pack"Linus Torvalds1-0/+2
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 Hamano1-0/+4
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 Hamano1-0/+19
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 Hamano1-1/+1
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 Hamano1-1/+0
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 Hamano1-0/+1
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 McMullan1-1/+1
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-06[PATCH] Operations on refsDaniel Barkalow1-0/+1
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 Torvalds1-2/+8
Only with gcc. It fixes some warnings for certain versions of gcc, but not apparently all.
2005-06-05More work on merging with git-read-tree..Linus Torvalds1-0/+1
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-05Make fiel checkout function available to the git libraryLinus Torvalds1-0/+11
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 Hamano1-0/+1
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 Hamano1-0/+1
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 Torvalds1-0/+1
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-01Add "unpack_sha1_header()" helper functionLinus Torvalds1-0/+1
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 Torvalds1-0/+1
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 Torvalds1-0/+1
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 Hamano1-0/+9
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 Gerst1-2/+2
- 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 Baudis1-4/+0
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 Roberts1-2/+2
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 Roberts1-1/+1
Signed-off-by: Brad Roberts <braddr@puremagic.com> Signed-off-by: Petr Baudis <pasky@ucw.cz>
2005-05-15Cleanup the x-allocation functionsBrad Roberts1-2/+10
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 Hamano1-0/+1
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 Baudis1-8/+17
2005-05-11Mark the variable declarations in .h files as externPetr Baudis1-2/+2
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-09Introduce GIT_DIR environment variable.Junio C Hamano1-7/+6
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-09Rename environment variables.Junio C Hamano1-4/+11
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-07Add git-update-cache --replace option.Junio C Hamano1-1/+3
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 Hamano1-0/+1
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-06[PATCH] Remove unused sha1_file_directory variable.Junio C Hamano1-1/+0
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 Torvalds1-1/+1
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 Torvalds1-0/+1
Kind of like ctime(), but not as broken.
2005-05-05Fix symlink handlingLinus Torvalds1-3/+1
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 Sievers1-1/+9
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 Torvalds1-3/+0
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-01Add git-write-blob.Junio C Hamano1-0/+1
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 Torvalds1-0/+1
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 Toernig1-0/+9
Not everybody has "d_type".
2005-04-30[PATCH] compat: support pre-1.2 zlibEdgar Toernig1-0/+4
Older zlib's don't have deflateBound()
2005-04-30[PATCH] Do date parsing by hand...Edgar Toernig1-0/+3
...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 Hamano1-3/+4
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 Li1-0/+16
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 Torvalds1-1/+1
Use "unsigned long" for the size, like we do everywhere else.
2005-04-25Simplify "write_sha1_file()" interfacesLinus Torvalds1-1/+1
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-23[PATCH] Additional functions for the objects databaseDaniel Barkalow1-0/+5
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-22New "diff-cache" implementation.Linus Torvalds1-0/+2
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 Torvalds1-0/+3
Next step: make "diff-cache" use it.
2005-04-21Add support for alternate SHA1 library implementations.Linus Torvalds1-1/+1
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 Torvalds1-0/+8
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-20[PATCH] Accept commit in some places when tree is needed.Junio C Hamano1-0/+4
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 Torvalds1-0/+1
(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 Torvalds1-1/+0
This allows us to both calculate it and verify it faster.
2005-04-20Do SHA1 hash _before_ compression.Linus Torvalds1-1/+1
And add a "convert-cache" program to convert from old-style to new-style.
2005-04-16Be much more liberal about the file mode bits.Linus Torvalds1-0/+3
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 Hamano1-5/+7
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 Hamano1-1/+1
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-15Make cache entry comparison take the new "state" flag into account.Linus Torvalds1-3/+4
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-15Encode a few extra flags per index entry.Linus Torvalds1-2/+6
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 Torvalds1-13/+18
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 Baudis1-1/+4
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 Torvalds1-1/+1
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 Torvalds1-4/+4
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 Torvalds1-2/+2
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-09This implements the new "recursive tree" write-tree.Linus Torvalds1-1/+1
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 Torvalds1-0/+1
The "diff-tree" program needs it.
2005-04-09Make "write_cache()" and friends available as generic routines.Linus Torvalds1-2/+5
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 Torvalds1-1/+9
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 Torvalds1-0/+1
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 Torvalds1-1/+1
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 Torvalds1-0/+1
And fix up header declarations.
2005-04-08Factor out "read_sha1_file" into mapping/inflating/unmapping.Linus Torvalds1-0/+2
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 Torvalds1-0/+1
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.
2005-04-07Initial revision of "git", the information manager from hellLinus Torvalds1-0/+93