summaryrefslogtreecommitdiff
path: root/cache.h
AgeCommit message (Collapse)Author
2005-11-29working from subdirectory: preparationJunio C Hamano
- prefix_filename() is like prefix_path() but can be used to name any file on the filesystem, not the files that might go into the index file. - setup_git_directory_gently() tries to find the GIT_DIR, but does not die() if called outside a git repository. Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-11-28Introduce i18n.commitencoding.Junio C Hamano
This is to hold what the project-local rule as to the charset/encoding for the commit log message is. Lack of it defaults to utf-8. Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-11-27init-db: check template and repository format.Junio C Hamano
This makes init-db repository version aware. It checks if an existing config file says the repository being reinitialized is of a wrong version and aborts before doing further harm. When copying the templates, it makes sure the they are of the right repository format version. Otherwise the templates are ignored with an warning message. It copies the templates before creating the HEAD, and if the config file is copied from the template directory, reads it, primarily to pick up the value of core.symrefsonly. It changes the way the result of the filemode reliability test is written to the configuration file using git_config_set(). The test is done even if the config file was copied from the templates. And finally, our own repository format version is written to the config file. Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-11-27Repository format version check.Junio C Hamano
This adds the repository format version code, first done by Martin Atukunda. Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-11-22git-var: constness and globalness cleanup.Junio C Hamano
var.c::git_var read function did not have to return writable strings; make it and the functions it points at return const char * instead. ident.c::get_ident() did not need to be global, so make it static. Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-11-21Fix sparse warningsTimo Hirvonen
Make some functions static and convert func() function prototypes to to func(void). Fix declaration after statement, missing declaration and redundant declaration warnings. Signed-off-by: Timo Hirvonen <tihirvon@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-11-20git-config-set: add more optionsJohannes Schindelin
... namely --replace-all, to replace any amount of matching lines, not just 0 or 1, --get, to get the value of one key, --get-all, the multivar version of --get, and --unset-all, which deletes all matching lines from .git/config Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-11-20Library code for user-relative paths, take three.Andreas Ericsson
This patch provides the work-horse of the user-relative paths feature, using Linus' idea of a blind chdir() and getcwd() which makes it remarkably simple. Signed-off-by: Andreas Ericsson <ae@op5.se> Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-11-20Add functions git_config_set() and git_config_set_multivar()Johannes Schindelin
The function git_config_set() does exactly what you think it does. Given a key (in the form "core.filemode") and a value, it sets the key to the value. Example: git_config_set("core.filemode", "true"); The function git_config_set_multivar() is meant for setting variables which can have several values for the same key. Example: [diff] twohead = resolve twohead = recarsive the typo in the second line can be replaced by git_config_set_multivar("diff.twohead", "recursive", "^recar"); The third argument of the function is a POSIX extended regex which has to match the value. If there is no key/value pair with a matching value, a new key/value pair is added. These commands are also capable of unsetting (deleting) entries: git_config_set_multivar("diff.twohead", NULL, "sol"); will delete the entry twohead = resolve Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-11-17git's rev-parse.c function show_datestring presumes gnu dateLinus Torvalds
Ok. This is the insane patch to do this. It really isn't very careful, and the reason I call it "approxidate()" will become obvious when you look at the code. It is very liberal in what it accepts, to the point where sometimes the results may not make a whole lot of sense. It accepts "last week" as a date string, by virtue of "last" parsing as the number 1, and it totally ignoring superfluous fluff like "ago", so "last week" ends up being exactly the same thing as "1 week ago". Fine so far. It has strange side effects: "last december" will actually parse as "Dec 1", which actually _does_ turn out right, because it will then notice that it's not December yet, so it will decide that you must be talking about a date last year. So it actually gets it right, but it's kind of for the "wrong" reasons. It also accepts the numbers 1..10 in string format ("one" .. "ten"), so you can do "ten weeks ago" or "ten hours ago" and it will do the right thing. But it will do some really strange thigns too: the string "this will last forever", will not recognize anyting but "last", which is recognized as "1", which since it doesn't understand anything else it will think is the day of the month. So if you do gitk --since="this will last forever" the date will actually parse as the first day of the current month. And it will parse the string "now" as "now", but only because it doesn't understand it at all, and it makes everything relative to "now". Similarly, it doesn't actually parse the "ago" or "from now", so "2 weeks ago" is exactly the same as "2 weeks from now". It's the current date minus 14 days. But hey, it's probably better (and certainly faster) than depending on GNU date. So now you can portably do things like gitk --since="two weeks and three days ago" git log --since="July 5" git-whatchanged --since="10 hours ago" git log --since="last october" and it will actually do exactly what you thought it would do (I think). It will count 17 days backwards, and it will do so even if you don't have GNU date installed. (I don't do "last monday" or similar yet, but I can extend it to that too if people want). It was kind of fun trying to write code that uses such totally relaxed "understanding" of dates yet tries to get it right for the trivial cases. The result should be mixed with a few strange preprocessor tricks, and be submitted for the IOCCC ;) Feel free to try it out, and see how many strange dates it gets right. Or wrong. And if you find some interesting (and valid - not "interesting" as in "strange", but "interesting" as in "I'd be interested in actually doing this) thing it gets wrong - usually by not understanding it and silently just doing some strange things - please holler. Now, as usual this certainly hasn't been getting a lot of testing. But my code always works, no? Linus Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-11-15diff: make default rename detection limit configurable.Junio C Hamano
A while ago, a rename-detection limit logic was implemented as a response to this thread: http://marc.theaimsgroup.com/?l=git&m=112413080630175 where gitweb was found to be using a lot of time and memory to detect renames on huge commits. git-diff family takes -l<num> flag, and if the number of paths that are rename destination candidates (i.e. new paths with -M, or modified paths with -C) are larger than that number, skips rename/copy detection even when -M or -C is specified on the command line. This commit makes the rename detection limit easier to use. You can have: [diff] renamelimit = 30 in your .git/config file to specify the default rename detection limit. You can override this from the command line; giving 0 means 'unlimited': git diff -M -l0 We might want to change the default behaviour, when you do not have the configuration, to limit it to say 20 paths or so. This would also help the diffstat generation after a big 'git pull'. Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-11-15Add config variable core.symrefsonlyJohannes Schindelin
This allows you to force git to avoid symlinks for refs. Just add something like [core] symrefsonly = true to .git/config. DonĀ“t forget to "git checkout your_branch", or it does not do anything... Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-10-29Support receiving server capabilitiesJohannes Schindelin
This patch implements the client side of backward compatible upload-pack protocol extension, <20051027141619.0e8029f2.vsu@altlinux.ru> by Sergey. The updated server can append "server_capabilities" which is supposed to be a string containing space separated features of the server, after one of elements in the initial list of SHA1-refname line, hidden with an embedded NUL. After get_remote_heads(), check if the server supports the feature like if (server_supports("multi_ack")) do_something(); Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-10-26pack-objects: Allow use of pre-generated pack.Junio C Hamano
git-pack-objects can reuse pack files stored in $GIT_DIR/pack-cache directory, when a necessary pack is found. This is hopefully useful when upload-pack (called from git-daemon) is expected to receive requests for the same set of objects many times (e.g full cloning request of any project, or updates from the set of heads previous day to the latest for a slow moving project). Currently git-pack-objects does *not* keep pack files it creates for reusing. It might be useful to add --update-cache option to it, which would allow it store pack files it created in the pack-cache directory, and prune rarely used ones from it. Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-10-15Ignore funny refname sent from remoteJunio C Hamano
This allows the remote side (most notably, upload-pack) to show additional information without affecting the downloader. Peek-remote does not ignore them -- this is to make it useful for Pasky's automatic tag following. Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-10-15Unlocalized isspace and friendsLinus Torvalds
Do our own ctype.h, just to get the sane semantics: we want locale-independence, _and_ we want the right signed behaviour. Plus we only use a very small subset of ctype.h anyway (isspace, isalpha, isdigit and isalnum). Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-10-13Keep track of whether a pack is local or notLinus Torvalds
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>
2005-10-12Use git config file for committer name and email infoLinus Torvalds
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>
2005-10-11show-branch: optionally use unique prefix as name.Junio C Hamano
git-show-branch acquires two new options. --sha1-name to name commits using the unique prefix of their object names, and --no-name to not to show names at all. This was outlined in <7vk6gpyuyr.fsf@assigned-by-dhcp.cox.net> Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-10-11Use the same move_temp_to_file in git-http-fetch.Junio C Hamano
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>
2005-10-10Add ".git/config" file parserLinus Torvalds
This is a first cut at a very simple parser for a git config file. The format of the file is a simple ini-file like thing, with simple variable/value pairs. You can (and should) make the variables have a simple single-level scope, ie a valid file looks something like this: # # This is the config file, and # a '#' or ';' character indicates # a comment # ; core variables [core] ; Don't trust file modes filemode = false ; Our diff algorithm [diff] external = "/usr/local/bin/gnu-diff -u" renames = true which parses into three variables: "core.filemode" is associated with the string "false", and "diff.external" gets the appropriate quoted value. Right now we only react to one variable: "core.filemode" is a boolean that decides if we should care about the 0100 (user-execute) bit of the stat information. Even that is just a parsing demonstration - this doesn't actually implement that st_mode compare logic itself. Different programs can react to different config options, although they should always fall back to calling "git_default_config()" on any config option name that they don't recognize. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-10-08[PATCH] If NO_MMAP is defined, fake mmap() and munmap()Johannes Schindelin
Since some platforms do not support mmap() at all, and others do only just so, this patch introduces the option to fake mmap() and munmap() by malloc()ing and read()ing explicitely. Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
2005-10-07Show original and resulting blob object info in diff output.Junio C Hamano
This adds more cruft to diff --git header to record the blob SHA1 and the mode the patch/diff is intended to be applied against, to help the receiving end fall back on a three-way merge. The new header looks like this: diff --git a/apply.c b/apply.c index 7be5041..8366082 100644 --- a/apply.c +++ b/apply.c @@ -14,6 +14,7 @@ // files that are being modified, but doesn't apply the patch // --stat does just a diffstat, and doesn't actually apply +// --show-index-info shows the old and new index info for... ... Upon receiving such a patch, if the patch did not apply cleanly to the target tree, the recipient can try to find the matching old objects in her object database and create a temporary tree, apply the patch to that temporary tree, and attempt a 3-way merge between the patched temporary tree and the target tree using the original temporary tree as the common ancestor. The patch lifts the code to compute the hash for an on-filesystem object from update-index.c and makes it available to the diff output routine. Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-10-02Add git-symbolic-refJunio C Hamano
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-02Use resolve_ref() to implement read_ref().Junio C Hamano
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-02[PATCH] Allow reading "symbolic refs" that point to other refsLinus Torvalds
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-10-01Consolidate null_sha1[].Junio C Hamano
Signed-off-by: Junio C Hamano <junio@twinsun.com>
2005-09-27[PATCH] Provide access to git_dir through get_git_dir().Sven Verdoolaege
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-09-25Diff clean-up.Junio C Hamano
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 Torvalds
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 Hamano
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 Torvalds
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 Hamano
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 Hagervall
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 Hamano
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-29Merge refs/heads/portable from http://www.cs.berkeley.edu/~ejr/gits/git.git Junio C Hamano
2005-08-24Support +<src>:<dst> format in push as well.Junio C Hamano
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-08-24Fix ?: statements.Jason Riedy
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-24Replace zero-length array decls with [].Jason Riedy
C99 denotes variable-sized members with [], not [0]. Signed-off-by: Jason Riedy <ejr@cs.berkeley.edu>
2005-08-19Fix __attribute__ changes.Junio C Hamano
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-19[PATCH] Spell __attribute__ correctly in cache.h.Jason Riedy
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 Torvalds
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-17[PATCH] Make "git diff" work inside relative subdirectoriesLinus Torvalds
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 Barkalow
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 Hamano
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-10[PATCH] -Werror fixesTimo Sirainen
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 Hamano
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-06[PATCH] git: add git_mkstemp()Holger Eitzenberger
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-08-04Renaming push.Junio C Hamano
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 Hamano
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>