Commit graph

4275 commits

Author SHA1 Message Date
Junio C Hamano 00703e6d68 cache-tree: a bit more debugging support.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-05-03 16:10:45 -07:00
Junio C Hamano c2b9ae4330 read-tree: invalidate cache-tree entry when a new index entry is added.
When doing two-way merge, we failed to invalidate the directory
that a new entry is added (we correctly did so for modified and
deleted entries).

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-05-03 16:07:02 -07:00
Junio C Hamano a84faf7770 Fix test-dump-cache-tree in one-tree disappeared case.
When reconstructing an invalidated subtree for reference purposes by
test-dump-cache-tree, we did not handle the case where we shouldn't
have a cached and invalidated subtree in the result, leading to an
unneeded die().

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-05-03 15:33:32 -07:00
Junio C Hamano cdc08b33ef fsck-objects: mark objects reachable from cache-tree
When fsck-objects scanned cache-tree, it forgot to mark the
trees it found reachable and in use.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-05-01 22:15:54 -07:00
Johannes Schindelin 0111ea38cb cache-tree: replace a sscanf() by two strtol() calls
On one of my systems, sscanf() first calls strlen() on the buffer. But
this buffer is not terminated by NUL. So git crashed.

strtol() does not share that problem, as it stops reading after the
first non-digit.

[jc: original patch was wrong and did not read the cache-tree
 structure correctly; this has been fixed up and tested minimally
 with fsck-objects. ]

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-05-01 22:14:03 -07:00
Junio C Hamano 7bc70a590d cache-tree.c: typefix
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-27 22:48:27 -07:00
Junio C Hamano d2cb7c6e93 test-dump-cache-tree: validate the cached data as well.
While dumping the cached data, try recomputing everything from
scratch to make sure things match.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-27 16:22:45 -07:00
Junio C Hamano 2956dd3bd7 cache_tree_update: give an option to update cache-tree only.
When the extra "dryrun" parameter is true, cache_tree_update()
recomputes the invalid entry but does not actually creates
new tree object.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-27 16:21:54 -07:00
Junio C Hamano 7927a55d5b read-tree: teach 1-way merege and plain read to prime cache-tree.
This teaches read-tree to fully populate valid cache-tree when
reading a tree from scratch, or reading a single tree into an
existing index, reusing only the cached stat information (i.e.
one-way merge).  We have already taught update-index about cache-tree,
so "git checkout" followed by updates to a few path followed by
a "git commit" would become very efficient.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-27 01:33:07 -07:00
Junio C Hamano b34c39cf31 read-tree: teach 1 and 2 way merges about cache-tree.
This teaches one-way and two-way "read-tree -m" (and its special
form, "read-tree --reset" as well) not to discard cache-tree but
invalidate only the changed parts of the tree.  When switching
between related branches, this helps the eventual commit
(i.e. write-tree) by keeping cache-tree valid as much as
possible.

This does not prime cache-tree yet, but we ought to be able to
do that for no-merge (i.e. reading from a tree object) case and,
and also perhaps 1 way merge case.

With this patch applied, switching between the tip of Linux 2.6
kernel tree and a branch that touches one path (fs/ext3/Makefile)
from it invalidates only 3 paths out of 1201 cache-tree entries
in the index, and subsequent write-tree takes about a half as
much time as before.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-27 00:34:12 -07:00
Junio C Hamano 497c32136f update-index: when --unresolve, smudge the relevant cache-tree entries.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-26 22:05:05 -07:00
Junio C Hamano e7afa1115b Merge branch 'master' into jc/cache-tree
* master:
  t0000-basic: more commit-tree tests.
  commit-tree.c: check_valid() microoptimization.
  Fix filename verification when in a subdirectory
  rebase: typofix.
  socksetup: don't return on set_reuse_addr() error
2006-04-26 18:32:45 -07:00
Junio C Hamano 9af0b8dbe2 t0000-basic: more commit-tree tests.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-26 18:25:15 -07:00
Junio C Hamano 69bcc43eca Merge branch 'fix'
* fix:
  commit-tree.c: check_valid() microoptimization.
  Fix filename verification when in a subdirectory
  rebase: typofix.
  socksetup: don't return on set_reuse_addr() error
