gitweb.git
string-list: add string_list initializer helper functionTanay Abhra Fri, 18 Jul 2014 09:18:59 +0000 (02:18 -0700)

string-list: add string_list initializer helper function

The string-list API has STRING_LIST_INIT_* macros to be used
to define variables with initializers, but lacks functions
to initialize an uninitialized piece of memory to be used as
a string-list at the run-time.
Introduce `string_list_init()` function for that.

Signed-off-by: Tanay Abhra <tanayabh@gmail.com>
Reviewed-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t800[12]: work around MSys limitationKarsten Blees Thu, 17 Jul 2014 15:37:05 +0000 (17:37 +0200)

t800[12]: work around MSys limitation

MSys works very hard to convert Unix-style paths into DOS-style ones.
*Very* hard.

So hard, indeed, that

git blame -L/hello/,/green/

is translated into something like

git blame -LC:/msysgit/hello/,C:/msysgit/green/

As seen in msys_p2w in src\msys\msys\rt\src\winsup\cygwin\path.cc, line
3204ff:

case '-':
//
// here we check for POSIX paths as attributes to a POSIX switch.
//
...

seemingly absolute POSIX paths in single-letter options get expanded by
msys.dll unless they contain '=' or ';'.

So a quick and very dirty fix is to use '-L/;*evil/'. (Using an equal sign
works only when it is before a comma, so in the above example, /=*green/
would still be converted to a DOS-style path.)

The -L mangling can be done by the script, just before the parameter is
passed to the executable. This version does not modify the body of the
tests and is active on MinGW only.

Commit-message-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Author: Stepan Kasal <kasal@ucw.cz>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Stepan Kasal <kasal@ucw.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t9902: mingw-specific fix for gitfile link filesPat Thoyts Thu, 17 Jul 2014 15:37:04 +0000 (17:37 +0200)

t9902: mingw-specific fix for gitfile link files

The path in a .git platform independent link file needs to be absolute
and under mingw we need it to be a windows type path, not a unix style
path so it should start with a drive letter and not a /.

Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
Signed-off-by: Stepan Kasal <kasal@ucw.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t4210: skip command-line encoding tests on mingwPat Thoyts Thu, 17 Jul 2014 15:37:03 +0000 (17:37 +0200)

t4210: skip command-line encoding tests on mingw

On Windows the application command line is provided as unicode and in
mingw-git we convert that to utf-8. So these tests that require a iso-8859-1
input are being subverted by the encoding transformations we perform and
should be skipped.

Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
Signed-off-by: Stepan Kasal <kasal@ucw.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

MinGW: disable legacy encoding testsKarsten Blees Thu, 17 Jul 2014 15:37:02 +0000 (17:37 +0200)

MinGW: disable legacy encoding tests

On Windows, all native APIs are Unicode-based. It is impossible to pass
legacy encoded byte arrays to a process via command line or environment
variables. Disable the tests that try to do so.

In t3901, most tests still work if we don't mess up the repository encoding
in setup, so don't switch to ISO-8859-1 on MinGW.

Note that i18n tests that do their encoding tricks via encoded files (such
as t3900) are not affected by this.

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Stepan Kasal <kasal@ucw.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t0110/MinGW: skip tests that pass arbitrary bytes on... Karsten Blees Sat, 19 Jul 2014 19:37:19 +0000 (21:37 +0200)

t0110/MinGW: skip tests that pass arbitrary bytes on the command line

On Windows, the command line is a Unicode string, it is not possible to
pass arbitrary bytes to a program. Disable tests that try to do so.

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

unix-socket: remove stale socket before calling chdir()René Scharfe Sun, 20 Jul 2014 08:00:41 +0000 (10:00 +0200)

unix-socket: remove stale socket before calling chdir()

unix_stream_listen() is given a path. It calls unix_sockaddr_init(),
which in turn can call chdir(). After that a relative path doesn't
mean the same as before. Any use of the original path should thus
happen before that call. For that reason, unlink the given path
(to get rid of a possibly existing stale socket) right at the
beginning of the function.

Noticed-by: Karsten Blees <karsten.blees@gmail.com>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Win32: enable color output in Windows cmd.exeKarsten Blees Thu, 17 Jul 2014 15:38:06 +0000 (17:38 +0200)

Win32: enable color output in Windows cmd.exe

Git requires the TERM environment variable to be set for all color*
settings. Simulate the TERM variable if it is not set (default on Windows).

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Stepan Kasal <kasal@ucw.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Win32: patch Windows environment on startupKarsten Blees Thu, 17 Jul 2014 15:38:05 +0000 (17:38 +0200)

Win32: patch Windows environment on startup

Fix Windows specific environment settings on startup rather than checking
for special values on every getenv call.

As a side effect, this makes the patched environment (i.e. with properly
initialized TMPDIR and TERM) available to child processes.

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Stepan Kasal <kasal@ucw.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Win32: keep the environment sortedKarsten Blees Thu, 17 Jul 2014 15:38:04 +0000 (17:38 +0200)

Win32: keep the environment sorted

The Windows environment is sorted, keep it that way for O(log n)
environment access.

Change compareenv to compare only the keys, so that it can be used to
find an entry irrespective of the value.

Change lookupenv to binary seach for an entry. Return one's complement of
the insert position if not found (libc's bsearch returns NULL).

Replace MSVCRT's getenv with a minimal do_getenv based on the binary search
function.

Change do_putenv to insert new entries at the correct position. Simplify
the function by swapping if conditions and using memmove instead of for
loops.

Move qsort from make_environment_block to mingw_startup. We still need to
sort on startup to make sure that the environment is sorted according to
our compareenv function (while Win32 / CreateProcess requires the
environment block to be sorted case-insensitively, CreateProcess currently
doesn't enforce this, and some applications such as bash just don't care).

Note that environment functions are _not_ thread-safe and are not required
to be so by POSIX, the application is responsible for synchronizing access
to the environment. MSVCRT's getenv and our new getenv implementation are
better than that in that they are thread-safe with respect to other getenv
calls as long as the environment is not modified. Git's indiscriminate use
of getenv in background threads currently requires this property.

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Stepan Kasal <kasal@ucw.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Win32: use low-level memory allocation during initializ... Karsten Blees Thu, 17 Jul 2014 15:38:03 +0000 (17:38 +0200)

Win32: use low-level memory allocation during initialization

As of d41489a6 "Add more large blob test cases", git's high-level memory
allocation functions (xmalloc, xmemdupz etc.) access the environment to
simulate limited memory in tests (see 'getenv("GIT_ALLOC_LIMIT")' in
memory_limit_check()). These functions should not be used before the
environment is fully initialized (particularly not to initialize the
environment itself).

The current solution ('environ = NULL; ALLOC_GROW(environ...)') only works
because MSVCRT's getenv() reinitializes environ when it is NULL (i.e. it
leaves us with two sets of unusabe (non-UTF-8) and unfreeable (CRT-
allocated) environments).

