1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-10-31 22:37:54 +01:00
Commit graph

54 commits

Author SHA1 Message Date
Junio C Hamano
f9253394a2 [PATCH] Add git-verify-pack command.
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-29 09:11:39 -07:00
Junio C Hamano
3c84974207 [PATCH] Fixlets on top of Nico's clean-up.
If we prefer 0 as maxsize for diff_delta() to say "unlimited", let's be
consistent about it.

This patch also fixes type mismatch in a call to get_delta_hdr_size()
from packed_delta_info().

Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-06-29 09:11:38 -07:00
Nicolas Pitre
dcde55bc58 [PATCH] assorted delta code cleanup
This is a wrap-up patch including all the cleanups I've done to the
delta code and its usage.  The most important change is the
factorization of the delta header handling code.

Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-06-29 09:11:38 -07:00
Linus Torvalds
e5e3e0f500 Fix packed_delta_info() that was broken by the delta header packing change
Pointed out by Junio.
2005-06-28 22:42:45 -07:00
Linus Torvalds
01247d8742 Make git pack files use little-endian size encoding
This makes it match the new delta encoding, and admittedly makes the
code easier to follow.

This also updates the PACK file version to 2, since this (and the delta
encoding change in the previous commit) are incompatible with the old
format.
2005-06-28 22:15:57 -07:00
Linus Torvalds
fead2836a1 Merge fighting fsck-cache updates from Junio
It's just easier to let git help out with the merge than it is to try to
fix up the diffs.
2005-06-28 15:20:10 -07:00
Junio C Hamano
9a217f2a72 [PATCH] Expose packed_git and alt_odb.
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-28 15:16:25 -07:00
Junio C Hamano
d85a4feeee [PATCH] Bugfix: initialize pack_base to NULL.
This was causing random segfaults, because use_packed_git() got
confused by random garbage there.

Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-06-28 15:12:25 -07:00
Linus Torvalds
a733cb606f Change pack file format. Hopefully for the last time.
This also adds a header with a signature, version info, and the number
of objects to the pack file.  It also encodes the file length and type
more efficiently.
2005-06-28 14:21:02 -07:00
Linus Torvalds
a69d094366 Teach packing about "tag" objects
(And teach sha1_file and unpack-object know how to unpack them too, of
course)
2005-06-28 09:58:23 -07:00
Junio C Hamano
5db47c2bb3 [PATCH] Obtain sha1_file_info() for deltified pack entry properly.
The initial one was not doing enough to figure things out
without uncompressing too much.  It also fixes a potential
segfault resulting from missing use_packed_git() call.

We would need to introduce unuse_packed_git() call and do proper
use counting to figure out when it is safe to unmap, but
currently we do not unmap packed file yet.

Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-06-28 08:53:21 -07:00
Junio C Hamano
d410c0f5a9 [PATCH] Skip writing out sha1 files for objects in packed git.
Now, there's still a misfeature there, which is that when you
create a new object, it doesn't check whether that object
already exists in the pack-file, so you'll end up with a few
recent objects that you really don't need (notably tree
objects), and this patch fixes it.

Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-06-27 19:40:21 -07:00
Junio C Hamano
1f688557c0 [PATCH] Teach read_sha1_file() and friends about packed git object store.
GIT_OBJECT_DIRECTORY and GIT_ALTERNATE_OBJECT_DIRECTORIES can
have the "pack" subdirectory that houses "packed GIT" files
produced by git-pack-objects (e.g. .git/objects/pack/foo.pack
and .git/objects/pack/foo.idx; always store them as pairs).  The
following functions in sha1_file.c can then read object contents
from such packed file:

 - sha1_object_info()
 - has_sha1_file()
 - read_sha1_file()

Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-06-27 15:27:51 -07:00
Junio C Hamano
36e4d74a21 [PATCH] Enhance sha1_file_size() into sha1_object_info()
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 15:27:51 -07:00
Junio C Hamano
c4584ae3fd [PATCH] Remove "delta" object representation.
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-27 15:27:51 -07:00
Mika Kukkonen
d565b3412a [PATCH] Fix several gcc4 signedness warnings
Here is a patch that fixes several gcc4 warnings about different signedness,
all between char and unsigned char. I tried to keep the patch minimal
so resertod to casts in three places.

Signed-off-by: Mika Kukkonen <mikukkon@iki.fi>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-06-21 13:30:55 -07:00
Jason McMullan
5d6ccf5ce7 [PATCH] Anal retentive 'const unsigned char *sha1'
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-08 13:04:53 -07:00
Daniel Barkalow
95fc75129a [PATCH] Operations on refs
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-06 17:09:45 -07:00
Junio C Hamano
65c2e0c349 [PATCH] Find size of SHA1 object without inflating everything.
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 15:48:33 -07:00
Junio C Hamano
4a62b61939 [PATCH] Handle deltified object correctly in git-*-pull family.
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-02 15:48:33 -07:00
Linus Torvalds
5180cacc20 Split up unpack_sha1_file() some more
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-02 07:57:25 -07:00
Linus Torvalds
c4483576b8 Add "unpack_sha1_header()" helper function
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-06-01 17:54:59 -07:00
Linus Torvalds
e871b649a3 unpack_sha1_file: zero-pad the unpacked object.
This makes them easier to parse without having to worry about
running off the end, and allows us to treat commits as normal
strings.
2005-05-25 18:25:08 -07:00
Linus Torvalds
6b0c312106 Include file cleanups..
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-22 11:54:17 -07:00
Nicolas Pitre
91d7b8afc2 [PATCH] delta read
This makes the core code aware of delta objects and undeltafy them as
needed.  The convention is to use read_sha1_file() to have
undeltafication done automatically (most users do that already so this
is transparent).

