Code

git.git
17 years agoUse diff* with --exit-code in git-am, git-rebase and git-merge-ours
Alex Riesen [Sun, 25 Mar 2007 00:56:13 +0000 (01:56 +0100)]
Use diff* with --exit-code in git-am, git-rebase and git-merge-ours

This simplifies the shell code, reduces its memory footprint, and
speeds things up. The performance improvements should be noticable
when git-rebase works on big commits.

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoDocument --quiet option to git-diff
Alex Riesen [Sun, 25 Mar 2007 00:55:43 +0000 (01:55 +0100)]
Document --quiet option to git-diff

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agowrite_sha1_from_fd() should make new objects read-only
Nicolas Pitre [Sat, 24 Mar 2007 16:02:27 +0000 (12:02 -0400)]
write_sha1_from_fd() should make new objects read-only

... like it is done everywhere else.

Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agomake it more obvious that temporary files are temporary files
Nicolas Pitre [Sat, 24 Mar 2007 15:58:22 +0000 (11:58 -0400)]
make it more obvious that temporary files are temporary files

When some operations are interrupted (or "die()'d" or crashed) then the
partial object/pack/index file may remain around.  Make it more obvious
in their name that those files are temporary stuff and can be cleaned up
if no operation is in progress.

Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoupdate-hook: remove e-mail sending hook.
Andy Parkins [Fri, 23 Mar 2007 10:21:59 +0000 (10:21 +0000)]
update-hook: remove e-mail sending hook.

The update hook's only job is to decide is a particular update
is allowed or not.  It was not the right place to send out
update notification e-mails from to begin with, as the final
stage of updating refs can fail after this hook runs.

Signed-off-by: Andy Parkins <andyparkins@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agogit-am documentation: describe what is taken from where.
Junio C Hamano [Sat, 24 Mar 2007 10:08:54 +0000 (03:08 -0700)]
git-am documentation: describe what is taken from where.

Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agogit-revert: Revert revert message to old behaviour
Johannes Schindelin [Fri, 23 Mar 2007 16:06:11 +0000 (17:06 +0100)]
git-revert: Revert revert message to old behaviour

When converting from the shell script, based on a misreading of the
sed invocation, the builtin included the abbreviated commit name,
and did _not_ include the quotes around the oneline message.

This fixes it.

[jc: with a fix for the typo/thinko spotted by Linus, and also
 removing the unwanted abbrev at the beginning.]

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoMerge branch 'maint'
Junio C Hamano [Sat, 24 Mar 2007 06:29:37 +0000 (23:29 -0700)]
Merge branch 'maint'

* maint:
  gitweb: Fix "next" link in commit view

17 years agoDocumentation: bisect: make a comment fit better in the man page.
Christian Couder [Sat, 24 Mar 2007 05:32:05 +0000 (06:32 +0100)]
Documentation: bisect: make a comment fit better in the man page.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoDocumentation: bisect: add some titles to some paragraphs.
Christian Couder [Sat, 24 Mar 2007 05:30:33 +0000 (06:30 +0100)]
Documentation: bisect: add some titles to some paragraphs.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoDocumentation: bisect: reformat more paragraphs.
Christian Couder [Sat, 24 Mar 2007 05:31:49 +0000 (06:31 +0100)]
Documentation: bisect: reformat more paragraphs.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoDocumentation: bisect: reword one paragraph.
Christian Couder [Sat, 24 Mar 2007 05:31:16 +0000 (06:31 +0100)]
Documentation: bisect: reword one paragraph.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoDocumentation: bisect: reformat some paragraphs.
Christian Couder [Sat, 24 Mar 2007 05:29:58 +0000 (06:29 +0100)]
Documentation: bisect: reformat some paragraphs.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoFix path-limited "rev-list --bisect" termination condition.
Junio C Hamano [Fri, 23 Mar 2007 20:34:49 +0000 (13:34 -0700)]
Fix path-limited "rev-list --bisect" termination condition.

In a path-limited bisection, when the $bad commit is not
changing the limited path, and the number of suspects is 1, the
code miscounted and returned $bad from find_bisection(), which
is not marked with TREECHANGE.  This is of course filtered by
the output routine, resulting in an empty output, in turn
causing git-bisect driver to say "$bad was both good and bad".

Illustration.  Suppose you have these four commits, and only C
changes path P.  You know D is bad and A is good.

A---B---C*--D

git-bisect driver runs this to find a bisection point:

$ git rev-list --bisect A..D -- P

which calls find_bisection() with B, C and D.  The set of
commits that is given to this function is the same set of
commits as rev-list without --bisect option and pathspec
returns.  Among them, only C is marked with TREECHANGE.  Let's
call the set of commits given to find_bisection() that are
marked with TREECHANGE (or all of them if no path limiter is in
effect) "the bisect set".  In the above example, the size of the
bisect set is 1 (contains only "C").

For each commit in its input, find_bisection() computes the
number of commits it can reach in the bisect set.  For a commit
in the bisect set, this number includes itself, so the number is
1 or more.  This number is called "depth", and computed by
count_distance() function.

When you have a bisect set of N commits, and a commit has depth
D, how good is your bisection if you returned that commit?  How
good this bisection is can be measured by how many commits are
effectively tested "together" by testing one commit.

Currently you have (N-1) untested commits (the tip of the bisect
set, although it is included in the bisect set, is already known
to be bad).  If the commit with depth D turns out to be bad,
then your next bisect set will have D commits and you will have
(D-1) untested commits left, which means you tested (N-1)-(D-1)
= (N-D) commits with this bisection.  If it turns out to be good, then
your next bisect set will have (N-D) commits, and you will have
(N-D-1) untested commits left, which means you tested
(N-1)-(N-D-1) = D commits with this bisection.

