gitweb.git
Update draft release notes to 1.8.4Junio C Hamano Mon, 24 Jun 2013 20:53:03 +0000 (13:53 -0700)

Update draft release notes to 1.8.4

For now, comment out the description on two "git status" UI
configuration, until the reverted topic can be resurrected.

Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'rr/am-quit-empty-then-abort-fix'Junio C Hamano Mon, 24 Jun 2013 20:49:00 +0000 (13:49 -0700)

Merge branch 'rr/am-quit-empty-then-abort-fix'

Recent "rebase --autostash" update made it impossible to recover
with "git am --abort" from a repository where "git am" without mbox
was run by mistake and then was killed with "^C".

* rr/am-quit-empty-then-abort-fix:
t/am: use test_path_is_missing() where appropriate
am: handle stray $dotest directory

Merge branch 'rt/cherry-pick-continue-advice-in-status'Junio C Hamano Mon, 24 Jun 2013 20:48:57 +0000 (13:48 -0700)

Merge branch 'rt/cherry-pick-continue-advice-in-status'

* rt/cherry-pick-continue-advice-in-status:
wt-status: give better advice when cherry-pick is in progress

Merge branch 'nk/config-local-doc'Junio C Hamano Mon, 24 Jun 2013 20:48:55 +0000 (13:48 -0700)

Merge branch 'nk/config-local-doc'

* nk/config-local-doc:
config: Add description of --local option

Merge branch 'jk/mergetool-lib-refactor'Junio C Hamano Mon, 24 Jun 2013 20:48:53 +0000 (13:48 -0700)

Merge branch 'jk/mergetool-lib-refactor'

Code cleanup.

* jk/mergetool-lib-refactor:
mergetool--lib: refactor {diff,merge}_cmd logic

Merge branch 'jk/doc-build-move-infordir-def'Junio C Hamano Mon, 24 Jun 2013 20:48:51 +0000 (13:48 -0700)

Merge branch 'jk/doc-build-move-infordir-def'

Makefile cleanup.

* jk/doc-build-move-infordir-def:
Documentation/Makefile: move infodir to be with other '*dir's
Documentation/Makefile: fix spaces around assignments

Merge branch 'fg/submodule-fixup'Junio C Hamano Mon, 24 Jun 2013 20:48:50 +0000 (13:48 -0700)

Merge branch 'fg/submodule-fixup'

Code cleanup.

* fg/submodule-fixup:
git-submodule.sh: remove duplicate call to set_rev_name

Merge branch 'dk/version-gen-gitdir'Junio C Hamano Mon, 24 Jun 2013 20:48:48 +0000 (13:48 -0700)

Merge branch 'dk/version-gen-gitdir'

Allow packaging a tarball in a working tree with $GIT_DIR set elsewhere.

* dk/version-gen-gitdir:
GIT-VERSION-GEN: support non-standard $GIT_DIR path

Merge branch 'dk/maint-t5150-dirname'Junio C Hamano Mon, 24 Jun 2013 20:48:46 +0000 (13:48 -0700)

Merge branch 'dk/maint-t5150-dirname'

Fix a test script.

* dk/maint-t5150-dirname:
tests: allow sha1's as part of the path

Merge branch 'rs/unpack-trees-tree-walk-conflict-field'Junio C Hamano Mon, 24 Jun 2013 20:48:44 +0000 (13:48 -0700)

Merge branch 'rs/unpack-trees-tree-walk-conflict-field'

Code clean-up.

* rs/unpack-trees-tree-walk-conflict-field:
unpack-trees: don't shift conflicts left and right

Merge branch 'rr/rebase-sha1-by-string-query'Junio C Hamano Mon, 24 Jun 2013 20:48:40 +0000 (13:48 -0700)

Merge branch 'rr/rebase-sha1-by-string-query'

Allow various commit objects to be given to "git rebase" by ':/look
for this string' syntax, e.g. "git rebase --onto ':/there'".

* rr/rebase-sha1-by-string-query:
rebase: use peel_committish() where appropriate
sh-setup: add new peel_committish() helper
t/rebase: add failing tests for a peculiar revision

Merge branch 'mm/rm-coalesce-errors'Junio C Hamano Mon, 24 Jun 2013 20:48:35 +0000 (13:48 -0700)

Merge branch 'mm/rm-coalesce-errors'

Give a single message followed by list of paths from "git rm" to
report multiple paths that cannot be removed.

* mm/rm-coalesce-errors:
rm: introduce advice.rmHints to shorten messages
rm: better error message on failure for multiple files

Merge branch 'jh/libify-note-handling'Junio C Hamano Mon, 24 Jun 2013 20:48:30 +0000 (13:48 -0700)

Merge branch 'jh/libify-note-handling'

Make it possible to call into copy-notes API from the sequencer code.

* jh/libify-note-handling:
Move create_notes_commit() from notes-merge.c into notes-utils.c
Move copy_note_for_rewrite + friends from builtin/notes.c to notes-utils.c
finish_copy_notes_for_rewrite(): Let caller provide commit message

Merge branch 'fc/sequencer-plug-leak'Junio C Hamano Mon, 24 Jun 2013 20:48:28 +0000 (13:48 -0700)

Merge branch 'fc/sequencer-plug-leak'

Plug a small leak in an error codepath.

* fc/sequencer-plug-leak:
sequencer: avoid leaking message buffer when refusing to create an empty commit
sequencer: remove useless indentation

bash prompt: mention that PROMPT_COMMAND mode is fasterSZEDER Gábor Mon, 24 Jun 2013 00:28:02 +0000 (02:28 +0200)

bash prompt: mention that PROMPT_COMMAND mode is faster

__git_ps1() is usually added to the prompt inside a command
substitution, imposing the overhead of fork()ing a subshell. Using
__git_ps1() for $PROMPT_COMMAND is slightly faster, because it avoids
that command substitution.

Mention this in the comments about setting up the git prompt.

The whole series speeds up the bash prompt on Windows/MSysGit
considerably. Here are some timing results in three scenarios, each
repeated 10 times:

At the top of the work tree, before:

$ time for i in {0..9} ; do prompt="$(__git_ps1)" ; done

real 0m1.716s
user 0m0.301s
sys 0m0.772s

After:

real 0m0.687s
user 0m0.075s
sys 0m0.396s

After, from $PROMPT_COMMAND:

$ time for i in {0..9} ; do __git_ps1 '\h:\w' '$ ' ; done

real 0m0.546s
user 0m0.075s
sys 0m0.181s

At the top of the work tree, detached head, before:

real 0m2.574s
user 0m0.376s
sys 0m1.207s

After:

real 0m1.139s
user 0m0.151s
sys 0m0.500s

After, from $PROMPT_COMMAND:

real 0m1.030s
user 0m0.245s
sys 0m0.336s

In a subdirectory, during rebase, stash status indicator enabled,
before:

real 0m3.557s
user 0m0.495s
sys 0m1.767s

After:

real 0m0.717s
user 0m0.120s
sys 0m0.300s

After, from $PROMPT_COMMAND:

real 0m0.577s
user 0m0.047s
sys 0m0.258s

On Linux the speedup ratio is comparable to Windows, but overall it
was about an order of magnitude faster to begin with. The last case
from above, repeated 100 times, before:

$ time for i in {0..99} ; do prompt="$(__git_ps1)" ; done