Add our own set of malloc-or-die functions to be used in startup code.

Also check the result of __wgetmainargs, which may fail if there's not
enough memory for wide-char arguments and environment.

This patch is in preparation of the sorted environment feature, which
completely replaces MSVCRT's getenv() implementation.

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Stepan Kasal <kasal@ucw.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Win32: reduce environment array reallocationsKarsten Blees Thu, 17 Jul 2014 15:38:02 +0000 (17:38 +0200)

Win32: reduce environment array reallocations

Move environment array reallocation from do_putenv to the respective
callers. Keep track of the environment size in a global variable. Use
ALLOC_GROW in mingw_putenv to reduce reallocations. Allocate a
sufficiently sized environment array in make_environment_block to prevent
reallocations.

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Stepan Kasal <kasal@ucw.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Win32: don't copy the environment twice when spawning... Karsten Blees Thu, 17 Jul 2014 15:38:01 +0000 (17:38 +0200)

Win32: don't copy the environment twice when spawning child processes

When spawning child processes via start_command(), the environment and all
environment entries are copied twice. First by make_augmented_environ /
copy_environ to merge with child_process.env. Then a second time by
make_environment_block to create a sorted environment block string as
required by CreateProcess.

Move the merge logic to make_environment_block so that we only need to copy
the environment once. This changes semantics of the env parameter: it now
expects a delta (such as child_process.env) rather than a full environment.
This is not a problem as the parameter is only used by start_command()
(all other callers previously passed char **environ, and now pass NULL).

The merge logic no longer xstrdup()s the environment strings, so do_putenv
must not free them. Add a parameter to distinguish this from normal putenv.

Remove the now unused make_augmented_environ / free_environ API.

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Stepan Kasal <kasal@ucw.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Win32: factor out environment block creationKarsten Blees Thu, 17 Jul 2014 15:38:00 +0000 (17:38 +0200)

Win32: factor out environment block creation

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Stepan Kasal <kasal@ucw.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Win32: unify environment function namesKarsten Blees Thu, 17 Jul 2014 15:37:59 +0000 (17:37 +0200)

Win32: unify environment function names

Environment helper functions use random naming ('env' prefix or suffix or
both, with or without '_'). Change to POSIX naming scheme ('env' suffix,
no '_').

Env_setenv has more in common with putenv than setenv. Change to do_putenv.

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Stepan Kasal <kasal@ucw.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Win32: unify environment case-sensitivityKarsten Blees Thu, 17 Jul 2014 15:37:58 +0000 (17:37 +0200)

Win32: unify environment case-sensitivity

The environment on Windows is case-insensitive. Some environment functions
(such as unsetenv and make_augmented_environ) have always used case-
sensitive comparisons instead, while others (getenv, putenv, sorting in
spawn*) were case-insensitive.

Prevent potential inconsistencies by using case-insensitive comparison in
lookup_env (used by putenv, unsetenv and make_augmented_environ).

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Stepan Kasal <kasal@ucw.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Win32: fix environment memory leaksKarsten Blees Thu, 17 Jul 2014 15:37:57 +0000 (17:37 +0200)

Win32: fix environment memory leaks

All functions that modify the environment have memory leaks.

Disable gitunsetenv in the Makefile and use env_setenv (via mingw_putenv)
instead (this frees removed environment entries).

Move xstrdup from env_setenv to make_augmented_environ, so that
mingw_putenv no longer copies the environment entries (according to POSIX
[1], "the string [...] shall become part of the environment"). This also
fixes the memory leak in gitsetenv, which expects a POSIX compliant putenv.

[1] http://pubs.opengroup.org/onlinepubs/009695399/functions/putenv.html

Note: This patch depends on taking control of char **environ and having
our own mingw_putenv (both introduced in "Win32: Unicode environment
(incoming)").

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Stepan Kasal <kasal@ucw.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Win32: Unicode environment (incoming)Karsten Blees Thu, 17 Jul 2014 15:37:56 +0000 (17:37 +0200)

Win32: Unicode environment (incoming)

Convert environment from UTF-16 to UTF-8 on startup.

No changes to getenv() are necessary, as the MSVCRT version is implemented
on top of char **environ.

However, putenv / _wputenv from MSVCRT no longer work, for two reasons:
1. they try to keep environ, _wenviron and the Win32 process environment
in sync, using the default system encoding instead of UTF-8 to convert
between charsets
2. msysgit and MSVCRT use different allocators, memory allocated in git
cannot be freed by the CRT and vice versa

Implement mingw_putenv using the env_setenv helper function from the
environment merge code.

Note that in case of memory allocation failure, putenv now dies with error
message (due to xrealloc) instead of failing with ENOMEM. As git assumes
setenv / putenv to always succeed, this prevents it from continuing with
incorrect settings.

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Stepan Kasal <kasal@ucw.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Win32: Unicode environment (outgoing)Karsten Blees Thu, 17 Jul 2014 15:37:55 +0000 (17:37 +0200)

Win32: Unicode environment (outgoing)

Convert environment from UTF-8 to UTF-16 when creating other processes.

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Stepan Kasal <kasal@ucw.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-testsvn: use internal argv_array of struct child... René Scharfe Fri, 18 Jul 2014 15:20:19 +0000 (17:20 +0200)

remote-testsvn: use internal argv_array of struct child_process in cmd_import()

Use the existing argv_array member instead of providing our own. This
way we don't have to initialize or clean it up explicitly.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

bundle: use internal argv_array of struct child_process... René Scharfe Thu, 17 Jul 2014 23:27:41 +0000 (01:27 +0200)

bundle: use internal argv_array of struct child_process in create_bundle()

Use the existing argv_array member instead of providing our own. This
way the argv_array is cleared after use automatically for us; it was
leaking before.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

fast-import: use hashcmp() for SHA1 hash comparisonRené Scharfe Fri, 18 Jul 2014 16:00:51 +0000 (18:00 +0200)

fast-import: use hashcmp() for SHA1 hash comparison

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

transport: simplify fetch_objs_via_rsync() using argv_arrayRené Scharfe Fri, 18 Jul 2014 15:12:34 +0000 (17:12 +0200)

transport: simplify fetch_objs_via_rsync() using argv_array

Use the existing argv_array member instead of building the arguments
list using a string array and a strbuf. This way we don't need magic
number constants and allocations are cleaned up for us automatically
by run_command().

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

run-command: use internal argv_array of struct child_pr... René Scharfe Wed, 16 Jul 2014 21:57:47 +0000 (23:57 +0200)

run-command: use internal argv_array of struct child_process in run_hook_ve()

Use the existing argv_array member instead of providing our own. This
way we don't have to initialize or clean it up explicitly.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

MinGW: Skip test redirecting to fd 4Johannes Schindelin Thu, 17 Jul 2014 15:37:00 +0000 (17:37 +0200)

MinGW: Skip test redirecting to fd 4

... because that does not work in MinGW.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Stepan Kasal <kasal@ucw.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

use commit_list_count() to count the members of commit_... René Scharfe Wed, 16 Jul 2014 23:52:09 +0000 (01:52 +0200)

use commit_list_count() to count the members of commit_lists

Call commit_list_count() instead of open-coding it repeatedly.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

strbuf: use strbuf_addstr() for adding C stringsRené Scharfe Wed, 16 Jul 2014 23:38:18 +0000 (01:38 +0200)

strbuf: use strbuf_addstr() for adding C strings

Avoid code duplication and let strbuf_addstr() call strlen() for us.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

use local cloning if insteadOf makes a local URLMichael Barabanov Thu, 17 Jul 2014 07:09:32 +0000 (00:09 -0700)

use local cloning if insteadOf makes a local URL

Move the is_local logic to the place where origin remote has been setup and
check if the remote url can be used to do local cloning.

This saves a lot of space (and time) in some of the mirroring scenarios that
involve insteadOf rewrites.

Signed-off-by: Michael Barabanov <michael.barabanov@windriver.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Revert "Windows: teach getenv to do a case-sensitive... Karsten Blees Thu, 17 Jul 2014 15:37:54 +0000 (17:37 +0200)

Revert "Windows: teach getenv to do a case-sensitive search"

This reverts commit df599e9612788b728ce43a03159b85f1fe624d6a.

As of 5e9637c6 "i18n: add infrastructure for translating Git with gettext",
eval_gettext uses MinGW envsubst.exe instead of git-sh-i18n--envsubst.exe
for variable substitution. This breaks git-submodule.sh messages and tests,
as envsubst.exe doesn't support case-sensitive environment lookup (the same
is true for almost everything on Windows, including MSys and Cygwin tools).

