Code

git.git
14 years agot3417: Add test cases for "rebase --whitespace=fix"
Björn Gustavsson [Sat, 6 Mar 2010 14:31:17 +0000 (15:31 +0100)]
t3417: Add test cases for "rebase --whitespace=fix"

The command "git rebase --whitespace=fix HEAD~<N>" is supposed to
only clean up trailing whitespace, and the expectation is that it
cannot fail.

Unfortunately, if one commit adds a blank line at the end of a file
and a subsequent commit adds more non-blank lines after the blank
line, "git apply" (used indirectly by "git rebase") will fail to apply
the patch of the second commit.

Signed-off-by: Björn Gustavsson <bgustavsson@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agot4124: Add additional tests of --whitespace=fix
Björn Gustavsson [Sat, 6 Mar 2010 14:31:04 +0000 (15:31 +0100)]
t4124: Add additional tests of --whitespace=fix

Signed-off-by: Björn Gustavsson <bgustavsson@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agoapply: Allow blank context lines to match beyond EOF
Björn Gustavsson [Sat, 6 Mar 2010 14:30:42 +0000 (15:30 +0100)]
apply: Allow blank context lines to match beyond EOF

"git apply --whitespace=fix" will not always succeed when used
on a series of patches in the following circumstances:

* One patch adds a blank line at the end of a file. (Since
  --whitespace=fix is used, the blank line will *not* be added.)

* The next patch adds non-blank lines after the blank line
  introduced in the first patch. That patch will not apply
  because the blank line that is expected to be found at end
  of the file is no longer there.

A patch series that starts by deleting lines at the end
will fail in a similar way.

Fix this problem by allowing a blank context line at the beginning
of a hunk to match if parts of it falls beyond end of the file.
We still require that at least one non-blank context line match
before the end of the file.

If the --ignore-space-change option is given (as well as the
--whitespace=fix option), blank context lines falling beyond the end
of the file will be copied unchanged to the target file (i.e. they
will have the same line terminators and extra spaces will not be
removed).

Signed-off-by: Björn Gustavsson <bgustavsson@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agoapply: Remove the quick rejection test
Björn Gustavsson [Sat, 6 Mar 2010 14:30:29 +0000 (15:30 +0100)]
apply: Remove the quick rejection test

In the next commit, we will make it possible for blank context
lines to match beyond the end of the file. That means that a hunk
with a preimage that has more lines than present in the file may
be possible to successfully apply. Therefore, we must remove
the quick rejection test in find_pos().

find_pos() will already work correctly without the quick
rejection test, but that might not be obvious. Therefore,
comment the test for handling out-of-range line numbers in
find_pos() and cast the "line" variable to the same (unsigned)
type as img->nr.

What are performance implications of removing the quick
rejection test?

It can only help "git apply" to reject a patch faster. For example,
if I have a file with one million lines and a patch that removes
slightly more than 50 percent of the lines and try to apply that
patch twice, the second attempt will fail slightly faster
with the test than without (based on actual measurements).

However, there is the pathological case of a patch with many
more context lines than the default three, and applying that patch
using "git apply -C1". Without the rejection test, the running
time will be roughly proportional to the number of context lines
times the size of the file. That could be handled by writing
a more complicated rejection test (it would have to count the
number of blanks at the end of the preimage), but I don't find
that worth doing until there is a real-world use case that
would benfit from it.

It would be possible to keep the quick rejection test if
--whitespace=fix is not given, but I don't like that from
a testing point of view.

Signed-off-by: Björn Gustavsson <bgustavsson@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agoapply: Don't unnecessarily update line lengths in the preimage
Björn Gustavsson [Sat, 6 Mar 2010 14:30:21 +0000 (15:30 +0100)]
apply: Don't unnecessarily update line lengths in the preimage

In match_fragment(), the line lengths in the preimage are updated
just before calling update_pre_post_images(). That is not
necessary, since update_pre_post_images() itself will
update the line lengths based on the buffer passed to it.

Signed-off-by: Björn Gustavsson <bgustavsson@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agostash: suggest the correct command line for unknown options.
Matthieu Moy [Fri, 5 Mar 2010 18:43:23 +0000 (19:43 +0100)]
stash: suggest the correct command line for unknown options.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agot7406: Fix submodule init config tests
Stephen Boyd [Fri, 5 Mar 2010 08:20:38 +0000 (00:20 -0800)]
t7406: Fix submodule init config tests

These tests have been broken since they were introduced in commits
ca2cedb (git-submodule: add support for --rebase., 2009-04-24) and
42b4917 (git-submodule: add support for --merge., 2009-06-03).
'git submodule init' expects the submodules to exist in the index.
In this case, the submodules don't exist and therefore looking for
the submodules will always fail. To make matters worse, git submodule
fails visibly to the user by saying:

error: pathspec 'rebasing' did not match any file(s) known to git.
Did you forget to 'git add'?

but doesn't return an error code. This allows the test to fail silently.
Fix it by adding the submodules first.

Cc: Johan Herland <johan@herland.net>
Cc: Peter Hutterer <peter.hutterer@who-t.net>
Cc: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Stephen Boyd <bebarino@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agoUpdate draft release notes to 1.7.0.2
Junio C Hamano [Fri, 5 Mar 2010 06:39:38 +0000 (22:39 -0800)]
Update draft release notes to 1.7.0.2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agoMerge branch 'jn/gitweb-config-error-die' into maint
Junio C Hamano [Fri, 5 Mar 2010 06:27:12 +0000 (22:27 -0800)]
Merge branch 'jn/gitweb-config-error-die' into maint

* jn/gitweb-config-error-die:
  gitweb: Die if there are parsing errors in config file

14 years agoMerge branch 'jn/maint-fix-pager' into maint
Junio C Hamano [Fri, 5 Mar 2010 06:27:04 +0000 (22:27 -0800)]
Merge branch 'jn/maint-fix-pager' into maint

* jn/maint-fix-pager:
  tests: Fix race condition in t7006-pager
  t7006-pager: if stdout is not a terminal, make a new one
  tests: Add tests for automatic use of pager
  am: Fix launching of pager
  git svn: Fix launching of pager
  git.1: Clarify the behavior of the --paginate option
  Make 'git var GIT_PAGER' always print the configured pager
  Fix 'git var' usage synopsis

14 years agoMerge branch 'tr/maint-cherry-pick-list' into maint
Junio C Hamano [Fri, 5 Mar 2010 06:26:44 +0000 (22:26 -0800)]
Merge branch 'tr/maint-cherry-pick-list' into maint