Therefore, the goodness of this bisection is is min(N-D, D), and
find_bisection() function tries to find a commit that maximizes
this, by initializing "closest" variable to 0 and whenever a
commit with the goodness that is larger than the current
"closest" is found, that commit and its goodness are remembered
by updating "closest" variable.  The "the commit with the best
goodness so far" is kept in "best" variable, and is initialized
to a commit that happens to be at the beginning of the list of
commits given to this function (which may or may not be in the
bisect set when path-limit is in use).

However, when N is 1, then the sole tree-changing commit has
depth of 1, and min(N-D, D) evaluates to 0.  This is not larger
than the initial value of "closest", and the "so far the best
one" commit is never replaced in the loop.

When path-limit is not in use, this is not a problem, as any
commit in the input set is tree-changing.  But when path-limit
is in use, and when the starting "bad" commit does not change
the specified path, it is not correct to return it.

Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agogitweb: Fix "next" link in commit view
Jakub Narebski [Fri, 23 Mar 2007 20:04:31 +0000 (21:04 +0100)]
gitweb: Fix "next" link in commit view

Fix copy'n'paste error in commit c9d193df which caused that "next"
link for merge commits in "commit" view
  (merge: _commit_ _commit_ ...)
was to "commitdiff" view instead of being to "commit" view.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agogit-bisect.sh: properly dq $GIT_DIR
Junio C Hamano [Fri, 23 Mar 2007 20:24:22 +0000 (13:24 -0700)]
git-bisect.sh: properly dq $GIT_DIR

Otherwise you would be in trouble if your GIT_DIR has IFS letters in it.

Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agogit-bisect: typofix
Junio C Hamano [Fri, 23 Mar 2007 20:15:21 +0000 (13:15 -0700)]
git-bisect: typofix

The branch you are on while bisecting is always "bisect", and
checking for "refs/heads/bisect*" is wrong.  Only check if it is
exactly "refs/heads/bisect".

Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agocheckout: report where the new HEAD is upon detaching HEAD
Junio C Hamano [Fri, 23 Mar 2007 09:37:19 +0000 (02:37 -0700)]
checkout: report where the new HEAD is upon detaching HEAD

After "git reset" moves the HEAD around, it reports which commit
you are on, which gives the user a warm fuzzy feeling of
assurance.  Give the same assurance from git-checkout when
moving the detached HEAD around.

Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoBisect: implement "git bisect run <cmd>..." to automatically bisect.
Christian Couder [Fri, 23 Mar 2007 07:49:59 +0000 (08:49 +0100)]
Bisect: implement "git bisect run <cmd>..." to automatically bisect.

This idea was suggested by Bill Lear
(Message-ID: <17920.38942.364466.642979@lisa.zopyra.com>)
and I think it is a very good one.

This patch adds a new test file for "git bisect run", but there
is currently only one basic test.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoBisect: convert revs given to good and bad to commits
Uwe Kleine-König [Thu, 22 Mar 2007 16:18:08 +0000 (17:18 +0100)]
Bisect: convert revs given to good and bad to commits

Without this the rev could be (e.g.) a tag and then the condition to end the
bisect might fail and you have to check the already known to be bad revision
once more.

Signed-off-by: Uwe Kleine-König <ukleinek@informatik.uni-freiburg.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agot4118: be nice to non-GNU sed
Johannes Schindelin [Fri, 23 Mar 2007 01:05:28 +0000 (21:05 -0400)]
t4118: be nice to non-GNU sed

Elias Pipping:
> I'm on a mac, hence /usr/bin/sed is not gnu sed, which makes
> t4118 fail.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Ack'd-by: Elias Pipping <pipping@macports.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agogit-apply: Do not free the wrong buffer when we convert the data for writeout
Junio C Hamano [Fri, 23 Mar 2007 00:32:51 +0000 (17:32 -0700)]
git-apply: Do not free the wrong buffer when we convert the data for writeout

When we write out the result of patch application, we sometimes
need to munge the data (e.g. under core.autocrlf).  After doing
so, what we should free is the temporary buffer that holds the
converted data returned from convert_to_working_tree(), not the
original one.

This patch also moves the call to open() up in the function, as
the caller expects us to fail cheaply if leading directories
need to be created (and then the caller creates them and calls
us again).  For that calling pattern, attempting conversion
before opening the file adds unnecessary overhead.

Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoMerge git://git2.kernel.org/pub/scm/gitk/gitk
Junio C Hamano [Thu, 22 Mar 2007 10:05:34 +0000 (03:05 -0700)]
Merge git://git2.kernel.org/pub/scm/gitk/gitk

* git://git2.kernel.org/pub/scm/gitk/gitk:
  [PATCH] prefer "git COMMAND" over "git-COMMAND" in gitk

17 years agoMerge branch 'maint'
Junio C Hamano [Thu, 22 Mar 2007 10:05:25 +0000 (03:05 -0700)]
Merge branch 'maint'

* maint:
  Documentation/pack-format.txt: Clear up description of types.
  fix typo in git-am manpage

17 years agoDocumentation/pack-format.txt: Clear up description of types.
Peter Eriksen [Wed, 21 Mar 2007 18:43:37 +0000 (19:43 +0100)]
Documentation/pack-format.txt: Clear up description of types.

Signed-off-by: Peter Eriksen <s022018@student.dtu.dk>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoupdate HEAD reflog when branch pointed to by HEAD is directly modified
Nicolas Pitre [Wed, 21 Mar 2007 21:11:44 +0000 (17:11 -0400)]
update HEAD reflog when branch pointed to by HEAD is directly modified

The HEAD reflog is updated as well as the reflog for the branch pointed
to by HEAD whenever it is referenced with "HEAD".

There are some cases where a specific branch may be modified directly.
In those cases, the HEAD reflog should be updated as well if it is a
symref to that branch in order to be consistent.

Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoupdate-hook: abort early if the project description is unset
Andy Parkins [Tue, 20 Mar 2007 10:58:32 +0000 (10:58 +0000)]
update-hook: abort early if the project description is unset

