Commit graph

19996 commits

Author SHA1 Message Date
Junio C Hamano 39eea7bdd9 Fix incorrect error check while reading deflated pack data
The loop in get_size_from_delta() feeds a deflated delta data from the
pack stream _until_ we get inflated result of 20 bytes[*] or we reach the
end of stream.

    Side note. This magic number 20 does not have anything to do with the
    size of the hash we use, but comes from 1a3b55c (reduce delta head
    inflated size, 2006-10-18).

The loop reads like this:

    do {
        in = use_pack();
        stream.next_in = in;
        st = git_inflate(&stream, Z_FINISH);
        curpos += stream.next_in - in;
    } while ((st == Z_OK || st == Z_BUF_ERROR) &&
             stream.total_out < sizeof(delta_head));

This git_inflate() can return:

 - Z_STREAM_END, if use_pack() fed it enough input and the delta itself
   was smaller than 20 bytes;

 - Z_OK, when some progress has been made;

 - Z_BUF_ERROR, if no progress is possible, because we either ran out of
   input (due to corrupt pack), or we ran out of output before we saw the
   end of the stream.

The fix b3118bd (sha1_file: Fix infinite loop when pack is corrupted,
2009-10-14) attempted was against a corruption that appears to be a valid
stream that produces a result larger than the output buffer, but we are
not even trying to read the stream to the end in this loop.  If avail_out
becomes zero, total_out will be the same as sizeof(delta_head) so the loop
will terminate without the "fix".  There is no fix from b3118bd needed for
this loop, in other words.

The loop in unpack_compressed_entry() is quite a different story.  It
feeds a deflated stream (either delta or base) and allows the stream to
produce output up to what we expect but no more.

    do {
        in = use_pack();
        stream.next_in = in;
        st = git_inflate(&stream, Z_FINISH);
        curpos += stream.next_in - in;
    } while (st == Z_OK || st == Z_BUF_ERROR)

This _does_ risk falling into an endless interation, as we can exhaust
avail_out if the length we expect is smaller than what the stream wants to
produce (due to pack corruption).  In such a case, avail_out will become
zero and inflate() will return Z_BUF_ERROR, while avail_in may (or may
not) be zero.