* tr/maint-cherry-pick-list:
  cherry_pick_list: quit early if one side is empty

14 years agoMerge branch 'ld/maint-diff-quiet-w' into maint
Junio C Hamano [Fri, 5 Mar 2010 06:26:39 +0000 (22:26 -0800)]
Merge branch 'ld/maint-diff-quiet-w' into maint

* ld/maint-diff-quiet-w:
  git-diff: add a test for git diff --quiet -w
  git diff --quiet -w: check and report the status

14 years agoMerge branch 'rs/optim-text-wrap' into maint
Junio C Hamano [Fri, 5 Mar 2010 06:26:33 +0000 (22:26 -0800)]
Merge branch 'rs/optim-text-wrap' into maint

* rs/optim-text-wrap:
  utf8.c: speculatively assume utf-8 in strbuf_add_wrapped_text()
  utf8.c: remove strbuf_write()
  utf8.c: remove print_spaces()
  utf8.c: remove print_wrapped_text()

14 years agoMerge branch 'dp/read-not-mmap-small-loose-object' into maint
Junio C Hamano [Fri, 5 Mar 2010 06:26:17 +0000 (22:26 -0800)]
Merge branch 'dp/read-not-mmap-small-loose-object' into maint

* dp/read-not-mmap-small-loose-object:
  hash-object: don't use mmap() for small files

14 years agoMerge branch 'np/compress-loose-object-memsave' into maint
Junio C Hamano [Fri, 5 Mar 2010 06:26:05 +0000 (22:26 -0800)]
Merge branch 'np/compress-loose-object-memsave' into maint

* np/compress-loose-object-memsave:
  sha1_file: be paranoid when creating loose objects
  sha1_file: don't malloc the whole compressed result when writing out objects

14 years agoMerge branch 'jc/maint-status-preload' into maint
Junio C Hamano [Fri, 5 Mar 2010 06:25:45 +0000 (22:25 -0800)]
Merge branch 'jc/maint-status-preload' into maint

* jc/maint-status-preload:
  status: preload index to optimize lstat(2) calls

14 years agoMerge branch 'gf/maint-sh-setup-nongit-ok' into maint
Junio C Hamano [Fri, 5 Mar 2010 06:25:37 +0000 (22:25 -0800)]
Merge branch 'gf/maint-sh-setup-nongit-ok' into maint

* gf/maint-sh-setup-nongit-ok:
  require_work_tree broken with NONGIT_OK

14 years agoMerge branch 'cc/maint-bisect-paths' into maint
Junio C Hamano [Fri, 5 Mar 2010 06:25:23 +0000 (22:25 -0800)]
Merge branch 'cc/maint-bisect-paths' into maint

* cc/maint-bisect-paths:
  bisect: error out when passing bad path parameters

14 years agoMerge branch 'maint-1.6.6' into maint
Junio C Hamano [Fri, 5 Mar 2010 06:24:25 +0000 (22:24 -0800)]
Merge branch 'maint-1.6.6' into maint

* maint-1.6.6:
  Remove extra '-' from git-am(1)

14 years agoMerge branch 'maint-1.6.5' into maint-1.6.6
Junio C Hamano [Fri, 5 Mar 2010 06:24:19 +0000 (22:24 -0800)]
Merge branch 'maint-1.6.5' into maint-1.6.6

* maint-1.6.5:
  Remove extra '-' from git-am(1)

14 years agoRemove extra '-' from git-am(1)
Michal Sojka [Thu, 4 Mar 2010 12:08:28 +0000 (13:08 +0100)]
Remove extra '-' from git-am(1)

Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agorun-command.c: fix build warnings on Ubuntu
Michael Wookey [Fri, 29 Jan 2010 22:38:19 +0000 (09:38 +1100)]
run-command.c: fix build warnings on Ubuntu