It was annoying to always have the first email from a project be from
the "Unnamed repository; edit this file to name it for gitweb project";
just because it's so easy to forget to set it.

This patch checks to see if the description file is still default (or
empty) and aborts if so - allowing you to fix the problem before sending
out silly looking emails to every developer.

Signed-off-by: Andy Parkins <andyparkins@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agogit-merge: Put FETCH_HEAD data in merge commit message
Michael S. Tsirkin [Thu, 22 Mar 2007 09:07:30 +0000 (11:07 +0200)]
git-merge: Put FETCH_HEAD data in merge commit message

This makes git-fetch <URL> && git-merge FETCH_HEAD produce the
same merge message as git-pull <URL>.

Signed-off-by: Michael S. Tsirkin <mst@dev.mellanox.co.il>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agogit-rebase: make 'rebase HEAD branch' work as expected.
Junio C Hamano [Thu, 22 Mar 2007 09:54:59 +0000 (02:54 -0700)]
git-rebase: make 'rebase HEAD branch' work as expected.

When you want to amend the commit message of 3 commits before
the tip of the current branch, say 'master',

A--B--C--D--E(master)

it is sometimes handy to make your head detached at that commit
with:

$ git checkout HEAD~3 ;# check out B
$ git commit --amend ;# without modifying contents...

to create:

          .B'(HEAD)
         /
A--B--C--D--E(master)

and then rebase 'master' branch onto HEAD with this:

$ git rebase HEAD master

to result in:

          .B'-C'-D'-E(master=HEAD)
         /
A--B--C--D--E

However, the current code interprets HEAD after it switches to
the branch 'master', which means the rebase will not do
anything.  You have to say something unwieldly like this
instead:

$ git rebase $(git rev-parse HEAD) master

This fixes it by expanding the $onto commit name before
switching to the target branch.

Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agotree_entry_interesting(): allow it to say "everything is interesting"
Junio C Hamano [Thu, 22 Mar 2007 00:00:27 +0000 (17:00 -0700)]
tree_entry_interesting(): allow it to say "everything is interesting"

In addition to optimizing pathspecs that would never match,
which was done earlier, this optimizes pathspecs that would
always match (e.g. "arch/" while the traversal is already in
"arch/i386/" hierarchy).

This patch makes the worst case slightly more palatable, while
improving average case.

Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agotree-diff: avoid strncmp()
Junio C Hamano [Wed, 21 Mar 2007 19:34:46 +0000 (12:34 -0700)]
tree-diff: avoid strncmp()

If we already know that some of the pathspecs can match later
entries in the tree we are looking at, we do not have to do more
expensive strncmp() upfront before comparing the length of the
match pattern and the path, as a path longer than the match
pattern will not match it, and a path shorter than the match
pattern will match only if the path is a directory-component
wise prefix of the match pattern.

Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoTeach tree_entry_interesting() that the tree entries are sorted.
Junio C Hamano [Wed, 21 Mar 2007 16:51:47 +0000 (09:51 -0700)]
Teach tree_entry_interesting() that the tree entries are sorted.

When we are looking at a tree entry with pathspecs, if all the
pathspecs sort strictly earlier than the entry we are currently
looking at, there is no way later entries in the same tree would
match our pathspecs, because the entries are sorted.

Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoSwitch over tree descriptors to contain a pre-parsed entry
Linus Torvalds [Wed, 21 Mar 2007 17:09:56 +0000 (10:09 -0700)]
Switch over tree descriptors to contain a pre-parsed entry

This makes the tree descriptor contain a "struct name_entry" as part of
it, and it gets filled in so that it always contains a valid entry. On
some benchmarks, it improves performance by up to 15%.

That makes tree entry "extract" trivial, and means that we only actually
need to decode each tree entry just once: we decode the first one when
we initialize the tree descriptor, and each subsequent one when doing
"update_tree_entry()".  In particular, this means that we don't need to
do strlen() both at extract time _and_ at update time.

Finally, it also allows more sharing of code (entry_extract(), that
wanted a "struct name_entry", just got totally trivial, along with the
"tree_entry()" function).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoInitialize tree descriptors with a helper function rather than by hand.
Linus Torvalds [Wed, 21 Mar 2007 17:08:25 +0000 (10:08 -0700)]
Initialize tree descriptors with a helper function rather than by hand.

This removes slightly more lines than it adds, but the real reason for
doing this is that future optimizations will require more setup of the
tree descriptor, and so we want to do it in one place.

Also renamed the "desc.buf" field to "desc.buffer" just to trigger
compiler errors for old-style manual initializations, making sure I
didn't miss anything.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoRemove "pathlen" from "struct name_entry"
Linus Torvalds [Wed, 21 Mar 2007 17:07:46 +0000 (10:07 -0700)]
Remove "pathlen" from "struct name_entry"

Since we have the "tree_entry_len()" helper function these days, and
don't need to do a full strlen(), there's no point in saving the path
length - it's just redundant information.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years ago[PATCH] prefer "git COMMAND" over "git-COMMAND" in gitk
Brandon Casey [Mon, 19 Mar 2007 23:00:37 +0000 (18:00 -0500)]
[PATCH] prefer "git COMMAND" over "git-COMMAND" in gitk

Preferring git _space_ COMMAND over git _dash_ COMMAND allows the
user to have only git and gitk in their path. e.g. when git and gitk
are symbolic links in a personal bin directory to the real git and gitk.

Signed-off-by: Paul Mackerras <paulus@samba.org>
17 years agofix typo in git-am manpage
Michael S. Tsirkin [Wed, 21 Mar 2007 08:37:36 +0000 (10:37 +0200)]
fix typo in git-am manpage

Fix typo in git-am manpage

Signed-off-by: Michael S. Tsirkin <mst@dev.mellanox.co.il>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoblame: cmp_suspect is not "cmp" anymore.
Junio C Hamano [Wed, 21 Mar 2007 06:37:51 +0000 (23:37 -0700)]
blame: cmp_suspect is not "cmp" anymore.

