Commit graph

14097 commits

Author SHA1 Message Date
Junio C Hamano 628522ec14 sha1-lookup: more memory efficient search in sorted list of SHA-1
Currently, when looking for a packed object from the pack idx, a
simple binary search is used.

A conventional binary search loop looks like this:

        unsigned lo, hi;
        do {
                unsigned mi = (lo + hi) / 2;
                int cmp = "entry pointed at by mi" minus "target";
                if (!cmp)
                        return mi; "mi is the wanted one"
                if (cmp > 0)
                        hi = mi; "mi is larger than target"
                else
                        lo = mi+1; "mi is smaller than target"
        } while (lo < hi);
	"did not find what we wanted"

The invariants are:

  - When entering the loop, 'lo' points at a slot that is never
    above the target (it could be at the target), 'hi' points at
    a slot that is guaranteed to be above the target (it can
    never be at the target).

  - We find a point 'mi' between 'lo' and 'hi' ('mi' could be
    the same as 'lo', but never can be as high as 'hi'), and
    check if 'mi' hits the target.  There are three cases:

     - if it is a hit, we have found what we are looking for;

     - if it is strictly higher than the target, we set it to
       'hi', and repeat the search.

     - if it is strictly lower than the target, we update 'lo'
       to one slot after it, because we allow 'lo' to be at the
       target and 'mi' is known to be below the target.

    If the loop exits, there is no matching entry.

When choosing 'mi', we do not have to take the "middle" but
anywhere in between 'lo' and 'hi', as long as lo <= mi < hi is
satisfied.  When we somehow know that the distance between the
target and 'lo' is much shorter than the target and 'hi', we
could pick 'mi' that is much closer to 'lo' than (hi+lo)/2,
which a conventional binary search would pick.

This patch takes advantage of the fact that the SHA-1 is a good
hash function, and as long as there are enough entries in the
table, we can expect uniform distribution.  An entry that begins
with for example "deadbeef..." is much likely to appear much
later than in the midway of a reasonably populated table.  In
fact, it can be expected to be near 87% (222/256) from the top
of the table.

This is a work-in-progress and has switches to allow easier
experiments and debugging.  Exporting GIT_USE_LOOKUP environment
variable enables this code.

On my admittedly memory starved machine, with a partial KDE
repository (3.0G pack with 95M idx):

    $ GIT_USE_LOOKUP=t git log -800 --stat HEAD >/dev/null
    3.93user 0.16system 0:04.09elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k
    0inputs+0outputs (0major+55588minor)pagefaults 0swaps

Without the patch, the numbers are:

    $ git log -800 --stat HEAD >/dev/null
    4.00user 0.15system 0:04.17elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
    0inputs+0outputs (0major+60258minor)pagefaults 0swaps

In the same repository:

    $ GIT_USE_LOOKUP=t git log -2000 HEAD >/dev/null
    0.12user 0.00system 0:00.12elapsed 97%CPU (0avgtext+0avgdata 0maxresident)k
    0inputs+0outputs (0major+4241minor)pagefaults 0swaps

Without the patch, the numbers are:

    $ git log -2000 HEAD >/dev/null
    0.05user 0.01system 0:00.07elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k
    0inputs+0outputs (0major+8506minor)pagefaults 0swaps

There isn't much time difference, but the number of minor faults
seems to show that we are touching much smaller number of pages,
which is expected.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-09 01:23:52 -07:00
Junio C Hamano 2a5fe25458 Merge branch 'jc/rename'
* 'jc/rename' (early part):
  Optimize rename detection for a huge diff
2008-04-09 01:09:12 -07:00
Junio C Hamano 018465d998 Merge branch 'gp/gitweb'
* gp/gitweb:
  gitweb: fallback to system-wide config file (fixup)
  gitweb: fallback to system-wide config file if default config does not exist
2008-04-09 00:44:48 -07:00
Junio C Hamano 3c993de9f2 Merge branch 'mk/unpack-careful'
* mk/unpack-careful:
  t5300: add test for "index-pack --strict"
  receive-pack: allow using --strict mode for unpacking objects
  unpack-objects: fix --strict handling
  t5300: add test for "unpack-objects --strict"
  unpack-objects: prevent writing of inconsistent objects
