update-index: fix segfault with missing --cacheinfo argument

Running "git update-index --cacheinfo" without any further
arguments results in a segfault rather than an error
message. Commit ec160ae (update-index: teach --cacheinfo a
new syntax "mode,sha1,path", 2014-03-23) added code to
examine the format of the argument, but forgot to handle the
NULL case.

Returning an error from the parser is enough, since we then
treat it as an old-style "--cacheinfo <mode> <sha1> <path>",
and complain that we have less than 3 arguments to read.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t5000, t5003: do not use test_cmp to compare binary files

test_cmp() is primarily meant to compare text files (and display the
difference for debug purposes).

Raw "cmp" is better suited to compare binary files (tar, zip, etc.).

On MinGW, test_cmp is a shell function mingw_test_cmp that tries to
read both files into environment, stripping CR characters (introduced
in commit 4d715ac0).

This function usually speeds things up, as fork is extremly slow on
Windows.  But no wonder that this function is extremely slow and
sometimes even crashes when comparing large tar or zip files.

Signed-off-by: Stepan Kasal <kasal@ucw.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
shortlog: allow --exclude=<glob> to be passed

These two commands are supposed to be equivalent:

  $ git log --exclude=refs/notes/\* --all --no-merges --since=2.days |
    git shortlog
  $ git shortlog --exclude=refs/notes/\* --all --no-merges --since=2.days

However, the latter does not understand the ref-exclusion command
line option, even though other options understood by "log", such as
"--all" and "--no-merges", are understood.

This was because e7b432c5 (revision: introduce --exclude=<glob> to
tame wildcards, 2013-08-30) did not wire the new option fully to the
machinery.  A new option understood by handle_revision_pseudo_opt()
must be told to handle_revision_opt() as well.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
fetch doc: on pulling multiple refspecs

Replace desription of old-style "Pull:" lines in remotes/
configuration with modern remote.*.fetch variables.

As this note applies only to "git pull", enable it only
in git-pull manual page.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
fetch doc: update refspec format description

The text made it sound as if the leading plus is the only thing that
is optional, and forgot that <lhs> is the same as <lhs>:, i.e. fetch
it and do not store anywhere.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
fetch doc: remove "short-cut" section

It is misleading to mention that <ref> that does not store is to
fetch the ref into FETCH_HEAD, because a refspec that does store is
also to fetch the LHS into FETCH_HEAD.  It is doubly misleading to
list it as part of "short-cut".  <ref> stands for a refspec that has
it on the LHS with a colon and an empty RHS, and that definition
should be given at the beginning of the entry where the format is
defined.

Tentatively remove this misleading description, which leaves the
`tag <tag>` as the only true short-hand, so move it at the beginning
of the entry.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
t9001: avoid non-portable '\n' with sed

t9001 used a '\n' in a sed expression to split one line into two
lines.  Some versions of sed (/usr/bin/sed under Mac OS X) simply
ignore the '\' before the 'n', treating '\n' as 'n'.

As the test already requires perl as a prerequisite, use perl
instead of sed.

Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t7810-grep.sh: remove duplicate test_config()

t/t7810-grep.sh had its own test_config() function which served the
same purpose as the one in t/test-lib-functions.sh.  Removed, all tests
pass.

Signed-off-by: Jeremiah Mahler <jmmahler@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t9903: run pc mode tests again with PS1 expansion disabled

Bash has a shell option that makes it possible to disable parameter
expansion in PS1.  Test __git_ps1's ability to detect and react to
disabled PS1 expansion by running the "pc mode" tests twice:  once
with PS1 parameter expansion enabled and once with it disabled.

Signed-off-by: Richard Hansen <rhansen@bbn.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t9903: include "Bash" in test names via new $shellname var

Define a new 'shellname' variable in lib-bash.sh and use it in the
prompt test names.  This is a step toward moving the shell prompt
tests to a separate library file so that they can be reused to test
prompting in Zsh.

Signed-off-by: Richard Hansen <rhansen@bbn.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t9903: move PS1 color code variable definitions to lib-bash.sh

Define a new 'set_ps1_format_vars' function in lib-bash.sh that sets
the c_red, c_green, c_lblue, and c_clear variables.  Call this
function from run_pcmode_tests().  This is a step toward moving the
shell prompt tests to a separate library file so that they can be
reused to test prompting in Zsh.

Signed-off-by: Richard Hansen <rhansen@bbn.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t9903: move prompt tests to a new lib-prompt-tests.sh file

This is a step toward creating a new test script that runs the same
prompt tests as t9903 but with Zsh instead of Bash.

Signed-off-by: Richard Hansen <rhansen@bbn.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
lib-prompt-tests.sh: put all tests inside a function

Modify lib-prompt-tests.sh so that it does nothing when sourced except
define a function for running the prompt tests (plus some "private"
helper functions).

Signed-off-by: Richard Hansen <rhansen@bbn.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
lib-prompt-tests.sh: add variable for string that encodes percent in PS1

To add a literal percent character to a Zsh prompt, the string "%%" is
used in PS1.  Bash and POSIX shells simply use "%".  To accommodate
this difference, use ${percent} where a percent character is expected
and define the percent variable in the set_ps1_format_vars function.

Signed-off-by: Richard Hansen <rhansen@bbn.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
test-lib: make it possible to override how test code is eval'd

If a command named 'test_eval_override' exists, use it instead of
'eval' to run the test code.

This is needed to support zsh test cases:  test-lib.sh must be sourced
in sh emulation mode due to fundamental incompatibilities between the
POSIX sh language and the zsh language.  When a function is defined
while zsh is emulating some shell, zsh notes the shell that is being
emulated and records it along with the function definition.  This
enables zsh to temporarily re-enable the shell emulation mode whenever
the function is called, allowing zsh scripts to mix and match code
written for different shell languages.  (This description of zsh shell
emulation is not completely accurate, but it's close enough.)

Because test_eval_ is defined while zsh is in sh emulation mode, the
shell code passed as an argument to test_expect_success would normally
be evaluated in sh emulation mode.  However, with this change, it is
now possible to evaluate the test code in zsh mode by adding the
following line to a zsh-based test script:

    emulate -R zsh -c 'test_eval_override () { eval "$*"; }'

With test_eval_override defined in zsh emulation mode, the call to
test_eval_override from test_eval_ will temporarily cause zsh to
switch from sh emulation mode to zsh emulation mode.

Signed-off-by: Richard Hansen <rhansen@bbn.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t9904: new __git_ps1 tests for Zsh

These are the same tests as in t9903, but run in zsh instead of bash.

Signed-off-by: Richard Hansen <rhansen@bbn.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
replace: add --graft option

The usage string for this option is:

git replace [-f] --graft <commit> [<parent>...]

First we create a new commit that is the same as <commit>
except that its parents are [<parents>...]

Then we create a replace ref that replace <commit> with
the commit we just created.

With this new option, it should be straightforward to
convert grafts to replace refs.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
replace: add test for --graft

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation: replace: add --graft option

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib: add convert-grafts-to-replace-refs.sh

This patch adds into contrib/ an example script to convert
grafts from an existing grafts file into replace refs using
the new --graft option of "git replace".

While at it let's mention this new script in the
"git replace" documentation for the --graft option.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>