real 0m2.806s
user 0m0.180s
sys 0m0.264s

After:

real 0m0.857s
user 0m0.020s
sys 0m0.028s

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>

bash prompt: avoid command substitution when finalizing... SZEDER Gábor Mon, 17 Jun 2013 19:42:55 +0000 (21:42 +0200)

bash prompt: avoid command substitution when finalizing gitstring

Before setting $PS1, __git_ps1() uses a command substitution to
redirect the output from a printf into a variable. Spare the overhead
of fork()ing a subshell by using 'printf -v <var>' to directly assign
the output to that variable.

zsh's printf doesn't support the '-v <var>' option, so stick with the
command substitution when under zsh.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>

bash prompt: avoid command substitution when checking... SZEDER Gábor Fri, 12 Aug 2011 12:17:12 +0000 (14:17 +0200)

bash prompt: avoid command substitution when checking for untracked files

When enabled, the bash prompt can indicate the presence of untracked
files with a '%' sign. __git_ps1() checks for untracked files by running the
'$(git ls-files --others --exclude-standard)' command substitution,
and displays the indicator when there is no output.

Avoid this command substitution by additionally passing
'--error-unmatch *', and checking the command's return value.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>

bash prompt: use bash builtins to check stash stateSZEDER Gábor Fri, 1 Apr 2011 15:47:37 +0000 (17:47 +0200)

bash prompt: use bash builtins to check stash state

When the environment variable $GIT_PS1_SHOWSTASHSTATE is set
__git_ps1() checks the presence of stashes by running 'git rev-parse
--verify refs/stash'. This command not only checks that the
'refs/stash' ref exists but also, well, verifies that it's a valid
ref.

However, we don't need to be that thorough for the bash prompt. We
can omit that verification and only check whether 'refs/stash' exists
or not. Since 'git pack-refs' never packs 'refs/stash', it's a matter
of checking the existence of a ref file. Perform this check using
only bash builtins to spare the overhead of fork()+exec()ing a git
process.

Also run 'git pack-refs --all' in the corresponding test to document
that the prompt script depends on 'git pack-refs' not packing
'refs/stash' and to catch possible breakages should this behavior ever
change.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>

bash prompt: use bash builtins to check for unborn... SZEDER Gábor Mon, 24 Jun 2013 10:49:19 +0000 (12:49 +0200)

bash prompt: use bash builtins to check for unborn branch for dirty state

When the dirty work tree and index status indicator is enabled,
__git_ps1() checks for changes in the index by running 'git diff-index
--cached --quiet HEAD --' and looking at its exit code. However, that
makes sense only when HEAD points to a valid commit: on an unborn
branch the failure of said command would be caused by the invalid
HEAD, not by changes in the index. Therefore, __git_ps1() first
checks for a valid HEAD by running 'git rev-parse --quiet --verify
HEAD'.

Since the previous patch we implicitly check HEAD's validity by
running 'git rev-parse ... --short HEAD', making the dirty status
indicator's 'git rev-parse' check redundant. It's sufficient to check
for non-emptyness of the variable holding the abbreviated commit
object name, thereby sparing the overhead of fork()+exec()ing a git
process.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>

bash prompt: combine 'git rev-parse' for detached headSZEDER Gábor Mon, 24 Jun 2013 00:16:02 +0000 (02:16 +0200)

bash prompt: combine 'git rev-parse' for detached head

When describing a detached HEAD according to the $GIT_PS1_DESCRIBE
environment variable fails, __git_ps1() now runs the '$(git rev-parse
--short HEAD)' command substitution to get the abbreviated detached
HEAD commit object name. This imposes the overhead of fork()ing a
subshell and fork()+exec()ing a git process.

Avoid this overhead by combining this command substitution with the
"main" 'git rev-parse' execution for getting the path to the .git
directory & co. This means that we'll look for the abbreviated commit
object name even when it's not necessary, because we're on a branch or
the detached HEAD can be described. It doesn't matter, however,
because once 'git rev-parse' is up and running to fulfill all those
other queries, the additional overhead of looking for the abbreviated
commit object name is not measurable because it's lost in the noise.

There is a caveat, however, when we are on an unborn branch, because
in that case HEAD doesn't point to a valid commit, hence the query for
the abbreviated commit object name fails. Therefore, '--short HEAD'
must be the last options to 'git rev-parse' in order to get all the
other necessary information for the prompt even on an unborn branch.
Furthermore, in that case, and in that case only, 'git rev-parse'
doesn't output the last line containing the abbreviated commit object
name, obviously, so we have to take care to only parse it if 'git
rev-parse' exited without any error.

Although there are tests already excercising __git_ps1() on unborn
branches, they all do so implicitly. Add a test that checks this
explicitly.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>

bash prompt: combine 'git rev-parse' executions in... SZEDER Gábor Mon, 17 Jun 2013 20:58:42 +0000 (22:58 +0200)

bash prompt: combine 'git rev-parse' executions in the main code path

There are a couple of '$(git rev-parse --<opt>)' command substitutions
in __git_ps1() and three of them are executed in the main code path:

- the first to get the path to the .git directory ('--git-dir'),
- the second to check whether we're inside the .git directory
('--is-inside-git-dir'),
- and the last, depending on the results of the second, either
* to check whether it's a bare repo ('--is-bare-repository'), or
* to check whether inside a work tree ('--is-inside-work-tree').

Naturally, this imposes the overhead of fork()ing three subshells and
fork()+exec()ing three git commands.

Combine these four 'git rev-parse' queries into a single one and use
bash parameter expansions to parse the combined output, i.e. to
separate the path to the .git directory from the true/false of
'--is-inside-git-dir', etc. This way we can eliminate two of the
three subshells and git commands.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>

bash prompt: use bash builtins to find out current... SZEDER Gábor Thu, 31 Mar 2011 21:41:18 +0000 (23:41 +0200)

bash prompt: use bash builtins to find out current branch

__git_ps1() runs the '$(git symbolic-ref HEAD)' command substitution
to find out whether we are on a branch and to find out the name of
that branch. This imposes the overhead of fork()ing a subshell and
fork()+exec()ing a git process.

Since HEAD is in most cases a single-line file and the symbolic ref
format is quite simple to recognize and parse, read and parse it using
only bash builtins, thereby sparing all that fork()+exec() overhead.
Don't display the git prompt if reading HEAD fails, because a readable
HEAD is required for a git repository. HEAD can also be a symlink
symbolic ref (due to 'core.preferSymlinkRefs'), so use bash builtins
for reading HEAD only when HEAD is not a symlink.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>

bash prompt: use bash builtins to find out rebase stateSZEDER Gábor Thu, 31 Mar 2011 22:25:16 +0000 (00:25 +0200)

bash prompt: use bash builtins to find out rebase state

During an ongoing interactive rebase __git_ps1() finds out the name of
the rebased branch, the total number of patches and the number of the
current patch by executing a '$(cat .git/rebase-merge/<FILE>)' command
substitution for each. That is not quite the most efficient way to
read single line single word files, because it imposes the overhead of
fork()ing a subshell and fork()+exec()ing 'cat' several times.

Use the 'read' bash builtin instead to avoid those overheads.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>

bash prompt: run 'git rev-parse --git-dir' directly... SZEDER Gábor Mon, 17 Jun 2013 21:55:16 +0000 (23:55 +0200)