If the delta object itself has to be accessed then it must be done
through map_sha1_file() and unpack_sha1_file().

In that context mktag.c has been switched to read_sha1_file() as there
is no reason to do the full map+unpack manually.

Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-05-20 15:41:45 -07:00
Linus Torvalds
e99d59ff0b sparse cleanup
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.
2005-05-20 11:46:10 -07:00
Brian Gerst
bf0f910d1d [PATCH] Kill a bunch of pointer sign warnings for gcc4
- 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-18 08:44:23 -07:00
Petr Baudis
f1a7eb36b0 Merge with http://members.cox.net/junkio/git-jc.git 2005-05-11 02:00:49 +02:00
Junio C Hamano
8ac069ac0a Introduce GIT_DIR environment variable.
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-09 22:57:58 -07:00
Junio C Hamano
d19938ab60 Rename environment variables.
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-09 17:57:56 -07:00
Junio C Hamano
ddd5d0568d Stylistic fixes to sha1_file.c
This fixes stylistic problems and one unused variable spotted by
Petr Baudis.  The buf variable unused in prepare_alt_odb() is
gone and the "creepy" function is more heavily documented.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-05-08 13:51:13 -07:00
Thomas Glanzmann
6ffcee883b [PATCH] Really *do* nothing in while loop
A deflate loop in sha1_file.c would have /* nothing */ as its
body, but the semicolon was missing, so the next command was run.
Fortunately the loop went through exactly once so it didn't trigger
an actual bug so far.

Signed-Off-by: Thomas Glanzmann <sithglan@stud.uni-erlangen.de>
Signed-off-by: Petr Baudis <pasky@ucw.cz>
2005-05-08 17:29:33 +02:00
Thomas Glanzmann
a1df57abb9 [PATCH] Add #include <limits.h> so that git compiles under Solaris
<JC> Editorial Note.  We may want to include standard headers in one
of those headers everybody includes, e.g. cache.h, to reduce clutters,
but this commit is as Thomas posted to the GIT list.

Date:	Sat, 7 May 2005 10:41:41 +0200
Signed-off-by: Thomas Glanzmann <sithglan@stud.uni-erlangen.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-05-07 12:32:21 -07:00
Junio C Hamano
383f85b72a Free compressed buffer after write_sha1_file() is done.
This does not matter for commands that write just a handful SHA1 files,
but is noticeable in git-convert-cache which essentially traverses the
entire object database.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-05-07 01:27:00 -07:00
Junio C Hamano
ace1534d6f Introduce SHA1_FILE_DIRECTORIES to support multiple object databases.
SHA1_FILE_DIRECTORIES environment variable is a colon separated paths
used when looking for SHA1 files not found in the usual place for
reading.  Creating a new SHA1 file does not use this alternate object
database location mechanism.  This is useful to archive older, rarely
used objects into separate directories.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-05-07 00:38:04 -07:00
Junio C Hamano
bf60144c0a [PATCH] Remove unused sha1_file_directory variable.
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-06 17:02:24 -07:00
Linus Torvalds
a31c6d022e sha1_file: make the new sha1 object writing be coda-friendly.
Coda doesn't like cross-directory hardlinks. So try to fall back
on a plain rename instead.
2005-05-03 15:16:18 -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
ca4c7db9ef Remove the ugly jit-style parent syntax.
If somebody wants it later, we can re-do it, but for now we consider
it an experiment that wasn't worth it. Git will still honor symbolic
names, it just won't look up parents for you.

Of course, you can always do it by hand if you want to.
2005-05-01 19:16:06 -07:00
Linus Torvalds
35ad33823e Add "look up parent" logic for the simple names.
It uses the jit syntax, at least for now. 0-xxxx is the first parent of xxxx,
while 1-xxxx is the second, and so on. You can use just "-xxxx" for the first
parent, but a lot of commands will think that the initial '-' implies a
command line flag.
2005-05-01 18:13:16 -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
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
Andreas Gal
da6abf5d9c [PATCH] fix segfault in fsck-cache
Here is how to trigger it:

   echo blob 100 > .git/objects/00/ae4e8d3208e09f2cf7a38202a126f728cadb49

Then run fsck-cache. It will try to unpack after the header to calculate 
the hash, inflate returns total_out == 0 and memcpy() dies.

The patch below seems to work with ZLIB 1.1 and 1.2.

Signed-off-by: Andreas Gal <gal@uci.edu>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-24 14:04:13 -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
144bde78e9 Use O_NOATIME when opening the sha1 files.
We really don't care about atime, and it sucks to dirty the
inode cache just for it.

This is more than a one-liner only because we need to be able to
clear the O_NOATIME flag in case some of the objects are owned
by others (in which case open will return EPERM), and because not
everybody has the O_NOATIME flag.
2005-04-23 11:09:32 -07:00
Linus Torvalds
860edf7a71 Fix up some problems from the commit->tree helper patch 2005-04-20 18:49:41 -07:00