Building git on Ubuntu 9.10 warns that the return value of write(2)
isn't checked. These warnings were introduced in commits:

  2b541bf8 ("start_command: detect execvp failures early")
  a5487ddf ("start_command: report child process setup errors to the
parent's stderr")

GCC details:

  $ gcc --version
  gcc (Ubuntu 4.4.1-4ubuntu9) 4.4.1

Silence the warnings by reading (but not making use of) the return value
of write(2).

Signed-off-by: Michael Wookey <michaelwookey@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agoStart preparing for 1.7.0.2
Junio C Hamano [Wed, 3 Mar 2010 07:11:36 +0000 (23:11 -0800)]
Start preparing for 1.7.0.2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agoMerge branch 'tc/maint-transport-ls-remote-with-void' into maint
Junio C Hamano [Wed, 3 Mar 2010 06:55:22 +0000 (22:55 -0800)]
Merge branch 'tc/maint-transport-ls-remote-with-void' into maint

* tc/maint-transport-ls-remote-with-void:
  transport: add got_remote_refs flag

14 years agoMerge branch 'hm/maint-imap-send-crlf' into maint
Junio C Hamano [Wed, 3 Mar 2010 06:55:03 +0000 (22:55 -0800)]
Merge branch 'hm/maint-imap-send-crlf' into maint

* hm/maint-imap-send-crlf:
  git-imap-send: Convert LF to CRLF before storing patch to draft box

14 years agoMerge branch 'sp/maint-push-sideband' into maint
Junio C Hamano [Wed, 3 Mar 2010 06:54:50 +0000 (22:54 -0800)]
Merge branch 'sp/maint-push-sideband' into maint

* sp/maint-push-sideband:
  receive-pack: Send internal errors over side-band #2
  t5401: Use a bare repository for the remote peer
  receive-pack: Send hook output over side band #2
  receive-pack: Wrap status reports inside side-band-64k
  receive-pack: Refactor how capabilities are shown to the client
  send-pack: demultiplex a sideband stream with status data
  run-command: support custom fd-set in async
  run-command: Allow stderr to be a caller supplied pipe

Conflicts:
builtin-receive-pack.c
run-command.c
t/t5401-update-hooks.sh

14 years agoMerge branch 'jc/maint-fix-test-perm' into maint
Junio C Hamano [Wed, 3 Mar 2010 06:38:02 +0000 (22:38 -0800)]
Merge branch 'jc/maint-fix-test-perm' into maint

* jc/maint-fix-test-perm:
  lib-patch-mode.sh: Fix permission
  t6000lib: Fix permission

14 years agoMerge branch 'np/fast-import-idx-v2' into maint
Junio C Hamano [Wed, 3 Mar 2010 06:28:49 +0000 (22:28 -0800)]
Merge branch 'np/fast-import-idx-v2' into maint

* np/fast-import-idx-v2:
  fast-import: use the diff_delta() max_delta_size argument
  fast-import: honor pack.indexversion and pack.packsizelimit config vars
  fast-import: make default pack size unlimited
  fast-import: use write_idx_file() instead of custom code
  fast-import: use sha1write() for pack data
  fast-import: start using struct pack_idx_entry

14 years agogitweb: Fix project-specific feature override behavior
Jakub Narebski [Mon, 1 Mar 2010 21:51:34 +0000 (22:51 +0100)]
gitweb: Fix project-specific feature override behavior

This commit fixes a bug in processing project-specific override in
a situation when there is no project, e.g. for the projects list page.

When 'snapshot' feature had project specific config override enabled
by putting
  $feature{'snapshot'}{'override'} = 1;

(or equivalent) in $GITWEB_CONFIG, and when viewing toplevel gitweb
page, which means the projects list page (to be more exact this
happens for any project-less action), gitweb would put the following
Perl warnings in error log:

  gitweb.cgi: Use of uninitialized value $git_dir in concatenation (.) or string at gitweb.cgi line 2065.
  fatal: error processing config file(s)
  gitweb.cgi: Use of uninitialized value $git_dir in concatenation (.) or string at gitweb.cgi line 2221.
  gitweb.cgi: Use of uninitialized value $git_dir in concatenation (.) or string at gitweb.cgi line 2218.

The problem is in the following fragment of code:

  # path to the current git repository
  our $git_dir;
  $git_dir = "$projectroot/$project" if $project;

  # list of supported snapshot formats
  our @snapshot_fmts = gitweb_get_feature('snapshot');
  @snapshot_fmts = filter_snapshot_fmts(@snapshot_fmts);

For the toplevel gitweb page, which is the list of projects, $project is not
defined, therefore neither is $git_dir.  gitweb_get_feature() subroutine
calls git_get_project_config() if project specific override is turned
on... but we don't have project here.

Those errors mentioned above occur in the following fragment of code in
git_get_project_config():

   # get config
   if (!defined $config_file ||
       $config_file ne "$git_dir/config") {
   %config = git_parse_project_config('gitweb');
   $config_file = "$git_dir/config";
   }

git_parse_project_config() calls git_cmd() which has '--git-dir='.$git_dir

There are (at least) three possible solutions:
1. Harden gitweb_get_feature() so that it doesn't call
   git_get_project_config() if $project (and therefore $git_dir) is not
   defined; there is no project for project specific config.
2. Harden git_get_project_config() like you did in your fix, returning early
   if $git_dir is not defined.
3. Harden git_cmd() so that it doesn't add "--git-dir=$git_dir" if $git_dir
   is not defined, and change git_get_project_config() so that it doesn't
   even try to access $git_dir if it is not defined.

This commit implements both 1.) and 2.), i.e. gitweb_get_feature() doesn't
call project-specific override if $git_dir is not defined (if there is no
project), and git_get_project_config() returns early if $git_dir is not
defined.

Add a test for this bug to t/t9500-gitweb-standalone-no-errors.sh test.

Reported-by: Eli Barzilay <eli@barzilay.org>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agogitweb multiple project roots documentation
Sylvain Rabot [Tue, 2 Mar 2010 00:04:57 +0000 (01:04 +0100)]
gitweb multiple project roots documentation

This commit adds in the gitweb/README file a description of how to use gitweb
with several project roots using apache virtualhost rewrite rules.

Signed-off-by: Sylvain Rabot <sylvain@abstraction.fr>
Acked-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agobisect: error out when passing bad path parameters
Christian Couder [Sun, 28 Feb 2010 22:19:09 +0000 (23:19 +0100)]
bisect: error out when passing bad path parameters

As reported by Mark Lodato, "git bisect", when it was started with
path parameters that match no commit was kind of working without
taking account of path parameters and was reporting something like:

Bisecting: -1 revisions left to test after this (roughly 0 steps)

It is more correct and safer to just error out in this case, before
displaying the revisions left, so this patch does just that.

Note that this bug is very old, it exists at least since v1.5.5.
And it is possible to detect that case earlier in the bisect
algorithm, but it is not clear that it would be an improvement to
error out earlier, on the contrary it may change the behavior of
"git rev-list --bisect-all" for example, which is currently correct.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agoGit 1.7.0.1 v1.7.0.1
Junio C Hamano [Sun, 28 Feb 2010 19:41:24 +0000 (11:41 -0800)]
Git 1.7.0.1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agoRemove reference to GREP_COLORS from documentation
Mark Lodato [Sat, 27 Feb 2010 04:57:48 +0000 (23:57 -0500)]
Remove reference to GREP_COLORS from documentation

There is no longer support for external grep, as per bbc09c2 (grep: rip
out support for external grep, 2010-01-12), so remove the reference to it
from the documentation.

Signed-off-by: Mark Lodato <lodatom@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agosha1_name: fix segfault caused by invalid index access
Markus Heidelberg [Sun, 28 Feb 2010 15:49:15 +0000 (16:49 +0100)]
sha1_name: fix segfault caused by invalid index access

The code to see if user input "git show :path" makes sense tried to access
the index without properly checking the array bound.

Signed-off-by: Markus Heidelberg <markus.heidelberg@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agoreflog: honor gc.reflogexpire=never
Adam Simpkins [Sat, 27 Feb 2010 03:50:03 +0000 (19:50 -0800)]
reflog: honor gc.reflogexpire=never

Previously, if gc.reflogexpire or gc.reflogexpire were set to "never"
or "false", the builtin default values were used instead.

Signed-off-by: Adam Simpkins <simpkins@facebook.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agoprune: honor --expire=never
Adam Simpkins [Sat, 27 Feb 2010 03:50:02 +0000 (19:50 -0800)]
prune: honor --expire=never

Previously, prune treated an expiration time of 0 to mean that no
expire argument was supplied, and everything should be pruned.  As a
result, "prune --expire=never" would prune all unreachable objects,
regardless of their timestamp.

prune can be called with --expire=never automatically by gc, when the
gc.pruneExpire configuration is set to "never".

Signed-off-by: Adam Simpkins <simpkins@facebook.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agoMerge branch 'maint-1.6.6' into maint
Junio C Hamano [Fri, 26 Feb 2010 07:21:42 +0000 (23:21 -0800)]
Merge branch 'maint-1.6.6' into maint