The earlier round makes the function return "is it different"
and it does not return a value suitable for sorting anymore.  Reverse
the logic to return "are they the same suspect" instead, and rename
it to "same_suspect()".

Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agominor git-prune optimization
Nicolas Pitre [Wed, 21 Mar 2007 03:32:13 +0000 (23:32 -0400)]
minor git-prune optimization

Don't try to remove the containing directory for every pruned object but
try only once after the directory has been scanned instead.

Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoimprove checkout message when asking for same branch
Nicolas Pitre [Wed, 21 Mar 2007 02:26:47 +0000 (22:26 -0400)]
improve checkout message when asking for same branch

Change the feedback message if doing 'git checkout foo' when already on
branch "foo".

Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoBe more careful about zlib return values
Linus Torvalds [Tue, 20 Mar 2007 18:38:34 +0000 (11:38 -0700)]
Be more careful about zlib return values

When creating a new object, we use "deflate(stream, Z_FINISH)" in a loop
until it no longer returns Z_OK, and then we do "deflateEnd()" to finish
up business.

That should all work, but the fact is, it's not how you're _supposed_ to
use the zlib return values properly:

 - deflate() should never return Z_OK in the first place, except if we
   need to increase the output buffer size (which we're not doing, and
   should never need to do, since we pre-allocated a buffer that is
   supposed to be able to hold the output in full). So the "while()" loop
   was incorrect: Z_OK doesn't actually mean "ok, continue", it means "ok,
   allocate more memory for me and continue"!

 - if we got an error return, we would consider it to be end-of-stream,
   but it could be some internal zlib error.  In short, we should check
   for Z_STREAM_END explicitly, since that's the only valid return value
   anyway for the Z_FINISH case.

 - we never checked deflateEnd() return codes at all.

Now, admittedly, none of these issues should ever happen, unless there is
some internal bug in zlib. So this patch should make zero difference, but
it seems to be the right thing to do.

We should probablybe anal and check the return value of "deflateInit()"
too!

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoDon't ever return corrupt objects from "parse_object()"
Linus Torvalds [Tue, 20 Mar 2007 17:05:20 +0000 (10:05 -0700)]
Don't ever return corrupt objects from "parse_object()"

Looking at the SHA1 validation code due to the corruption that Alexander
Litvinov is seeing under Cygwin, I notice that one of the most central
places where we read objects, we actually do end up verifying the SHA1 of
the result, but then we happily parse it anyway.

And using "printf" to write the error message means that it not only can
get lost, but will actually mess up stdout, and cause other strange and
hard-to-debug failures downstream.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoindex-pack: more validation checks and cleanups
Nicolas Pitre [Tue, 20 Mar 2007 21:07:48 +0000 (17:07 -0400)]
index-pack: more validation checks and cleanups

When appending objects to a pack, make sure the appended data is really
what we expect instead of simply loading potentially corrupted objects
and legitimating them by computing a SHA1 of that corrupt data.

With this the sha1_object() can lose its test_for_collision parameter
which is now redundent.

Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoindex-pack: use hash_sha1_file()
Nicolas Pitre [Tue, 20 Mar 2007 20:02:09 +0000 (16:02 -0400)]
index-pack: use hash_sha1_file()

Use hash_sha1_file() instead of duplicating code to compute object SHA1.
While at it make it accept a const pointer.

Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agodon't ever allow SHA1 collisions to exist by fetching a pack
Nicolas Pitre [Tue, 20 Mar 2007 19:32:35 +0000 (15:32 -0400)]
don't ever allow SHA1 collisions to exist by fetching a pack

Waaaaaaay back Git was considered to be secure as it never overwrote
an object it already had.  This was ensured by always unpacking the
packfile received over the network (both in fetch and receive-pack)
and our already existing logic to not create a loose object for an
object we already have.

Lately however we keep "large-ish" packfiles on both fetch and push
by running them through index-pack instead of unpack-objects.  This
would let an attacker perform a birthday attack.

How?  Assume the attacker knows a SHA-1 that has two different
data streams.  He knows the client is likely to have the "good"
one.  So he sends the "evil" variant to the other end as part of
a "large-ish" packfile.  The recipient keeps that packfile, and
indexes it.  Now since this is a birthday attack there is a SHA-1
collision; two objects exist in the repository with the same SHA-1.
They have *very* different data streams.  One of them is "evil".

Currently the poor recipient cannot tell the two objects apart,
short of by examining the timestamp of the packfiles.  But lets
say the recipient repacks before he realizes he's been attacked.
We may wind up packing the "evil" version of the object, and deleting
the "good" one.  This is made *even more likely* by Junio's recent
rearrange_packed_git patch (b867092f).

It is extremely unlikely for a SHA1 collisions to occur, but if it
ever happens with a remote (hence untrusted) object we simply must
not let the fetch succeed.

Normally received packs should not contain objects we already have.
But when they do we must ensure duplicated objects with the same SHA1
actually contain the same data.

Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agogit-fetch: Fix single_force in append_fetch_head
Santi Béjar [Sun, 18 Mar 2007 23:16:23 +0000 (00:16 +0100)]
git-fetch: Fix single_force in append_fetch_head

This fixes the single force (+) when fetched with fetch_per_ref.

Also use $LF as separator because IFS is $LF.

Signed-off-by: Santi Béjar <sbejar@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoMerge git://git2.kernel.org/pub/scm/gitk/gitk
Junio C Hamano [Tue, 20 Mar 2007 06:47:22 +0000 (23:47 -0700)]
Merge git://git2.kernel.org/pub/scm/gitk/gitk

* git://git2.kernel.org/pub/scm/gitk/gitk:
  [PATCH] gitk: bind <F5> key to Update (reread commits)