30a615ac "Windows/i18n: rename $path to prevent clashes with $PATH" renames
the conflicting variable in git-submodule.sh, so that it works on Windows
(i.e. with case-insensitive environment, regardless of the toolset).

Revert to the documented behaviour of case-insensitive environment on
Windows.

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Stepan Kasal <kasal@ucw.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

.mailmap: map different names with the same email addre... Stefan Beller Thu, 10 Jul 2014 12:48:26 +0000 (14:48 +0200)

.mailmap: map different names with the same email address together

Pretty much one year ago (94b410bba864, Jul 12 2013, .mailmap: Map
email addresses to names) I cleaned up the output of `git shortlog
-sne` of git.git by writing a .mailmap file fot the git.git project.

During the year Jens, Kazuki and Trần contributed to git.git using
different names, but the same email address; unify them.

Signed-off-by: Stefan Beller <stefanbeller@googlemail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

tag: support configuring --sort via .gitconfigJacob Keller Wed, 16 Jul 2014 21:48:02 +0000 (14:48 -0700)

tag: support configuring --sort via .gitconfig

Add support for configuring default sort ordering for git tags. Command
line option will override this configured value, using the exact same
syntax.

Cc: Jeff King <peff@peff.net>
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

rebase: omit patch-identical commits with --fork-pointJohn Keeping Wed, 16 Jul 2014 19:23:49 +0000 (20:23 +0100)

rebase: omit patch-identical commits with --fork-point

When the `--fork-point` argument was added to `git rebase`, we changed
the value of $upstream to be the fork point instead of the point from
which we want to rebase. When $orig_head..$upstream is empty this does
not change the behaviour, but when there are new changes in the upstream
we are no longer checking if any of them are patch-identical with
changes in $upstream..$orig_head.

Fix this by introducing a new variable to hold the fork point and using
this to restrict the range as an extra (negative) revision argument so
that the set of desired revisions becomes (in fork-point mode):

git rev-list --cherry-pick --right-only \
$upstream...$orig_head ^$fork_point

This allows us to correctly handle the scenario where we have the
following topology:

C --- D --- E <- dev
/
B <- master@{1}
/
o --- B' --- C* --- D* <- master

where:
- B' is a fixed-up version of B that is not patch-identical with B;
- C* and D* are patch-identical to C and D respectively and conflict
textually if applied in the wrong order;
- E depends textually on D.

The correct result of `git rebase master dev` is that B is identified as
the fork-point of dev and master, so that C, D, E are the commits that
need to be replayed onto master; but C and D are patch-identical with C*
and D* and so can be dropped, so that the end result is:

o --- B' --- C* --- D* --- E <- dev

If the fork-point is not identified, then picking B onto a branch
containing B' results in a conflict and if the patch-identical commits
are not correctly identified then picking C onto a branch containing D
(or equivalently D*) results in a conflict.

This change allows us to handle both of these cases, where previously we
either identified the fork-point (with `--fork-point`) but not the
patch-identical commits *or* (with `--no-fork-point`) identified the
patch-identical commits but not the fact that master had been rewritten.

Reported-by: Ted Felix <ted@tedfelix.com>
Signed-off-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

refs.c: add a public is_branch functionRonnie Sahlberg Tue, 15 Jul 2014 23:02:38 +0000 (16:02 -0700)

refs.c: add a public is_branch function

Both refs.c and fsck.c have their own private copies of the is_branch function.
Delete the is_branch function from fsck.c and make the version in refs.c
public.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

config: use chmod() instead of fchmod()Karsten Blees Tue, 15 Jul 2014 22:54:30 +0000 (00:54 +0200)

config: use chmod() instead of fchmod()

There is no fchmod() on native Windows platforms (MinGW and MSVC), and the
equivalent Win32 API (SetFileInformationByHandle) requires Windows Vista.

Use chmod() instead.

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Sync with 2.0.2Junio C Hamano Wed, 16 Jul 2014 18:48:16 +0000 (11:48 -0700)

Sync with 2.0.2

* maint:
Git 2.0.2
annotate: use argv_array

Eighth batch for 2.1Junio C Hamano Wed, 16 Jul 2014 18:47:32 +0000 (11:47 -0700)

Eighth batch for 2.1

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

Merge branch 'ah/fix-http-push'Junio C Hamano Wed, 16 Jul 2014 18:33:11 +0000 (11:33 -0700)

Merge branch 'ah/fix-http-push'

An ancient rewrite passed a wrong pointer to a curl library
function in a rarely used code path.

* ah/fix-http-push:
http-push.c: make CURLOPT_IOCTLDATA a usable pointer

Merge branch 'rs/code-cleaning'Junio C Hamano Wed, 16 Jul 2014 18:33:09 +0000 (11:33 -0700)

Merge branch 'rs/code-cleaning'

