Commit graph

40 commits

Author SHA1 Message Date
Junio C Hamano 217542640e built-in tar-tree and remote tar-tree
This makes tar-tree a built-in.  As an added bonus, you can now
say:

	git tar-tree --remote=remote-repository <ent> [<base>]

This does not work with git-daemon yet, but should work with
localhost and git over ssh transports.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-05-19 17:48:34 -07:00
Dmitry V. Levin 31fff305bc Separate object name errors from usage errors
Separate object name errors from usage errors.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-05-08 16:25:33 -07:00
Peter Eriksen 8e44025925 Use blob_, commit_, tag_, and tree_type throughout.
This replaces occurences of "blob", "commit", "tag", and "tree",
where they're really used as type specifiers, which we already
have defined global constants for.

Signed-off-by: Peter Eriksen <s022018@student.dtu.dk>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-04 00:11:19 -07:00
Rene Scharfe 139faba8f5 Remove useless pointer update
buf is not used afterwards.  The compiler optimized the dead store out
anyway, but let's clean the source, too.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-02 12:58:45 -07:00
Junio C Hamano 1b0c7174a1 tree/diff header cleanup.
Introduce tree-walk.[ch] and move "struct tree_desc" and
associated functions from various places.

Rename DIFF_FILE_CANON_MODE(mode) macro to canon_mode(mode) and
move it to cache.h.  This macro returns the canonicalized
st_mode value in the host byte order for files, symlinks and
directories -- to be compared with a tree_desc entry.
create_ce_mode(mode) in cache.h is similar but is intended to be
used for index entries (so it does not work for directories) and
returns the value in the network byte order.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-03-29 23:54:13 -08:00
Junio C Hamano 48d6e97afe Merge branch 'rs/tar-tree' into next
* rs/tar-tree:
  tar-tree: Use the prefix field of a tar header
  tar-tree: Remove obsolete code
  tar-tree: Use write_entry() to write the archive contents
  tar-tree: Introduce write_entry()
  tar-tree: Use SHA1 of root tree for the basedir
  git-apply: safety fixes
  Removed bogus "<snap>" identifier.
  Clarify and expand some hook documentation.
  commit-tree: check return value from write_sha1_file()
  send-email: Identify author at the top when sending e-mail
  Format tweaks for asciidoc.
2006-03-25 17:43:22 -08:00
Rene Scharfe 4c691724f1 tar-tree: Use the prefix field of a tar header
... to store parts of the path, if possible.  This allows us to avoid
writing extended headers in certain cases (long pathes can only be
split at '/' chars).

Also adds a file to the test repo with a 100 chars long directory name.
Even old versions of tar that don't understand POSIX extended headers
should be able to handle this testcase.

Btw.: The longest path in the kernel tree currently has 70 chars.
Together with a 30 chars long prefix this would already cross the
field limit of 100 chars.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-03-25 16:40:34 -08:00
Rene Scharfe 86da1c567d tar-tree: Remove obsolete code
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-03-25 16:37:08 -08:00
Rene Scharfe cb0c6df6f5 tar-tree: Use write_entry() to write the archive contents
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-03-25 16:36:54 -08:00
Rene Scharfe ae64bbc18c tar-tree: Introduce write_entry()
... and use it initially to write global extended header records.
Improvements compared to the old write_header():

  - Uses a struct ustar_header instead of hardcoded offsets.
  - Takes one struct strbuf as path argument instead of a (basedir,
    prefix, name) tuple.
  - Not only writes the tar header, but also the contents of the
    file, if any.
  - Does not write directly into the ring buffer.  This allows the
    code to be layed out more naturally, because there is no more
    ordering constraint.  Before we had to first finish writing the
    extended header, now we can construct the extended and normal
    headers in parallel.
  - The typeflag parameter has been replaced by (reasonable) magic
    values.  path == NULL indicates an extended header, additionally
    sha1 == NULL means it is a global extended header.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-03-25 16:35:43 -08:00