2008-04-09 00:44:17 -07:00
Junio C Hamano 769f60aed3 Merge branch 'fl/send-email-outside'
* fl/send-email-outside:
  send-email: Don't require to be called in a repository
  Git.pm: Don't require repository instance for ident
  Git.pm: Don't require a repository instance for config
  var: Don't require to be in a git repository.
2008-04-09 00:42:23 -07:00
Junio C Hamano 3ee5538a0c Merge branch 'jc/rebase'
* jc/rebase:
  rebase [--onto O] A B: omit needless checkout
2008-04-09 00:40:46 -07:00
Junio C Hamano ce47dc0775 Merge branch 'jk/add-i-mode'
* jk/add-i-mode:
  add--interactive: allow user to choose mode update
  add--interactive: ignore mode change in 'p'atch command
2008-04-09 00:29:24 -07:00
Junio C Hamano ba9f517bdd Merge branch 'gs/pretty-hexval'
* gs/pretty-hexval:
  pretty.c: add %x00 format specifier.
2008-04-09 00:18:25 -07:00
Junio C Hamano 1d2375ddfe GIT 1.5.5
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-07 21:57:43 -07:00
Junio C Hamano fae09a8084 Merge git://git.kernel.org/pub/scm/gitk/gitk
* git://git.kernel.org/pub/scm/gitk/gitk:
  gitk: Fix changing colors through Edit->Preferences
2008-04-07 21:52:23 -07:00
Eric Wong f61cc48d28 git-svn: fix following renamed paths when tracking a single path
When using git-svn to follow only a single (empty) path per
svn-remote (i.e. not using --stdlayout), following the history
of a renamed path was broken in
c586879cdf.

This reverts the regression for the single (emtpy) path per
svn-remote case.