* rs/code-cleaning:
fsck: simplify fsck_commit_buffer() by using commit_list_count()
commit: use commit_list_append() instead of duplicating its code
merge: simplify merge_trivial() by using commit_list_append()
use strbuf_addch for adding single characters
use strbuf_addbuf for adding strbufs

Merge branch 'jk/skip-prefix'Junio C Hamano Wed, 16 Jul 2014 18:33:06 +0000 (11:33 -0700)

Merge branch 'jk/skip-prefix'

One more to an already graduated topic.

* jk/skip-prefix:
tag: use skip_prefix instead of magic numbers

Merge branch 'po/error-message-style'Junio C Hamano Wed, 16 Jul 2014 18:33:03 +0000 (11:33 -0700)

Merge branch 'po/error-message-style'

* po/error-message-style:
doc: give some guidelines for error messages

Merge branch 'jl/test-lint-scripts'Junio C Hamano Wed, 16 Jul 2014 18:33:01 +0000 (11:33 -0700)

Merge branch 'jl/test-lint-scripts'

* jl/test-lint-scripts:
t/Makefile: always test all lint targets when running tests
t/Makefile: check helper scripts for non-portable shell commands too

Merge branch 'zk/log-graph-showsig'Junio C Hamano Wed, 16 Jul 2014 18:32:57 +0000 (11:32 -0700)

Merge branch 'zk/log-graph-showsig'

The "--show-signature" option did not pay much attention to
"--graph".

* zk/log-graph-showsig:
log: fix indentation for --graph --show-signature

Merge branch 'mg/fix-log-mergetag-color'Junio C Hamano Wed, 16 Jul 2014 18:32:36 +0000 (11:32 -0700)

Merge branch 'mg/fix-log-mergetag-color'

* mg/fix-log-mergetag-color:
log: correctly identify mergetag signature verification status

Merge branch 'kb/path-max-must-go'Junio C Hamano Wed, 16 Jul 2014 18:32:33 +0000 (11:32 -0700)

Merge branch 'kb/path-max-must-go'

* kb/path-max-must-go:
cache.h: rename cache_def_free to cache_def_clear

Merge branch 'cb/filter-branch-prune-empty-degenerate... Junio C Hamano Wed, 16 Jul 2014 18:29:06 +0000 (11:29 -0700)

Merge branch 'cb/filter-branch-prune-empty-degenerate-merges'

"filter-branch" left an empty single-parent commit that results when
all parents of a merge commit gets mapped to the same commit, even
under "--prune-empty".

* cb/filter-branch-prune-empty-degenerate-merges:
filter-branch: eliminate duplicate mapped parents

Merge branch 'mk/merge-incomplete-files'Junio C Hamano Wed, 16 Jul 2014 18:26:04 +0000 (11:26 -0700)

Merge branch 'mk/merge-incomplete-files'

Merging changes into a file that ends in an incomplete line made the
last line into a complete one, even when the other branch did not
change anything around the end of file.

* mk/merge-incomplete-files:
git-merge-file: do not add LF at EOF while applying unrelated change
t6023-merge-file.sh: fix and mark as broken invalid tests

Merge branch 'jk/strip-suffix'Junio C Hamano Wed, 16 Jul 2014 18:25:59 +0000 (11:25 -0700)

Merge branch 'jk/strip-suffix'

* jk/strip-suffix:
prepare_packed_git_one: refactor duplicate-pack check
verify-pack: use strbuf_strip_suffix
strbuf: implement strbuf_strip_suffix
index-pack: use strip_suffix to avoid magic numbers
use strip_suffix instead of ends_with in simple cases
replace has_extension with ends_with
implement ends_with via strip_suffix
add strip_suffix function
sha1_file: replace PATH_MAX buffer with strbuf in prepare_packed_git_one()

Merge branch 'ep/submodule-code-cleanup'Junio C Hamano Wed, 16 Jul 2014 18:25:57 +0000 (11:25 -0700)

Merge branch 'ep/submodule-code-cleanup'

* ep/submodule-code-cleanup:
submodule.c: use the ARRAY_SIZE macro

Merge branch 'jk/replace-edit-raw'Junio C Hamano Wed, 16 Jul 2014 18:25:55 +0000 (11:25 -0700)

Merge branch 'jk/replace-edit-raw'

Teach "git replace --edit" mode a "--raw" option to allow
editing the bare-metal representation data of objects.

* jk/replace-edit-raw:
replace: add a --raw mode for --edit

Merge branch 'cc/replace-edit'Junio C Hamano Wed, 16 Jul 2014 18:25:47 +0000 (11:25 -0700)

Merge branch 'cc/replace-edit'

Teach "git replace" an "--edit" mode.

* cc/replace-edit:
replace: use argv_array in export_object
avoid double close of descriptors handed to run_command
replace: replace spaces with tabs in indentation

Merge branch 'tb/crlf-tests'Junio C Hamano Wed, 16 Jul 2014 18:25:45 +0000 (11:25 -0700)

Merge branch 'tb/crlf-tests'

* tb/crlf-tests:
t0027: combinations of core.autocrlf, core.eol and text
t0025: rename the test files

Merge branch 'nd/split-index'Junio C Hamano Wed, 16 Jul 2014 18:25:40 +0000 (11:25 -0700)

Merge branch 'nd/split-index'

An experiment to use two files (the base file and incremental
changes relative to it) to represent the index to reduce I/O cost
of rewriting a large index when only small part of the working tree
changes.

* nd/split-index: (32 commits)
t1700: new tests for split-index mode
t2104: make sure split index mode is off for the version test
read-cache: force split index mode with GIT_TEST_SPLIT_INDEX
read-tree: note about dropping split-index mode or index version
read-tree: force split-index mode off on --index-output
rev-parse: add --shared-index-path to get shared index path
update-index --split-index: do not split if $GIT_DIR is read only
update-index: new options to enable/disable split index mode
split-index: strip pathname of on-disk replaced entries
split-index: do not invalidate cache-tree at read time
split-index: the reading part
split-index: the writing part
read-cache: mark updated entries for split index
read-cache: save deleted entries in split index
read-cache: mark new entries for split index
read-cache: split-index mode
read-cache: save index SHA-1 after reading
entry.c: update cache_changed if refresh_cache is set in checkout_entry()
cache-tree: mark istate->cache_changed on prime_cache_tree()
cache-tree: mark istate->cache_changed on cache tree update
...

Git 2.0.2 v2.0.2Junio C Hamano Wed, 16 Jul 2014 18:19:56 +0000 (11:19 -0700)

Git 2.0.2

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

Merge branch 'jc/fix-clone-single-starting-at-a-tag... Junio C Hamano Wed, 16 Jul 2014 18:17:36 +0000 (11:17 -0700)

Merge branch 'jc/fix-clone-single-starting-at-a-tag' into maint