2006-04-26 17:08:00 -07:00
Junio C Hamano 5981e09999 commit-tree.c: check_valid() microoptimization.
There is no point reading the whole object just to make sure it exists and
it is of the expected type.  We added sha1_object_info() for such need
after this code was written, so use it.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-26 16:55:25 -07:00
Linus Torvalds e23d0b4a4a Fix filename verification when in a subdirectory
When we are in a subdirectory of a git archive, we need to take the prefix
of that subdirectory into accoung when we verify filename arguments.

Noted by Matthias Lederhofer

This also uses the improved error reporting for all the other git commands
that use the revision parsing interfaces, not just git-rev-parse. Also, it
makes the error reporting for mixed filenames and argument flags clearer
(you cannot put flags after the start of the pathname list).

[jc: with fix to a trivial typo noticed by Timo Hirvonen]

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-26 12:16:21 -07:00
Junio C Hamano b176e6ba5b rebase: typofix.
Noticed by Sean.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-26 12:16:19 -07:00
Junio C Hamano b8ed7f0f40 Merge branch 'master' into jc/cache-tree
* master:
  commit-tree: allow generic object name for the tree as well.
  Makefile: remove and create xdiff library from scratch.
  t0000-basic: Add ls-tree recursive test back.
  Libified diff-index: backward compatibility fix.
  Libify diff-index.
  Libify diff-files.
  Makefile: remove and create libgit.a from scratch.
  Document the configuration file
  Document git-var -l listing also configuration variables
  rev-parse: better error message for ambiguous arguments
  make update-index --chmod work with multiple files and --stdin
  socksetup: don't return on set_reuse_addr() error
  Fix "git show --stat"
  git-update-index --unresolve
  Add git-unresolve <paths>...
  Add colordiff for git to contrib/colordiff.
  gitk: Let git-rev-list do the argument list parsing
2006-04-26 03:29:09 -07:00
Junio C Hamano 3496277a56 commit-tree: allow generic object name for the tree as well.
We use get_sha1() for -p (parent) objects, but still used
get_sha1_hex() for the tree.  Just to be consistent, allow
extended SHA1 expression for the tree object name.

Note that this is not to encourage funky things like this:

	git-commit-tree HEAD^{tree} -p HEAD

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-26 03:18:51 -07:00
Junio C Hamano 2d86d2c6fc Makefile: remove and create xdiff library from scratch.
... in the same spirit as 71459c193d.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-26 03:12:58 -07:00
Junio C Hamano fdeb6bf55b t0000-basic: Add ls-tree recursive test back.
When we updated ls-tree recursive output to omit the tree nodes,
246cc52f38 adjusted the old test
so that we do not expect to see trees in its output.  Later,
with 0f8f45cb4a, we added back the
ability to show both with -t option, but we forgot to update the
test as well.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-26 02:27:59 -07:00
Junio C Hamano e9b5b75ca8 Merge branch 'jc/diff'
* jc/diff:
  Libified diff-index: backward compatibility fix.
  Libify diff-index.
  Libify diff-files.
2006-04-25 23:12:21 -07:00
Junio C Hamano 71459c193d Makefile: remove and create libgit.a from scratch.
Foolishly I renamed diff.o around which caused an old diff.o
taken out of libgit.a and got linked into resulting binary and
exhibited mysterious breakage for many people.  This borrows
from the kernel Makefile (scripts/Makefile.build) to first remove
the target and then recreate.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-25 23:11:17 -07:00
Junio C Hamano 0f8820528e test-dump-cache-tree: report number of subtrees.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-25 17:40:24 -07:00
Junio C Hamano 61fa30972c cache-tree: sort the subtree entries.
Not that this makes practical performance difference; the kernel tree
for example has 200 or so directories that have subdirectory, and the
largest ones have 57 of them (fs and drivers).  With a test to apply
600 patches with git-apply and git-write-tree, this did not make more
than one per-cent of a difference, but it is a good cleanup.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-25 17:40:02 -07:00
Junio C Hamano 53dc3f3e80 Teach fsck-objects about cache-tree.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-25 16:37:08 -07:00
Serge E. Hallyn 7d09fbe4ab socksetup: don't return on set_reuse_addr() error
The set_reuse_addr() error case was the only error case in
socklist() where we returned rather than continued.  Not sure
why.  Either we must free the socklist, or continue.  This patch
continues on error.