17 years agomake git clone -q suppress the noise with http fetch
Chris Wright [Tue, 20 Mar 2007 02:18:18 +0000 (19:18 -0700)]
make git clone -q suppress the noise with http fetch

We already have -q in git clone.  So for those who care to suppress
the noise during an http based clone, make -q actually do a quiet
http fetch.

Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Cc: Fernando Herrera <fherrera@onirica.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoFix loose object uncompression check.
Linus Torvalds [Tue, 20 Mar 2007 05:49:53 +0000 (22:49 -0700)]
Fix loose object uncompression check.

The thing is, if the output buffer is empty, we should *still* actually
use the zlib routines to *unpack* that empty output buffer.

But we had a test that said "only unpack if we still expect more output".

So we wouldn't use up all the zlib stream, because we felt that we didn't
need it, because we already had all the bytes we wanted. And it was
"true": we did have all the output data. We just needed to also eat all
the input data!

We've had this bug before - thinking that we don't need to inflate()
anything because we already had it all..

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agocontrib/continuous: a continuous integration build manager
Shawn O. Pearce [Tue, 20 Mar 2007 04:33:41 +0000 (00:33 -0400)]
contrib/continuous: a continuous integration build manager

This is a simple but powerful continuous integration build system
for Git.  It works by receiving push events from repositories
through the post-receive hook, aggregates them on a per-branch
basis into a first-come-first-serve build queue, and lets a
background build daemon perform builds one at a time.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoProvide some technical documentation for shallow clones
Johannes Schindelin [Tue, 20 Mar 2007 02:41:11 +0000 (03:41 +0100)]
Provide some technical documentation for shallow clones

There has not been any work on the shallow stuff lately, so it is hard
to find out what it does, and how. This document describes the ideas
as well as the current problems, and can serve as a starting point for
shallow people.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoAdd a HOWTO for setting up a standalone git daemon
Johannes Schindelin [Tue, 20 Mar 2007 02:29:56 +0000 (03:29 +0100)]
Add a HOWTO for setting up a standalone git daemon

Setting up a git-daemon came up the other day on IRC, and it is slightly
non trivial for the uninitiated.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoxdiff/xutils.c(xdl_hash_record): factor out whitespace handling
Johannes Schindelin [Tue, 20 Mar 2007 03:05:10 +0000 (04:05 +0100)]
xdiff/xutils.c(xdl_hash_record): factor out whitespace handling

Since in at least one use case, xdl_hash_record() takes over 15% of the
CPU time, it makes sense to even micro-optimize it. For many cases, no
whitespace special handling is needed, and in these cases we should not
even bother to check for whitespace in _every_ iteration of the loop.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoblame: micro-optimize cmp_suspect()
Junio C Hamano [Tue, 20 Mar 2007 05:17:10 +0000 (22:17 -0700)]
blame: micro-optimize cmp_suspect()

The commit structures are guaranteed their uniqueness by the object
layer, so we can check their address and see if they are the same
without going down to the object sha1 level.

Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoReplace remaining instances of strdup with xstrdup.
James Bowes [Mon, 19 Mar 2007 21:42:40 +0000 (17:42 -0400)]
Replace remaining instances of strdup with xstrdup.

Signed-off-by: James Bowes <jbowes@dangerouslyinc.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agouse a LRU eviction policy for the delta base cache
Nicolas Pitre [Mon, 19 Mar 2007 20:31:04 +0000 (16:31 -0400)]
use a LRU eviction policy for the delta base cache

This provides a smoother degradation in performance when the cache
gets trashed due to the delta_base_cache_limit being reached.  Limited
testing with really small delta_base_cache_limit values appears to confirm
this.

Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoclean up the delta base cache size a bit
Nicolas Pitre [Mon, 19 Mar 2007 20:28:51 +0000 (16:28 -0400)]
clean up the delta base cache size a bit

Currently there are 3 different ways to deal with the cache size.
Let's stick to only one.  The compiler is smart enough to produce the exact
same code in those cases anyway.

Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoGIT 1.5.1-rc1 v1.5.1-rc1
Junio C Hamano [Mon, 19 Mar 2007 09:28:29 +0000 (02:28 -0700)]
GIT 1.5.1-rc1

I think we can start to slow down, as we now have covered
everything I listed earlier in the short-term release plan.

The last release 1.5.0 took painfully too long.

Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoFix merge-index
Junio C Hamano [Mon, 19 Mar 2007 09:48:37 +0000 (02:48 -0700)]
Fix merge-index

An earlier conversion to run_command() from execlp() forgot that
run_command() takes an array that is terminated with NULL.

Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoSet up for better tree diff optimizations
Linus Torvalds [Sun, 18 Mar 2007 22:18:30 +0000 (15:18 -0700)]
Set up for better tree diff optimizations

This is mainly just a cleanup patch, and sets up for later changes where
the tree-diff.c "interesting()" function can return more than just a
yes/no value.

In particular, it should be quite possible to say "no subsequent entries
in this tree can possibly be interesting any more", and thus allow the
callers to short-circuit the tree entirely.

In fact, changing the callers to do so is trivial, and is really all this
patch really does, because changing "interesting()" itself to say that
nothing further is going to be interesting is definitely more complicated,
considering that we may have arbitrary pathspecs.

But in cleaning up the callers, this actually fixes a potential small
performance issue in diff_tree(): if the second tree has a lot of
uninterestign crud in it, we would keep on doing the "is it interesting?"
check on the first tree for each uninteresting entry in the second one.

The answer is obviously not going to change, so that was just not helping.
The new code is clearer and simpler and avoids this issue entirely.

I also renamed "interesting()" to "tree_entry_interesting()", because I
got frustrated by the fact that

 - we actually had *another* function called "interesting()" in another
   file, and I couldn't tell from the profiles which one was the one that
   mattered more.

 - when rewriting it to return a ternary value, you can't just do