"git clone -b brefs/tags/bar" would have mistakenly thought we were
following a single tag, even though it was a name of the branch,
because it incorrectly used strstr().

* jc/fix-clone-single-starting-at-a-tag:
builtin/clone.c: detect a clone starting at a tag correctly

Merge branch 'jk/pretty-G-format-fixes' into maintJunio C Hamano Wed, 16 Jul 2014 18:17:21 +0000 (11:17 -0700)

Merge branch 'jk/pretty-G-format-fixes' into maint

"%G" (nothing after G) is an invalid pretty format specifier, but
the parser did not notice it as garbage.

* jk/pretty-G-format-fixes:
move "%G" format test from t7510 to t6006
pretty: avoid reading past end-of-string with "%G"
t7510: check %G* pretty-format output
t7510: test a commit signed by an unknown key
t7510: use consistent &&-chains in loop
t7510: stop referring to master in later tests

Merge branch 'rs/fix-alt-odb-path-comparison' into... Junio C Hamano Wed, 16 Jul 2014 18:17:08 +0000 (11:17 -0700)

Merge branch 'rs/fix-alt-odb-path-comparison' into maint

Code to avoid adding the same alternate object store twice was
subtly broken for a long time, but nobody seems to have noticed.

* rs/fix-alt-odb-path-comparison:
sha1_file: avoid overrunning alternate object base string

Merge branch 'jk/commit-buffer-length' into maintJunio C Hamano Wed, 16 Jul 2014 18:16:38 +0000 (11:16 -0700)

Merge branch 'jk/commit-buffer-length' into maint

A handful of code paths had to read the commit object more than
once when showing header fields that are usually not parsed. The
internal data structure to keep track of the contents of the commit
object has been updated to reduce the need for this double-reading,
and to allow the caller find the length of the object.

* jk/commit-buffer-length:
reuse cached commit buffer when parsing signatures
commit: record buffer length in cache
commit: convert commit->buffer to a slab
commit-slab: provide a static initializer
use get_commit_buffer everywhere
convert logmsg_reencode to get_commit_buffer
use get_commit_buffer to avoid duplicate code
use get_cached_commit_buffer where appropriate
provide helpers to access the commit buffer
provide a helper to set the commit buffer
provide a helper to free commit buffer
sequencer: use logmsg_reencode in get_message
logmsg_reencode: return const buffer
do not create "struct commit" with xcalloc
commit: push commit_index update into alloc_commit_node
alloc: include any-object allocations in alloc_report
replace dangerous uses of strbuf_attach
commit_tree: take a pointer/len pair rather than a const strbuf

Merge branch 'bc/fix-rebase-merge-skip' into maintJunio C Hamano Wed, 16 Jul 2014 18:16:16 +0000 (11:16 -0700)

Merge branch 'bc/fix-rebase-merge-skip' into maint

During "git rebase --merge", a conflicted patch could not be
skipped with "--skip" if the next one also conflicted.

* bc/fix-rebase-merge-skip:
rebase--merge: fix --skip with two conflicts in a row

Merge branch 'maint-1.9' into maintJunio C Hamano Wed, 16 Jul 2014 18:11:06 +0000 (11:11 -0700)

Merge branch 'maint-1.9' into maint

* maint-1.9:
annotate: use argv_array

Merge branch 'maint-1.8.5' into maint-1.9Junio C Hamano Wed, 16 Jul 2014 18:10:30 +0000 (11:10 -0700)

Merge branch 'maint-1.8.5' into maint-1.9

* maint-1.8.5:
annotate: use argv_array
t7300: repair filesystem permissions with test_when_finished
enums: remove trailing ',' after last item in enum

annotate: use argv_arrayRené Scharfe Wed, 16 Jul 2014 08:51:33 +0000 (10:51 +0200)

annotate: use argv_array

Simplify the code and get rid of some magic constants by using
argv_array to build the argument list for cmd_blame. Be lazy and let
the OS release our allocated memory, as before.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

MinGW: fix compile error due to missing ELOOPKarsten Blees Tue, 15 Jul 2014 22:53:27 +0000 (00:53 +0200)

MinGW: fix compile error due to missing ELOOP

MinGW and MSVC before 2010 don't define ELOOP, use EMLINK (aka "Too many
links") instead.

Signed-off-by: Karsten Blees <blees@dcon.de>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

rebase--am: use --cherry-pick instead of --ignore-if... John Keeping Tue, 15 Jul 2014 19:14:02 +0000 (20:14 +0100)

rebase--am: use --cherry-pick instead of --ignore-if-in-upstream

When using `git format-patch --ignore-if-in-upstream` we are only
allowed to give a single revision range. In the next commit we will
want to add an additional exclusion revision in order to handle fork
points correctly, so convert `git-rebase--am` to use a symmetric
difference with `--cherry-pick --right-only`.

This does not change the result of the format-patch invocation, just how
we spell the arguments.

Signed-off-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

sha1_file: do not add own object directory as alternateEphrim Khong Tue, 15 Jul 2014 11:29:45 +0000 (13:29 +0200)

sha1_file: do not add own object directory as alternate

When adding alternate object directories, we try not to add the
directory of the current repository to avoid cycles. Unfortunately,
that test was broken, since it compared an absolute with a relative
path.

Signed-off-by: Ephrim Khong <dr.khong@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t5539: update a flaky testJeff King Mon, 14 Jul 2014 05:40:22 +0000 (01:40 -0400)

t5539: update a flaky test

The test creates some unrelated commits in two separate repositories,
and then fetches from one to the other. Since the commit creation
happens in a subshell, the first commit in each ends up with the
same test_tick value. When fetch-pack looks at the two root commits
"unrelated1" and "new-too", the exact sequence of ACKs is different
depending on which one it pulls out of the queue first.

With the current code, it happens to be "unrelated1" (though this is not
at all guaranteed by the prio_queue data structure, it is deterministic
for this particular sequence of input). We see the ready-ACK, and the
test succeeds.

With the stable queue, we reliably get "new-too" out (since it is our
local tip, it is added to the queue before we even talk to the remote).
We never see a ready-ACK, and the test fails due to the grep on the
TRACE_PACKET output at the end (the fetch itself succeeds as expected).

I'm really not quite clear on what's supposed to be going on in the
test. I can make it pass with this change.

tests: do not pass iso8859-1 encoded parameterPat Thoyts Mon, 2 Sep 2013 14:44:54 +0000 (15:44 +0100)

tests: do not pass iso8859-1 encoded parameter

git commit -m with some iso8859-1 encoded stuff is doomed to fail in MinGW,
because Windows don't let you pass encoded bytes to a process (CreateProcessW
always takes a UTF-16LE encoded string).

It is safe to pass the iso8859-1 message using a file or a pipe.