Rene Scharfe 2c6df2d5d1 tar-tree: Use SHA1 of root tree for the basedir
... instead of the made-up "0".

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-03-25 16:34:37 -08:00
Junio C Hamano 84a9b58c42 sha1_name: warning ambiguous refs.
This makes sure that many commands that take refs on the command
line to honor core.warnambiguousrefs configuration.  Earlier,
the commands affected by this patch did not read the
configuration file.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-03-23 23:41:18 -08:00
Junio C Hamano 473d404b53 tar-tree: file/dirmode fix.
This fixes two bugs introduced when we switched to generic tree
traversal code.

 (1) directory mode recorded silently became 0755, not 0777

 (2) if passed a tree object (not a commit), it emitted an
     alarming error message (but proceeded anyway).

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-03-03 21:36:38 -08:00
Linus Torvalds 7ec57556b2 Make git-tar-tree use the tree_desc abstractions
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-01-31 16:07:02 -08:00
Daniel Barkalow c3f9281255 Use struct commit in tar-tree
It was open-coding getting the commit date from a commit.

Signed-off-by: Daniel Barkalow <barkalow@iabervon>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-01-30 19:08:38 -08:00
Daniel Barkalow 5207234a68 Use struct tree in tar-tree
It was using an open-coded tree parser; use a struct tree instead.

Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-01-30 19:08:37 -08:00
Junio C Hamano 3ac0ebbba4 tar-tree: finish honoring extractor's umask in git-tar-tree.
Earlier commit 38ec15a973 forgot
to apply the same principle of not forcing go-w to the base
directory when specified.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-01-07 15:11:11 -08:00
Junio C Hamano 1c15afb934 xread/xwrite: do not worry about EINTR at calling sites.
We had errno==EINTR check after read(2)/write(2) sprinkled all
over the places, always doing continue.  Consolidate them into
xread()/xwrite() wrapper routines.

Credits for suggestion goes to HPA -- bugs are mine.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-19 18:28:16 -08:00
Junio C Hamano 53228a5fb8 Make the rest of commands work from a subdirectory.
These commands are converted to run from a subdirectory.

    commit-tree convert-objects merge-base merge-index mktag
    pack-objects pack-redundant prune-packed read-tree tar-tree
    unpack-file unpack-objects update-server-info write-tree

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-11-28 23:13:02 -08:00
Junio C Hamano 38ec15a973 Honor extractor's umask in git-tar-tree.
The archive generated with git-tar-tree had 0755 and 0644 mode bits.
This inconvenienced the extractor with umask 002 by robbing g+w bit
unconditionally.  Just write it out with loose permissions bits and
let the umask of the extractor do its job.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-10-01 23:14:06 -07:00
Timo Sirainen 4ec99bf080 [PATCH] -Werror fixes
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-09 22:28:19 -07:00
Petr Baudis 4d1f119033 [PATCH] Unify usage strings declaration
All usage strings are now declared as static const char [].

This is carried over from my old git-pb branch.

Signed-off-by: Petr Baudis <pasky@ucw.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-07-29 17:21:50 -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
Rene Scharfe a325a11b88 [PATCH] git-tar-tree: fix write_trailer
write_trailer() writes the last 10k (a full block) of the tar archive.
write_if_needed() writes out a block *if* it is full and then sets
the offset to 0.  In nine out of ten cases the messed up write_trailer()
function didn't manage to fill the block thus not writing anything at
all, truncating the archive.  I was "lucky" to hit the other case and so
my testing ran OK.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-06-03 07:36:42 -07:00
Rene Scharfe 9b5b9f398c [PATCH] git-tar-tree: cleanup write_trailer()
replace open-coded variants of get_record().

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-06-02 18:30:08 -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
Alexey Nezhdanov 667bb59b2d [PATCH] cleanup of in-code names
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>
2005-05-19 10:52:00 -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 92747a907c Add copyright notice of Rene Scharfe to tar-tree.c 2005-05-09 23:33:02 +02:00
Rene Scharfe e7d3dd248f [PATCH] Lift path length limits from git-tar-tree.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-05-06 22:12:08 -07:00
Junio C Hamano 3d0291c450 [PATCH] Do not initialize sha1_file_directory by hand.
Some commands initialize sha1_file_directory by hand.  There is no
need to do so; sha1_file.c knows how to handle it.

