Commit graph

2190 commits

Author SHA1 Message Date
Junio C Hamano c9d8563c81 Merge branch 'bc/maint-keep-pack'
* bc/maint-keep-pack:
  repack: only unpack-unreachable if we are deleting redundant packs
2008-11-16 00:49:02 -08:00
Junio C Hamano 47a792539a Merge branch 'jk/commit-v-strip'
* jk/commit-v-strip:
  status: show "-v" diff even for initial commit
  wt-status: refactor initial commit printing
  define empty tree sha1 as a macro
2008-11-16 00:48:59 -08:00
Brandon Casey 83d0289df6 repack: only unpack-unreachable if we are deleting redundant packs
The -A option calls pack-objects with the --unpack-unreachable option so
that the unreachable objects in local packs are left in the local object
store loose. But if the -d option to repack was _not_ used, then these
unpacked loose objects are redundant and unnecessary.

Update tests in t7701.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-14 21:39:10 -08:00
Junio C Hamano a0d3ab9c27 Merge git://git.bogomips.org/git-svn
* git://git.bogomips.org/git-svn:
  git-svn: proper detection of bare repositories
  git-svn: respect i18n.commitencoding config
  git-svn: don't escape tilde ('~') for http(s) URLs
2008-11-13 22:30:17 -08:00
Junio C Hamano 6d14414d21 Merge branch 'jk/maint-commit-v-strip'
* jk/maint-commit-v-strip:
  commit: Fix stripping of patch in verbose mode.
2008-11-12 22:26:56 -08:00
Junio C Hamano 7b51b77dbc Merge branch 'np/pack-safer'
* np/pack-safer:
  t5303: fix printf format string for portability
  t5303: work around printf breakage in dash
  pack-objects: don't leak pack window reference when splitting packs
  extend test coverage for latest pack corruption resilience improvements
  pack-objects: allow "fixing" a corrupted pack without a full repack
  make find_pack_revindex() aware of the nasty world
  make check_object() resilient to pack corruptions
  make packed_object_info() resilient to pack corruptions
  make unpack_object_header() non fatal
  better validation on delta base object offsets
  close another possibility for propagating pack corruption
2008-11-12 22:26:35 -08:00
Junio C Hamano 3fdd37fe15 Merge branch 'mk/maint-cg-push'
* mk/maint-cg-push:
  git push: Interpret $GIT_DIR/branches in a Cogito compatible way

Conflicts:
	t/t5516-fetch-push.sh
2008-11-12 22:26:24 -08:00
Junio C Hamano ecbbfb15a4 Merge branch 'bc/maint-keep-pack'
* bc/maint-keep-pack:
  t7700: test that 'repack -a' packs alternate packed objects
  pack-objects: extend --local to mean ignore non-local loose objects too
  sha1_file.c: split has_loose_object() into local and non-local counterparts
  t7700: demonstrate mishandling of loose objects in an alternate ODB
  builtin-gc.c: use new pack_keep bitfield to detect .keep file existence
  repack: do not fall back to incremental repacking with [-a|-A]
  repack: don't repack local objects in packs with .keep file
  pack-objects: new option --honor-pack-keep
  packed_git: convert pack_local flag into a bitfield and add pack_keep
  t7700: demonstrate mishandling of objects in packs with a .keep file
2008-11-12 22:00:43 -08:00
Junio C Hamano a5b2d4ac24 Merge branch 'mv/remote-rename'
* mv/remote-rename:
  git-remote: document the migration feature of the rename subcommand
  git-remote rename: migrate from remotes/ and branches/
  remote: add a new 'origin' variable to the struct
  Implement git remote rename
2008-11-12 22:00:25 -08:00
Junio C Hamano 902a4a252a Merge branch 'jk/deny-push-to-current'
* jk/deny-push-to-current:
  receive-pack: detect push to current branch of non-bare repo
  t5516: refactor oddball tests
2008-11-12 21:56:14 -08:00
Junio C Hamano 72b6157aa8 Merge branch 'jk/diff-convfilter'
* jk/diff-convfilter:
  enable textconv for diff in verbose status/commit
  wt-status: load diff ui config
  only textconv regular files
  userdiff: require explicitly allowing textconv
  refactor userdiff textconv code

Conflicts:
	t/t4030-diff-textconv.sh