bash prompt: run 'git rev-parse --git-dir' directly instead of __gitdir()

__git_ps1() finds out the path to the repository by using the
__gitdir() helper function. __gitdir() is basically just a wrapper
around 'git rev-parse --git-dir', extended with support for
recognizing a remote repository given as argument, to use the path
given on the command line, and with a few shortcuts to recognize a git
repository in cwd or at $GIT_DIR quickly without actually running 'git
rev-parse'. However, the former two is only necessary for the
completion script but makes no sense for the bash prompt, while the
latter shortcuts are performance optimizations __git_ps1() can do
without (they just avoid the overhead of fork()+exec()ing a git
process).

Run 'git rev-parse --git-dir' directly in __git_ps1(), because it will
allow this patch series to combine several $(git rev-parse ...)
command substitutions in the main code path, and the overall
performance benefit will far outweigh the loss of those few shortcuts
in __gitdir(). Furthermore, since __gitdir() is not needed anymore
for the prompt, remove it from the prompt script finally eliminating
its duplication between the prompt and completion scripts. Also
remove the comment from the completion script warning about this code
duplication.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>

bash prompt: return early from __git_ps1() when not... SZEDER Gábor Mon, 5 Sep 2011 18:53:37 +0000 (20:53 +0200)

bash prompt: return early from __git_ps1() when not in a git repository

... to gain one level of indentation for the bulk of the function.