* maint-1.6.6:
  t3301-notes: insert a shbang line in ./fake_editor.sh

14 years agogrep docs: document --no-index option
Mark Lodato [Fri, 26 Feb 2010 03:40:13 +0000 (22:40 -0500)]
grep docs: document --no-index option

Also clarify --cached and <tree>.

Signed-off-by: Mark Lodato <lodatom@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agogrep docs: --cached and <tree>... are incompatible
Mark Lodato [Fri, 26 Feb 2010 03:40:12 +0000 (22:40 -0500)]
grep docs: --cached and <tree>... are incompatible

In the synopsis for git-grep(1), show that --cached and <tree>... cannot
be used together.

Signed-off-by: Mark Lodato <lodatom@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agogrep docs: use AsciiDoc literals consistently
Mark Lodato [Fri, 26 Feb 2010 03:40:11 +0000 (22:40 -0500)]
grep docs: use AsciiDoc literals consistently

The convention for this particular page is to use AsciiDoc literal
strings only for options (`-x` or `--long`), but not for definition list
terms and not for <meta-vars>.

Signed-off-by: Mark Lodato <lodatom@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agogrep docs: pluralize "Example" section
Mark Lodato [Fri, 26 Feb 2010 03:40:10 +0000 (22:40 -0500)]
grep docs: pluralize "Example" section

Signed-off-by: Mark Lodato <lodatom@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agot3301-notes: insert a shbang line in ./fake_editor.sh
Johannes Sixt [Thu, 25 Feb 2010 10:39:50 +0000 (11:39 +0100)]
t3301-notes: insert a shbang line in ./fake_editor.sh

This is required on Windows because git-notes is now a built-in
rather than a shell script.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agoFix gitmkdtemp: correct test for mktemp() return value
Filippo Negroni [Thu, 25 Feb 2010 10:01:31 +0000 (10:01 +0000)]
Fix gitmkdtemp: correct test for mktemp() return value

In gitmkdtemp, the return value of mktemp is not tested correctly.
mktemp() always returns its 'template' argument, even upon failure.
An error is signalled by making the template an empty string.

Signed-off-by: Filippo Negroni <fnegroni@flexerasoftware.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agopack-objects documentation: Fix --honor-pack-keep as well.
Nelson Elhage [Thu, 25 Feb 2010 00:11:23 +0000 (19:11 -0500)]
pack-objects documentation: Fix --honor-pack-keep as well.

Signed-off-by: Nelson Elhage <nelhage@mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agois_submodule_modified(): clear environment properly
Giuseppe Bilotta [Wed, 24 Feb 2010 23:34:18 +0000 (00:34 +0100)]
is_submodule_modified(): clear environment properly

Rather than only clearing GIT_INDEX_FILE, take the list of environment
variables to clear from local_repo_env, appending the settings for
GIT_DIR and GIT_WORK_TREE.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agosubmodules: ensure clean environment when operating in a submodule
Giuseppe Bilotta [Wed, 24 Feb 2010 23:34:17 +0000 (00:34 +0100)]
submodules: ensure clean environment when operating in a submodule

git-submodule used to take care of clearing GIT_DIR whenever it operated
on a submodule index or configuration, but forgot to unset GIT_WORK_TREE
or other repo-local variables. This would lead to failures e.g. when
GIT_WORK_TREE was set.

This only happened in very unusual contexts such as operating on the
main worktree from outside of it, but since "git-gui: set GIT_DIR and
GIT_WORK_TREE after setup" (a9fa11fe5bd5978bb) such failures could also
be provoked by invoking an external tool such as "git submodule update"
from the Git Gui in a standard setup.

Solve by using the newly introduced clear_local_git_env() shell function
to ensure that all repo-local environment variables are unset.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agoshell setup: clear_local_git_env() function
Giuseppe Bilotta [Wed, 24 Feb 2010 23:34:16 +0000 (00:34 +0100)]
shell setup: clear_local_git_env() function

Introduce an auxiliary function to clear all repo-local environment
variables. This should be invoked by any shell script that switches
repository during execution, to ensure that the environment is clean
and that things such as the git dir and worktree are set up correctly.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agorev-parse: --local-env-vars option
Giuseppe Bilotta [Wed, 24 Feb 2010 23:34:15 +0000 (00:34 +0100)]
rev-parse: --local-env-vars option

This prints the list of repo-local environment variables.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agoRefactor list of of repo-local env vars
Giuseppe Bilotta [Wed, 24 Feb 2010 23:34:14 +0000 (00:34 +0100)]
Refactor list of of repo-local env vars

Move the list of GIT_* environment variables that are local to a
repository into a static list in environment.c, as it is also
useful elsewhere. Also add the missing GIT_CONFIG variable to the
list.

Make it easy to use the list both by NULL-termination and by size;
the latter (excluding the terminating NULL) is stored in the
local_repo_env_size define.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agopack-objects documentation: reword "objects that appear in the standard input"
Junio C Hamano [Wed, 24 Feb 2010 23:41:27 +0000 (15:41 -0800)]
pack-objects documentation: reword "objects that appear in the standard input"

These were written back when we always read objects from the standard
input.  These days --revs and its friends can feed only the start and
end points and have the command internally enumerate the objects.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agocommit: quote the user name in the example
Matt Kraai [Wed, 24 Feb 2010 14:18:25 +0000 (06:18 -0800)]
commit: quote the user name in the example

If the user runs

 git config --global user.name Your Name

as suggested, user.name will be set to "Your".  With this patch, the
suggested command will be

 git config --global user.name "Your Name"

which will set user.name to "Your Name" and hopefully help users avoid
the former mistake.

Signed-off-by: Matt Kraai <kraai@ftbfs.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agoMerge branch 'ml/maint-grep-doc' into maint
Junio C Hamano [Wed, 24 Feb 2010 23:33:23 +0000 (15:33 -0800)]
Merge branch 'ml/maint-grep-doc' into maint

* ml/maint-grep-doc:
  grep documentation: clarify what files match

14 years agofetch --all/--multiple: keep all the fetched branch information
Junio C Hamano [Wed, 24 Feb 2010 19:02:05 +0000 (11:02 -0800)]
fetch --all/--multiple: keep all the fetched branch information

Since "git fetch" learned "--all" and "--multiple" options, it has become
tempting for users to say "git pull --all".  Even though it may fetch from
remotes that do not need to be fetched from for merging with the current
branch, it is handy.

"git fetch" however clears the list of fetched branches every time it
contacts a different remote.  Unless the current branch is configured to
merge with a branch from a remote that happens to be the last in the list
of remotes that are contacted, "git pull" that fetches from multiple
remotes will not be able to find the branch it should be merging with.