2008-11-12 21:50:58 -08:00
Junio C Hamano 459d60084f Merge branch 'jk/diff-convfilter-test-fix'
* jk/diff-convfilter-test-fix:
  Avoid using non-portable `echo -n` in tests.
  add userdiff textconv tests
  document the diff driver textconv feature
  diff: add missing static declaration

Conflicts:
	Documentation/gitattributes.txt
2008-11-12 21:50:41 -08:00
Junio C Hamano df5e12f7d4 Merge branch 'st/tag'
* st/tag:
  tag: Add more tests about mixing incompatible modes and options
  tag: Check that options are only allowed in the appropriate mode
2008-11-12 21:49:25 -08:00
Brandon Casey 3289b9dec5 t7700: test that 'repack -a' packs alternate packed objects
Previously, when 'repack -a' was called and there were no packs in the local
repository without a .keep file, the repack would fall back to calling
pack-objects with '--unpacked --incremental'. This resulted in the created
pack file, if any, to be missing the packed objects in the alternate object
store. Test that this specific case has been fixed.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-12 17:29:41 -08:00
Junio C Hamano 6cd3729eae Merge branch 'maint'
* maint:
  Start 1.6.0.5 cycle
  Fix pack.packSizeLimit and --max-pack-size handling
  checkout: Fix "initial checkout" detection
  Remove the period after the git-check-attr summary

Conflicts:
	RelNotes
2008-11-12 15:03:57 -08:00
Nicolas Pitre a1e4760fcf Fix pack.packSizeLimit and --max-pack-size handling
If the limit was sufficiently low, having a single object written
could bust the limit (by design), but caused the remaining allowed
size to go negative for subsequent objects, which for an unsigned
variable is a rather huge limit.

Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-12 14:55:03 -08:00
Jeff King 1324fb6f16 status: show "-v" diff even for initial commit
Since we can use the same "diff against empty tree" trick as
we do for the non-initial case, it is trivial to make this
work.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-12 13:55:17 -08:00
Junio C Hamano 4deca329f5 Merge branch 'jk/maint-commit-v-strip' into jk/commit-v-strip
* jk/maint-commit-v-strip:
  commit: Fix stripping of patch in verbose mode.
2008-11-12 13:54:53 -08:00
Jeff King 0b38227f28 commit: Fix stripping of patch in verbose mode.
When the "-v" option is given, we put diff of what is to be committed into
the commit template, and then strip it back out again after the user has
edited it.

We used to look for the diff by searching for the "diff --git a/"
header. With diff.mnemonicprefix set in the configuration, however, this
pattern does not match.  The pattern is loosened to cover this case.

Also, if the user puts their own diff in the message (e.g., as a sample
output), then we will accidentally trigger the pattern, removing part of
their output.

We can avoid doing this stripping altogether if the user didn't use "-v"
in the first place, so we know that any match we find will be a false
positive.

[jc: this fix was split out of a series originally meant for master.]

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-12 13:54:31 -08:00
Brandon Casey daae062595 pack-objects: extend --local to mean ignore non-local loose objects too
With this patch, --local means pack only local objects that are not already
packed.

Additionally, this fixes t7700 testing whether loose objects in an alternate
object database are repacked.

Signed-off-by: Brandon Casey <drafnel@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-12 10:29:22 -08:00
Brandon Casey 3c3df42910 t7700: demonstrate mishandling of loose objects in an alternate ODB
Loose objects residing in an alternate object database should not be packed
when the -l option to repack is used.

Signed-off-by: Brandon Casey <drafnel@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-12 10:29:22 -08:00
Brandon Casey dd718365cc repack: don't repack local objects in packs with .keep file
If the user created a .keep file for a local pack, then it can be inferred
that the user does not want those objects repacked.

This fixes the repack bug tested by t7700.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-12 10:28:12 -08:00
Brandon Casey 9245ddd515 t7700: demonstrate mishandling of objects in packs with a .keep file
Objects residing in pack files that have an associated .keep file are not
supposed to be repacked into new pack files, but they are.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-12 10:28:06 -08:00
Miklos Vajna 1dd1239aa3 git-remote rename: migrate from remotes/ and branches/
Remote definition that came from $GIT_DIR/remotes/nick and
$GIT_DIR/branches/nick are migrated to [remotes "nick"] section in the
configuration file.

Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-11 20:24:18 -08:00
Martin Koegler 18afe101eb git push: Interpret $GIT_DIR/branches in a Cogito compatible way
Current git versions ignore everything after # (called <head> in the
following) when pushing. Older versions (before cf818348f1),
interpret #<head> as part of the URL, which make git bail out.

