Commit graph

289 commits

Author SHA1 Message Date
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
Linus Torvalds 68849b5442 date handling: handle "AM"/"PM" on time
And be a bitmore careful about matching: if we don't recognize a word
or a number, we skip the whole thing, rather than trying the next character
in that word/number.

Finally: since ctime() adds the final '\n', don't add another one in test-date.
2005-05-01 12:34:56 -07:00
Linus Torvalds 198b0fb635 date.c: allow even more varied time formats
(and some added checks for truly non-sensical stuff)
2005-05-01 11:48:34 -07:00
Junio C Hamano e2a669bb2e [PATCH] Allow removing files in a subdirectory.
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>
2005-05-01 09:33:12 -07:00
Junio C Hamano 21a08dcbe7 [PATCH] Really fix git-merge-one-file-script this time.
The merge-cache program was updated to pass executable bits when
calling git-merge-one-file-script, but the called script
supplied as an example were not using them carefully.

This patch fixes the following problems in the script:

 * When a new file is created in a directory, which is a file in
   the work tree, it tried to create leading directory but did
   not check for failure from the "mkdir -p" command.

 * The script did not check the exit status from the
   git-update-cache command at all.

 * The parameter "$4" to the script is a file name that can
   contain almost any characters, so it must be quoted with
   double quotes and also needs to be preceded with -- to mark
   it as a non-option when passed to certain commands.

 * The chmod command was used with parameter "$6" or "$7" to set
   the mode bits.  This contradicts with the strategy taken by
   checkout-cache, where we honor user's umask and force only
   the executable bits.  With this patch, it creates a new file
   by redirecting into it (thus honoring user's default umask),
   and then uses "chmod +x" if we want the resulting file
   executable.  Without this fix, the merge result becomes 0644
   or 0755 for users whose umask is 002 for whom it should
   become 0664 or 0775.

 * When "$1 -> $2 -> $3" case was not handled, the script did
   not say which path it was working on, which was not so useful
   when used with the -a option of git-merge-cache.

Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-05-01 09:33:12 -07:00
Junio C Hamano 5d2f8b2753 [PATCH] Add git-apply-patch-script.
I said:

     - Stop attempting to be compatible with cg-patch, and drop
       (mode:XXXXXX) bits from the diff.

     - Do keep the /dev/null change for created and deleted case.

     - No "Index:" line, no "Mode change:" line, anywhere in the
       output.  Anything that wants the mode bits and sha1 hash can
       do things from GIT_EXTERNAL_DIFF mechanism.  Maybe document
       suggested usage better.

This adds an example script git-apply-patch-script, that can be
used as the GIT_EXTERNAL_DIFF to apply changes between two trees
directly on the current work tree, like this:

 GIT_EXTERNAL_DIFF=git-apply-patch-script git-diff-tree -p <tree> <tree>

Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-05-01 09:33:12 -07:00
Junio C Hamano c983370e5e [PATCH] Rework built-in diff to make its output more dense.
Linus says,

    The fewer lines there are that don't usually tell a human
    anything, the better. Dense is good.

This patch makes the default diff output more dense.  This
removes the previous misguided attempt to be cg-patch
compatible.

Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-05-01 09:33:12 -07:00
Junio C Hamano a6f3f3b108 [PATCH] Resurrect diff-tree-helper -R
Diff-tree-helper take two patch inadvertently dropped the
support of -R option, which is necessary to produce reverse diff
based on diff-cache and diff-files output (diff-tree does not
matter since you can feed two trees in reverse order).  This
patch restores it.

Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-30 17:59:35 -07:00
Daniel Barkalow 4250a5e5b1 [PATCH] Split out "pull" from particular methods
The method for deciding what to pull is useful separately from any of the
ways of actually fetching the objects.

So split out "pull" functionality from http-pull and rpull

Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-30 16:53:56 -07:00
Linus Torvalds 5e7921e7c1 rev-tree.c: don't include unnecessary header files
We used to have all these time-related issues, long gone now.
2005-04-30 16:26:56 -07:00
Linus Torvalds 7f26664f1f date.c: fix printout of timezone offsets that aren't exact hours
We'd get the sign wrong for the minutes part of a negative offset.
2005-04-30 16:18:41 -07:00
Linus Torvalds 92e2311b6c date.c: only use the TZ names if we don't have anything better.
Also, add EEST (hey, it's Finland).
2005-04-30 15:21:57 -07:00
Linus Torvalds 5e2a78a410 date.c: split up dst information in the timezone table
This still doesn't actually really _use_ it properly, nor make any
distinction between different DST rules, but at least we could (if
we wanted to) fake it a bit better.

Right now the code actually still says "it's always summer". I'm
from Finland, I don't like winter.
2005-04-30 14:53:12 -07:00
Linus Torvalds a90588821a date.c: fix parsing of dates in mm/dd/yy format
We looked at the year one character too early, and we
didn't accept a two-character year date after 2000.
2005-04-30 14:31:28 -07:00
Linus Torvalds eaa8512923 date.c: use the local timezone if none specified 2005-04-30 14:25:02 -07:00
Nicolas Pitre 1771039129 [PATCH] fix usage string for renamed git commands
Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-30 13:59:38 -07:00
Linus Torvalds 89967023da Make the date parsing accept pretty much any random crap.
This date parser turns line-noise into a date. Cool.
2005-04-30 13:19:56 -07:00
Linus Torvalds 3a6a23e67d Make git-fsck-cache error printouts a bit more informative.
Show the types of objects involved in broken links, and don't bother
warning about unreachable tag files (if somebody cares about tags,
they'll use the --tags flag to see them).
2005-04-30 11:22:26 -07:00
Linus Torvalds 9b23b4bc1c Rename "show-files" to "ls-files"
As suggested by Nicolas Pitre
2005-04-30 11:02:21 -07:00
Linus Torvalds 4b18242190 Fix up d_type handling - we need to include <dirent.h> before
we play with the d_type compatibility macros.
2005-04-30 09:59:31 -07:00
Edgar Toernig ae200ee594 [PATCH] compat: replace AF_LOCAL with AF_UNIX
There's no AF_LOCAL in POSIX
2005-04-30 09:51:03 -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
tony.luck@intel.com d167f147dc [PATCH] Fix AUTHOR_DATE timezone confusion
This switches git-commit-tree to using curl_getdate() for the
AUTHOR_DATE, and thus fixes the problem with "mktime()" parsing dates in
the local timezone.  It also ends up being more permissive about the
format of the date. 

Signed-off-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-29 20:27:04 -07:00
Jonas Fonseca e1a1388d85 [PATCH] git-fsck-cache: Gracefully handle non-commit IDs
Gracefully handle non-commit IDs instead of segfaulting.

Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-29 20:00:40 -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
Junio C Hamano 0fc65a4572 [PATCH] leftover bits for git rename
Linus said:

    "Let's see what else I forgot.."

Not that many, but here they are.

Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-29 16:25:05 -07:00
Junio C Hamano e515f31896 [PATCH] Makefile: The big git command renaming fallout fix.
Here is another.  This one belongs to a clean-up category.

Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-29 15:04:13 -07:00
Linus Torvalds 2d280e1c5e Update the merge scripts for the big git rename.
Let's see what else I forgot..
2005-04-29 15:02:43 -07:00
Junio C Hamano aed7a5a9da [PATCH] The big git command renaming fallout fix.
This fixes the git-export which calls diff-tree.

Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-29 14:54:50 -07:00
Linus Torvalds a3df180138 Rename git core commands to be "git-xxxx" to avoid name clashes.
This also regularizes the make. The source files themselves don't get
the "git-" prefix, because that's just inconvenient. So instead we just
make the rule that "git-xxxx" depends on "xxxx.c", and do that for
all the core programs (ie the old "git-mktag.c" got renamed to just
"mktag.c" to match everything else).

And "show-diff" got renamed to "git-diff-files" while at it, since
that's what it really should be to match the other git-diff-xxx cases.
2005-04-29 14:09:11 -07:00
Rene Scharfe d840b3b285 [PATCH] GIT: Honour SHA1_FILE_DIRECTORY env var in git-pull-script
If you set SHA1_FILE_DIRECTORY to something else than .git/objects
git-pull-script will store the fetched files in a location the rest of
the tools does not expect.

git-prune-script also ignores this setting, but I think this is good,
because pruning a shared tree to fit a single project means throwing
away a lot of useful data. :-)

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-29 12:08:03 -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
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
Nicolas Pitre cf9a113d35 [PATCH] add short options to show-files
The show-files long options are cumbersome to type.  This patch adds
equivalent short options.

Also add missing "unmerged" to usage string.

Finally reduce the number of lines for argument parsing in half.

Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-28 15:06:25 -07:00
Junio C Hamano 0cc087e304 [PATCH] diff-tree does not need -r in git-export.c
No need to pass -r anymore, since diff-tree -p implies recursive
behaviour these days.

Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-28 12:22:11 -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
Nicolas Pitre 9ff768e940 [PATCH] Give show-files the ability to process exclusion pattern.
This can be used with the famous dontdiff file as follows to find out
about uncommitted files just like dontdiff is used with the diff
command:

    show-files --others --exclude-from=dontdiff

and the exclude list can be reversed with the --ignore switch.

Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-28 11:44:04 -07:00
Junio C Hamano b836825b55 [PATCH] diff-cache.c compilation warning fix.
Nobody uses return value from show_new_file() function but it is
defined as returning int and falls off at the end without
returning.  Make it void.

Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-28 10:13:01 -07:00
Junio C Hamano 532149d727 [PATCH] diff.c: clean temporary files
When diff-cache -p and friends are interrupted, they can leave
their temporary files behind.  Also when the external diff
program is killed instead of exiting (this usually happens when
piping the output to a pager, which can cause SIGPIPE when the
user quits viewing the diff early), they incorrectly died
without cleaning their temporary file.

This fixes these problems. 

Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-28 10:13:01 -07:00
Junio C Hamano 91a6eaa05d [PATCH] diff-tree-helper: do not report unmerged path outside specification.
My bad.  diff-tree-helper reports all unmerged paths even when
the command line specifies to filter the paths.  This patch
fixes it.  Also reverse-diff option was left out during the last
round, which this patch restores as well.

Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-28 10:13:01 -07:00
Junio C Hamano 2f97813870 [PATCH] Make diff-cache and friends output more cg-patch friendly.
This changes the way the default arguments to diff are built when
diff-cache and friends are invoked with -p and there is no
GIT_EXTERNAL_DIFF environment variable.  It attempts to be more cg-patch
friendly by:

 - Showing diffs against /dev/null to denote added or removed
   files;

 - Showing file modes for existing files as a comment after the
   diff label.

Unfortunately with this change GIT_DIFF_CMD customization cannot
be supported easily anymore, so it has been dropped.
GIT_DIFF_OPTS customization to change diffs from unified to
context is still there, though.

Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-28 08:04:39 -07:00
Linus Torvalds d5e276884a Fix up recent object model cleanups
Make sure the Makefile knows about the object header dependencies, and
add declarations for tag lookup/parsing.
2005-04-28 07:50:39 -07:00
Daniel Barkalow c418eda493 [PATCH] Rework fsck-cache to use parse_object()
With support for parse_object() and tags in the core, fsck_cache can just
call them, and can be simplified a bit.

Signed-Off-By: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-28 07:46:33 -07:00
Daniel Barkalow e9eefa6761 [PATCH] Add function to parse an object of unspecified type (take 2)
This adds a function that parses an object from the database when we have
to look up its actual type. It also checks the hash of the file, due to
its heritage as part of fsck-cache.

Signed-Off-By: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-28 07:46:33 -07:00
Daniel Barkalow 2636f61437 [PATCH] Add tag header/parser to library
This adds preliminary support for tags in the library. It doesn't even
store the signature, however, let alone provide any way of checking it.

Signed-Off-By: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-28 07:46:33 -07:00
Daniel Barkalow a510bfaa8c [PATCH] Mark blobs as parsed when they're actually parsed
This eliminates the special case for blobs versus other types of
objects. Now the scheme is entirely regular and I won't introduce stupid
bugs. (And fsck-cache doesn't have to do the do-nothing parse)

Signed-Off-By: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-28 07:46:33 -07:00
Junio C Hamano 3a663fd984 [PATCH] diff-tree -p implies diff-tree -p -r
This makes diff-tree -p imply recursive behaviour.

Other commands in the family always takes a flat universe view
so this is not even needed.

Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-27 16:25:59 -07:00
Junio C Hamano ce9be4e4e8 [PATCH] Use diff-tree -p -r instead of "git diff" in git-export.
Now diff-tree can produce patch itself, there is no reason to
depend on Cogito to show diff in the git-export output anymore.

Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-27 15:36:01 -07:00