Make "fetch" clear FETCH_HEAD (unless --append is given) and then append
the list of branches fetched to it (even when --append is not given).  That
way, "pull" will be able to find the data for the branch being merged in
FETCH_HEAD no matter where the remote appears in the list of remotes to be
contacted by "git fetch".

Reported-by: Michael Lukashov
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agopush: fix segfault for odd config
Jeff King [Wed, 24 Feb 2010 17:08:53 +0000 (12:08 -0500)]
push: fix segfault for odd config

If you have a branch.$X.merge config option, but no branch.$X.remote, and
your configuration tries to push tracking branches, git will segfault.

The problem is that even though branch->merge_nr is 1, you don't actually
have an upstream since there is no remote.  Other callsites generally
check explicitly that branch->merge is not NULL, so let's do that here,
too.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agobuiltin-fetch --all/--multi: propagate options correctly
Junio C Hamano [Wed, 24 Feb 2010 18:22:06 +0000 (10:22 -0800)]
builtin-fetch --all/--multi: propagate options correctly

When running a subfetch, the code propagated some options but not others.
Propagate --force, --update-head-ok and --keep options as well.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agot5521: fix and modernize
Junio C Hamano [Wed, 24 Feb 2010 18:22:05 +0000 (10:22 -0800)]
t5521: fix and modernize

All of these tests were bogus, as they created new directory and tried to
run "git pull" without even running "git init" in there.  They were mucking
with the repository in $TEST_DIRECTORY.

While fixing it, modernize the style not to chdir around outside of
subshell.  Otherwise a failed test will take us to an unexpected directory
and we need to chdir back to the test directory in each test, which is
ugly and error prone.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agoam: remove rebase-apply directory before gc
Jonathan Nieder [Mon, 22 Feb 2010 14:35:46 +0000 (08:35 -0600)]
am: remove rebase-apply directory before gc

When git am does an automatic gc it doesn't clean up the rebase-apply
directory until after this has finished.  This means that if the user
aborts the gc then future am or rebase operations will report that an
existing operation is in progress, which is undesirable and confusing.

Reported by Mark Brown <broonie@debian.org> through
http://bugs.debian.org/570966

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agorerere: fix memory leak if rerere images can't be read
Bert Wesarg [Tue, 23 Feb 2010 20:11:53 +0000 (21:11 +0100)]
rerere: fix memory leak if rerere images can't be read

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agoDocumentation: mention conflict marker size argument (%L) for merge driver
Bert Wesarg [Tue, 23 Feb 2010 20:11:12 +0000 (21:11 +0100)]
Documentation: mention conflict marker size argument (%L) for merge driver

23a64c9e (conflict-marker-size: new attribute, 2010-01-16) introduced the
new attribute and also pass the conflict marker size as %L to merge driver
commands. This documents the substitution.

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agoadd-interactive: fix bogus diff header line ordering
Jeff King [Tue, 23 Feb 2010 01:05:44 +0000 (20:05 -0500)]
add-interactive: fix bogus diff header line ordering

When we look at a patch for adding hunks interactively, we
first split it into a header and a list of hunks. Some of
the header lines, such as mode changes and deletion, however,
become their own selectable hunks. Later when we reassemble
the patch, we simply concatenate the header and the selected
hunks. This leads to patches like this:

  diff --git a/file b/file
  index d95f3ad..0000000
  --- a/file
  +++ /dev/null
  deleted file mode 100644
  @@ -1 +0,0 @@
  -content

Notice how the deletion comes _after_ the ---/+++ lines,
when it should come before.

In many cases, we can get away with this as git-apply
accepts the slightly bogus input. However, in the specific
case of a deletion line that is being applied via "apply
-R", this malformed patch triggers an assert in git-apply.
This comes up when discarding a deletion via "git checkout
-p".

Rather than try to make git-apply accept our odd input,
let's just reassemble the patch in the correct order.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agoUse git_mkstemp_mode instead of plain mkstemp to create object files
Matthieu Moy [Mon, 22 Feb 2010 22:32:16 +0000 (23:32 +0100)]
Use git_mkstemp_mode instead of plain mkstemp to create object files

We used to unnecessarily give the read permission to group and others,
regardless of the umask, which isn't serious because the objects are
still protected by their containing directory, but isn't necessary
either.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agogit_mkstemps_mode: don't set errno to EINVAL on exit.
Matthieu Moy [Mon, 22 Feb 2010 22:32:15 +0000 (23:32 +0100)]
git_mkstemps_mode: don't set errno to EINVAL on exit.

When reaching the end of git_mkstemps_mode, at least one call to open()
has been done, and errno has been set accordingly. Setting errno is
therefore not necessary, and actually harmfull since callers can't
distinguish e.g. permanent failure from ENOENT, which can just mean that
we need to create the containing directory.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agoUse git_mkstemp_mode and xmkstemp_mode in odb_mkstemp, not chmod later.
Matthieu Moy [Mon, 22 Feb 2010 22:32:14 +0000 (23:32 +0100)]
Use git_mkstemp_mode and xmkstemp_mode in odb_mkstemp, not chmod later.

We used to create 0600 files, and then use chmod to set the group and
other permission bits to the umask. This usually has the same effect
as a normal file creation with a umask.

But in the presence of ACLs, the group permission plays the role of
the ACL mask: the "g" bits of newly created files are chosen according
to default ACL mask of the directory, not according to the umask, and
doing a chmod() on these "g" bits affect the ACL's mask instead of
actual group permission.

In other words, creating files with 0600 and then doing a chmod to the
umask creates files which are unreadable by users allowed in the
default ACL. To create the files without breaking ACLs, we let the
umask do it's job at the file's creation time, and get rid of the
later chmod.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agogit_mkstemp_mode, xmkstemp_mode: variants of gitmkstemps with mode argument.
Matthieu Moy [Mon, 22 Feb 2010 22:32:13 +0000 (23:32 +0100)]
git_mkstemp_mode, xmkstemp_mode: variants of gitmkstemps with mode argument.

gitmkstemps emulates the behavior of mkstemps, which is usually used
to create files in a shared directory like /tmp/, hence, it creates
files with permission 0600.

Add git_mkstemps_mode() that allows us to specify the desired mode, and
make git_mkstemps() a wrapper that always uses 0600 to call it. Later we
will use git_mkstemps_mode() when creating pack files.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agoMove gitmkstemps to path.c
Matthieu Moy [Mon, 22 Feb 2010 22:32:12 +0000 (23:32 +0100)]
Move gitmkstemps to path.c