As branches origin from Cogito, it is the best to correct this by using
the behaviour of cg-push, that is to push HEAD to remote refs/heads/<head>.

Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-11 15:26:40 -08:00
Junio C Hamano a2d2c478f3 t5303: fix printf format string for portability
printf "\x01" is bad; write printf "\001" for portability.

Testing with dash is a good way to find this kind of POSIX.1 violation
breakages.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-09 13:11:06 -08:00
Junio C Hamano 8c1f6f6c57 t5303: work around printf breakage in dash
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-09 13:08:38 -08:00
Junio C Hamano a9645b780b Merge branch 'maint'
* maint:
  Documentation: bisect: change a few instances of "git-cmd" to "git cmd"
  Documentation: rev-list: change a few instances of "git-cmd" to "git cmd"
  checkout: Don't crash when switching away from an invalid branch.
2008-11-09 10:56:26 -08:00
Jeff King 986e82396a receive-pack: detect push to current branch of non-bare repo
Pushing into the currently checked out branch of a non-bare
repository can be dangerous; the HEAD then loses sync with
the index and working tree, and it looks in the receiving
repo as if the pushed changes have been reverted in the
index (since they were never there in the first place).

This patch adds a safety valve that checks for this
condition and either generates a warning or denies the
update. We trigger the check only on a non-bare repository,
since a bare repo does not have a working tree (and in fact,
pushing to the HEAD branch is a common workflow for
publishing repositories).

The behavior is configurable via receive.denyCurrentBranch,
defaulting to "warn" so as not to break existing setups
(though it may, after a deprecation period, switch to
"refuse" by default). For users who know what they are doing
and want to silence the warning (e.g., because they have a
post-receive hook that reconciles the HEAD and working
tree), they can turn off the warning by setting it to false
or "ignore".

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-09 10:16:50 -08:00
Jeff King b2dc968e60 t5516: refactor oddball tests
t5516 sets up some utility functions for starting each test
with a clean slate. However, there were a few tests added
that do not use these functions, but instead make their own
repositories.

Let's bring these in line with the rest of the tests. Not
only do we reduce the number of lines, but these tests will
benefit from any further enhancements to the utility
scripts.

The conversion is pretty straightforward. Most of the tests
created a parent/child clone relationship, for which we now
use 'testrepo' as the parent.  One test looked in testrepo,
but relied on previous tests to have set it up; it now sets
up testrepo explicitly, which makes it a bit more robust to
changes in the script, as well.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-09 10:14:57 -08:00
Alexandre Julliard 323e00fd46 checkout: Don't crash when switching away from an invalid branch.
When using alternates, it is possible for HEAD to end up pointing to
an invalid commit. git checkout should be able to recover from that
situation without crashing.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-09 10:11:39 -08:00
Junio C Hamano bc9c0248a5 Merge branch 'maint'
* maint:
  GIT 1.6.0.4
  Update RPM spec for the new location of git-cvsserver.
  push: fix local refs update if already up-to-date
  do not force write of packed refs

Conflicts:
	builtin-revert.c
2008-11-08 21:33:55 -08:00
Junio C Hamano 832e719d79 Merge branch 'cb/maint-update-ref-fix' into maint
* cb/maint-update-ref-fix:
  push: fix local refs update if already up-to-date
  do not force write of packed refs
2008-11-08 17:32:49 -08:00
Junio C Hamano 3b8572a429 Merge branch 'mv/maint-branch-m-symref' into maint
* mv/maint-branch-m-symref:
  update-ref --no-deref -d: handle the case when the pointed ref is packed
  git branch -m: forbid renaming of a symref
  Fix git update-ref --no-deref -d.
  rename_ref(): handle the case when the reflog of a ref does not exist
  Fix git branch -m for symrefs.
2008-11-08 16:07:37 -08:00
Jeff King 6abe9c87c7 t5400: expect success for denying deletion
Commit a240de11 introduced this test and the code to make it
successful.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-08 16:02:32 -08:00
Deskin Miller 6e5121f26e git-svn: proper detection of bare repositories
When in a bare repository (or .git, for that matter), git-svn would fail
to initialise properly, since git rev-parse --show-cdup would not output
anything.  However, git rev-parse --show-cdup actually returns an error
code if it's really not in a git directory.