To avoid breaking the tests in a committed revision, this is an
addendum to a patch originally submitted by

  Santhosh Kumar Mani <santhoshmani@gmail.com>:
  > git-svn: add test for renamed directory fetch
  >
  > This test tries to fetch a directory which had renames in the
  > history from a SVN repository.

  [ew: unneccesary dependency on the starting an HTTP server
   removed from Santhosh's original test.]

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-07 00:16:08 -07:00
Junio C Hamano a1c0dca43a Merge branch 'jc/maint-apply-match-beginning'
* jc/maint-apply-match-beginning:
  Fix "git apply" to correctly enforce "match at the beginning"
2008-04-06 20:04:29 -07:00
Pascal Obry aba201c6e8 Add prefix oriented completions for diff and format-patch commands.
Signed-off-by: Pascal Obry <pascal@obry.net>
Acked-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-06 20:03:09 -07:00
Christian Couder f2b3e3c722 test suite: remove useless TERM cruft in "t7005-editor.sh"
In commit 15387e3 (Test suite: reset TERM to its previous value after
testing., 2007-10-26), I added a workaround to reset TERM to its previous
value before the "test_done" at the end of "t7005-editor.sh" because
otherwise "test_done" would have printed the test result with a bad TERM
env variable (this resulted in output with no color on konsole).

But since commit c2116a1 (test-lib: fix TERM to dumb for test
repeatability, 2008-03-06), colored output is printed in a subshell with
TERM reset to its original value so the earlier workaround is not needed
anymore.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-06 20:02:43 -07:00
Pascal Obry d9e3b7025f Add interactive option in rebase command completion list.
Signed-off-by: Pascal Obry <pascal@obry.net>
Acked-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-06 20:01:17 -07:00
Junio C Hamano ee5a317e01 Fix "git apply" to correctly enforce "match at the beginning"
An earlier commit 4be6096 (apply --unidiff-zero: loosen sanity checks for
--unidiff=0 patches, 2006-09-17) made match_beginning and match_end
computed incorrectly.  If a hunk inserts at the beginning, old position
recorded at the hunk is line 0, and if a hunk changes at the beginning, it
is line 1.  The new test added to t4104 exposes that the old code did not
insist on matching at the beginning for a patch to add a line to an empty
file.

An even older 65aadb9 (apply: force matching at the beginning.,
2006-05-24) was equally wrong in that it tried to take hints from the
number of leading context lines, to decide if the hunk must match at the
beginning, but we can just look at the line number in the hunk to decide.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-06 19:21:45 -07:00
Peter Eriksen 9de328fea9 Add description of OFS_DELTA to the pack format description
Signed-off-by: Peter Eriksen <s022018@student.dtu.dk>
Acked-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-06 17:22:46 -07:00
Gerrit Pape 80dd7b4497 gitk: Fix changing colors through Edit->Preferences
With tcl/tk8.5 the lset command seems to behave differently.  When
changing the background color through Edit->Preferences, the changes
are applied, but new dialogs, such as View->New view... barf with

 Error: unknown color name "{#ffffff}"

Additionally when closing gitk, and starting it up again, a bad value
has been saved to ~/.gitk, preventing gitk from running properly; it
fails with

 Error in startup script: unknown color name "{#ffffff}"
 ...

This commit fixes the problem by changing the color dialogs to pass
the empty string {} as the list index to choosecolor.  This causes
the lset and lindex commands used by choosecolor to use and set the
whole variable (bgcolor, fgcolor or selectbgcolor) rather than
treating them as a 1-element list.  Tested with tcl/tk8.4 and 8.5.

Dmitry Potapov reported this problem through
 http://bugs.debian.org/472615

Signed-off-by: Gerrit Pape <pape@smarden.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2008-04-06 13:07:27 +10:00
Peter Eriksen ba1333fec3 git-pack-objects.txt: Make wording slightly less ambiguous
It is a bit confusing on first read, that

        "The packed archive format (.pack) is designed
        to be unpackable..."

Signed-off-by: Peter Eriksen <s022018@student.dtu.dk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-05 16:51:16 -07:00
Kevin Ballard f53423b0e0 git-fetch: Don't trigger a bus error when given the refspec "tag"
When git-fetch encounters the refspec "tag" it assumes that the next
argument will be a tag name. If there is no next argument, it should
die gracefully instead of erroring.

Signed-off-by: Kevin Ballard <kevin@sb.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-05 16:31:45 -07:00
Jakub Narebski 4ed4a34716 Revert "gitweb: Add 'status_str' to parse_difftree_raw_line output"
This reverts commit 6aa6f92fda.

It caused is_deleted() subroutine to output warnings when dealing with
old, legacy gitweb blobdiff URLs without either 'hb' or 'hpb'
parameters.

This fixes http://bugs.debian.org/469083

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-05 16:30:49 -07:00
Gerrit Pape 26ffcb7690 gitweb: fallback to system-wide config file (fixup)
The earlier one did not correctly propagate GITWEB_CONFIG_SYSTEM from
Makefile to generated gitweb.cgi script.

Signed-off-by: Gerrit Pape <pape@smarden.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-05 12:03:01 -07:00
Junio C Hamano 77ad7a49d3 Merge git://repo.or.cz/git-gui
* git://repo.or.cz/git-gui:
  git-gui: use +/- instead of ]/[ to show more/less context in diff
  git-gui: Update french translation
  git-gui: Switch keybindings for [ and ] to bracketleft and bracketright
2008-04-04 22:38:32 -07:00
Michele Ballabio 729ffa50f7 git-gui: use +/- instead of ]/[ to show more/less context in diff
On some systems, brackets cannot be used as event details
(they don't have a keysym), so use +/- instead (both on
keyboard and keypad) and add ctrl-= as a synonym of ctrl-+
for convenience.

[sp: Had to change accelerator to show only "$M1T-="; the
     original version included "$M1T-+ $M1T-=" but this is
	 not drawn at all on Mac OS X.]

Signed-off-by: Michele Ballabio <barra_cuda@katamail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-04-05 00:03:19 -04:00
Christian Couder ccb3b537cc git-gui: Update french translation
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-04-04 23:53:50 -04:00
Shawn O. Pearce 54906addfa git-gui: Switch keybindings for [ and ] to bracketleft and bracketright
Thanks to Michele Ballabio for the quick fix.
This resolves the error introduced by c91ee2bd61.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-04-03 21:38:12 -04:00
Junio C Hamano 6c41b80153 GIT 1.5.5-rc3
The rate of fixes that trickle in has slowed and we are definitely
getting there.  Hopefully one final round and we will have the final
1.5.5 soon.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-02 11:13:25 -07:00
Junio C Hamano eedb9d9eab Merge branch 'js/filter-branch'
* js/filter-branch:
  filter-branch: Fix renaming a directory in the tree-filter
  filter-branch: Test renaming directories in a tree-filter
2008-04-02 11:13:23 -07:00
Teemu Likonen cfc4ba33e3 Describe the bug in handling filenames with funny characters in 'git add -i'
The interactive mode does not work with files whose names contain
characters that need C-quoting.  `core.quotepath` configuration can be
used to work this limitation around to some degree, but backslash,
double-quote and control characters will still have problems.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-02 10:36:31 -07:00
Junio C Hamano 7ae512b7da Merge git://repo.or.cz/git-gui
* git://repo.or.cz/git-gui:
  git-gui 0.10
  git-gui: Add shortcut keys for Show More/Less Context
2008-04-02 10:29:10 -07:00
Junio C Hamano 5fbd0a44cf Merge branch 'bc/mktag'
* bc/mktag:
  mktag.c: tweak validation of tagger field and adjust test script
  mktag.c: improve verification of tagger field and tests
2008-04-02 00:23:19 -07:00
Junio C Hamano e0efa033c8 Merge branch 'pb/cvsserver'
* pb/cvsserver:
  git-cvsserver: handle change type T
2008-04-02 00:22:20 -07:00
Junio C Hamano 22e885e6d8 Merge branch 'dd/cvsserver'
* dd/cvsserver:
  cvsserver: Use the user part of the email in log and annotate results
  cvsserver: Add test for update -p
  cvsserver: Implement update -p (print to stdout)
  cvsserver: Add a few tests for 'status' command
  cvsserver: Do not include status output for subdirectories if -l is passed
  cvsserver: Only print the file part of the filename in status header
  cvsserver: Respond to the 'editors' and 'watchers' commands
2008-04-02 00:22:15 -07:00
Junio C Hamano 860bbd5039 Merge branch 'je/cvsserver'
* je/cvsserver:
  Allow git-cvsserver database table name prefix to be specified.
2008-04-02 00:22:06 -07:00
Johannes Sixt 64fb19ba63 t7004-tag: Skip more tests if gpg is not available.
This test was already careful enough to skip signed tag tests if gpg
is not available, but it must also skip all verify tests, even those
that are about non-signed tags, because they also invoke gpg.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-02 00:13:43 -07:00
Johannes Sixt 69fe5ef6c7 verify-tag: Clean up the temporary file if gpg cannot be started.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-02 00:08:30 -07:00
Christian Couder 4637e47acc help: Add a missing OPT_END().
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-01 23:40:06 -07:00
Junio C Hamano e85dc0a3c7 Accept git aliases outside a git repository
af05d67 (Always set *nongit_ok in setup_git_directory_gently(),
2008-03-25) had a change from the patch originally submitted that resulted
in disabling aliases outside a git repository.

It turns out that some people used "alias.fubar = diff --color-words" in
$HOME/.gitconfig to use non-index diff (or any command that do not need
git repository) outside git repositories, and this change broke them,
so this resurrects the support for such usage.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-01 23:40:02 -07:00
Shawn O. Pearce 3d654be48f git-gui 0.10
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-04-02 02:17:11 -04:00
Jonathan del Strother c91ee2bd61 git-gui: Add shortcut keys for Show More/Less Context
Bound to Ctrl/Cmd + left & right square brackets, depending on
your platform.

[sp: Added missing binds for . to allow shortcuts to work when
     not focused in the commit message area.]

Signed-off-by: Jonathan del Strother <jon.delStrother@bestbefore.tv>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-04-02 01:33:32 -04:00
Brandon Casey ba26ab99d4 mktag.c: tweak validation of tagger field and adjust test script
Update the verify_tag() function to remove an unnecessary test, and add
additional check for angle brackets in the name and email field, and
spaces in the email field. The timestamp and timezone sections are made
more straight forward by using strspn().

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-31 22:43:34 -07:00
veillette@yahoo.ca 6a589fda2e filter-branch: Fix renaming a directory in the tree-filter
Commit d89c1df (filter-branch: don't use xargs -0, 2008-03-12) replaced a
'ls-files | xargs rm' pipeline by 'git clean'. 'git clean' however does
not recurse and remove directories by default.

Now, consider a tree-filter that renames a directory.

  1. For the first commit everything works as expected

  2. Then filter-branch checks out the files for the next commit. This
     leaves the new directory behind because there is no real "branch
     switching" involved that would notice that the directory can be
     removed.

  3. Then filter-branch invokes 'git clean' to remove exactly those
     left-overs. But here it does not remove the directory.

  4. The next tree-filter does not work as expected because there already
     exists a directory with the new name.

Just add -d to 'git clean', so that empty directories are removed.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-31 01:09:50 -07:00
Johannes Sixt 90356287e6 filter-branch: Test renaming directories in a tree-filter
This test currently fails.

If b is a directory then 'mv a b' is not a plain "rename", but really a
"move", so we must also test that the directory does not exist with the
old name in the directory with the new name.

There's also some cleanup in the corresponding "rename file" test to avoid
spurious shell syntax errors and "ambigous ref" error from 'git show' (but
these should show up only if the test would fail anyway). Plus we also
test for the non-existence of the old file.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2008-03-31 01:03:05 -07:00
Brandon Casey e0aaf781f6 mktag.c: improve verification of tagger field and tests
Since nearly its birth, git's tags have included a "tagger" field which
describes the name of tagger, email of tagger, and date and time of tagging.
But, this field was only loosely tested by git-mktag. Provide some thorough
testing for this field and also ensure that the tag header is separated
from the tag body by an empty line to reduce the convenience of creating
a flawed tag.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-30 22:54:09 -07:00
Junio C Hamano f58dbf23c3 diff-files: careful when inspecting work tree items
This fixes the same breakage in diff-files.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-30 22:22:09 -07:00
Junio C Hamano 948dd346fd diff-index: careful when inspecting work tree items
Earlier, if you changed a staged path into a directory in the work tree,
we happily ran lstat(2) on it and found that it exists, and declared that
the user changed it to a gitlink.

This is wrong for two reasons:

 (1) It may be a directory, but it may not be a submodule, and in the
     latter case, the change we need to report is "the blob at the path
     has disappeared".  We need to check with resolve_gitlink_ref() to be
     consistent with what "git add" and "git update-index --add" does.

 (2) lstat(2) may have succeeded only because a leading component of the
     path was turned into a symbolic link that points at something that
     exists in the work tree.  In such a case, the path itself does not
     exist anymore, as far as the index is concerned.

This fixes these breakages in diff-index that the previous patch has
exposed.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-30 22:22:09 -07:00
Junio C Hamano 6301f303d4 Add corner case tests for diff-index and diff-files
diff-index and diff-files can get confused in corner cases when an indexed
blob turns into something else in the work tree.  This patch adds tests to
expose such breakages.

The test is classified under t2XXX series instead of t4XXX series, because
the ultimate objective is to fix "add -u" (and "commit -a" that shares the
same issue).

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-30 22:22:09 -07:00
Josh Elsasser 6aeeffd144 Allow git-cvsserver database table name prefix to be specified.
Adds a gitcvs.dbtablenameprefix config variable, the contents of which
are prepended to any database tables names used by git-cvsserver. The
same substutions as gitcvs.dbname and gitcvs.dbuser are supported, and
any non-alphabetic characters are replaced with underscores.

A typo found in contrib/completion/git-completion.bash is also fixed.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-30 22:21:35 -07:00
Bryan Donlan c20711d29d Silence cpio's "N blocks" output when cloning locally
Pass --quiet to cpio in git-clone to hide the (confusing) "0 blocks" message.
For compatibility with operating systems which might not support GNUisms,
the presence of --quiet is probed for by grepping cpio's --help output.

Signed-off-by: Bryan Donlan <bdonlan@fushizen.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-30 22:21:06 -07:00
Eric Wong 67dac28b90 git-svn: remove redundant slashes from show-ignore
Jonathan Scott Duff wrote:

> Recently I tried "git svn showignore" on my parrot repository and it
> failed.  I tracked it down to the prop_walk() sub.  When it recurses,
> $path has an extra / on the beginning (i.e., when it recurses, it
> tries to get the props for "//apps" instead of "/apps").   I *think*
> this is because $path is used in the recursive call rather than $p
> (which seems to contain a properly transformed $path).  Anyway, I've
> attached a patch that works for me and I think is generally the right
> thing.

Patch-submitted-by: Jonathan Scott Duff
Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-30 22:03:05 -07:00