This function used to be only a compatibility function, but we're
going to extend it and actually use it, so make it part of Git.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agoAdd a testcase for ACL with restrictive umask.
Matthieu Moy [Mon, 22 Feb 2010 22:32:11 +0000 (23:32 +0100)]
Add a testcase for ACL with restrictive umask.

Right now, Git creates unreadable pack files on non-shared
repositories when the user has a umask of 077, even when the default
ACLs for the directory would give read/write access to a specific
user.

Loose object files are created world-readable, which doesn't break ACLs,
but isn't necessarily desirable.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agotests: Fix race condition in t7006-pager
Jonathan Nieder [Mon, 22 Feb 2010 08:46:33 +0000 (02:46 -0600)]
tests: Fix race condition in t7006-pager

Pagers that do not consume their input are dangerous: for example,

 $ GIT_PAGER=: git log
 $ echo $?
 141
 $

The only reason these tests were able to work before was that
'git log' would write to the pipe (and not fill it) before the
pager had time to terminate and close the pipe.

Fix it by using a program that consumes its input, namely wc (as
suggested by Johannes).

Reported-by: Johannes Sixt <j.sixt@viscovery.net>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agosha1_file: be paranoid when creating loose objects
Nicolas Pitre [Sun, 21 Feb 2010 20:48:06 +0000 (15:48 -0500)]
sha1_file: be paranoid when creating loose objects

We don't want the data being deflated and stored into loose objects
to be different from what we expect.  While the deflated data is
protected by a CRC which is good enough for safe data retrieval
operations, we still want to be doubly sure that the source data used
at object creation time is still what we expected once that data has
been deflated and its CRC32 computed.

The most plausible data corruption may occur if the source file is
modified while Git is deflating and writing it out in a loose object.
Or Git itself could have a bug causing memory corruption.  Or even bad
RAM could cause trouble.  So it is best to make sure everything is
coherent and checksum protected from beginning to end.

To do so we compute the SHA1 of the data being deflated _after_ the
deflate operation has consumed that data, and make sure it matches
with the expected SHA1.  This way we can rely on the CRC32 checked by
the inflate operation to provide a good indication that the data is still
coherent with its SHA1 hash.  One pathological case we ignore is when
the data is modified before (or during) deflate call, but changed back
before it is hashed.

There is some overhead of course. Using 'git add' on a set of large files:

Before:

real    0m25.210s
user    0m23.783s
sys     0m1.408s

After:

real    0m26.537s
user    0m25.175s
sys     0m1.358s

The overhead is around 5% for full data coherency guarantee.

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agogit-diff: add a test for git diff --quiet -w
Larry D'Anna [Mon, 22 Feb 2010 02:58:44 +0000 (21:58 -0500)]
git-diff: add a test for git diff --quiet -w

This patch adds two test cases for:

6977c25 git diff --quiet -w: check and report the status

Signed-off-by: Larry D'Anna <larry@elder-gods.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agohash-object: don't use mmap() for small files
Dmitry Potapov [Sun, 21 Feb 2010 06:32:19 +0000 (09:32 +0300)]
hash-object: don't use mmap() for small files

Using read() instead of mmap() can be 39% speed up for 1Kb files and is
1% speed up 1Mb files. For larger files, it is better to use mmap(),
because the difference between is not significant, and when there is not
enough memory, mmap() performs much better, because it avoids swapping.

Signed-off-by: Dmitry Potapov <dpotapov@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agosha1_file: don't malloc the whole compressed result when writing out objects
Nicolas Pitre [Sun, 21 Feb 2010 04:27:31 +0000 (23:27 -0500)]
sha1_file: don't malloc the whole compressed result when writing out objects

There is no real advantage to malloc the whole output buffer and
deflate the data in a single pass when writing loose objects. That is
like only 1% faster while using more memory, especially with large
files where memory usage is far more. It is best to deflate and write
the data out in small chunks reusing the same memory instead.

For example, using 'git add' on a few large files averaging 40 MB ...

Before:
21.45user 1.10system 0:22.57elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+828040outputs (0major+142640minor)pagefaults 0swaps

After:
21.50user 1.25system 0:22.76elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+828040outputs (0major+104408minor)pagefaults 0swaps

While the runtime stayed relatively the same, the number of minor page
faults went down significantly.

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agot7006-pager: if stdout is not a terminal, make a new one
Jonathan Nieder [Sat, 20 Feb 2010 08:50:25 +0000 (02:50 -0600)]
t7006-pager: if stdout is not a terminal, make a new one

Testing pagination requires (fake or real) access to a terminal so we
can see whether the pagination automatically kicks in, which makes it
hard to get good coverage when running tests without --verbose.  There
are a number of ways to work around that:

 - Replace all isatty calls with calls to a custom xisatty wrapper
   that usually checks for a terminal but can be overridden for tests.
   This would be workable, but it would require implementing xisatty
   separately in three languages (C, shell, and perl) and making sure
   that any code that is to be tested always uses the wrapper.

 - Redirect stdout to /dev/tty.  This would be problematic because
   there might be no terminal available, and even if a terminal is
   available, it might not be appropriate to spew output to it.

 - Create a new pseudo-terminal on the fly and capture its output.

This patch implements the third approach.

The new test-terminal.perl helper uses IO::Pty from Expect.pm to create
a terminal and executes the program specified by its arguments with
that terminal as stdout.  If the IO::Pty module is missing or not
working on a system, the test script will maintain its old behavior
(skipping most of its tests unless GIT_TEST_OPTS includes --verbose).

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agocherry_pick_list: quit early if one side is empty
Thomas Rast [Sat, 20 Feb 2010 11:42:04 +0000 (12:42 +0100)]
cherry_pick_list: quit early if one side is empty

The --cherry-pick logic starts by counting the commits on each side,
so that it can filter away commits on the bigger one.  However, so
far it missed an opportunity for optimization: it doesn't need to do
any work if either side is empty.

This in particular helps the common use-case 'git rebase -i HEAD~$n':
it internally uses --cherry-pick, but since HEAD~$n is a direct
ancestor the left side is always empty.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agotests: Add tests for automatic use of pager
Jonathan Nieder [Fri, 19 Feb 2010 07:18:58 +0000 (01:18 -0600)]
tests: Add tests for automatic use of pager