Fix the issue by checking for an explicit error from git rev-parse, and
setting $git_dir appropriately if instead it just does not output.

Signed-off-by: Deskin Miller <deskinm@umich.edu>
Acked-by: Eric Wong <normalperson@yhbt.net>
2008-11-06 01:39:41 -08:00
Eric Wong aab5720551 git-svn: respect i18n.commitencoding config
SVN itself always stores log messages in the repository as
UTF-8.  git always stores/retrieves everything as raw binary
data with no transformations whatsoever.

To interact with SVN, we need to encode log messages as UTF-8
before sending them to SVN, as SVN cannot do it for us.  When
retrieving log messages from SVN, we also need to (attempt to)
reencode the UTF-8 log message back to the user-specified commit
encoding.

Note, handling i18n.logoutputencoding for "git svn log" also
needs to be done in a future change.

Also, this change only deals with the encoding of commit
messages and nothing else (path names, blob content, ...).

In-Reply-To: <8b168cfb0810282014r789ac01dnec51824de1078f0@mail.gmail.com>
James North <tocapicha@gmail.com> wrote:
> Hi,
>
> I'm using git-svn on a system with ISO-8859-1 encoding. The problem is
> when I try to use "git svn dcommit" to send changes to a remote svn
> (also ISO-8859-1).
>
> Seems like git-svn is sending commit messages with utf-8 (just a
> guessing...) and they look bad on the remote svn log. E.g. "Ca?\241a
> de cami?\243n"
>
> I have tried using i18n.commitencoding=ISO-8859-1 as suggested by the
> warning when doing "git svn dcommit" but messages still are sent with
> wrong encoding.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2008-11-06 00:52:18 -08:00
Clemens Buchacher 16ed2f48be push: fix local refs update if already up-to-date
git push normally updates local refs only after a successful push. If the
remote already has the updates -- pushed indirectly through another repository,
for example -- we forget to update local tracking refs.

Signed-off-by: Clemens Buchacher <drizzd@aon.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-05 14:22:10 -08:00
Clemens Buchacher 5bdd8d4a30 do not force write of packed refs
We force writing a ref if it does not exist. Originally, we only had to look
for the ref file to check if it existed. Now we have to look for a packed ref
as well. Luckily, resolve_ref already does all the work for us.

Signed-off-by: Clemens Buchacher <drizzd@aon.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-05 14:09:43 -08:00
Miklos Vajna bf98421a33 Implement git remote rename
The new rename subcommand does the followings:

1) Renames the remote.foo configuration section to remote.bar

2) Updates the remote.bar.fetch refspecs

3) Updates the branch.*.remote settings

4) Renames the tracking branches: renames the normal refs and rewrites
   the symrefs to point to the new refs.

Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-05 12:23:48 -08:00
Junio C Hamano efcce2e1f0 Merge branch 'mv/maint-branch-m-symref'
* mv/maint-branch-m-symref:
  update-ref --no-deref -d: handle the case when the pointed ref is packed
  git branch -m: forbid renaming of a symref
  Fix git update-ref --no-deref -d.
  rename_ref(): handle the case when the reflog of a ref does not exist
  Fix git branch -m for symrefs.
2008-11-05 11:33:19 -08:00
Samuel Tardieu e0e03a731b tag: Add more tests about mixing incompatible modes and options
Signed-off-by: Samuel Tardieu <sam@rfc1149.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-04 15:46:47 -08:00
Junio C Hamano 275ee50c81 Merge branch 'np/index-pack'
* np/index-pack:
  index-pack: don't leak leaf delta result
  improve index-pack tests
  fix multiple issues in index-pack
  index-pack: smarter memory usage during delta resolution
  index-pack: rationalize delta resolution code
2008-11-02 16:36:37 -08:00
Junio C Hamano 7ff866eb1b Merge branch 'sh/rebase-i-p'
* sh/rebase-i-p:
  git-rebase--interactive.sh: comparision with == is bashism
  rebase-i-p: minimum fix to obvious issues
  rebase-i-p: if todo was reordered use HEAD as the rewritten parent
  rebase-i-p: do not include non-first-parent commits touching UPSTREAM
  rebase-i-p: only list commits that require rewriting in todo
  rebase-i-p: fix 'no squashing merges' tripping up non-merges
  rebase-i-p: delay saving current-commit to REWRITTEN if squashing
  rebase-i-p: use HEAD for updating the ref instead of mapping OLDHEAD
  rebase-i-p: test to exclude commits from todo based on its parents