(The patch looks quite unreadable, you'd better check it with 'git
diff -w'.)

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>

bash prompt: print unique detached HEAD abbreviated... SZEDER Gábor Sun, 23 Jun 2013 23:55:42 +0000 (01:55 +0200)

bash prompt: print unique detached HEAD abbreviated object name

When describing a detached HEAD according to the $GIT_PS1_DESCRIBE
environment variable fails, __git_ps1() runs 'cut -c1-7 .git/HEAD' to
show the 7 hexdigits abbreviated commit object name in the prompt.
Obviously, this neither respects core.abbrev nor produces a unique
object name.

Fix this by using 'git rev-parse --short HEAD' instead and adjust the
corresponding test to use non-standard number of hexdigits.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>

bash prompt: add a test for symbolic link symbolic... SZEDER Gábor Fri, 24 Aug 2012 17:52:48 +0000 (19:52 +0200)

bash prompt: add a test for symbolic link symbolic refs

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>

completion, bash prompt: move __gitdir() tests to compl... SZEDER Gábor Mon, 17 Jun 2013 18:31:51 +0000 (20:31 +0200)

completion, bash prompt: move __gitdir() tests to completion test suite

Currently __gitdir() is duplicated in the git completion and prompt
scripts, while its tests are in the prompt test suite. This patch
series is about to change __git_ps1() in a way that it won't need
__gitdir() anymore and __gitdir() will be removed from the prompt
script.

So move all __gitdir() tests from the prompt test suite over to the
completion test suite. Update the setup tests so that they perform
only those steps that are necessary for each test suite.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>

Revert "Merge branch 'jg/status-config'"Junio C Hamano Mon, 24 Jun 2013 15:18:07 +0000 (08:18 -0700)

Revert "Merge branch 'jg/status-config'"

This reverts commit 1a22bd31f0a5130ce6c934951a5526ceb774c2be, reversing
changes made to 3e7a5b489e45ae8a3a0b222893d58b172d883136.

It makes it impossible to "git commit" when status.short is set, and
also "git status --porcelain" output is affected by status.branch.

bash prompt: use 'write_script' helper in interactive... SZEDER Gábor Fri, 24 Aug 2012 18:03:58 +0000 (20:03 +0200)

bash prompt: use 'write_script' helper in interactive rebase test

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>

bash prompt: fix redirection coding style in testsSZEDER Gábor Mon, 17 Jun 2013 20:34:16 +0000 (22:34 +0200)

bash prompt: fix redirection coding style in tests

Use '>file' instead of '> file', in accordance with the coding
guidelines.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>

Update draft release notes to 1.8.4Junio C Hamano Sun, 23 Jun 2013 21:55:45 +0000 (14:55 -0700)

Update draft release notes to 1.8.4

Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'mz/rebase-tests'Junio C Hamano Sun, 23 Jun 2013 21:53:26 +0000 (14:53 -0700)

Merge branch 'mz/rebase-tests'

* mz/rebase-tests:
rebase topology tests: fix commit names on case-insensitive file systems
tests: move test for rebase messages from t3400 to t3406
t3406: modernize style
add tests for rebasing merged history
add tests for rebasing root
add tests for rebasing of empty commits
add tests for rebasing with patch-equivalence present
add simple tests of consistency across rebase types

Merge branch 'jk/unpack-entry-fallback-to-another'Junio C Hamano Sun, 23 Jun 2013 21:53:20 +0000 (14:53 -0700)

Merge branch 'jk/unpack-entry-fallback-to-another'

* jk/unpack-entry-fallback-to-another:
unpack_entry: do not die when we fail to apply a delta
t5303: drop "count=1" from corruption dd

Merge branch 'jk/apache-test-for-2.4'Junio C Hamano Sun, 23 Jun 2013 21:53:17 +0000 (14:53 -0700)

Merge branch 'jk/apache-test-for-2.4'

* jk/apache-test-for-2.4:
lib-httpd/apache.conf: check version only after mod_version loads
t/lib-httpd/apache.conf: configure an MPM module for apache 2.4
t/lib-httpd/apache.conf: load compat access module in apache 2.4
t/lib-httpd/apache.conf: load extra auth modules in apache 2.4
t/lib-httpd/apache.conf: do not use LockFile in apache >= 2.4

Merge branch 'cm/remote-mediawiki-perlcritique'Junio C Hamano Sun, 23 Jun 2013 21:53:13 +0000 (14:53 -0700)

Merge branch 'cm/remote-mediawiki-perlcritique'

* cm/remote-mediawiki-perlcritique: (31 commits)
git-remote-mediawiki: make error message more precise
git-remote-mediawiki: add a perlcritic rule in Makefile
git-remote-mediawiki: add a .perlcriticrc file
git-remote-mediawiki: clearly rewrite double dereference
git-remote-mediawiki: fix a typo ("mediwiki" instead of "mediawiki")
git-remote-mediawiki: put non-trivial numeric values in constants.
git-remote-mediawiki: don't use quotes for empty strings
git-remote-mediawiki: replace "unless" statements with negated "if" statements
git-remote-mediawiki: brace file handles for print for more clarity
git-remote-mediawiki: modify strings for a better coding-style
git-remote-mediawiki: put long code into a subroutine
git-remote-mediawiki: remove import of unused open2
git-remote-mediawiki: check return value of open
git-remote-mediawiki: assign a variable as undef and make proper indentation
git-remote-mediawiki: rename a variable ($last) which has the name of a keyword
git-remote-mediawiki: remove unused variable $entry
git-remote-mediawiki: turn double-negated expressions into simple expressions
git-remote-mediawiki: change the name of a variable
git-remote-mediawiki: add newline in the end of die() error messages
git-remote-mediawiki: change style in a regexp
...

Merge branch 'bp/remote-mw-tests'Junio C Hamano Sun, 23 Jun 2013 21:53:11 +0000 (14:53 -0700)

Merge branch 'bp/remote-mw-tests'

* bp/remote-mw-tests:
git-remote-mediawiki: remove hardcoded version number in the test suite

Merge branch 'rr/rebase-autostash'Junio C Hamano Sun, 23 Jun 2013 21:53:07 +0000 (14:53 -0700)

Merge branch 'rr/rebase-autostash'

* rr/rebase-autostash:
rebase: finish_rebase() in noop rebase
rebase: finish_rebase() in fast-forward rebase
rebase: guard against missing files in read_basic_state()

Merge branch 'rr/prompt-rebase-breakage-fix'Junio C Hamano Sun, 23 Jun 2013 21:53:05 +0000 (14:53 -0700)

Merge branch 'rr/prompt-rebase-breakage-fix'

* rr/prompt-rebase-breakage-fix:
prompt: squelch error output from cat

Merge branch 'jg/status-config'Junio C Hamano Sun, 23 Jun 2013 21:51:58 +0000 (14:51 -0700)

Merge branch 'jg/status-config'

"git status" learned status.branch and status.short configuration
variables to use --branch and --short options by default (override
with --no-branch and --no-short options from the command line).

* jg/status-config:
status: introduce status.branch to enable --branch by default
status: introduce status.short to enable --short by default

add -i: add extra options at the right place in "diff... Junio C Hamano Sun, 23 Jun 2013 19:19:05 +0000 (12:19 -0700)

add -i: add extra options at the right place in "diff" command line

Appending "--diff-algorithm=histogram" at the end of canned command
line for various modes of "diff" is correct for most of them but not
for "stash" that has a non-option already wired in, like so:

'stash' => {
DIFF => 'diff-index -p HEAD',

Appending an extra option after non-option may happen to work due to
overly lax command line parser, but that is not something we should
rely on. Instead, splice in the extra argument immediately after the
command name (i.e. 'diff-index', 'diff-files', etc.).

Signed-off-by: Junio C Hamano <gitster@pobox.com>

test-lib: support running tests under valgrind in parallelThomas Rast Sun, 23 Jun 2013 18:12:59 +0000 (20:12 +0200)

test-lib: support running tests under valgrind in parallel

With the new --valgrind-parallel=<n> option, we support running the
tests in a single test script under valgrind in parallel using 'n'
processes.

This really follows the dumbest approach possible, as follows:

* We spawn the test script 'n' times, using a throw-away
TEST_OUTPUT_DIRECTORY. Each of the instances is given options that
ensures that it only runs every n-th test under valgrind, but
together they cover the entire range.

* We add up the numbers from the individual tests, and provide the
usual output.

This is really a gross hack at this point, and should be improved. In
particular we should keep the actual outputs somewhere more easily
discoverable, and summarize them to the user.

Nevertheless, this is already workable and gives a speedup of more
than 2 on a dual-core (hyperthreaded) machine, using n=4. This is
expected since the overhead of valgrind is so big (on the order of 20x
under good conditions, and a large startup overhead at every git
invocation) that redundantly running the non-valgrind tests in between
is not that expensive.

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Thomas Rast <trast@inf.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

test-lib: allow prefixing a custom string before "ok... Thomas Rast Sun, 23 Jun 2013 18:12:58 +0000 (20:12 +0200)

test-lib: allow prefixing a custom string before "ok N" etc.

This is not really meant for external use, and thus not documented. It
allows the next commit to neatly distinguish between sub-tests and the
main run.

The format is intentionally not valid TAP. The use in the next commit
would not result in anything valid either way, and it seems better to
make it obvious.

Signed-off-by: Thomas Rast <trast@inf.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

test-lib: valgrind for only tests matching a patternThomas Rast Sun, 23 Jun 2013 18:12:57 +0000 (20:12 +0200)

test-lib: valgrind for only tests matching a pattern

With the new --valgrind-only=<pattern> option, one can enable
--valgrind at a per-test granularity, exactly analogous to
--verbose-only from the previous commit.

The options are wired such that --valgrind implies --verbose (as
before), but --valgrind-only=<pattern> implies
--verbose-only=<pattern> unless --verbose is also in effect.

Signed-off-by: Thomas Rast <trast@inf.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

test-lib: verbose mode for only tests matching a patternThomas Rast Sun, 23 Jun 2013 18:12:56 +0000 (20:12 +0200)

test-lib: verbose mode for only tests matching a pattern

With the new --verbose-only=<pattern> option, one can enable --verbose
at a per-test granularity. The pattern is matched against the test
number, e.g.

./t0000-basic.sh --verbose-only='2[0-2]'

to see only the full output of test 20-22, while showing the rest in the
one-liner format.

As suggested by Jeff King, this takes care to wrap the entire
test_expect_* block, but nothing else, in the verbose toggling. We
can use the test_start/end functions from the previous commit for the
purpose.

This is arguably not *too* useful on its own, but makes the next patch
easier to follow.

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Thomas Rast <trast@inf.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

test-lib: self-test that --verbose worksThomas Rast Sun, 23 Jun 2013 18:12:55 +0000 (20:12 +0200)

test-lib: self-test that --verbose works

t0000 contains some light self-tests of test-lib.sh, but --verbose was
not covered. Add a test.

The only catch is that the presence of a test harness influences the
output (specifically, the presence of some empty lines). So we need
to unset TEST_HARNESS or set it to a known value. Leaving it unset
leads to spurious test failures in the final summary, which come from
the subtest. So we always set it.

Signed-off-by: Thomas Rast <trast@inf.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

user-manual: Update download size for Git and the kernelW. Trevor King Wed, 19 Jun 2013 01:55:22 +0000 (21:55 -0400)

user-manual: Update download size for Git and the kernel

They've grown since d19fbc3 (Documentation: add git user's manual,
2007-01-07) when the stats were initially added. I've rounded
download sizes up to the nearest multiple of ten MiB to decrease the
precision and give a bit of growing room. Exact sizes:

$ git clone git://git.kernel.org/pub/scm/git/git.git
Initialized empty Git repository in /tmp/git/.git/
remote: Counting objects: 156872, done.
remote: Compressing objects: 100% (40826/40826), done.
remote: Total 156872 (delta 115322), reused 155492 (delta 114094)
Receiving objects: 100% (156872/156872), 37.29 MiB | 7.54 MiB/s, done.
Resolving deltas: 100% (115322/115322), done.

$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Initialized empty Git repository in /tmp/linux/.git/
remote: Counting objects: 3057404, done.
remote: Compressing objects: 100% (474769/474769), done.
Receiving objects: 100% (3057404/3057404), 634.33 MiB | 27.95 MiB/s, done.
remote: Total 3057404 (delta 2570385), reused 3040910 (delta 2554408)
Resolving deltas: 100% (2570385/2570385), done.
Checking out files: 100% (43012/43012), done.

Signed-off-by: W. Trevor King <wking@tremily.us>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t/t5505-remote: test multiple push/pull in remotes... Ramkumar Ramachandra Sat, 22 Jun 2013 07:58:18 +0000 (13:28 +0530)

t/t5505-remote: test multiple push/pull in remotes-file

Extend the test "migrate a remote from named file in $GIT_DIR/remotes"
to test that multiple "Push:" and "Pull:" lines in the remotes-file
works as expected.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

ls-remote doc: don't encourage use of branches-fileRamkumar Ramachandra Sat, 22 Jun 2013 07:58:17 +0000 (13:28 +0530)

ls-remote doc: don't encourage use of branches-file

One outdated example encourages the use of $GIT_DIR/branches files.
Replace it with an equivalent example using a remote.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

ls-remote doc: rewrite <repository> paragraphRamkumar Ramachandra Sat, 22 Jun 2013 07:58:16 +0000 (13:28 +0530)

ls-remote doc: rewrite <repository> paragraph

Replace the <repository> paragraph containing specific references to
$GIT_DIR/branches and "." with a generic urls-or-remotes paragraph
referencing the relevant sections in the git-fetch(1) manpage.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

ls-remote doc: fix example invocation on git.gitRamkumar Ramachandra Sat, 22 Jun 2013 07:58:15 +0000 (13:28 +0530)

ls-remote doc: fix example invocation on git.git

Under the EXAMPLES section, there is one invocation on the git.git
repository that attempts to list the refs master, pu, and rc. The ref
rc does not exist in today's repository, so remove it. Among other
things, this example demonstrates that the "<refs>..." argument is
simply a filter; requesting a non-existent ref is not an error.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t/t5505-remote: test url-with-# in branches-fileRamkumar Ramachandra Sat, 22 Jun 2013 07:58:13 +0000 (13:28 +0530)

t/t5505-remote: test url-with-# in branches-file

Add one more test similar to "migrate a remote from named file in
$GIT_DIR/branches" to check that a url with a # can be used to specify
the branch name (as opposed to the constant "master").

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote: remove dead code in read_branches_file()Ramkumar Ramachandra Sat, 22 Jun 2013 07:58:12 +0000 (13:28 +0530)

remote: remove dead code in read_branches_file()

The first line of the function checks that the remote-name contains a
slash ('/'), and sets the "slash" variable accordingly. The only caller
of read_branches_file() is remote_get_1(); the calling codepath is
guarded by valid_remote_nick(), which checks that the remote does not
contain a slash. Therefore, the "slash" variable can never be set:
remove the dead code that assumes otherwise.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t/t5505-remote: use test_path_is_missingRamkumar Ramachandra Sat, 22 Jun 2013 07:58:10 +0000 (13:28 +0530)

t/t5505-remote: use test_path_is_missing

Replace instances of ! test -f with test_path_is_missing.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t/t5505-remote: test push-refspec in branches-fileRamkumar Ramachandra Sat, 22 Jun 2013 07:58:09 +0000 (13:28 +0530)

t/t5505-remote: test push-refspec in branches-file

The test "migrate a remote from named file in $GIT_DIR/branches" reads
the branches-file, but only checks that the url and fetch-refspec are
set correctly. Check that the push-refspec is also set correctly.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t/t5505-remote: modernize styleRamkumar Ramachandra Sat, 22 Jun 2013 07:58:08 +0000 (13:28 +0530)

t/t5505-remote: modernize style

Modernize the style of all tests throughout the file:

- Remove spurious blank lines.

- Indent the test body.

- Make sure that all lines end with &&, to make it easier to spot
breaks in the chain.

- When executing something in a subshell, put the parenthesis on
separate lines and indent the body. Also make sure that the
first statement in the subshell is a 'cd'.

- When redirecting input or output, do not use SP between
redirection operator and the target filename.

- Use the <<-\EOF and <<-EOF forms of heredoc, not <<EOF, when the
command is indented and the heredoc text itself does not have to
have a leading tab.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Documentation: Update 'linux-2.6.git' -> 'linux.git'W. Trevor King Sat, 22 Jun 2013 14:46:27 +0000 (10:46 -0400)

Documentation: Update 'linux-2.6.git' -> 'linux.git'

The 3.x tree has been out for a while now. The -2.6 repository name
survived the initial release [1], but kernel.org now only lists
'linux.git' (for aegl as well as torvalds) [2].

[1]: http://article.gmane.org/gmane.linux.kernel/1147422
On 2011-05-30 01:47:57 GMT, Linus Torvalds wrote:
> ... yes, that means that my git tree is still called
> "linux-2.6.git" on kernel.org.
[2]: http://git.kernel.org/cgit/

Signed-off-by: W. Trevor King <wking@tremily.us>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Documentation: Update the NFS remote examples to use... W. Trevor King Sat, 22 Jun 2013 14:46:26 +0000 (10:46 -0400)

Documentation: Update the NFS remote examples to use the staging repo

linux-nfs.org seems to have restructured their repository layout since
8391c60 (git-remote.txt: fix example url, 2007-11-02), and Bruce's
repo is now at git://git.linux-nfs.org/projects/bfields/linux.git.
Bruce also has a more richer internal branch structure (master,
everything, for-3.1, ...), so updating the existing example to use his
current repo may be confusing.

To simplify, I've replaced the NFS repo with Greg's staging repo.
I've also updated the output of the surrounding commands to match the
output of a current run through.

Signed-off-by: W. Trevor King <wking@tremily.us>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

doc/clone: Pick more compelling paths for the --referen... W. Trevor King Sat, 22 Jun 2013 14:46:25 +0000 (10:46 -0400)

doc/clone: Pick more compelling paths for the --reference example

There may be times when using one of your local repositories as a
reference for a new clone make sense, but the implied version-bump in
the old example isn't one of them. I think a more intuitive example
is multi-user system with a central reference clone, and the new paths
hint at this use case.

Signed-off-by: W. Trevor King <wking@tremily.us>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

doc/clone: Remove the '--bare -l -s' exampleW. Trevor King Sat, 22 Jun 2013 14:46:24 +0000 (10:46 -0400)

doc/clone: Remove the '--bare -l -s' example

There are other examples in git-clone.txt demonstrating both '--bare'
and '-l -s'.

Signed-off-by: W. Trevor King <wking@tremily.us>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

lib-httpd/apache.conf: check version only after mod_ver... Jeff King Fri, 21 Jun 2013 18:12:51 +0000 (14:12 -0400)

lib-httpd/apache.conf: check version only after mod_version loads

Commit 0442743 introduced an <IfVersion> directive near the
top of the apache config file. However, at that point we
have not yet checked for and loaded the mod_version module.
This means that the directive will behave oddly if
mod_version is dynamically loaded, failing to match when it
should.

We can fix this by moving the whole block below the
LoadModule directive for mod_version.

Reported-by: Brian Gernhardt <brian@gernhardtsoftware.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Sync with maintJunio C Hamano Fri, 21 Jun 2013 18:26:41 +0000 (11:26 -0700)

Sync with maint

* maint:
completion: complete diff --word-diff

t6003: add --author-date-order testJunio C Hamano Fri, 21 Jun 2013 18:08:02 +0000 (11:08 -0700)

t6003: add --author-date-order test

Tweak the --topo/date-order test vector a bit and mark the author
dates of two commits (a2 and a3) earlier than their own committer
dates, making them much older than other commits that are made on
parallel branches to simulate the case where a long running topic
was rebased recently.

They will show up as recent in the --date-order output due to their
timestamps, but they appear a lot later in the --author-date-order
output, even though their committer timestamp says otherwise.

Signed-off-by: Junio C Hamano <gitster@pobox.com>

topology tests: teach a helper to set author dates... Junio C Hamano Fri, 21 Jun 2013 18:03:32 +0000 (11:03 -0700)

topology tests: teach a helper to set author dates as well

Introduce on_dates helper that is similar to on_committer_date but
also sets the author date, not just the committer date.

At this step, just set the same timestamp to the author date as the
committer date, as no test looks at author date yet.

Signed-off-by: Junio C Hamano <gitster@pobox.com>

t6003: add --date-order testJunio C Hamano Fri, 21 Jun 2013 17:52:06 +0000 (10:52 -0700)

t6003: add --date-order test

The "--date-order" output is a slight twist of "--topo-order" in
that commits from parallel histories are shown in their committer
date order without an attempt to clump commits from a single line
of history together like --topo-order does.

Signed-off-by: Junio C Hamano <gitster@pobox.com>

topology tests: teach a helper to take abbreviated... Junio C Hamano Fri, 21 Jun 2013 17:29:59 +0000 (10:29 -0700)

topology tests: teach a helper to take abbreviated timestamps

The on_committer_date helper in t/lib-t6000 is used in t6002 and
t6003 with timestamps on a single day within a single minute
(i.e. 1971-08-16 00:00) and the tests repeat this over and over.

The actual value of the timestamp, however, does not matter very
much; only their relative ordering does.

Introduce another helper to expand only the suffix of the timestamp
to a full timestamp to make the lines shorter, and use it in this
helper. Also, because all the commits in the test are made with
specific GIT_COMMITTER_DATE, stop unsetting it at the end of the
helper.

We'll be specifying the author timestamp to these test commits in a
later patch, which will be helped with this change.

Also remove a test that was commented-out from t6003; it used to
test a commit with the same parent listed twice, which was allowed
by mistake but was fixed long time ago.

Signed-off-by: Junio C Hamano <gitster@pobox.com>

t/lib-t6000: style fixesJunio C Hamano Fri, 21 Jun 2013 17:12:48 +0000 (10:12 -0700)

t/lib-t6000: style fixes

Mostly fixes to initial indentation with 8-SP (they should be HT)
and wrapping long lines.

Signed-off-by: Junio C Hamano <gitster@pobox.com>

web--browse: support /usr/bin/cygstart on CygwinYaakov Selkowitz Fri, 21 Jun 2013 07:24:32 +0000 (02:24 -0500)

web--browse: support /usr/bin/cygstart on Cygwin

While both GUI and console Cygwin browsers do exist, anecdotal evidence
suggests most users rely on their native Windows browser. cygstart,
which is a long-standing part of the base Cygwin installation, will
cause the page to be opened in the default Windows browser (the one
registered to open .html files).

Signed-off-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

transport-helper: be quiet on read errors from helpersJeff King Fri, 21 Jun 2013 07:05:39 +0000 (03:05 -0400)

transport-helper: be quiet on read errors from helpers

Prior to commit 81d340d4, we did not print any error message
if a remote transport helper died unexpectedly. If a helper
did not print any error message (e.g., because it crashed),
the user could be left confused. That commit tried to
rectify the situation by printing a note that the helper
exited unexpectedly.

However, this makes a much more common case worse: when a
helper does die with a useful message, we print the extra
"Reading from 'git-remote-foo failed" message. This can also
end up confusing users, as they may not even know what
remote helpers are (e.g., the fact that http support comes
through git-remote-https is purely an implementation detail
that most users do not know or care about).

Since we do not have a good way of knowing whether the
helper printed a useful error, and since the common failure
mode is for it to do so, let's default to remaining quiet.
Debuggers can dig further by setting GIT_TRANSPORT_HELPER_DEBUG.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

completion: complete diff --word-diffRamkumar Ramachandra Tue, 18 Jun 2013 19:24:05 +0000 (00:54 +0530)

completion: complete diff --word-diff

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

apply: carefully strdup a possibly-NULL nameThomas Rast Fri, 21 Jun 2013 11:38:00 +0000 (13:38 +0200)

apply: carefully strdup a possibly-NULL name

2901bbe (apply: free patch->{def,old,new}_name fields, 2012-03-21)
cleaned up the memory management of filenames in the patches, but
forgot that find_name_traditional() can return NULL as a way of saying
"I couldn't find a name".

That NULL unfortunately gets passed into xstrdup() next, resulting in
a segfault. Use null_strdup() so as to safely propagate the null,
which will let us emit the correct error message.

Reported-by: DevHC on #git
Signed-off-by: Thomas Rast <trast@inf.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Update draft release notes to 1.8.4Junio C Hamano Thu, 20 Jun 2013 23:13:41 +0000 (16:13 -0700)

Update draft release notes to 1.8.4

Merge branch 'cm/remote-mediawiki'Junio C Hamano Thu, 20 Jun 2013 23:02:42 +0000 (16:02 -0700)

Merge branch 'cm/remote-mediawiki'

* cm/remote-mediawiki:
git-remote-mediawiki: display message when launched directly

Merge branch 'rs/match-trees-refactor'Junio C Hamano Thu, 20 Jun 2013 23:02:40 +0000 (16:02 -0700)

Merge branch 'rs/match-trees-refactor'

Code cleanup.

* rs/match-trees-refactor:
match-trees: factor out fill_tree_desc_strict

Merge branch 'rs/logical-vs-binary-or'Junio C Hamano Thu, 20 Jun 2013 23:02:38 +0000 (16:02 -0700)

Merge branch 'rs/logical-vs-binary-or'

Code cleanup.

* rs/logical-vs-binary-or:
use logical OR (||) instead of binary OR (|) in logical context

Merge branch 'mm/color-auto-default'Junio C Hamano Thu, 20 Jun 2013 23:02:33 +0000 (16:02 -0700)

Merge branch 'mm/color-auto-default'

Flip the default for color.ui to 'auto', which is what many
tutorials recommend new users to do.

* mm/color-auto-default:
make color.ui default to 'auto'
config: refactor management of color.ui's default value

Merge branch 'rs/discard-index-discard-array'Junio C Hamano Thu, 20 Jun 2013 23:02:30 +0000 (16:02 -0700)

Merge branch 'rs/discard-index-discard-array'

* rs/discard-index-discard-array:
read-cache: free cache in discard_index
read-cache: add simple performance test

Merge branch 'nd/traces'Junio C Hamano Thu, 20 Jun 2013 23:02:28 +0000 (16:02 -0700)

Merge branch 'nd/traces'

* nd/traces:
git.txt: document GIT_TRACE_PACKET
core: use env variable instead of config var to turn on logging pack access

Merge branch 'fc/show-non-empty-errors-in-test'Junio C Hamano Thu, 20 Jun 2013 23:02:24 +0000 (16:02 -0700)

Merge branch 'fc/show-non-empty-errors-in-test'

* fc/show-non-empty-errors-in-test:
test: test_must_be_empty helper

Merge branch 'fc/makefile'Junio C Hamano Thu, 20 Jun 2013 23:02:21 +0000 (16:02 -0700)

Merge branch 'fc/makefile'

Makefile simplification.

* fc/makefile:
Makefile: use $^ to avoid listing prerequisites on the command line
build: do not install git-remote-testgit
build: generate and clean test scripts

Merge branch 'js/test-ln-s-add'Junio C Hamano Thu, 20 Jun 2013 23:02:18 +0000 (16:02 -0700)

Merge branch 'js/test-ln-s-add'

Many tests that check the behaviour of symbolic links stored in the
index or the tree objects do not have to be skipped on a filesystem
that lack symbolic link support.

* js/test-ln-s-add:
t4011: remove SYMLINKS prerequisite
t6035: use test_ln_s_add to remove SYMLINKS prerequisite
t3509, t4023, t4114: use test_ln_s_add to remove SYMLINKS prerequisite
t3100: use test_ln_s_add to remove SYMLINKS prerequisite
t3030: use test_ln_s_add to remove SYMLINKS prerequisite
t0000: use test_ln_s_add to remove SYMLINKS prerequisite
tests: use test_ln_s_add to remove SYMLINKS prerequisite (trivial cases)
tests: introduce test_ln_s_add
t3010: modernize style
test-chmtime: Fix exit code on Windows

Merge branch 'nd/make-wildmatch-default'Junio C Hamano Thu, 20 Jun 2013 23:02:14 +0000 (16:02 -0700)

Merge branch 'nd/make-wildmatch-default'

* nd/make-wildmatch-default:
Makefile: promote wildmatch to be the default fnmatch implementation

pull: merge into unborn by fast-forwarding from empty... Thomas Rast Thu, 20 Jun 2013 22:38:28 +0000 (18:38 -0400)

pull: merge into unborn by fast-forwarding from empty tree

The logic for pulling into an unborn branch was originally
designed to be used on a newly-initialized repository
(d09e79c, git-pull: allow pulling into an empty repository,
2006-11-16). It thus did not initially deal with
uncommitted changes in the unborn branch. The case of an
_unstaged_ untracked file was fixed by 4b3ffe5 (pull: do not
clobber untracked files on initial pull, 2011-03-25).
However, it still clobbered existing staged files, both when
the file exists in the merged commit (it will be
overwritten), and when it does not (it will be deleted).

We fix this by doing a two-way merge, where the "current"
side of the merge is an empty tree, and the "target" side is
HEAD (already updated to FETCH_HEAD at this point). This
amounts to claiming that all work in the index was done vs.
an empty tree, and thus all content of the index is
precious.

Note that this use of read-tree just gives us protection
against overwriting index and working tree changes. It will
not actually result in a 3-way merge conflict in the index.
This is fine, as this is a rare situation, and the conflict
would not be interesting anyway (it must, by definition, be
an add/add conflict with the whole content conflicting). And
it makes it simpler for the user to recover, as they have no
HEAD to "git reset" back to.

Reported-by: Stefan Schüßler <mail@stefanschuessler.de>
Signed-off-by: Thomas Rast <trast@inf.ethz.ch>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

pull: update unborn branch tip after indexJeff King Thu, 20 Jun 2013 22:36:31 +0000 (18:36 -0400)

pull: update unborn branch tip after index

When commit d09e79c taught git to pull into an unborn
branch, it first updated the unborn branch to point at the
pulled commit, and then used read-tree to update the index
and working tree. That ordering made sense, since any
failure of the latter step would be due to filesystem
errors, and one could then recover with "git reset --hard".

Later, commit 4b3ffe5 added extra safety for existing files
in the working tree by asking read-tree to bail out when it
would overwrite such a file. This error mode is much less
"your pull failed due to random errors" and more like "we
reject this pull because it would lose data". In that case,
it makes sense not to update the HEAD ref, just as a regular
rejected merge would do.

This patch reverses the order of the update-ref and
read-tree calls, so that we do not touch the HEAD ref at all if a
merge is rejected. This also means that we would not update
HEAD in case of a transient filesystem error, but those are
presumably less rare (and one can still recover by repeating
the pull, or by accessing FETCH_HEAD directly).

While we're reorganizing the code, we can drop the "exit 1"
from the end of our command chain. We exit immediately
either way, and just calling exit without an argument will
use the exit code from the last command.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

for_each_ref: load all loose refs before packed refsJeff King Thu, 20 Jun 2013 08:37:53 +0000 (10:37 +0200)

for_each_ref: load all loose refs before packed refs

If we are iterating through the refs using for_each_ref (or
any of its sister functions), we can get into a race
condition with a simultaneous "pack-refs --prune" that looks
like this:

0. We have a large number of loose refs, and a few packed
refs. refs/heads/z/foo is loose, with no matching entry
in the packed-refs file.

1. Process A starts iterating through the refs. It loads
the packed-refs file from disk, then starts lazily
traversing through the loose ref directories.

2. Process B, running "pack-refs --prune", writes out the
new packed-refs file. It then deletes the newly packed
refs, including refs/heads/z/foo.

3. Meanwhile, process A has finally gotten to
refs/heads/z (it traverses alphabetically). It
descends, but finds nothing there. It checks its
cached view of the packed-refs file, but it does not
mention anything in "refs/heads/z/" at all (it predates
the new file written by B in step 2).

The traversal completes successfully without mentioning
refs/heads/z/foo at all (the name, of course, isn't
important; but the more refs you have and the farther down
the alphabetical list a ref is, the more likely it is to hit
the race). If refs/heads/z/foo did exist in the packed refs
file at state 0, we would see an entry for it, but it would
show whatever sha1 the ref had the last time it was packed
(which could be an arbitrarily long time ago).

This can be especially dangerous when process A is "git
prune", as it means our set of reachable tips will be
incomplete, and we may erroneously prune objects reachable
from that tip (the same thing can happen if "repack -ad" is
used, as it simply drops unreachable objects that are
packed).

This patch solves it by loading all of the loose refs for
our traversal into our in-memory cache, and then refreshing
the packed-refs cache. Because a pack-refs writer will
always put the new packed-refs file into place before
starting the prune, we know that any loose refs we fail to
see will either truly be missing, or will have already been
put in the packed-refs file by the time we refresh.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

get_packed_ref_cache: reload packed-refs file when... Jeff King Thu, 20 Jun 2013 08:37:52 +0000 (10:37 +0200)

get_packed_ref_cache: reload packed-refs file when it changes

Once we read the packed-refs file into memory, we cache it
to save work on future ref lookups. However, our cache may
be out of date with respect to what is on disk if another
process is simultaneously packing the refs. Normally it
is acceptable for us to be a little out of date, since there
is no guarantee whether we read the file before or after the
simultaneous update. However, there is an important special
case: our packed-refs file must be up to date with respect
to any loose refs we read. Otherwise, we risk the following
race condition:

0. There exists a loose ref refs/heads/master.

1. Process A starts and looks up the ref "master". It
first checks $GIT_DIR/master, which does not exist. It
then loads (and caches) the packed-refs file to see if
"master" exists in it, which it does not.

2. Meanwhile, process B runs "pack-refs --all --prune". It
creates a new packed-refs file which contains
refs/heads/master, and removes the loose copy at
$GIT_DIR/refs/heads/master.

3. Process A continues its lookup, and eventually tries
$GIT_DIR/refs/heads/master. It sees that the loose ref
is missing, and falls back to the packed-refs file. But
it examines its cached version, which does not have
refs/heads/master. After trying a few other prefixes,
it reports master as a non-existent ref.

There are many variants (e.g., step 1 may involve process A
looking up another ref entirely, so even a fully qualified
refname can fail). One of the most interesting ones is if
"refs/heads/master" is already packed. In that case process
A will not see it as missing, but rather will report
whatever value happened to be in the packed-refs file before
process B repacked (which might be an arbitrarily old
value).

We can fix this by making sure we reload the packed-refs
file from disk after looking at any loose refs. That's
unacceptably slow, so we can check its stat()-validity as a
proxy, and read it only when it appears to have changed.

Reading the packed-refs file after performing any loose-ref
system calls is sufficient because we know the ordering of
the pack-refs process: it always makes sure the newly
written packed-refs file is installed into place before
pruning any loose refs. As long as those operations by B
appear in their executed order to process A, by the time A
sees the missing loose ref, the new packed-refs file must be
in place.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

add a stat_validity structMichael Haggerty Thu, 20 Jun 2013 08:37:51 +0000 (10:37 +0200)

add a stat_validity struct

It can sometimes be useful to know whether a path in the
filesystem has been updated without going to the work of
opening and re-reading its content. We trust the stat()
information on disk already to handle index updates, and we
can use the same trick here.

This patch introduces a "stat_validity" struct which
encapsulates the concept of checking the stat-freshness of a
file. It is implemented on top of "struct stat_data" to
reuse the logic about which stat entries to trust for a
particular platform, but hides the complexity behind two
simple functions: check and update.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Extract a struct stat_data from cache_entryMichael Haggerty Thu, 20 Jun 2013 08:37:50 +0000 (10:37 +0200)

Extract a struct stat_data from cache_entry

Add public functions fill_stat_data() and match_stat_data() to work
with it. This infrastructure will later be used to check the validity
of other types of file.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

packed_ref_cache: increment refcount when lockedMichael Haggerty Thu, 20 Jun 2013 08:37:49 +0000 (10:37 +0200)

packed_ref_cache: increment refcount when locked

Increment the packed_ref_cache reference count while it is locked to
prevent its being freed.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

do_for_each_entry(): increment the packed refs cache... Michael Haggerty Thu, 20 Jun 2013 08:37:48 +0000 (10:37 +0200)

do_for_each_entry(): increment the packed refs cache refcount

This function calls a user-supplied callback function which could do
something that causes the packed refs cache to be invalidated. So
acquire a reference count on the data structure to prevent our copy
from being freed while we are iterating over it.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

refs: manage lifetime of packed refs cache via referenc... Michael Haggerty Thu, 20 Jun 2013 08:37:47 +0000 (10:37 +0200)

refs: manage lifetime of packed refs cache via reference counting

In struct packed_ref_cache, keep a count of the number of users of the
data structure. Only free the packed ref cache when the reference
count goes to zero rather than when the packed ref cache is cleared.
This mechanism will be used to prevent the cache data structure from
being freed while it is being iterated over.

So far, only the reference in struct ref_cache::packed is counted;
other users will be adjusted in separate commits.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

refs: implement simple transactions for the packed... Michael Haggerty Thu, 20 Jun 2013 08:37:46 +0000 (10:37 +0200)

refs: implement simple transactions for the packed-refs file

Handle simple transactions for the packed-refs file at the
packed_ref_cache level via new functions lock_packed_refs(),
commit_packed_refs(), and rollback_packed_refs().

Only allow the packed ref cache to be modified (via add_packed_ref())
while the packed refs file is locked.

Change clone to add the new references within a transaction.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

refs: wrap the packed refs cache in a level of indirectionMichael Haggerty Thu, 20 Jun 2013 08:37:45 +0000 (10:37 +0200)

refs: wrap the packed refs cache in a level of indirection

As we know, we can solve any problem in this manner. In this case,
the problem is to avoid freeing a packed refs cache while somebody is
using it. So add a level of indirection as a prelude to
reference-counting the packed refs cache.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

pack_refs(): split creation of packed refs and entry... Michael Haggerty Thu, 20 Jun 2013 08:37:44 +0000 (10:37 +0200)

pack_refs(): split creation of packed refs and entry writing

Split pack_refs() into multiple passes:

* Iterate over loose refs. For each one that can be turned into a
packed ref, create a corresponding entry in the packed refs cache.

* Write the packed refs to the packed-refs file.

This change isolates the mutation of the packed-refs file to a single
place.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

repack_without_ref(): split list curation and entry... Michael Haggerty Thu, 20 Jun 2013 08:37:43 +0000 (10:37 +0200)

repack_without_ref(): split list curation and entry writing

The repack_without_ref() function first removes the deleted ref from
the internal packed-refs list, then writes the packed-refs list to
disk, omitting any broken or stale entries. This patch splits that
second step into multiple passes:

* collect the list of refnames that should be deleted from packed_refs

* delete those refnames from the cache

* write the remainder to the packed-refs file

The purpose of this change is to make the "write the remainder" part
reusable.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t7400: test of UTF-8 submodule names pass under Mac OSTorsten Bögershausen Thu, 20 Jun 2013 14:58:48 +0000 (16:58 +0200)

t7400: test of UTF-8 submodule names pass under Mac OS

submodules with names using UTF-8 need core.precomposeunicode true
under Mac OS X, set it in the test case.

Improve the portability:

- Not all shells on all OS may understand literal UTF-8 strings.
- Use a help variable filled by printf, as we do it in e.g. t0050.

"strange names" can be called UTF-8, rephrase the heading.

While at it, unbreak &&-chain in the test, and use test_config.

Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

send-email: sanitize author when writing From lineMichael S. Tsirkin Tue, 18 Jun 2013 12:49:26 +0000 (15:49 +0300)

send-email: sanitize author when writing From line

sender is now sanitized, but we didn't sanitize author when checking
whether From: line is needed in the message body.

As a result git started writing duplicate From: lines when author
matched sender and has utf8 characters.

Reported-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

send-email: add test for duplicate utf8 nameMichael S. Tsirkin Tue, 18 Jun 2013 12:49:29 +0000 (15:49 +0300)

send-email: add test for duplicate utf8 name

Verify that author name is not duplicated if it matches sender, even
if it is in utf8 (the test expects a failure that will be fixed in
the next patch).

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

diff: add --ignore-blank-lines optionAntoine Pelisse Wed, 19 Jun 2013 18:46:07 +0000 (20:46 +0200)

diff: add --ignore-blank-lines option

The goal of the patch is to introduce the GNU diff
-B/--ignore-blank-lines as closely as possible. The short option is not
available because it's already used for "break-rewrites".

When this option is used, git-diff will not create hunks that simply
add or remove empty lines, but will still show empty lines
addition/suppression if they are close enough to "valuable" changes.

There are two differences between this option and GNU diff -B option:
- GNU diff doesn't have "--inter-hunk-context", so this must be handled
- The following sequence looks like a bug (context is displayed twice):

$ seq 5 >file1
$ cat <<EOF >file2
change
1
2

3
4
5
change
EOF
$ diff -u -B file1 file2
--- file1 2013-06-08 22:13:04.471517834 +0200
+++ file2 2013-06-08 22:13:23.275517855 +0200
@@ -1,5 +1,7 @@
+change
1
2
+
3
4
5
@@ -3,3 +5,4 @@
3
4
5
+change

So here is a more thorough description of the option:
- real changes are interesting
- blank lines that are close enough (less than context size) to
interesting changes are considered interesting (recursive definition)
- "context" lines are used around each hunk of interesting changes
- If two hunks are separated by less than "inter-hunk-context", they
will be merged into one.

The implementation does the "interesting changes selection" in a single
pass.

Signed-off-by: Antoine Pelisse <apelisse@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

random typofixes (committed missing a 't', successful... Veres Lajos Wed, 19 Jun 2013 05:37:24 +0000 (07:37 +0200)

random typofixes (committed missing a 't', successful missing an 's')

Signed-off-by: Veres Lajos <vlajos@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>