Signed-off-by: Serge E. Hallyn <serue@us.ibm.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
(cherry picked from 0032d548db commit)
2006-04-24 23:07:54 -07:00
Junio C Hamano 36932eab77 Merge branch 'fix'
* fix:
  Document the configuration file
  Document git-var -l listing also configuration variables
  rev-parse: better error message for ambiguous arguments
2006-04-24 22:26:57 -07:00
Petr Baudis 1ab661ddb7 Document the configuration file
This patch adds a Documentation/config.txt file included by git-repo-config
and currently aggregating hopefully all the available git plumbing / core
porcelain configuration variables, as well as briefly describing the format.

It also updates an outdated bit of the example in git-repo-config(1).

Signed-off-by: Petr Baudis <pasky@suse.cz>
2006-04-24 22:26:37 -07:00
Petr Baudis 4ee6bc9913 Document git-var -l listing also configuration variables
Signed-off-by: Petr Baudis <pasky@suse.cz>
2006-04-24 22:26:34 -07:00
Paul Mackerras 3e1a70d925 rev-parse: better error message for ambiguous arguments
Currently, if git-rev-parse encounters an argument that is neither a
recognizable revision name nor the name of an existing file or
directory, and it hasn't encountered a "--" argument, it prints an
error message saying "No such file or directory".  This can be
confusing for users, including users of programs such as gitk that
use git-rev-parse, who may then think that they can't ask about the
history of files that no longer exist.

This makes it print a better error message, one that points out the
ambiguity and tells the user what to do to fix it.

Signed-off-by: Paul Mackerras <paulus@samba.org>
2006-04-24 22:22:29 -07:00
Junio C Hamano bad68ec924 index: make the index file format extensible.
... and move the cache-tree data into it.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-24 21:24:13 -07:00
Junio C Hamano dd0c34c46b cache-tree: protect against "git prune".
We reused the cache-tree data without verifying the tree object
still exists.  Recompute in cache_tree_update() an otherwise
valid cache-tree entry when the tree object disappeared.

This is not usually a problem, but theoretically without this
fix things can break when the user does something like this:

	- read-index from a side branch
	- write-tree the result
	- remove the side branch with "git branch -D"
	- remove the unreachable objects with "git prune"
	- write-tree what is in the index.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-24 15:12:42 -07:00
Junio C Hamano be02b3c53e Merge branch 'ar/chmod-series'
* ar/chmod-series:
  make update-index --chmod work with multiple files and --stdin
2006-04-24 02:08:35 -07:00
Junio C Hamano c6df547a41 Merge branch 'sh/daemon'
* sh/daemon:
  socksetup: don't return on set_reuse_addr() error
2006-04-24 02:08:28 -07:00
Junio C Hamano 2effe71b7c Merge branch 'jc/cc-stat'
* jc/cc-stat:
  Fix "git show --stat"
2006-04-24 02:06:40 -07:00
Junio C Hamano cdb63506a0 Merge branch 'jc/unresolve'
* jc/unresolve:
  git-update-index --unresolve
  Add git-unresolve <paths>...
2006-04-24 02:05:55 -07:00
Junio C Hamano 3a403e49b9 Merge branch 'jc/color'
* jc/color:
  Add colordiff for git to contrib/colordiff.
2006-04-24 02:05:07 -07:00
Junio C Hamano a549e11cc2 Merge git://git.kernel.org/pub/scm/gitk/gitk
* git://git.kernel.org/pub/scm/gitk/gitk:
  gitk: Let git-rev-list do the argument list parsing