Thanks-to: Karsten Blees <blees@dcon.de>
Author: Stepan Kasal <kasal@ucw.cz>
Signed-off-by: Stepan Kasal <kasal@ucw.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Win32: Unicode file name support (dirent)Karsten Blees Sat, 14 Jan 2012 21:01:09 +0000 (22:01 +0100)

Win32: Unicode file name support (dirent)

Changes opendir/readdir to use Windows Unicode APIs and convert between
UTF-8/UTF-16.

Removes parameter checks that are already covered by xutftowcs_path. This
changes detection of ENAMETOOLONG from MAX_PATH - 2 to MAX_PATH (matching
is_dir_empty in mingw.c). If name + "/*" or the resulting absolute path is
too long, FindFirstFile fails and errno is set through err_win_to_posix.

Increases the size of dirent.d_name to accommodate the full
WIN32_FIND_DATA.cFileName converted to UTF-8 (UTF-16 to UTF-8 conversion
may grow by factor three in the worst case).

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Stepan Kasal <kasal@ucw.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Win32: Unicode file name support (except dirent)Karsten Blees Thu, 15 Mar 2012 17:21:28 +0000 (18:21 +0100)

Win32: Unicode file name support (except dirent)

Replaces Windows "ANSI" APIs dealing with file- or path names with their
Unicode equivalent, adding UTF-8/UTF-16LE conversion as necessary.

The dirent API (opendir/readdir/closedir) is updated in a separate commit.

Adds trivial wrappers for access, chmod and chdir.

Adds wrapper for mktemp (needed for both mkstemp and mkdtemp).

The simplest way to convert a repository with legacy-encoded (e.g. Cp1252)
file names to UTF-8 ist to checkout with an old msysgit version and
"git add --all & git commit" with the new version.

Includes a fix for bug reported by John Chen:
On Windows XP (not Win7), directories cannot be deleted while a find handle
is open, causing "Deletion of directory '...' failed. Should I try again?"
prompts.

Prior to this commit, these failures were silently ignored due to
strbuf_free in is_dir_empty resetting GetLastError to ERROR_SUCCESS.

Close the find handle in is_dir_empty so that git doesn't block deletion
of the directory even after all other applications have released it.

Reported-by: John Chen <john0312@gmail.com>
Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Stepan Kasal <kasal@ucw.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

paint_down_to_common: use prio_queueJeff King Mon, 14 Jul 2014 05:53:54 +0000 (01:53 -0400)

paint_down_to_common: use prio_queue

When we are traversing to find merge bases, we keep our
usual commit_list of commits to process, sorted by their
commit timestamp. As we add each parent to the list, we have
to spend "O(width of history)" to do the insertion, where
the width of history is the number of simultaneous lines of
development.

If we instead use a heap-based priority queue, we can do
these insertions in "O(log width)" time. This provides minor
speedups to merge-base calculations (timings in linux.git,
warm cache, best-of-five):

[before]
$ git merge-base HEAD v2.6.12
real 0m3.251s
user 0m3.148s
sys 0m0.104s

[after]
$ git merge-base HEAD v2.6.12
real 0m3.234s
user 0m3.108s
sys 0m0.128s

That's only an 0.5% speedup, but it does help protect us
against pathological cases.

While we are munging the "interesting" function, we also
take the opportunity to give it a more descriptive name, and
convert the return value to an int (we returned the first
interesting commit, but nobody ever looked at it).

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

prio-queue: make output stable with respect to insertionJeff King Mon, 14 Jul 2014 05:51:59 +0000 (01:51 -0400)

prio-queue: make output stable with respect to insertion

If two items are added to a prio_queue and compare equal,
they currently come out in an apparently random order (this
order is deterministic for a particular sequence of
insertions and removals, but does not necessarily match the
insertion order). This makes it unlike using a date-ordered
commit_list, which is one of the main types we would like to
replace with it (because prio_queue does not suffer from
O(n) insertions).

We can make the priority queue stable by keeping an
insertion counter for each element, and using it to break
ties. This does increase the memory usage of the structure
(one int per element), but in practice it does not seem to
affect runtime. A best-of-five "git rev-list --topo-order"
on linux.git showed less than 1% difference (well within the
run-to-run noise).

In an ideal world, we would offer both stable and unstable
priority queues (the latter to try to maximize performance).
However, given the lack of a measurable performance
difference, it is not worth the extra code.

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

prio-queue: factor out compare and swap operationsJeff King Mon, 14 Jul 2014 05:42:50 +0000 (01:42 -0400)

prio-queue: factor out compare and swap operations

When manipulating the priority queue's heap, we frequently
have to compare and swap heap entries. As we are storing
only void pointers right now, this is quite easy to do
inline in a few lines. However, when we start using a more
complicated heap entry in a future patch, that will get
longer. Factoring out these operations lets us make future
changes in one place. It also makes the code a little
shorter and more readable.

Note that we actually accept indices into the queue array
instead of pointers. This is slightly less flexible than
passing pointers-to-pointers (we could not swap items from
unrelated arrays, but we would not want to), but will make
further refactoring simpler (and lets us avoid repeating
"queue->array" at each callsite, which led to some long
lines).

And finally, note that we are cleaning up an accidental use
of a "struct commit" pointer to hold a temporary entry
during swap. Even though we currently only use this code for
commits, it is supposed to be type-agnostic. In practice
this didn't matter anyway because we never dereferenced the
commit pointer (and on most systems, the pointer values
themselves are interchangeable between types).

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

.gitignore: "git-verify-commit" is a generated fileØyvind A. Holm Tue, 15 Jul 2014 13:40:24 +0000 (15:40 +0200)

.gitignore: "git-verify-commit" is a generated file