But this is not a right fix:

    do {
        in = use_pack();
        stream.next_in = in;
        st = git_inflate(&stream, Z_FINISH);
+       if (st == Z_BUF_ERROR && (stream.avail_in || !stream.avail_out)
+               break; /* wants more input??? */
        curpos += stream.next_in - in;
    } while (st == Z_OK || st == Z_BUF_ERROR)

as Z_BUF_ERROR from inflate() may be telling us that avail_in has also run
out before reading the end of stream marker.  In such a case, both avail_in
and avail_out would be zero, and the loop should iterate to allow the end
of stream marker to be seen by inflate from the input stream.

The right fix for this loop is likely to be to increment the initial
avail_out by one (we allocate one extra byte to terminate it with NUL
anyway, so there is no risk to overrun the buffer), and break out if we
see that avail_out has become zero, in order to detect that the stream
wants to produce more than what we expect.  After the loop, we have a
check that exactly tests this condition:

    if ((st != Z_STREAM_END) || stream.total_out != size) {
        free(buffer);
        return NULL;
    }

So here is a patch (without my previous botched attempts) to fix this
issue.  The first hunk reverts the corresponding hunk from b3118bd, and
the second hunk is the same fix proposed earlier.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-21 23:19:47 -07:00
Junio C Hamano 3694209ca1 Merge branch 'maint'
* maint:
  Document `delta` attribute in "git help attributes".
  Mark files in t/t5100 as UTF-8
  Remove a left-over file from t/t5100
2009-10-21 17:33:15 -07:00
Junio C Hamano 8e850a4dbd Merge branch 'gb/maint-gitweb-esc-param'
* gb/maint-gitweb-esc-param:
  gitweb: fix esc_param
2009-10-21 17:32:59 -07:00
Björn Gustavsson 550c66f3f9 git-clone.txt: Fix grammar and formatting
Add the missing definite article ("the") in several places.

Change "note to..." to "note for...", since "note to" means that
that the note is addressed to someone (source: Google search).

Change "progressbar" to "progress bar" (source: Wikipedia).

Format git commands, options, and file names consistently using
back quotes (i.e. a fixed font in the resulting HTML document).

Signed-off-by: Björn Gustavsson <bgustavsson@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-21 17:16:08 -07:00
Ingmar Vanhassel 2a94552887 import-tars: Add support for tarballs compressed with lzma, xz
Also handle the extensions .tlz and .txz, aliases for .tar.lzma and
.tar.xz respectively.

Signed-off-by: Ingmar Vanhassel <ingmar@exherbo.org>
Liked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-21 17:15:43 -07:00
Junio C Hamano 77e3efbf43 receive-pack: run "gc --auto --quiet" and optionally "update-server-info"
Introduce two new configuration variables, receive.autogc (defaults to
true) and receive.updateserverinfo (defaults to false).  When these are
set, receive-pack runs "gc --auto --quiet" and "update-server-info"
respectively after it finishes receiving data from "git push" and updating
refs.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Acked-by: Nicolas Pitre <nico@fluxnic.net>
2009-10-21 15:32:32 -07:00
Junio C Hamano dad5f89fc5 gc --auto --quiet: make the notice a bit less verboase
When "gc --auto --quiet" decides there is something to do, it tells the
user what it is doing, as it is going to make the user wait for a bit.

But the message was a bit too long.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-21 15:28:42 -07:00
Junio C Hamano 46148dd7ea git checkout --no-guess
Porcelains may want to make sure their calls to "git checkout" will
reliably fail regardless of the presense of random remote tracking
branches by the new DWIMmery introduced.

Luckily all existing in-tree callers have extra checks to make sure they
feed local branch name when they want to switch, or they explicitly ask to
detach HEAD at the given commit, so there is no need to add this option
for them.

As this is strictly script-only option, do not even bother to document it,
and do bother to hide it from "git checkout -h".

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-21 15:17:24 -07:00
Jari Aalto 6b276e19fa Documentation/fetch-options.txt: order options alphabetically
git-fetch.{1,html} will be helped with this patch

Signed-off-by: Jari Aalto <jari.aalto@cante.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-21 15:12:01 -07:00
Clemens Buchacher d504f6975d modernize fetch/merge/pull examples
The "git pull" documentation has examples which follow an outdated
style. Update the examples to use "git merge" where appropriate and
move the examples to the corresponding manpages.

Furthermore,

 - show that pull is equivalent to fetch and merge, which is still a
   frequently asked question,

 - explain the default fetch refspec.

Signed-off-by: Clemens Buchacher <drizzd@aon.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-21 14:20:50 -07:00
Nasser Grainawi 975457f185 Document delta attribute in "git help attributes".
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-21 14:07:44 -07:00
Johannes Sixt 814a9bfee9 Mark files in t/t5100 as UTF-8
This enables gitk to show the patch text with correct glyphs if the locale
is not UTF-8.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-21 11:27:50 -07:00
Johannes Sixt 66bcb6a68f Remove a left-over file from t/t5100
This mbox file must have been added by accident in e9fe804 (git-mailinfo:
Fix getting the subject from the in-body [PATCH] line, 2008-07-14).

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-21 11:27:48 -07:00
Junio C Hamano f29cd3938d fsck: default to "git fsck --full"
Linus and other git developers from the early days trained their fingers
to type the command, every once in a while even without thinking, to check
the consistency of the repository back when the lower core part of the git
was still being developed.  Developers who wanted to make sure that git
correctly dealt with packfiles could deliberately trigger their creation
and checked them after they were created carefully, but loose objects are
the ones that are written by various commands from random codepaths.  It
made some technical sense to have a mode that checked only loose objects
from the debugging point of view for that reason.

Even for git developers, there no longer is any reason to type "git fsck"
every five minutes these days, worried that some newly created objects
might be corrupt due to recent change to git.

The reason we did not make "--full" the default is probably we trust our
filesystems a bit too much.  At least, we trusted filesystems more than we
trusted the lower core part of git that was under development.

Once a packfile is created and we always use it read-only, there didn't
seem to be much point in suspecting that the underlying filesystems or
disks may corrupt them in such a way that is not caught by the SHA-1
checksum over the entire packfile and per object checksum.  That trust in
the filesystems might have been a good tradeoff between fsck performance
and reliability on platforms git was initially developed on and for, but
it may not be true anymore as we run on many more platforms these days.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-20 12:11:39 -07:00
Junio C Hamano a9d7c9552e Merge branch 'maint'
* maint:
  Documentation/git-gc.txt: change "references" to "reference"
2009-10-20 00:13:13 -07:00
Stephen Boyd e133d65c3e gitweb: linkify author/committer names with search
It's nice to search for an author by merely clicking on their name in
gitweb. This is usually faster than selecting the name, copying the
selection, pasting it into the search box, selecting between
author/committer and then hitting enter.

Linkify the avatar icon in log/shortlog view because the icon is directly
adjacent to the name and thus more related. The same is not true
when in commit/tag view where the icon is farther away.

Signed-off-by: Stephen Boyd <bebarino@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-20 00:08:16 -07:00
Matt Kraai 3ed0b11e7e Documentation/git-gc.txt: change "references" to "reference"
Signed-off-by: Matt Kraai <kraai@ftbfs.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-20 00:01:23 -07:00
Johannes Schindelin 752c0c2492 Add the --submodule option to the diff option family
When you use the option --submodule=log you can see the submodule
summaries inlined in the diff, instead of not-quite-helpful SHA-1 pairs.

The format imitates what "git submodule summary" shows.

To do that, <path>/.git/objects/ is added to the alternate object
databases (if that directory exists).

This option was requested by Jens Lehmann at the GitTogether in Berlin.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-19 22:31:00 -07:00
Thomas Rast b7b10385a8 stash list: drop the default limit of 10 stashes
'git stash list' had an undocumented limit of 10 stashes, unless other
git-log arguments were specified.  This surprised at least one user,
but possibly served to cut the output below a screenful without using
a pager.

Since the last commit, 'git stash list' will fire up a pager according
to the same rules as the 'git log' it calls, so we can drop the limit.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-19 22:28:26 -07:00
Thomas Rast 391c53bdcd stash list: use new %g formats instead of sed
With the new formats, we can rewrite 'git stash list' in terms of an
appropriate pretty format, instead of hand-editing with sed.  This has
the advantage that it obeys the normal settings for git-log, notably
the pager.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-19 22:28:26 -07:00
Thomas Rast 8f8f5476cd Introduce new pretty formats %g[sdD] for reflog information
Add three new --pretty=format escapes:

  %gD  long  reflog descriptor (e.g. refs/stash@{0})
  %gd  short reflog descriptor (e.g. stash@{0})
  %gs  reflog message

This is achieved by passing down the reflog info, if any, inside the
pretty_print_context struct.

We use the newly refactored get_reflog_selector(), and give it some
extra functionality to extract a shortened ref.  The shortening is
cached inside the commit_reflogs struct; the only allocation of it
happens in read_complete_reflog(), where it is initialised to 0.  Also
add another helper get_reflog_message() for the message extraction.

Note that the --format="%h %gD: %gs" tests may not work in real
repositories, as the --pretty formatter doesn't know to leave away the
": " on the last commit in an incomplete (because git-gc removed the
old part) reflog.  This equivalence is nevertheless the main goal of
this patch.

Thanks to Jeff King for reviews, the %gd testcase and documentation.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-19 22:28:26 -07:00
Thomas Rast 72b103fec7 reflog-walk: refactor the branch@{num} formatting
We'll use the same output in an upcoming commit, so refactor its
formatting (which was duplicated anyway) into a separate function.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-19 22:28:25 -07:00
Thomas Rast dd2e794a21 Refactor pretty_print_commit arguments into a struct
pretty_print_commit() has a bunch of rarely-used arguments, and
introducing more of them requires yet another update of all the call
sites.  Refactor most of them into a struct to make future extensions
easier.

The ones that stay "plain" arguments were chosen on the grounds that
all callers put real arguments there, whereas some callers have 0/NULL
for all arguments that were factored into the struct.

We declare the struct 'const' to ensure none of the callers are bitten
by the changed (no longer call-by-value) semantics.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-19 22:28:20 -07:00
Junio C Hamano e79999b1a2 Merge branch 'bg/rebase-reword'
* bg/rebase-reword:
  rebase -i: fix reword when using a terminal editor
  Teach 'rebase -i' the command "reword"
2009-10-19 00:49:21 -07:00
Stephen Boyd 7725cb5e8b rebase -i: fix reword when using a terminal editor
We don't want to use output() on git-commit --amend when rewording the
commit message. This leads to confusion as the editor is run in a
subshell with it's output saved away, leaving the user with a seemingly
frozen terminal.

Fix by removing the output part.

Signed-off-by: Stephen Boyd <bebarino@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-19 00:49:09 -07:00
Junio C Hamano 7f98ebc8fd format_commit_message(): fix function signature
The format template string was declared as "const void *" for some unknown
reason, even though it obviously is meant to be passed a string.  Make it
"const char *".

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-19 00:48:59 -07:00
Jeff King f6fdbb6804 cvsimport: fix relative argument filenames
One of the first things that cvsimport does is chdir to the
newly created git repo. This means that any filenames given
to us on the command line will be looked up relative to the
git repo directory. This is probably not what the user
expects, so let's remember and prepend the original
directory for relative filenames.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-19 00:31:02 -07:00
Junio C Hamano ee50af1566 Merge branch 'jp/maint-send-email-fold'
* jp/maint-send-email-fold:
  git-send-email.perl: fold multiple entry "Cc:" and multiple single line "RCPT TO:"s
2009-10-18 23:01:37 -07:00
Junio C Hamano 804edc13ae Merge branch 'cc/replace-no-replace'
* cc/replace-no-replace:
  git: add --no-replace-objects option to disable replacing
2009-10-18 23:01:31 -07:00
Junio C Hamano c22e5e994a Merge branch 'jn/maint-1.6.3-check-ref-format-doc'
* jn/maint-1.6.3-check-ref-format-doc:
  Documentation: describe check-ref-format --branch
2009-10-18 23:01:26 -07:00
Junio C Hamano e38d1c555e Merge branch 'jk/maint-1.6.3-ls-files-no-ignore-cached'
* jk/maint-1.6.3-ls-files-no-ignore-cached:
  ls-files: excludes should not impact tracked files
2009-10-18 23:01:22 -07:00
Junio C Hamano 03fee47d89 Merge branch 'jn/gitweb-show-size'
* jn/gitweb-show-size:
  gitweb: Add 'show-sizes' feature to show blob sizes in tree view
2009-10-18 23:01:14 -07:00
Junio C Hamano 8457e8ca86 Merge branch 'jp/fetch-tag-match'
* jp/fetch-tag-match:
  fetch: Speed up fetch by rewriting find_non_local_tags
2009-10-18 23:01:09 -07:00
Junio C Hamano 023adc077c Merge branch 'jn/gitweb-patch'
* jn/gitweb-patch:
  gitweb: Do not show 'patch' link for merge commits
2009-10-18 23:01:03 -07:00
Junio C Hamano 178071baa7 Merge branch 'tf/doc-pt-br'
* tf/doc-pt-br:
  Documentation: update pt-BR
2009-10-18 23:00:58 -07:00
Junio C Hamano 37ce6b12ac Merge branch 'dk/blame-el'
* dk/blame-el:
  git-blame.el: Change how blame information is shown.
2009-10-18 23:00:51 -07:00
Junio C Hamano d9499c80c1 Merge branch 'mr/instaweb-cgid'
* mr/instaweb-cgid:
  instaweb: support mod_cgid for apache2
2009-10-18 23:00:45 -07:00
René Scharfe fb423da0e5 describe: load refnames before calling describe()
Get rid of the static variable that was used to prevent loading all
the refnames multiple times by moving that code out of describe(),
simply making sure it is only run once that way.

Also change the error message that is shown in case no refnames are
found to not include a hash any more, as the error condition is not
specific to any particular revision.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-18 23:00:02 -07:00
Junio C Hamano bcc9b7427d Merge branch 'maint'
* maint:
  git push: say that --tag can't be used with --all or --mirror in help text
  git push: remove incomplete options list from help text
  document push's new quiet option
  Makefile: clean block-sha1/ directory instead of mozilla-sha1/
2009-10-18 22:58:53 -07:00
Nanako Shiraishi 8ef4c28b8d git push: say that --tag can't be used with --all or --mirror in help text
This replaces an earlier patch by Björn Gustavsson,

  Message-ID: <4AD75029.1010109@gmail.com>

Signed-off-by: しらいし ななこ <nanako3@lavabit.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-18 22:47:48 -07:00
Nanako Shiraishi fcb044ee57 git push: remove incomplete options list from help text
'git push -h' shows usage text with incomplete list of options and then
has a separate list of options that are supported. Imitate the way other
commands (I looked at 'git diff' for an example) show their options.

Signed-off-by: しらいし ななこ <nanako3@lavabit.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-18 22:47:29 -07:00
Jeff King 989119d96e document push's new quiet option
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-18 22:44:22 -07:00
Carlos R. Mafra 3edd98ac65 Makefile: clean block-sha1/ directory instead of mozilla-sha1/
'make clean' should remove the object files from block-sha1/
instead of the non-existent mozilla-sha1/ directory.

Signed-off-by: Carlos R. Mafra <crmafra@aei.mpg.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-18 19:45:38 -07:00
Junio C Hamano 70c9ac2f19 DWIM "git checkout frotz" to "git checkout -b frotz origin/frotz"
When 'frotz' is not a valid object name and not a tracked filename,
we used to complain and failed this command.  When there is only
one remote that has 'frotz' as one of its tracking branches, we can
DWIM it as a request to create a local branch 'frotz' forking from
the matching remote tracking branch.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-18 00:38:03 -07:00
Junio C Hamano c6e8c8005a check_filename(): make verify_filename() callable without dying
Make it possible to invole the logic of verify_filename() to make sure the
pathname arguments are unambiguous without actually dying.  The caller may
want to do something different.
2009-10-18 00:38:03 -07:00
Junio C Hamano ad12b81271 Start 1.6.6 cycle
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-17 00:11:43 -07:00
Junio C Hamano 9981c808b4 Merge branch 'jc/maint-blank-at-eof'
* jc/maint-blank-at-eof:
  diff -B: colour whitespace errors
  diff.c: emit_add_line() takes only the rest of the line
  diff.c: split emit_line() from the first char and the rest of the line
  diff.c: shuffling code around
  diff --whitespace: fix blank lines at end
  core.whitespace: split trailing-space into blank-at-{eol,eof}
  diff --color: color blank-at-eof
  diff --whitespace=warn/error: fix blank-at-eof check
  diff --whitespace=warn/error: obey blank-at-eof
  diff.c: the builtin_diff() deals with only two-file comparison
  apply --whitespace: warn blank but not necessarily empty lines at EOF
  apply --whitespace=warn/error: diagnose blank at EOF
  apply.c: split check_whitespace() into two
  apply --whitespace=fix: detect new blank lines at eof correctly
  apply --whitespace=fix: fix handling of blank lines at the eof
2009-10-17 00:11:03 -07:00
Junio C Hamano 7641eb400f Merge branch 'maint'
* maint:
  GIT 1.6.5.1
  grep: do not segfault when -f is used
2009-10-17 00:10:33 -07:00
Junio C Hamano b142da2a5d GIT 1.6.5.1
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-16 23:57:19 -07:00
Junio C Hamano 050dfc4535 Merge branch 'maint-1.6.4' into maint
* maint-1.6.4:
  grep: do not segfault when -f is used
2009-10-16 23:47:58 -07:00