1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-11-01 06:47:52 +01:00
Commit graph

14499 commits

Author SHA1 Message Date
Junio C Hamano
c04a7155a0 diff: make --dirstat binary-file safe
Instead of counting added and removed lines (and mixing the byte size
reported for binary files in the result), summarize the extent of damage
the same way as we count similarity for rename detection.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-09 01:25:28 -07:00
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
Lars Hjemli
c48799e560 Teach GIT-VERSION-GEN about the .git file
The presence of a .git directory used to be good enough evidence that
GIT-VERSION-GEN could use 'git describe' to get a version number. But
now .git might as well be a file so the test must be extended to cater for
such setups.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-09 01:22:50 -07:00
Lars Hjemli
ba88a1fee4 Teach git-submodule.sh about the .git file
When git-submodule tries to detect 'active' submodules, it checks for the
existence of a directory named '.git'. This isn't good enough now that .git
can be a file pointing to the real $GIT_DIR so the tests are changed to
reflect this.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-09 01:22:50 -07:00
Lars Hjemli
842abf06f3 Teach resolve_gitlink_ref() about the .git file
When .git in a submodule is a file, resolve_gitlink_ref() needs to pick up
the real GIT_DIR of the submodule from that file.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-09 01:22:50 -07:00
Lars Hjemli
b44ebb19e3 Add platform-independent .git "symlink"
This patch allows .git to be a regular textfile containing the path of
the real git directory (prefixed with "gitdir: "), which can be useful on
platforms lacking support for real symlinks.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-09 01:22:50 -07:00
Linus Torvalds
1102952b45 Make git-add behave more sensibly in a case-insensitive environment
This expands on the previous patch, and allows "git add" to sanely handle
a filename that has changed case, keeping the case in the index constant,
and avoiding aliases.

In particular, if you have an index entry called "File", but the
checked-out tree is case-corrupted and has an entry called "file"
instead, doing a

	git add .

(or naming "file" explicitly) will automatically notice that we have an
alias, and will replace the name "file" with the existing index
capitalization (ie "File").

However, if we actually have *both* a file called "File" and one called
"file", and they don't have the same lstat() information (ie we're on a
case-sensitive filesystem but have the "core.ignorecase" flag set), we
will error out if we try to add them both.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-09 01:22:25 -07:00
Linus Torvalds
6835550def When adding files to the index, add support for case-independent matches
This simplifies the matching case of "I already have this file and it is
up-to-date" and makes it do the right thing in the face of
case-insensitive aliases.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-09 01:22:25 -07:00
Linus Torvalds
1fa6ead492 Make unpack-tree update removed files before any updated files
This is immaterial on sane filesystems, but if you have a broken (aka
case-insensitive) filesystem, and the objective is to remove the file
'abc' and replace it with the file 'Abc', then we must make sure to do
the removal first.

Otherwise, you'd first update the file 'Abc' - which would just
overwrite the file 'abc' due to the broken case-insensitive filesystem -
and then remove file 'abc' - which would now brokenly remove the just
updated file 'Abc' on that broken filesystem.

By doing removals first, this won't happen.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-09 01:22:25 -07:00
Linus Torvalds
32260ad5db Make branch merging aware of underlying case-insensitive filsystems
If we find an unexpected file, see if that filename perhaps exists in a
case-insensitive way in the index, and whether the file matches that. If
so, ignore it as a known pre-existing file of a different name.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-09 01:22:25 -07:00
Linus Torvalds
0a9b88b7de Add 'core.ignorecase' option
..and start using it for directory entry traversal (ie "git status" will
not consider entries that match an existing entry case-insensitively to
be a new file)

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-09 01:22:25 -07:00
Linus Torvalds
cd2fef59ed Make hash_name_lookup able to do case-independent lookups
Right now nobody uses it, but "index_name_exists()" gets a flag so
you can enable it on a case-by-case basis.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-09 01:22:25 -07:00
Linus Torvalds
df292c791a Make "index_name_exists()" return the cache_entry it found
This allows verify_absent() in unpack_trees() to use the hash chains
rather than looking it up using the binary search.

Perhaps more importantly, it's also going to be useful for the next phase,
where we actually start looking at the cache entry when we do
case-insensitive lookups and checking the result.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-09 01:22:25 -07:00
Linus Torvalds
96872bc200 Move name hashing functions into a file of its own
It's really totally separate functionality, and if we want to start
doing case-insensitive hash lookups, I'd rather do it when it's
separated out.

It also renames "remove_index_entry()" to "remove_name_hash()", because
that really describes the thing better. It doesn't actually remove the
index entry, that's done by "remove_index_entry_at()", which is something
very different, despite the similarity in names.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-09 01:22:25 -07:00
Linus Torvalds
75dc6c7cb8 Make unpack_trees_options bit flags actual bitfields
Instead of wasting space with whole integers for a single bit.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-09 01:22:25 -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