if (interesting(...))
...

   any more, but want to assign the return value to a local variable. The
   name of choice for that variable would normally be "interesting", so
   I just wanted to make the function name be more specific, and avoid
   that whole issue (even though I then didn't choose that name for either
   of the users, just to avoid confusion in the patch itself ;)

In other words, this doesn't really change anything, but I think it's a
good thing to do, and if somebody comes along and writes the logic for
"yeah, none of the pathspecs you have are interesting", we now support
that trivially.

It could easily be a meaningful optimization for things like "blame",
where there's just one pathspec, and stopping when you've seen it would
allow you to avoid about 50% of the tree traversals on average.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoTrivial cleanup of track_tree_refs()
Linus Torvalds [Sun, 18 Mar 2007 20:38:19 +0000 (13:38 -0700)]
Trivial cleanup of track_tree_refs()

This makes "track_tree_refs()" use the same "tree_entry()" function for
counting the entries as it does for actually traversing them a few lines
later.

Not a biggie, but the reason I care was that this was the only user of
"update_tree_entry()" that didn't actually *extract* the tree entry first.
It doesn't matter as things stand now, but it meant that a separate
test-patch I had that avoided a few more "strlen()" calls by just saving
the entry length in the entry descriptor and using it directly when
updating wouldn't work without this patch.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agogit.el: Add support for commit hooks.
Alexandre Julliard [Sat, 17 Mar 2007 19:40:12 +0000 (20:40 +0100)]
git.el: Add support for commit hooks.

Run the pre-commit and post-commit hooks at appropriate places, and
display their output if any.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoMerge branch 'jb/gc'
Junio C Hamano [Mon, 19 Mar 2007 05:46:30 +0000 (22:46 -0700)]
Merge branch 'jb/gc'

* jb/gc:
  Make gc a builtin.

17 years agoMerge branch 'fl/cvsserver'
Junio C Hamano [Mon, 19 Mar 2007 05:44:25 +0000 (22:44 -0700)]
Merge branch 'fl/cvsserver'

* fl/cvsserver:
  cvsserver: further improve messages on commit and status
  cvsserver: Be more chatty

17 years agoLimit the size of the new delta_base_cache
Shawn O. Pearce [Mon, 19 Mar 2007 05:14:37 +0000 (01:14 -0400)]
Limit the size of the new delta_base_cache

The new configuration variable core.deltaBaseCacheLimit allows the
user to control how much memory they are willing to give to Git for
caching base objects of deltas.  This is not normally meant to be
a user tweakable knob; the "out of the box" settings are meant to
be suitable for almost all workloads.

We default to 16 MiB under the assumption that the cache is not
meant to consume all of the user's available memory, and that the
cache's main purpose was to cache trees, for faster path limiters
during revision traversal.  Since trees tend to be relatively small
objects, this relatively small limit should still allow a large
number of objects.

On the other hand we don't want the cache to start storing 200
different versions of a 200 MiB blob, as this could easily blow
the entire address space of a 32 bit process.

We evict OBJ_BLOB from the cache first (credit goes to Junio) as
we want to favor OBJ_TREE within the cache.  These are the objects
that have the highest inflate() startup penalty, as they tend to
be small and thus don't have that much of a chance to ammortize
that penalty over the entire data.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoMerge branch 'sp/run-command'
Junio C Hamano [Mon, 19 Mar 2007 05:21:06 +0000 (22:21 -0700)]
Merge branch 'sp/run-command'

* sp/run-command:
  Use run_command within send-pack
  Use run_command within receive-pack to invoke index-pack
  Use run_command within merge-index
  Use run_command for proxy connections
  Use RUN_GIT_CMD to run push backends
  Correct new compiler warnings in builtin-revert
  Replace fork_with_pipe in bundle with run_command
  Teach run-command to redirect stdout to /dev/null
  Teach run-command about stdout redirection

17 years agoMake git-send-email aware of Cc: lines.
J. Bruce Fields [Mon, 19 Mar 2007 01:37:53 +0000 (21:37 -0400)]
Make git-send-email aware of Cc: lines.

In the Linux kernel, for example, it's common to include Cc: lines
for cases when you want to remember to cc someone on a patch without
necessarily claiming they signed off on it.  Make git-send-email
aware of these.

Signed-off-by: "J. Bruce Fields" <bfields@citi.umich.edu>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agomergetool: print an appropriate warning if merge.tool is unknown
Theodore Ts'o [Mon, 19 Mar 2007 02:30:10 +0000 (22:30 -0400)]
mergetool: print an appropriate warning if merge.tool is unknown

Also add support for vimdiff

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
17 years agomergetool: Add support for vimdiff.
James Bowes [Mon, 19 Mar 2007 02:11:54 +0000 (22:11 -0400)]
mergetool: Add support for vimdiff.

Signed-off-by: James Bowes <jbowes@dangerouslyinc.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
17 years agoUpdate main git.html page to point at 1.5.0.5 documentation
Junio C Hamano [Sun, 18 Mar 2007 22:58:07 +0000 (15:58 -0700)]
Update main git.html page to point at 1.5.0.5 documentation

Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoMerge branch 'ar/diff'
Junio C Hamano [Sun, 18 Mar 2007 22:48:06 +0000 (15:48 -0700)]
Merge branch 'ar/diff'

* ar/diff:
  Add tests for --quiet option of diff programs
  try-to-simplify-commit: use diff-tree --quiet machinery.
  revision.c: explain what tree_difference does
  Teach --quiet to diff backends.
  diff --quiet
  Remove unused diffcore_std_no_resolve
  Allow git-diff exit with codes similar to diff(1)

17 years agoAvoid unnecessary strlen() calls
Linus Torvalds [Sun, 18 Mar 2007 03:06:24 +0000 (20:06 -0700)]
Avoid unnecessary strlen() calls

This is a micro-optimization that grew out of the mailing list discussion
about "strlen()" showing up in profiles.