Git’s automatic pagination support has some subtleties.  Add some
tests to make sure we don’t break:

 - when git will use a pager by default;
 - the effect of the --paginate and --no-pager options;
 - the effect of pagination on use of color;
 - how the choice of pager is configured.

This does not yet test:

 - use of pager by scripted commands (git svn and git am);
 - effect of the pager.* configuration variables;
 - setting of the LESS variable.

Some features involve checking whether stdout is a terminal, so many
of these tests are skipped unless output is passed through to the
terminal (i.e., unless $GIT_TEST_OPTS includes --verbose).

The immediate purpose for these tests was to avoid making things worse
after the breakage from my jn/editor-pager series (see commit 376f39,
2009-11-20).  Thanks to Sebastian Celis <sebastian@sebastiancelis.com>
for the report.

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agoDocumentation: pack-objects: Clarify --local's semantics.
Nelson Elhage [Fri, 19 Feb 2010 03:29:30 +0000 (22:29 -0500)]
Documentation: pack-objects: Clarify --local's semantics.

The current documentation suggests that --local also ignores any
objects in local packs, which is incorrect. Change the language to be
clearer and more parallel to the other options that ignore objects.

While we're at it, fix a trivial error in --incremental's
documentation.

Signed-off-by: Nelson Elhage <nelhage@mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agoutf8.c: speculatively assume utf-8 in strbuf_add_wrapped_text()
René Scharfe [Fri, 19 Feb 2010 22:20:44 +0000 (23:20 +0100)]
utf8.c: speculatively assume utf-8 in strbuf_add_wrapped_text()

is_utf8() works by calling utf8_width() for each character at the
supplied location.  In strbuf_add_wrapped_text(), we do that anyway
while wrapping the lines.  So instead of checking the encoding
beforehand, optimistically assume that it's utf-8 and wrap along
until an invalid character is hit, and when that happens start over.

This pays off if the text consists only of valid utf-8 characters.
The following command was run against the Linux kernel repo with
git 1.7.0:

$ time git log --format='%b' v2.6.32 >/dev/null

real 0m2.679s
user 0m2.580s
sys 0m0.100s

$ time git log --format='%w(60,4,8)%b' >/dev/null

real 0m4.342s
user 0m4.230s
sys 0m0.110s

And with this patch series:

$ time git log --format='%w(60,4,8)%b' >/dev/null

real 0m3.741s
user 0m3.630s
sys 0m0.110s

So the cost of wrapping is reduced to 70% in this case.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agoutf8.c: remove strbuf_write()
René Scharfe [Fri, 19 Feb 2010 22:16:45 +0000 (23:16 +0100)]
utf8.c: remove strbuf_write()

The patch before the previous one made sure that all callers of
strbuf_add_wrapped_text() supply a strbuf.  Replace all calls of
strbuf_write() with regular strbuf functions and remove it.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agoutf8.c: remove print_spaces()
René Scharfe [Fri, 19 Feb 2010 22:15:55 +0000 (23:15 +0100)]
utf8.c: remove print_spaces()

The previous patch made sure that strbuf_add_wrapped_text() (and thus
strbuf_add_indented_text(), too) always get a strbuf.  Make use of
this fact by adding strbuf_addchars(), a small helper that adds a
char the specified number of times to a strbuf, and use it to replace
print_spaces().

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agoutf8.c: remove print_wrapped_text()
René Scharfe [Fri, 19 Feb 2010 22:15:01 +0000 (23:15 +0100)]
utf8.c: remove print_wrapped_text()

strbuf_add_wrapped_text() is called only from print_wrapped_text()
without a strbuf (in which case it writes its results to stdout).

At its only callsite, supply a strbuf, call strbuf_add_wrapped_text()
directly and remove the wrapper function.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agogit-p4: fix bug in symlink handling
Evan Powers [Tue, 16 Feb 2010 08:44:08 +0000 (00:44 -0800)]
git-p4: fix bug in symlink handling

Fix inadvertent breakage from b932705 (git-p4: stream from perforce to
speed up clones, 2009-07-30) in the code that strips the trailing '\n'
from p4 print on a symlink. (In practice, contents is of the form
['target\n', ''].)

Signed-off-by: Evan Powers <evan.powers@gmail.com>
Acked-by: Pete Wyckoff <pw@padd.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agot1450: fix testcases that were wrongly expecting failure
Thomas Rast [Sat, 20 Feb 2010 00:18:44 +0000 (01:18 +0100)]
t1450: fix testcases that were wrongly expecting failure

Almost exactly a year ago in 02a6552 (Test fsck a bit harder), I
introduced two testcases that were expecting failure.

However, the only bug was that the testcases wrote *blobs* because I
forgot to pass -t tag to hash-object.  Fix this, and then adjust the
rest of the test to properly check the result.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agomailinfo: do not strip leading spaces even for a header line
Junio C Hamano [Sat, 20 Feb 2010 05:55:33 +0000 (21:55 -0800)]
mailinfo: do not strip leading spaces even for a header line

Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agoDocumentation: Fix indentation problem in git-commit(1)
Jacob Helwig [Mon, 15 Feb 2010 12:33:06 +0000 (04:33 -0800)]
Documentation: Fix indentation problem in git-commit(1)

Ever since the "See linkgit:git-config[1]..." paragraph was added to the
description for --untracked-files (d6293d1), the paragraphs for the
following options were indented at the same level as the "See
linkgit:git-config[1]" paragraph.  This problem showed up in the
manpages, but not in the HTML documentation.

While this does fix the alignment of the options following
--untracked-files in the manpage, the "See linkgit..." portion of the
description does not retain its previous indentation level in the
manpages, or HTML documentation.

Signed-off-by: Jacob Helwig <jacob.helwig@gmail.com>
Acked-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agoMerge branch 'jk/maint-rmdir-fix' into maint
Junio C Hamano [Fri, 19 Feb 2010 09:31:37 +0000 (01:31 -0800)]
Merge branch 'jk/maint-rmdir-fix' into maint

* jk/maint-rmdir-fix:
  rm: fix bug in recursive subdirectory removal

14 years agorm: fix bug in recursive subdirectory removal
Jeff King [Fri, 19 Feb 2010 05:57:21 +0000 (00:57 -0500)]
rm: fix bug in recursive subdirectory removal

If we remove a path in a/deep/subdirectory, we should try to
remove as many trailing components as possible (i.e.,
subdirectory, then deep, then a). However, the test for the
return value of rmdir was reversed, so we only ever deleted
at most one level.