builtin/verify-commit.c was added in commit d07b00b ("verify-commit:
scriptable commit signature verification", 2014-06-23), update
.gitignore to ignore the generated file.

Signed-off-by: Øyvind A. Holm <sunny@sunbase.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

prep_exclude: remove the artificial PATH_MAX limitNguyễn Thái Ngọc Duy Mon, 14 Jul 2014 09:50:22 +0000 (11:50 +0200)

prep_exclude: remove the artificial PATH_MAX limit

This fixes a segfault in git-status with long paths on Windows,
where PATH_MAX is only 260.

This also fixes the problem of silently ignoring .gitignore if the
full path exceeds PATH_MAX. Now add_excludes_from_file() will report
if it gets ENAMETOOLONG.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

dir.h: move struct exclude declaration to top levelNguyễn Thái Ngọc Duy Mon, 14 Jul 2014 09:48:03 +0000 (11:48 +0200)

dir.h: move struct exclude declaration to top level

There is no actual nested struct here. Move it out for clarity.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

dir.c: coding style fixNguyễn Thái Ngọc Duy Mon, 14 Jul 2014 09:47:11 +0000 (11:47 +0200)

dir.c: coding style fix

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

revert: add t3513 for submodule updatesJens Lehmann Thu, 19 Jun 2014 20:12:56 +0000 (22:12 +0200)

revert: add t3513 for submodule updates

Test that the revert command updates the work tree as expected (for
submodule changes which don't result in conflicts). Add a helper function
to first revert the checked out target commit to make the last revert
produce the to-be-tested work tree.

Set the KNOWN_FAILURE_CHERRY_PICK_SEES_EMPTY_COMMIT and
KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR switches to
document that revert has the similar failures.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

stash: add t3906 for submodule updatesJens Lehmann Thu, 19 Jun 2014 20:12:54 +0000 (22:12 +0200)

stash: add t3906 for submodule updates

Test that the stash apply command updates the work tree as expected for
changes which don't result in conflicts. To make that work add a helper
function that uses read-tree to apply the changes of the target commit
to the work tree, then stashes these changes and at last applies that
stash.

Implement the KNOWN_FAILURE_STASH_DOES_IGNORE_SUBMODULE_CHANGES switch
and reuse two other already present switches to expect the known
failure that stash does ignore submodule changes.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

am: add t4255 for submodule updatesJens Lehmann Sun, 15 Jun 2014 17:03:53 +0000 (19:03 +0200)

am: add t4255 for submodule updates

Test that the am command updates the work tree as expected (for submodule
changes which don't result in conflicts). To make that work add two
helper functions that use format-patch to create the input for am.

Add the KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES
switch to expect the known failure that --no-ff merges attempt to merge
the new files in the former submodule directory with those of the removed
submodule.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

cherry-pick: add t3512 for submodule updatesJens Lehmann Sun, 15 Jun 2014 17:03:18 +0000 (19:03 +0200)

cherry-pick: add t3512 for submodule updates

Test that the cherry-pick command updates the work tree as expected (for
submodule changes which don't result in conflicts).

Set KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES
and KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR to
document that cherry-pick has the same --no-ff known failures merge has.

Implement the KNOWN_FAILURE_CHERRY_PICK_SEES_EMPTY_COMMIT switch to expect
the known failure that while cherry picking just a SHA-1 update for an
ignored submodule the commit incorrectly fails with "The previous
cherry-pick is now empty, possibly due to conflict resolution.".

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

pull: add t5572 for submodule updatesJens Lehmann Sun, 15 Jun 2014 17:02:47 +0000 (19:02 +0200)

pull: add t5572 for submodule updates

Test that the pull command updates the work tree as expected (for
submodule changes which don't result in conflicts) when used without
arguments or with the '--ff', '--ff-only' and '--no-ff' flag each. Add
helper functions to reset the branch to be updated to to the current
HEAD so that pull is doing the transition from HEAD to the given branch.

Set KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES
and KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR to
document that pull has the same --no-ff known failures merge has.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

rebase: add t3426 for submodule updatesJens Lehmann Thu, 19 Jun 2014 20:12:51 +0000 (22:12 +0200)

rebase: add t3426 for submodule updates

Test that the rebase command updates the work tree as expected for
changes which don't result in conflicts. To make that work add two
helper functions that add a commit only touching files and then
revert it. This allows to rebase the target commit over these two
and to compare the result.

Set KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR to
document that "replace directory with submodule" fails for an
interactive rebase because a directory "sub1" already exists.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge: add t7613 for submodule updatesJens Lehmann Sun, 15 Jun 2014 17:01:41 +0000 (19:01 +0200)

merge: add t7613 for submodule updates

Test that the merge command updates the work tree as expected (for
submodule changes which don't result in conflicts) when used without
arguments or with the '--ff', '--ff-only' and '--no-ff' flag.

Implement the KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR
switch to expect the known failure that --no-ff merges do not create the
empty submodule directory.

The KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES
switch is also implemented to expect the known failure that --no-ff
merges attempt to merge the new files in the former submodule directory
with those of the removed submodule.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

bisect: add t6041 for submodule updatesJens Lehmann Thu, 19 Jun 2014 20:12:48 +0000 (22:12 +0200)

bisect: add t6041 for submodule updates

Test that the bisect command updates the work tree as expected. To make
that work with the new submodule test framework a git_bisect helper
function is added. This adds a commit after the one given to be switched
to and makes that one the bad commit. The starting point is then given to
bisect as the good commit which makes bisect change the work tree to the
commit in between, which is the commit given.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

reset: add t7112 for submodule updatesJens Lehmann Sun, 15 Jun 2014 17:00:28 +0000 (19:00 +0200)

reset: add t7112 for submodule updates

Test that the reset command updates the work tree as expected for changes
with '--keep', '--merge' (for changes which don't result in conflicts) and
'--hard'.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

read-tree: add t1013 for submodule updatesJens Lehmann Sun, 15 Jun 2014 16:59:51 +0000 (18:59 +0200)

read-tree: add t1013 for submodule updates

Test that the read-tree command updates the work tree as expected for
changes which don't result in conflicts with the '-m' and '--reset' flag.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

apply: add t4137 for submodule updatesJens Lehmann Sun, 15 Jun 2014 16:59:20 +0000 (18:59 +0200)

apply: add t4137 for submodule updates

Test that the apply command updates the work tree as expected for the
'--index' and the '--3way' options (for submodule changes which don't
result in conflicts).

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

checkout: call the new submodule update test frameworkJens Lehmann Sun, 15 Jun 2014 16:58:44 +0000 (18:58 +0200)

checkout: call the new submodule update test framework

Test that the checkout command updates the work tree as expected with
and without the '-f' flag.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

submodules: add the lib-submodule-update.sh test libraryJens Lehmann Tue, 1 Jul 2014 21:24:14 +0000 (23:24 +0200)

submodules: add the lib-submodule-update.sh test library

Add this test library to simplify covering all combinations of submodule
update scenarios without having to add those to a test of each work tree
manipulating command over and over again.

The functions test_submodule_switch() and test_submodule_forced_switch()
are intended to be called from a test script with a single argument. This
argument is either a work tree manipulating command (including any command
line options) or a function (when more than a single git command is needed
to switch work trees from the current HEAD to another commit). This
command (or function) is passed a target branch as argument. The two new
functions check that each submodule transition is handled as expected,
which currently means that submodule work trees are not affected until
"git submodule update" is called. The "forced" variant is for commands
using their '-f' or '--hard' option and expects them to overwrite local
modifications as a result. Each of these two functions contains 14
tests_expect_* calls.

Calling one of these test functions the first time creates a repository
named "submodule_update_repo". At first it contains two files, then a
single submodule is added in another commit followed by commits covering
all relevant submodule modifications. This repository is newly cloned into
the "submodule_update" for each test_expect_* to avoid interference
between different parts of the test functions (some to-be-tested commands
also manipulate refs along with the work tree, e.g. "git reset").

Follow-up commits will then call these two test functions for all work
tree manipulating commands (with a combination of all their options
relevant to what they do with the work tree) making sure they work as
expected. Later this test library will be extended to cover merges
resulting in conflicts too. Also it is intended to be easily extendable
for the recursive update functionality, where even more combinations of
submodule modifications have to be tested for.

This version documents two bugs in current Git with expected failures:

*) When a submodule is replaced with a tracked file of the same name the
submodule work tree including any local modifications (and even the
whole history if it uses a .git directory instead of a gitfile!) is
silently removed.

*) Forced work tree updates happily manipulate files in the directory of a
submodule that has just been removed in the superproject (but is of
course still present in the work tree due to the way submodules are
currently handled). This becomes dangerous when files in the submodule
directory are overwritten by files from the new superproject commit, as
any modifications to the submodule files will be lost) and is expected
to also destroy history in the - admittedly unlikely case - the new
commit adds a file named ".git" to the submodule directory.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

refs.c: change ref_transaction_update() to do error... Ronnie Sahlberg Fri, 20 Jun 2014 14:43:00 +0000 (07:43 -0700)

refs.c: change ref_transaction_update() to do error checking and return status

Update ref_transaction_update() do some basic error checking and return
non-zero on error. Update all callers to check ref_transaction_update() for
error. There are currently no conditions in _update that will return error but
there will be in the future. Add an err argument that will be updated on
failure. In future patches we will start doing both locking and checking
for name conflicts in _update instead of _commit at which time this function
will start returning errors for these conditions.

Also check for BUGs during update and die(BUG:...) if we are calling
_update with have_old but the old_sha1 pointer is NULL.

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Acked-by: Michael Haggerty <mhagger@alum.mit.edu>

refs.c: remove the onerr argument to ref_transaction_commitRonnie Sahlberg Fri, 20 Jun 2014 14:42:59 +0000 (07:42 -0700)

refs.c: remove the onerr argument to ref_transaction_commit

Since all callers now use QUIET_ON_ERR we no longer need to provide an onerr
argument any more. Remove the onerr argument from the ref_transaction_commit
signature.

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Acked-by: Michael Haggerty <mhagger@alum.mit.edu>

update-ref: use err argument to get error from ref_tran... Ronnie Sahlberg Fri, 20 Jun 2014 14:42:58 +0000 (07:42 -0700)

update-ref: use err argument to get error from ref_transaction_commit

Call ref_transaction_commit with QUIET_ON_ERR and use the strbuf that is
returned to print a log message if/after the transaction fails.

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Acked-by: Michael Haggerty <mhagger@alum.mit.edu>

refs.c: make update_ref_write update a strbuf on failureRonnie Sahlberg Fri, 20 Jun 2014 14:42:57 +0000 (07:42 -0700)

refs.c: make update_ref_write update a strbuf on failure

Change update_ref_write to also update an error strbuf on failure.
This makes the error available to ref_transaction_commit callers if the
transaction failed due to update_ref_sha1/write_ref_sha1 failures.

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Acked-by: Michael Haggerty <mhagger@alum.mit.edu>

refs.c: make ref_update_reject_duplicates take a strbuf... Ronnie Sahlberg Fri, 20 Jun 2014 14:42:56 +0000 (07:42 -0700)

refs.c: make ref_update_reject_duplicates take a strbuf argument for errors

Make ref_update_reject_duplicates return any error that occurs through a
new strbuf argument. This means that when a transaction commit fails in
this function we will now be able to pass a helpful error message back to the
caller.

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Acked-by: Michael Haggerty <mhagger@alum.mit.edu>

refs.c: log_ref_write should try to return meaningful... Ronnie Sahlberg Fri, 20 Jun 2014 14:42:55 +0000 (07:42 -0700)

refs.c: log_ref_write should try to return meaningful errno

Making errno from write_ref_sha1() meaningful, which should fix

* a bug in "git checkout -b" where it prints strerror(errno)
 despite errno possibly being zero or clobbered

* a bug in "git fetch"'s s_update_ref, which trusts the result of an
 errno == ENOTDIR check to detect D/F conflicts

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

refs.c: make resolve_ref_unsafe set errno to something... Ronnie Sahlberg Fri, 20 Jun 2014 14:42:54 +0000 (07:42 -0700)

refs.c: make resolve_ref_unsafe set errno to something meaningful on error

Making errno when returning from resolve_ref_unsafe() meaningful,
which should fix

* a bug in lock_ref_sha1_basic, where it assumes EISDIR
means it failed due to a directory being in the way

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

refs.c: commit_packed_refs to return a meaningful errno... Ronnie Sahlberg Fri, 20 Jun 2014 14:42:53 +0000 (07:42 -0700)

refs.c: commit_packed_refs to return a meaningful errno on failure

Making errno when returning from commit_packed_refs() meaningful,
which should fix

* a bug in "git clone" where it prints strerror(errno) based on
errno, despite errno possibly being zero and potentially having
been clobbered by that point
* the same kind of bug in "git pack-refs"

and prepares for repack_without_refs() to get a meaningful
error message when commit_packed_refs() fails without falling into
the same bug.

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

refs.c: make remove_empty_directories always set errno... Ronnie Sahlberg Fri, 20 Jun 2014 14:42:52 +0000 (07:42 -0700)

refs.c: make remove_empty_directories always set errno to something sane

Making errno when returning from remove_empty_directories() more
obviously meaningful, which should provide some peace of mind for
people auditing lock_ref_sha1_basic.

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

refs.c: verify_lock should set errno to something meani... Ronnie Sahlberg Fri, 20 Jun 2014 14:42:51 +0000 (07:42 -0700)

refs.c: verify_lock should set errno to something meaningful

Making errno when returning from verify_lock() meaningful, which
should almost but not completely fix

* a bug in "git fetch"'s s_update_ref, which trusts the result of an
errno == ENOTDIR check to detect D/F conflicts

ENOTDIR makes sense as a sign that a file was in the way of a
directory we wanted to create. Should "git fetch" also look for
ENOTEMPTY or EEXIST to catch cases where a directory was in the way
of a file to be created?

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

refs.c: make sure log_ref_setup returns a meaningful... Ronnie Sahlberg Fri, 20 Jun 2014 14:42:50 +0000 (07:42 -0700)

refs.c: make sure log_ref_setup returns a meaningful errno

Making errno when returning from log_ref_setup() meaningful,

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

refs.c: add an err argument to repack_without_refsRonnie Sahlberg Fri, 20 Jun 2014 14:42:49 +0000 (07:42 -0700)

refs.c: add an err argument to repack_without_refs

Update repack_without_refs to take an err argument and update it if there
is a failure. Pass the err variable from ref_transaction_commit to this
function so that callers can print a meaningful error message if _commit
fails due to this function.

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