2008-11-02 16:36:33 -08:00
Junio C Hamano 0eb5ebc1d8 Merge branch 'ag/blame-encoding'
* ag/blame-encoding:
  builtin-blame: Reencode commit messages according to git-log rules.
2008-11-02 16:36:30 -08:00
Nicolas Pitre 538cf6b6e5 extend test coverage for latest pack corruption resilience improvements
Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-02 15:22:35 -08:00
Nicolas Pitre 0e8189e270 close another possibility for propagating pack corruption
Abstract
--------

With index v2 we have a per object CRC to allow quick and safe reuse of
pack data when repacking.  This, however, doesn't currently prevent a
stealth corruption from being propagated into a new pack when _not_
reusing pack data as demonstrated by the modification to t5302 included
here.

The Context
-----------

The Git database is all checksummed with SHA1 hashes.  Any kind of
corruption can be confirmed by verifying this per object hash against
corresponding data.  However this can be costly to perform systematically
and therefore this check is often not performed at run time when
accessing the object database.

First, the loose object format is entirely compressed with zlib which
already provide a CRC verification of its own when inflating data.  Any
disk corruption would be caught already in this case.

Then, packed objects are also compressed with zlib but only for their
actual payload.  The object headers and delta base references are not
deflated for obvious performance reasons, however this leave them
vulnerable to potentially undetected disk corruptions.  Object types
are often validated against the expected type when they're requested,
and deflated size must always match the size recorded in the object header,
so those cases are pretty much covered as well.

Where corruptions could go unnoticed is in the delta base reference.
Of course, in the OBJ_REF_DELTA case,  the odds for a SHA1 reference to
get corrupted so it actually matches the SHA1 of another object with the
same size (the delta header stores the expected size of the base object
to apply against) are virtually zero.  In the OBJ_OFS_DELTA case, the
reference is a pack offset which would have to match the start boundary
of a different base object but still with the same size, and although this
is relatively much more "probable" than in the OBJ_REF_DELTA case, the
probability is also about zero in absolute terms.  Still, the possibility
exists as demonstrated in t5302 and is certainly greater than a SHA1
collision, especially in the OBJ_OFS_DELTA case which is now the default
when repacking.

Again, repacking by reusing existing pack data is OK since the per object
CRC provided by index v2 guards against any such corruptions. What t5302
failed to test is a full repack in such case.

The Solution
------------

As unlikely as this kind of stealth corruption can be in practice, it
certainly isn't acceptable to propagate it into a freshly created pack.
But, because this is so unlikely, we don't want to pay the run time cost
associated with extra validation checks all the time either.  Furthermore,
consequences of such corruption in anything but repacking should be rather
visible, and even if it could be quite unpleasant, it still has far less
severe consequences than actively creating bad packs.

So the best compromize is to check packed object CRC when unpacking
objects, and only during the compression/writing phase of a repack, and
only when not streaming the result.  The cost of this is minimal (less
than 1% CPU time), and visible only with a full repack.

Someone with a stats background could provide an objective evaluation of
this, but I suspect that it's bad RAM that has more potential for data
corruptions at this point, even in those cases where this extra check
is not performed.  Still, it is best to prevent a known hole for
corruption when recreating object data into a new pack.

What about the streamed pack case?  Well, any client receiving a pack
must always consider that pack as untrusty and perform full validation
anyway, hence no such stealth corruption could be propagated to remote
repositoryes already.  It is therefore worthless doing local validation
in that case.

Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-02 15:22:15 -08:00
Junio C Hamano f6276b788f Merge branch 'js/maint-fetch-update-head' into maint
* js/maint-fetch-update-head:
  pull: allow "git pull origin $something:$current_branch" into an unborn branch
  Fix fetch/pull when run without --update-head-ok
2008-11-02 13:37:16 -08:00
Junio C Hamano 86e67a088c Merge branch 'jk/maint-ls-files-other' into maint
* jk/maint-ls-files-other:
  refactor handling of "other" files in ls-files and status
2008-11-02 13:37:13 -08:00
Junio C Hamano d11ddaff02 Merge branch 'jc/maint-reset-remove-unmerged-new' into maint
* jc/maint-reset-remove-unmerged-new:
  reset --hard/read-tree --reset -u: remove unmerged new paths
2008-11-02 13:36:20 -08:00