Commit graph

1791 commits

Author SHA1 Message Date
Linus Torvalds db823d4a5a Fix symlink handling
We really always want to have S_IFREG there for non-symlinks,
otherwise we create corrupt index files.
2005-05-05 16:01:46 -07:00
Kay Sievers 8ae0a8c514 [PATCH] git and symlinks as tracked content
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-05 08:23:01 -07:00
Linus Torvalds aac1794132 Improve sha1 object file writing.
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-03 11:46:16 -07:00
Junio C Hamano 74400e7175 Add git-write-blob.
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-01 23:45:49 -07:00
Linus Torvalds 3c249c9506 Add "get_sha1()" helper function.
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-05-01 16:36:56 -07:00
Edgar Toernig b682969367 [PATCH] compat: missing dirent.d_type field
Not everybody has "d_type".
2005-04-30 09:51:03 -07:00
Edgar Toernig 9da3acfb19 [PATCH] compat: support pre-1.2 zlib
Older zlib's don't have deflateBound()
2005-04-30 09:51:03 -07:00
Edgar Toernig ecee9d9e79 [PATCH] Do date parsing by hand...
...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-30 09:46:49 -07:00
Junio C Hamano 40469ee9c6 [PATCH] Rename and extend read_tree_with_tree_or_commit_sha1
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-28 16:42:27 -07:00
Christopher Li 812666c8e6 [PATCH] introduce xmalloc and xrealloc
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-26 12:00:58 -07:00
Linus Torvalds f5b913c9cb Fix up the types in write_sha1_file
Use "unsigned long" for the size, like we do everywhere else.
2005-04-25 12:04:55 -07:00
Linus Torvalds a44c9a5e2e Simplify "write_sha1_file()" interfaces
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-25 10:19:53 -07:00
Daniel Barkalow 8237b1854c [PATCH] Additional functions for the objects database
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-23 18:47:23 -07:00
Linus Torvalds b5af910727 New "diff-cache" implementation.
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-22 17:15:28 -07:00
Linus Torvalds 94537c78a8 Move "read_tree()" to "tree.c" to be used as a generic helper function.
Next step: make "diff-cache" use it.
2005-04-22 16:42:37 -07:00
Linus Torvalds cef661fc79 Add support for alternate SHA1 library implementations.
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-21 12:33:22 -07:00
Linus Torvalds bb233d690a Add support for a "GIT_INDEX_FILE" environment variable.
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 10:55:18 -07:00
Junio C Hamano f4913f91a9 [PATCH] Accept commit in some places when tree is needed.
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-20 18:06:49 -07:00
Linus Torvalds 2dee060968 Improve build: add <unistd.h> and use -O2 instead of -O3
(Nobody should use -O3. It just makes bad inlining decisions).
2005-04-20 13:00:08 -07:00
Linus Torvalds ca9be05421 Make the sha1 of the index file go at the very end of the file.
This allows us to both calculate it and verify it faster.
2005-04-20 12:36:41 -07:00
Linus Torvalds d98b46f8d9 Do SHA1 hash _before_ compression.
And add a "convert-cache" program to convert from old-style
to new-style.
2005-04-20 01:10:46 -07:00
Linus Torvalds e44794706e Be much more liberal about the file mode bits.
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 22:26:31 -07:00
Junio C Hamano aee461985f [PATCH] Add --stage to show-files for new stage dircache.
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 08:33:23 -07:00
Junio C Hamano fcf712e60e [PATCH] Byteorder fix for read-tree, new -m semantics version.
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-16 08:30:20 -07:00
Linus Torvalds 95fd5bf82a Make cache entry comparison take the new "state" flag into account.
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-15 22:51:44 -07:00
Linus Torvalds f5cabd13d8 Encode a few extra flags per index entry.
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-15 21:45:38 -07:00
Linus Torvalds ccc4feb579 Convert the index file reading/writing to use network byte order.
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-15 10:44:27 -07:00
Petr Baudis 2de381f919 [PATCH] Consolidate the error handling
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-13 02:28:48 -07:00
Linus Torvalds 4bb04f2190 Rename ".dircache" directory to ".git"
I started out calling the tool "dircache". That's clearly moronic.
2005-04-11 15:47:57 -07:00
Linus Torvalds 73134b6d3f Add "-R" flag to "diff-tree", so that it will recursively traverse a tree of trees
as it diffs them.

This makes diff-tree usable again in the new world order.
2005-04-10 14:03:58 -07:00
Linus Torvalds 121481abf8 Make "update-cache" a bit friendlier to use (and harder to mis-use).
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-10 11:32:54 -07:00
Linus Torvalds d6d3f9d012 This implements the new "recursive tree" write-tree.
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-09 17:09:34 -07:00
Linus Torvalds 79517a067a Export "cache_name_compare()" helper function.
The "diff-tree" program needs it.
2005-04-09 12:59:11 -07:00
Linus Torvalds 197ee8c970 Make "write_cache()" and friends available as generic routines.
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-09 12:09:27 -07:00
Linus Torvalds 734aab758c Make the cache stat information comparator public.
Like the cache filename finder, it's a generically useful function,
rather than something specific to the current "show-diff" thing.
2005-04-09 09:48:20 -07:00
Linus Torvalds eb38c22f53 Make "cache_name_pos()" available to others.
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-09 09:26:55 -07:00
Linus Torvalds 59c1e24980 Fix missing return values and some error tests for empty index files
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-09 00:25:22 -07:00
Linus Torvalds 2ade934026 Add "check_sha1_signature()" helper function
And fix up header declarations.
2005-04-08 15:01:15 -07:00
Linus Torvalds 24778e335a Factor out "read_sha1_file" into mapping/inflating/unmapping.
This allows us to also actually check the sha1 hash using these
routines. Needed for the "fsck" thing.
2005-04-08 14:42:29 -07:00
Linus Torvalds bf0c6e839c Make "cat-file" output the file contents to stdout.
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-08 09:16:38 -07:00
Linus Torvalds e83c516331 Initial revision of "git", the information manager from hell 2005-04-07 15:13:13 -07:00