We used to pass regular C strings around to the low-level tree walking
routines, and while this worked fine, it meant that we needed to call
strlen() on strings that the caller always actually knew the size of
anyway.

So pass the length of the string down wih the string, and avoid
unnecessary calls to strlen(). Also, when extracting a pathname from a
tree entry, use "tree_entry_len()" instead of strlen(), since the length
of the pathname is directly calculable from the decoded tree entry itself
without having to actually do another strlen().

This shaves off another ~5-10% from some loads that are very tree
intensive (notably doing commit filtering by a pathspec).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>"
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoReuse cached data out of delta base cache.
Nicolas Pitre [Sun, 18 Mar 2007 01:13:57 +0000 (21:13 -0400)]
Reuse cached data out of delta base cache.

A malloc() + memcpy() will always be faster than mmap() +
malloc() + inflate().  If the data is already there it is
certainly better to copy it straight away.

With this patch below I can do 'git log drivers/scsi/ >
/dev/null' about 7% faster.  I bet it might be even more on
those platforms with bad mmap() support.

Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoImplement a simple delta_base cache
Linus Torvalds [Sat, 17 Mar 2007 19:44:06 +0000 (12:44 -0700)]
Implement a simple delta_base cache

This trivial 256-entry delta_base cache improves performance for some
loads by a factor of 2.5 or so.

Instead of always re-generating the delta bases (possibly over and over
and over again), just cache the last few ones. They often can get re-used.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoMake trivial wrapper functions around delta base generation and freeing
Linus Torvalds [Sat, 17 Mar 2007 19:42:15 +0000 (12:42 -0700)]
Make trivial wrapper functions around delta base generation and freeing

This doesn't change any code, it just creates a point for where we'd
actually do the caching of delta bases that have been generated.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoMerge 1.5.0.5 in from 'maint'
Junio C Hamano [Sun, 18 Mar 2007 22:36:44 +0000 (15:36 -0700)]
Merge 1.5.0.5 in from 'maint'

17 years agoGIT 1.5.0.5 v1.5.0.5
Junio C Hamano [Sun, 18 Mar 2007 21:40:35 +0000 (14:40 -0700)]
GIT 1.5.0.5

Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoMake gc a builtin.
James Bowes [Wed, 14 Mar 2007 01:58:22 +0000 (21:58 -0400)]
Make gc a builtin.

Signed-off-by: James Bowes <jbowes@dangerouslyinc.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoMerge branch 'maint'
Junio C Hamano [Sat, 17 Mar 2007 07:33:17 +0000 (00:33 -0700)]
Merge branch 'maint'

* maint:
  git-merge: finish when git-read-tree fails

17 years ago[PATCH] clean up pack index handling a bit
Nicolas Pitre [Fri, 16 Mar 2007 20:42:50 +0000 (16:42 -0400)]
[PATCH] clean up pack index handling a bit

Especially with the new index format to come, it is more appropriate
to encapsulate more into check_packed_git_idx() and assume less of the
index format in struct packed_git.

To that effect, the index_base is renamed to index_data with void * type
so it is not used directly but other pointers initialized with it. This
allows for a couple pointer cast removal, as well as providing a better
generic name to grep for when adding support for new index versions or
formats.

And index_data is declared const too while at it.

Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years ago[PATCH] add test for OFS_DELTA objects
Nicolas Pitre [Fri, 16 Mar 2007 17:50:18 +0000 (13:50 -0400)]
[PATCH] add test for OFS_DELTA objects

Make sure pack-objects with --delta-base-offset works fine, and that
it actually produces smaller packs as expected.

Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years ago[PATCH] fix t5300-pack-object.sh
Nicolas Pitre [Fri, 16 Mar 2007 17:37:42 +0000 (13:37 -0400)]
[PATCH] fix t5300-pack-object.sh

The 'use packed deltified objects' test was flawed as it failed to
remove the pack and index from the previous test, effectively preventing
the desired pack from being exercised as objects could be found in that
other pack instead.

Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years ago[PATCH] local-fetch.c: some error printing cleanup
Nicolas Pitre [Fri, 16 Mar 2007 17:20:19 +0000 (13:20 -0400)]
[PATCH] local-fetch.c: some error printing cleanup

Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoapplymbox: brown paper bag fix.
Junio C Hamano [Sat, 17 Mar 2007 04:22:05 +0000 (21:22 -0700)]
applymbox: brown paper bag fix.

An earlier patch 87ab7992 broke applymbox by blindly copying piece
from git-am, causing a harmless but annoying series of error messages.

Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agogit-merge: finish when git-read-tree fails
Santi Béjar [Fri, 16 Mar 2007 10:46:09 +0000 (11:46 +0100)]
git-merge: finish when git-read-tree fails

The message formating (commit v1.5.0.3-28-gbe242d5) broke the && chain.

Noticed by Dmitry Torokhov.

Signed-off-by: Santi Béjar <sbejar@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoAdd tests for --quiet option of diff programs
Alex Riesen [Wed, 14 Mar 2007 22:57:23 +0000 (23:57 +0100)]
Add tests for --quiet option of diff programs

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
17 years agouse xstrdup please
Shawn O. Pearce [Fri, 16 Mar 2007 01:02:51 +0000 (21:02 -0400)]
use xstrdup please

We generally prefer xstrdup to just plain strdup.
Make it so.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agogit-fetch, git-branch: Support local --track via a special remote '.'
Paolo Bonzini [Thu, 15 Mar 2007 08:23:20 +0000 (09:23 +0100)]
git-fetch, git-branch: Support local --track via a special remote '.'