The next patch will remove the variable altogether.

Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-05-06 17:00:20 -07:00
Rene Scharfe d5776d50aa [PATCH] git-tar-tree: add symlink support
Add symlink support to git-tar-tree.
2005-05-06 14:42:59 -07:00
Rene Scharfe 08f09dac01 [PATCH] git-tar-tree: make file contents accessible to write_header()
Pass pointer to filecontents to write_header() and pass pointer
to filecontents, its size and some flags to write_exntended_header().
These parameters are not used, yet.  They are added in preparation
to symlink support.
2005-05-06 14:42:59 -07:00
Rene Scharfe 71058b1f2b [PATCH] git-tar-tree: add extended header helpers
Introduce append_extended_header_prefix(), extended_header_len()
and append_extended_header().  These are helper functions that
make it easier to handle multiple entries in a pax extended
header.  append_log() is no longer needed and can go away.
2005-05-06 14:42:59 -07:00
Rene Scharfe 03d791ff11 [PATCH] git-tar-tree: add TYPEFLAG_ constants
Add TYPEFLAG_ constants.
2005-05-06 14:42:59 -07:00
Rene Scharfe a90a6e6a78 [PATCH] git-tar-tree: add get_record()
Add get_record() which returns a pointer to the next record in the block.
2005-05-06 14:42:59 -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
Rene Scharfe 87fec8fc9e [PATCH] GIT: Create tar archives of tree on the fly
Write commit ID to global extended pax header at the beginning of the tar
file, if possible.  get-tar-commit-id.c is an example program to get the
ID back out of such a tar archive.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-29 19:51:04 -07:00
Rene Scharfe db413479f1 [PATCH] Use read_object_with_reference() in tar-tree
This patch replaces the usage of read_tree_with_tree_or_commit_sha1()
with read_object_with_reference() in tar-tree.  As a result the code
that tries to figure out the commit time doesn't need to open the commit
object 'by hand' any more.

Signed-off-by: Rene Scharfe <lsrfire.ath.cx>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-28 22:19:02 -07:00
Rene Scharfe 731ab9ccf2 [PATCH] create tar archives of tree on the fly
This is an improved version of tar-tree, a streaming archive creator for
GIT.  The major added feature is blocking; all write(2) calls now have a
size of 10240, just as GNU tar (and tape drives) likes them.  The
buffering overhead does not seem to degrade performance because most
files in the repositories I tested this with are smaller than 10KB, so
we need fewer system calls. 

File names are still restricted to 500 bytes and the archive format
currently only allows for files up to 8GB.  Both restrictions can be
lifted if need be with more pax extended headers. 

The archive format used is the pax interchange format, i.e.  POSIX tar
format.  It can be read by (and created with) GNU tar.  If I read the
specs correctly tar-tree should now be standards compliant (modulo
bugs). 

Because it streams the archive (think ls-tree merged with cat-file),
tar-tree doesn't need to create any temporary files.  That makes it
quite fast. 

It accepts tree IDs and commit IDs as first parameter.  In the latter
case tar-tree tries to get the commit date out of the committer line. 
Else all files in the archive are time-stamped with the current time. 

An optional second parameter is used as a path prefix for all files in
the archive.  Example:

   $ tar-tree a2755a80f40e5794ddc20e00f781af9d6320fafb \
   linux-2.6.12-rc3 | bzip9 -9 > linux-2.6.12-rc3.tar.bz2

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-28 12:16:43 -07:00