aboutsummaryrefslogtreecommitdiff
path: root/update-cache.c
Commit message (Collapse)AuthorAge
* [PATCH] Make git-update-cache take relative pathnamesLinus Torvalds2005-08-17
| | | | | | | | This also makes "./filename" acceptable as a side effect, since the pathname normalization handles that too. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* [PATCH] Use SHA1 for git-update-cache --refreshBryan Larsen2005-07-08
| | | | | | | | | | | | | Change git-update-cache --refresh behaviour to use sha1's rather than comparing byte by byte. [JC demangled whitespace from the posted patch himself because he liked it so much. Also adjusted to the index_fd() interface slightly done differently from the original one.] 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>
* [PATCH] Add --info-only option to git-update-cache.Bryan Larsen2005-07-08
| | | | | | | | | | | | Add --info-only option to git-update-cache. [JC demangled whitespace from the posted patch himself because he liked it so much. Also adjusted to the index_fd() interface slightly done differently from the original one.] 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>
* [PATCH] Expose object ID computation functions.Bryan Larsen2005-07-08
| | | | | | | | | | | | | | 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>
* Add "-q" flag to git-update-cacheLinus Torvalds2005-06-20
| | | | | | | It suppresses the "needs update" message for subsequent "--refresh" cases (but not other errors). Will be useful for "git commit". Stay tuned.
* [PATCH] Make git-update-cache --force-remove regularPetr Baudis2005-06-05
| | | | | | | | | | | | Make the --force-remove flag behave same as --add, --remove and --replace. This means I can do git-update-cache --force-remove -- file1.c file2.c which is probably saner and also makes it easier to use in cg-rm. Signed-off-by: Petr Baudis <pasky@ucw.cz> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
* git-update-cache: allow dot-filesLinus Torvalds2005-05-24
| | | | | | | We still refuse to add ".", ".." and ".git". In theory, you could track another git-repository by allowing ".git", but the potential for confusion is just too high.
* sparse cleanupLinus Torvalds2005-05-20
| | | | | | | | | Fix various things that sparse complains about: - use NULL instead of 0 - make sure we declare everything properly, or mark it static - use proper function declarations ("fn(void)" instead of "fn()") Sparse is always right.
* [PATCH] cleanup of in-code namesAlexey Nezhdanov2005-05-19
| | | | | | | Fixes all in-code names that leaved during "big name change". Signed-off-by: Alexey Nezhdanov <snake@penza-gsm.ru> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
* [PATCH] Implement git-checkout-cache -u to update stat information in the cache.Junio C Hamano2005-05-19
| | | | | | | | | | 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>
* Rename cache_match_stat() to ce_match_stat()Brad Roberts2005-05-15
| | | | | Signed-off-by: Brad Roberts <braddr@puremagic.com> Signed-off-by: Petr Baudis <pasky@ucw.cz>
* Stick a comment to update-cache.c:refresh_cache() that you can'tPetr Baudis2005-05-11
| | | | just free(archive_cache[i]) when replacing it there.
* [patch] git: fix overflow in update-cache.cIngo Molnar2005-05-11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | this patch fixes a 1-byte overflow in update-cache.c (probably not exploitable). A specially crafted db object might trigger this overflow. the bug is that normally the 'type' field is parsed by read_sha1_file(), via: if (sscanf(buffer, "%10s %lu", type, size) != 2) i.e. 0-10 long strings, which take 1-11 bytes of space. Normally the type strings are stored in char [20] arrays, but in update-cache.c that is char [10], so a 1 byte overflow might occur. This should not happen with a 'friendly' DB, as the longest type string ("commit") is 7 bytes long. The fix is to use the customary char [20]. (someone might want to clean those open-coded constants up with a TYPE_LEN define, they do tend to cause problems like this. I'm not against open-coded constants (they make code much more readable), but for fields that get filled in from possibly hostile objects this is playing with fire.) hey, this might be the first true security fix for GIT? ;-) Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Petr Baudis <pasky@ucw.cz>
* Make update-cache be explicit about failed open() when doingPetr Baudis2005-05-11
| | | | add_file_to_cache().
* Fix git-update-cache --cacheinfo error message.Junio C Hamano2005-05-08
| | | | | | | The error detection logic was too lazy to distinguish parameter error and unable-to-add case. Signed-off-by: Junio C Hamano <junkio@cox.net>
* Allow removal of "path" when "path/file" exists.Junio C Hamano2005-05-08
| | | | | | | | | | | | | | When we used to have "path" as a file or a symlink, but now we have "path/file" (or in general, have "path" as a directory), we would want to remove "path" before adding "path/file". The logic in add_file_to_cache() only runs lstat() and does not detect this case and fails to allow removing it in this case. In the opposite case of having "path/file" in the index and having "path" on the filesystem as a file or a symlink we do allow removal of "path/file", so to be symmetric we should allow it as well, without forcing the user to say --force-remove. Signed-off-by: Junio C Hamano <junkio@cox.net>
* Add git-update-cache --replace option.Junio C Hamano2005-05-07
| | | | | | | | | | | | 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>
* Revert bogus optimization that avoids index file writesLinus Torvalds2005-05-06
| | | | | | | | | | 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.
* update-cache: remove compiler warningLinus Torvalds2005-05-06
| | | | "Unused variable len"
* [PATCH] fix compare symlink against readlink not dataKay Sievers2005-05-06
| | | | | | | | | | | | Fix update-cache to compare the blob of a symlink against the link-target and not the file it points to. Also ignore all permissions applied to links. Thanks to Greg for recognizing this while he added our list of symlinks back to the udev repository. Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
* Do not write out new index if nothing has changed.Junio C Hamano2005-05-05
| | | | | | | The git-update-cache command, especially with --refresh, may not change anything. In such a case, writing 1.6MB of the same thing is a waste. Signed-off-by: Junio C Hamano <junkio@cox.net>
* [PATCH] git and symlinks as tracked contentKay Sievers2005-05-05
| | | | | | | | | | 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>
* Implement git-update-cache --force-remove <path>Junio C Hamano2005-05-01
| | | | | | | | This new flag tells git-update-cache to remove the named path even when the work tree still happens to have the file. It is used to update git-merge-one-file-script not to smudge the work tree. Signed-off-by: Junio C Hamano <junkio@cox.net>
* Add git-write-blob.Junio C Hamano2005-05-01
| | | | | | | | | | | | | | 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>
* [PATCH] Make git-update-cache --refresh fail if update/merge needed.Junio C Hamano2005-05-01
| | | | | | | | | | | | Scripts may find it useful if they do not have to parse the output from the command but just can rely on its exit status. Earlier both Linus and myself thought this would be necessary to make git-prune-script safer but it turns out that the issue was somewhere else and not related to what this patch addresses. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
* [PATCH] Allow removing files in a subdirectory.Junio C Hamano2005-05-01
| | | | | | | | | | | | | | | | | | | | | | | | | I found this during a conflict merge testing. The original did not have either DF (a file) or DF/DF (a file DF/DF under a directory DF). One side created DF, the other created DF/DF. I first resolved DF as a new file by taking what the first side did. After that, the entry DF/DF cannot be resolved by running git-update-cache --remove although it does not exist on the filesystem. $ /bin/ls -F AN DF MN NM NN SS Z/ $ git-ls-files --stage | grep DF 100644 71420ab81e254145d26d6fc0cddee64c1acd4787 0 DF 100644 68a6d8b91da11045cf4aa3a5ab9f2a781c701249 2 DF/DF $ git-update-cache --remove DF/DF fatal: Unable to add DF/DF to database It turns out that the errno from open() in this case was not ENOENT but ENOTDIR, which the code did not check. Here is a fix. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
* [PATCH] introduce xmalloc and xreallocChristopher Li2005-04-26
| | | | | | | | 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>
* update-cache: remove index lock file on SIGINTLinus Torvalds2005-04-26
| | | | | This makes it a lot more pleasant to use when you interrupt a long-running operation.
* [PATCH] update-cache: add "--ignore-missing" optionJames Bottomley2005-04-24
| | | | | | | | | | | | | This adds an --ignore-missing option to update-cache, which makes it ignore missing files. Together with the "-n" option to checkout-cache, it allows me to do checkout-cache -n -f -a && update-cache --ignore-missing --refresh which only updates and refreshes the files I already have checked out. Signed-off-by: Linus Torvalds <torvalds@osdl.org>
* Add support for a "GIT_INDEX_FILE" environment variable.Linus Torvalds2005-04-21
| | | | | | | | | 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.
* The recent hash/compression switch-over missed the blob creation.Linus Torvalds2005-04-20
| | | | Happily, convert-cache just magically fixes all errors.
* [PATCH] Fix confusing behaviour of update-cache --refresh on unmerged paths.Junio C Hamano2005-04-18
| | | | | | | | | | | | The "update-cache --refresh" command attempts refresh_entry() on unmerged path, which results in as many "needs update" messages as there are unmerged stages for that path. This does not do any harm to the working directory, but it is confusing. Here is a fix. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
* [PATCH] Remove unused arguments from index_fd()Junio C Hamano2005-04-17
| | | | | | | | | | | | | The function index_fd() in update-cache.c takes 5 arguments, but two is not necessary and one that is a pointer to a structure really needs to be a pointer to one member of that structure. This patch cleans it up. Also it removes printf() apparently left after initial debugging. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
* Be much more liberal about the file mode bits.Linus Torvalds2005-04-16
| | | | | | 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.
* Encode a few extra flags per index entry.Linus Torvalds2005-04-15
| | | | | | 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.
* Add "--cacheinfo" option to update-cache.Linus Torvalds2005-04-15
| | | | | | This allows scripts to manually add entries to the cache explicitly. Need to do some way to remove them too, even if the path exists.
* Convert the index file reading/writing to use network byte order.Linus Torvalds2005-04-15
| | | | | | | 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).
* [PATCH] nsec portabilityPetr Baudis2005-04-13
| | | | | | | | It seems like the nsec portability is limited; in particular, older glibcs (<=2.2.4 at least) don't seem to like it. So access the nsec fields in struct stat only when -DNSEC. Signed-off-by: Petr Baudis <pasky@ucw.cz>
* [PATCH] Whitespace FixesIngo Molnar2005-04-13
| | | | | | | | Trivial whitespace fixes. From: Ingo Molnar <mingo@elte.hu> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Petr Baudis <pasky@ucw.cz>
* [PATCH] Consolidate the error handlingPetr Baudis2005-04-13
| | | | | | | 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>
* Allow zero-sized files to be checked in.Linus Torvalds2005-04-11
| | | | | | The kernel may not want it, but others probably do. Noted (again) by Junio Hamano.
* Rename ".dircache" directory to ".git"Linus Torvalds2005-04-11
| | | | I started out calling the tool "dircache". That's clearly moronic.
* Fix stale index.lock file removal using "atexit()".Linus Torvalds2005-04-11
| | | | Problem noted by Randy Dunlap.
* Fix "update-cache" not fixing up the size field as appropriate.Linus Torvalds2005-04-11
| | | | | The size field isn't in the tree information, so we need to update it if the sha1 matches.
* Make "update-cache --refresh" do what it really should do: justLinus Torvalds2005-04-11
| | | | | | | | | refresh the "stat" information. We need this after having done a "read-tree", for example, when the stat information does not match the checked-out tree, and we want to start getting efficient cache matching against the parts of the tree that are already up-to-date.
* Make "update-cache" a bit friendlier to use (and harder to mis-use).Linus Torvalds2005-04-10
| | | | | | | 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.
* Make "write_cache()" and friends available as generic routines.Linus Torvalds2005-04-09
| | | | | | 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).
* Make "cache_name_pos()" available to others.Linus Torvalds2005-04-09
| | | | | | | | 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.
* Use "-Wall -O2" for the compiler to get more warnings.Linus Torvalds2005-04-08
| | | | | | | And fix up the warnings that it pointed out. Let's keep the tree clean from early on. Not that the code is very beautiful anyway ;)
* Add copyright notices.Linus Torvalds2005-04-07
| | | | | | The tool interface sucks (especially "committing" information, which is just me doing everything by hand from the command line), but I think this is in theory actually a viable way of describing the world. So copyright it.