This patch adds support for a dummy remote '.' to avoid having
to declare a fake remote like

        [remote "local"]
                url = .
                fetch = refs/heads/*:refs/heads/*

Such a builtin remote simplifies the operation of "git-fetch",
which will populate FETCH_HEAD but will not pretend that two
repositories are in use, will not create a thin pack, and will
not perform any useless remapping of names.  The speed
improvement is around 20%, and it should improve more if
"git-fetch" is converted to a builtin.

To this end, git-parse-remote is grown with a new kind of
remote, 'builtin'.  In git-fetch.sh, we treat the builtin remote
specially in that it needs no pack/store operations.  In fact,
doing git-fetch on a builtin remote will simply populate
FETCH_HEAD appropriately.

The patch also improves of the --track/--no-track support,
extending it so that branch.<name>.remote items referring '.'
can be created.  Finally, it fixes a typo in git-checkout.sh.

Signed-off-by: Paolo Bonzini <bonzini@gnu.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agotry-to-simplify-commit: use diff-tree --quiet machinery.
Junio C Hamano [Wed, 14 Mar 2007 20:18:15 +0000 (13:18 -0700)]
try-to-simplify-commit: use diff-tree --quiet machinery.

This uses diff-tree --quiet machinery to terminate the internal
diff-tree between a commit and its parents via revs.pruning (not
revs.diffopt) as soon as we find enough about the tree change.

With respect to the optionally given pathspec, we are interested
if the tree of commit is identical to the parent's, only adds
new paths to the parent's, or there are other differences.  As
soon as we find out that there is one such other kind of
difference, we do not have to compare the rest of the tree.

Because we do not call standard diff_addremove/diff_change, we
instruct the diff-tree machinery to stop early by setting
has_changes when we say we found the trees to be different.

Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agorevision.c: explain what tree_difference does
Junio C Hamano [Wed, 14 Mar 2007 20:12:18 +0000 (13:12 -0700)]
revision.c: explain what tree_difference does

This explains how tree_difference variable is used, and updates two
places where the code knows symbolic constant REV_TREE_SAME is 0.

Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoTeach --quiet to diff backends.
Junio C Hamano [Wed, 14 Mar 2007 18:12:51 +0000 (11:12 -0700)]
Teach --quiet to diff backends.

This teaches git-diff-files, git-diff-index and git-diff-tree
backends to exit early under --quiet option.

Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agodiff --quiet
Junio C Hamano [Wed, 14 Mar 2007 18:12:13 +0000 (11:12 -0700)]
diff --quiet

This adds the command line option 'quiet' to tell 'git diff-*'
that we are not interested in the actual diff contents but only
want to know if there is any change.  This option automatically
turns --exit-code on, and turns off output formatting, as it
does not make much sense to show the first hit we happened to
have found.

The --quiet option is silently turned off (but --exit-code is
still in effect, so is silent output) if postprocessing filters
such as pickaxe and diff-filter are used.  For all practical
purposes I do not think of a reason to want to use these filters
and not viewing the diff output.

The backends have not been taught about the option with this patch.
That is a topic for later rounds.

Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoRemove unused diffcore_std_no_resolve
Junio C Hamano [Wed, 14 Mar 2007 17:36:42 +0000 (10:36 -0700)]
Remove unused diffcore_std_no_resolve

This was only used by diff-tree-helper program, whose purpose
was to translate a raw diff to a patch.

Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoAllow git-diff exit with codes similar to diff(1)
Alex Riesen [Wed, 14 Mar 2007 00:17:04 +0000 (01:17 +0100)]
Allow git-diff exit with codes similar to diff(1)

This introduces a new command-line option: --exit-code. The diff
programs will return 1 for differences, return 0 for equality, and
something else for errors.

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoMerge GIT 1.5.0.4
Junio C Hamano [Wed, 14 Mar 2007 22:59:04 +0000 (15:59 -0700)]
Merge GIT 1.5.0.4

17 years agoGIT 1.5.0.4 v1.5.0.4
Junio C Hamano [Wed, 14 Mar 2007 22:56:49 +0000 (15:56 -0700)]
GIT 1.5.0.4

Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoClarify doc for git-config --unset-all.
Yann Dirson [Wed, 14 Mar 2007 21:08:41 +0000 (22:08 +0100)]
Clarify doc for git-config --unset-all.

Previous formulation could make it appear as removing all lines
matching a regexp (at least, I was looking for such a flag, and
confused this flag for what I was looking for).

Signed-off-by: Yann Dirson <ydirson@altern.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agogit-checkout: fix "eval" used for merge labelling.
Junio C Hamano [Wed, 14 Mar 2007 16:48:13 +0000 (09:48 -0700)]
git-checkout: fix "eval" used for merge labelling.

The symbolic notation of the fork point can contain whitespaces (e.g.
"git checkout -m 'HEAD@{9 hours ago}'").  Quote strings properly
when using eval to prepare GITHEAD_$new

Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agoupdate-hook: fix incorrect use of git-describe and sed for finding previous tag
Andy Parkins [Wed, 14 Mar 2007 14:25:52 +0000 (14:25 +0000)]
update-hook: fix incorrect use of git-describe and sed for finding previous tag

Previously git-describe would output lines of the form
 v1.1.1-gf509d56
The update hook found the dash and stripped it off using
 sed 's/-g.*//'
The remainder was then used as the previous tag name.

However, git-describe has changed format.  The output is now of the form
 v1.1.1-23-gf509d56
The above sed fragment doesn't strip the middle "-23", and so the
previous tag name used would be "v1.1.1-23".  This is incorrect.

Since the hook script was written, git-describe now gained support for
"--abbrev=0", which it uses as a special flag to tell it not to output
anything other than the nearest tag name.  This patch fixes the problem,
and prevents any future recurrence by using this new flag rather than
sed to find the previous tag.

Signed-off-by: Andy Parkins <andyparkins@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
17 years agocvsserver: further improve messages on commit and status
Frank Lichtenheld [Tue, 13 Mar 2007 17:25:23 +0000 (18:25 +0100)]
cvsserver: further improve messages on commit and status

commit: Also print the old revision similar to how cvs does it and
prepend a line stating the filename so that one can actually
understand what happened when commiting more than one file.

status: Fix the RCS filename displayed. The directory was
printed twice.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>