The fix is in remove_path, so "apply" and "merge-recursive"
also are fixed.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agoDocumentation: describe --thin more accurately
Stephen Boyd [Thu, 18 Feb 2010 09:10:28 +0000 (01:10 -0800)]
Documentation: describe --thin more accurately

The description for --thin was misleading and downright wrong. Correct
it with some inspiration from the description of index-pack's --fix-thin
and some background information from Nicolas Pitre <nico@fluxnic.net>.

Signed-off-by: Stephen Boyd <bebarino@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agodocs: don't talk about $GIT_DIR/refs/ everywhere
Jeff King [Thu, 18 Feb 2010 01:16:20 +0000 (20:16 -0500)]
docs: don't talk about $GIT_DIR/refs/ everywhere

It is misleading to say that we pull refs from $GIT_DIR/refs/*, because we
may also consult the packed refs mechanism. These days we tend to treat
the "refs hierarchy" as more of an abstract namespace that happens to be
represented as $GIT_DIR/refs. At best, this is a minor inaccuracy, but at
worst it can confuse users who then look in $GIT_DIR/refs and find that it
is missing some of the refs they expected to see.

This patch drops most uses of "$GIT_DIR/refs/*", changing them into just
"refs/*", under the assumption that users can handle the concept of an
abstract refs namespace. There are a few things to note:

  - most cases just dropped the $GIT_DIR/ portion. But for cases where
    that left _just_ the word "refs", I changed it to "refs/" to help
    indicate that it was a hierarchy.  I didn't do the same for longer
    paths (e.g., "refs/heads" remained, instead of becoming
    "refs/heads/").

  - in some cases, no change was made, as the text was explicitly about
    unpacked refs (e.g., the discussion in git-pack-refs).

  - In some cases it made sense instead to note the existence of packed
    refs (e.g., in check-ref-format and rev-parse).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agoUpdate 1.7.0.1 release notes
Junio C Hamano [Wed, 17 Feb 2010 23:00:00 +0000 (15:00 -0800)]
Update 1.7.0.1 release notes

Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agoMerge branch 'jk/cherry-pick-reword' into maint
Junio C Hamano [Wed, 17 Feb 2010 22:55:24 +0000 (14:55 -0800)]
Merge branch 'jk/cherry-pick-reword' into maint

* jk/cherry-pick-reword:
  cherry-pick: prettify the advice message
  cherry-pick: show commit name instead of sha1
  cherry-pick: format help message as strbuf
  cherry-pick: refactor commit parsing code
  cherry-pick: rewrap advice message

14 years agoMerge branch 'jk/grep-double-dash' into maint
Junio C Hamano [Wed, 17 Feb 2010 22:55:15 +0000 (14:55 -0800)]
Merge branch 'jk/grep-double-dash' into maint

* jk/grep-double-dash:
  accept "git grep -- pattern"

14 years agoMerge branch 'jc/typo' into maint
Junio C Hamano [Wed, 17 Feb 2010 22:55:09 +0000 (14:55 -0800)]
Merge branch 'jc/typo' into maint

* jc/typo:
  Typofixes outside documentation area

14 years agostatus: preload index to optimize lstat(2) calls
Junio C Hamano [Wed, 17 Feb 2010 20:30:41 +0000 (12:30 -0800)]
status: preload index to optimize lstat(2) calls

Noticed by James Pickens

Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agofast-import: use the diff_delta() max_delta_size argument
Nicolas Pitre [Wed, 17 Feb 2010 19:05:56 +0000 (14:05 -0500)]
fast-import: use the diff_delta() max_delta_size argument

This let diff_delta() abort early if it is going to bust the given
size limit.  Also, only objects larger than 20 bytes are considered
as objects smaller than that are most certainly going to produce
larger deltas than the original object due to the additional headers.

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agofast-import: honor pack.indexversion and pack.packsizelimit config vars
Nicolas Pitre [Wed, 17 Feb 2010 19:05:55 +0000 (14:05 -0500)]
fast-import: honor pack.indexversion and pack.packsizelimit config vars

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agofast-import: make default pack size unlimited
Nicolas Pitre [Wed, 17 Feb 2010 19:05:54 +0000 (14:05 -0500)]
fast-import: make default pack size unlimited

Now that fast-import is creating packs with index version 2, there is
no point limiting the pack size by default.  A pack split will still
happen if off_t is not sufficiently large to hold large offsets.

While updating the doc, let's remove the "packfiles fit on CDs"
suggestion.  Pack files created by fast-import are still suboptimal and
a 'git repack -a -f -d' or even 'git gc --aggressive' would be a pretty
good idea before considering storage on CDs.

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agofast-import: use write_idx_file() instead of custom code
Nicolas Pitre [Wed, 17 Feb 2010 19:05:53 +0000 (14:05 -0500)]
fast-import: use write_idx_file() instead of custom code

This allows for the creation of pack index version 2 with its object
CRC and the possibility for a pack to be larger than 4 GB.

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agofast-import: use sha1write() for pack data
Nicolas Pitre [Wed, 17 Feb 2010 19:05:52 +0000 (14:05 -0500)]
fast-import: use sha1write() for pack data

This is in preparation for using write_idx_file().  Also, by using
sha1write() we get some buffering to reduces the number of write
syscalls, and the written data is SHA1 summed which allows for the extra
data integrity validation check performed in fixup_pack_header_footer()
(details on this in commit abeb40e5aa).

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agofast-import: start using struct pack_idx_entry
Nicolas Pitre [Wed, 17 Feb 2010 19:05:51 +0000 (14:05 -0500)]
fast-import: start using struct pack_idx_entry

This is in preparation for using write_idx_file().

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agorequire_work_tree broken with NONGIT_OK
Gabriel Filion [Wed, 17 Feb 2010 04:18:50 +0000 (23:18 -0500)]
require_work_tree broken with NONGIT_OK

With NONGIT_OK set, require_work_tree function outside a git repository
gives a syntax error.  This is caused by an incorrect use of "test" that
didn't anticipate $(git rev-parse --is-inside-work-tree) may return an
empty string.

Properly quote the argument to "test", and send the standard error stream
to /dev/null to avoid giving duplicate error messages.

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 years agogrep documentation: clarify what files match
Mark Lodato [Tue, 16 Feb 2010 00:25:40 +0000 (19:25 -0500)]
grep documentation: clarify what files match

Clarify that git-grep(1) searches only tracked files, and that each
<pathspec> is a pathspec, as in any other ordinary git commands.

Add an example to show a simple use case for searching all .c and .h
files in the current directory and below.

Signed-off-by: Mark Lodato <lodatom@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>