2006-04-24 01:39:01 -07:00
Junio C Hamano 17448209f5 Add test-dump-cache-tree
This was useful in diagnosing the corrupt index.aux format
problem.  But do not bother building or installing it by
default.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-24 00:26:31 -07:00
Junio C Hamano a6e5642f39 Use cache-tree in update-index.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-24 00:26:31 -07:00
Junio C Hamano 03ac6e6465 Invalidate cache-tree entries for touched paths in git-apply.
This updates git-apply to maintain cache-tree information.  With
this and the previous write-tree patch, repeated "apply --index"
followed by "write-tree" on a huge tree will hopefully become
faster.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-23 20:19:17 -07:00
Junio C Hamano a52139b47e Update write-tree to use cache-tree.
The updated write-tree reads from $GIT_DIR/index.aux to pick up
subtree objects information, updates the cache-tree with the
index, and updates index.aux file after writing a tree out of
the index file.

Until update-index and other programs that modify the index are
updated to maintain index.aux file, the index.aux file written
by the last write-tree will become stale immediately after they
update the index, which will result in the whole tree
recomputation just like the original write-tree.

The idea is to convert those commands to invalidate cache-tree
whenever they touch the index entries, and write updated
index.aux out.  After the index is updated with them, write-tree
will be able to reuse the parts of the cache-tree that have not
been touched.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-23 20:18:57 -07:00
Junio C Hamano 749864627c Add cache-tree.
The cache_tree data structure is to cache tree object names that
would result from the current index file.

The idea is to have an optional file to record each tree object
name that corresponds to a directory path in the cache when we
run write_cache(), and read it back when we run read_cache().
During various index manupulations, we selectively invalidate
the parts so that the next write-tree can bypass regenerating
tree objects for unchanged parts of the directory hierarchy.

We could perhaps make the cache-tree data an optional part of
the index file, but that would involve the index format updates,
so unless we need it for performance reasons, the current plan
is to use a separate file, $GIT_DIR/index.aux to store this
information and link it with the index file with the checksum
that is already used for index file integrity check.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-23 20:18:16 -07:00
Junio C Hamano 1af1c2b63d read-cache/write-cache: optionally return cache checksum SHA1.
read_cache_1() and write_cache_1() takes an extra parameter
*sha1 that returns the checksum of the index file when non-NULL.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-23 16:57:40 -07:00
Paul Mackerras 61e56c8823 gitk: Let git-rev-list do the argument list parsing
This is a fix for a problem reported by Jim Radford where an argument
list somewhere overflows on repositories with lots of tags.  In fact
it's now unnecessary to use git-rev-parse since git-rev-list can take
all the arguments that git-rev-parse can.  This is inspired by but not
the same as the solutions suggested by Jim Radford and Linus Torvalds.

Signed-off-by: Paul Mackerras <paulus@samba.org>
2006-04-23 18:00:24 +10:00
Alex Riesen 227bdb186f make update-index --chmod work with multiple files and --stdin
The patch makes "--chmod=-x" and "--chmod=+x" act like "--add"
and "--remove" to affect the behaviour of the command for the
rest of the path parameters, not just the following one.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-23 00:47:03 -07:00
Junio C Hamano 5c21ac0e7c Libified diff-index: backward compatibility fix.
"diff-index -m" does not mean "do not ignore merges", but means
"pretend missing files match the index".

The previous round tried to address this, but failed because
setup_revisions() ate "-m" flag before the caller had a chance
to intervene.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-22 04:03:32 -07:00
Junio C Hamano e09ad6e1e3 Libify diff-index.
The second installment to libify diff brothers.  The pathname
arguments are checked more strictly than before because we now
use the revision.c::setup_revisions() infrastructure.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-22 02:43:00 -07:00
Junio C Hamano 6973dcaee7 Libify diff-files.
This is the first installment to libify diff brothers.

The updated diff-files uses revision.c::setup_revisions()
infrastructure to parse its command line arguments, which means
the pathname arguments are checked more strictly than before.
The tests are adjusted to separate possibly missing paths from
the rest of arguments with double-dashes, to show the kosher
way.

As Linus pointed out, renaming diff.c to diff-lib.c was simply
stupid, so I am renaming it back.  The new diff-lib.c is to
contain pieces extracted from diff brothers.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-22 02:37:45 -07:00