gitweb.git
Win32: Thread-safe windows console outputKarsten Blees Sat, 14 Jan 2012 21:24:19 +0000 (22:24 +0100)

Win32: Thread-safe windows console output

Winansi.c has many static variables that are accessed and modified from
the [v][f]printf / fputs functions overridden in the file. This may cause
multi threaded git commands that print to the console to produce corrupted
output or even crash.

Additionally, winansi.c doesn't override all functions that can be used to
print to the console (e.g. fwrite, write, fputc are missing), so that ANSI
escapes don't work properly for some git commands (e.g. git-grep).

Instead of doing ANSI emulation in just a few wrapped functions on top of
the IO API, let's plug into the IO system and take advantage of the thread
safety inherent to the IO system.

Redirect stdout and stderr to a pipe if they point to the console. A
background thread reads from the pipe, handles ANSI escape sequences and
UTF-8 to UTF-16 conversion, then writes to the console.

The pipe-based stdout and stderr replacements must be set to unbuffered, as
MSVCRT doesn't support line buffering and fully buffered streams are
inappropriate for console output.

Due to the byte-oriented pipe, ANSI escape sequences and multi-byte UTF-8
sequences can no longer be expected to arrive in one piece. Replace the
string-based ansi_emulate() with a simple stateful parser (this also fixes
colored diff hunk headers, which were broken as of commit 2efcc977).

Override isatty to return true for the pipes redirecting to the console.

Exec/spawn obtain the original console handle to pass to the next process
via winansi_get_osfhandle().

All other overrides are gone, the default stdio implementations work as
expected with the piped stdout/stderr descriptors.

Global variables are either initialized on startup (single threaded) or
exclusively modified by the background thread. Threads communicate through
the pipe, no further synchronization is necessary.

The background thread is terminated by disonnecting the pipe after flushing
the stdio and pipe buffers. This doesn't work for anonymous pipes (created
via CreatePipe), as DisconnectNamedPipe only works on the read end, which
discards remaining data. Thus we have to setup the pipe manually, with the
write end beeing the server (opened with CreateNamedPipe) and the read end
the client (opened with CreateFile).

Limitations: doesn't track reopened or duped file descriptors, i.e.:
- fdopen(1/2) returns fully buffered streams
- dup(1/2), dup2(1/2) returns normal pipe descriptors (i.e. isatty() =
false, winansi_get_osfhandle won't return the original console handle)

Currently, only the git-format-patch command uses xfdopen(xdup(1)) (see
"realstdout" in builtin/log.c), but works well with these limitations.

Many thanks to Atsushi Nakagawa <atnak@chejz.com> for suggesting and
reviewing the thread-exit-mechanism.

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: add Unicode conversion functionsKarsten Blees Fri, 25 Nov 2011 20:05:06 +0000 (21:05 +0100)

Win32: add Unicode conversion functions

Add Unicode conversion functions to convert between Windows native UTF-16LE
encoding to UTF-8 and back.

To support repositories with legacy-encoded file names, the UTF-8 to UTF-16
conversion function tries to create valid, unique file names even for
invalid UTF-8 byte sequences, so that these repositories can be checked out
without error.

The current implementation leaves invalid UTF-8 bytes in range 0xa0 - 0xff
as is (producing printable Unicode chars \u00a0 - \u00ff, equivalent to
ISO-8859-1), and converts 0x80 - 0x9f to hex-code (\u0080 - \u009f are
control chars).

The Windows MultiByteToWideChar API was not used as it either drops invalid
UTF-8 sequences (on Win2k/XP; producing non-unique or even empty file
names) or converts them to the replacement char \ufffd (Vista/7; causing
ERROR_INVALID_NAME in subsequent calls to file system APIs).

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: warn if the console font doesn't support UnicodeKarsten Blees Sat, 31 Jul 2010 00:04:03 +0000 (00:04 +0000)

Win32: warn if the console font doesn't support Unicode

Unicode console output won't display correctly with default settings
because the default console font ("Terminal") only supports the system's
OEM charset. Unfortunately, this is a user specific setting, so it cannot
be easily fixed by e.g. some registry tricks in the setup program.

This change prints a warning on exit if console output contained non-ascii
characters and the console font is supposedly not a TrueType font (which
usually have decent Unicode support).

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: detect console streams more reliablyKarsten Blees Sat, 31 Jul 2010 00:04:02 +0000 (00:04 +0000)

Win32: detect console streams more reliably

GetStdHandle(STD_OUTPUT_HANDLE) doesn't work for stderr if stdout is
redirected. Use _get_osfhandle of the FILE* instead.

_isatty() is true for all character devices (including parallel and serial
ports). Check return value of GetConsoleScreenBufferInfo instead to
reliably detect console handles (also don't initialize internal state from
an uninitialized CONSOLE_SCREEN_BUFFER_INFO structure if the function
fails).

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: support Unicode console outputKarsten Blees Sat, 31 Jul 2010 00:04:01 +0000 (00:04 +0000)

Win32: support Unicode console output

WriteConsoleW seems to be the only way to reliably print unicode to the
console (without weird code page conversions).

Also redirects vfprintf to the winansi.c version.

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>

mingw: avoid const warningStepan Kasal Sat, 7 Jun 2014 06:46:41 +0000 (08:46 +0200)

mingw: avoid const warning

Fix const warnings in http-fetch.c and remote-curl.c main() where is
argv declared as const.

The fix should work for all future declarations of main, no matter
whether the second parameter's type is "char**", "const char**", or
"char *[]".

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

Win32: move main macro to a functionKarsten Blees Fri, 7 Jan 2011 18:47:23 +0000 (19:47 +0100)

Win32: move main macro to a function

The code in the MinGW main macro is getting more and more complex, move to
a separate initialization function for readabiliy and extensibility.

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

Windows: allow using UNC path for git repositoryCezary Zawadka Tue, 13 Jul 2010 14:17:43 +0000 (16:17 +0200)

Windows: allow using UNC path for git repository

[efl: moved MinGW-specific part to compat/]
[jes: fixed compilation on non-Windows]

Eric Sunshine fixed mingw_offset_1st_component() to return
consistently "foo" for UNC "//machine/share/foo", cf

http://groups.google.com/group/msysgit/browse_thread/thread/c0af578549b5dda0

Author: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Cezary Zawadka <czawadka@gmail.com>
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
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>

Git 1.9.3 v1.9.3Junio C Hamano Fri, 9 May 2014 17:59:07 +0000 (10:59 -0700)

Git 1.9.3

The third maintenance release for Git 1.9; contains all the fixes
that are scheduled to appear in Git 2.0 since 1.9.2.

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

shell doc: remove stray "+" in exampleJonathan Nieder Wed, 7 May 2014 23:44:01 +0000 (16:44 -0700)

shell doc: remove stray "+" in example

The git-shell(1) manpage says

EXAMPLE
To disable interactive logins, displaying a greeting
instead:

+

$ chsh -s /usr/bin/git-shell
$ mkdir $HOME/git-shell-commands
[...]

The stray "+" has been there ever since the example was added in
v1.8.3-rc0~210^2 (shell: new no-interactive-login command to print a
custom message, 2013-03-09). The "+" sign between paragraphs is
needed in asciidoc to attach extra paragraphs to a list item but here
it is not needed and ends up rendered as a literal "+". Remove it.

A quick search with "grep -e '<p>+' /usr/share/doc/git/html/*.html"
doesn't find any other instances of this problem.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Start preparing for 1.9.3Junio C Hamano Thu, 8 May 2014 17:05:22 +0000 (10:05 -0700)

Start preparing for 1.9.3

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

Merge branch 'cl/p4-use-diff-tree' into maintJunio C Hamano Thu, 8 May 2014 17:01:32 +0000 (10:01 -0700)

Merge branch 'cl/p4-use-diff-tree' into maint

"git p4" dealing with changes in binary files were broken by a
change in 1.9 release.

* cl/p4-use-diff-tree:
git-p4: format-patch to diff-tree change breaks binary patches

Merge branch 'rh/prompt-pcmode-avoid-eval-on-refname... Junio C Hamano Thu, 8 May 2014 17:01:18 +0000 (10:01 -0700)

Merge branch 'rh/prompt-pcmode-avoid-eval-on-refname' into maint

The shell prompt script (in contrib/), when using the PROMPT_COMMAND
interface, used an unsafe construct when showing the branch name in
$PS1.

* rh/prompt-pcmode-avoid-eval-on-refname:
git-prompt.sh: don't put unsanitized branch names in $PS1

Merge branch 'km/avoid-non-function-return-in-rebase... Junio C Hamano Thu, 8 May 2014 17:01:06 +0000 (10:01 -0700)

Merge branch 'km/avoid-non-function-return-in-rebase' into maint

"git rebase" used a POSIX shell construct FreeBSD /bin/sh does not
work well with.

* km/avoid-non-function-return-in-rebase:
Revert "rebase: fix run_specific_rebase's use of "return" on FreeBSD"
rebase: avoid non-function use of "return" on FreeBSD

Merge branch 'tb/unicode-6.3-zero-width' into maintJunio C Hamano Thu, 8 May 2014 17:00:45 +0000 (10:00 -0700)

Merge branch 'tb/unicode-6.3-zero-width' into maint

Some more Unicode codepoints defined in Unicode 6.3 as having zero
width have been taught to our display column counting logic.

* tb/unicode-6.3-zero-width:
utf8.c: partially update to version 6.3

Merge branch 'km/avoid-bs-in-shell-glob' into maintJunio C Hamano Thu, 8 May 2014 17:00:36 +0000 (10:00 -0700)

Merge branch 'km/avoid-bs-in-shell-glob' into maint

Some tests used shell constructs that did not work well on FreeBSD

* km/avoid-bs-in-shell-glob:
test: fix t5560 on FreeBSD

Merge branch 'km/avoid-cp-a' into maintJunio C Hamano Thu, 8 May 2014 16:59:41 +0000 (09:59 -0700)

Merge branch 'km/avoid-cp-a' into maint

Some tests used shell constructs that did not work well on FreeBSD

* km/avoid-cp-a:
test: fix t7001 cp to use POSIX options

git-p4: format-patch to diff-tree change breaks binary... Tolga Ceylan Wed, 7 May 2014 05:48:54 +0000 (22:48 -0700)

git-p4: format-patch to diff-tree change breaks binary patches

When applying binary patches a full index is required. format-patch
already handles this, but diff-tree needs '--full-index' argument
to always output full index. When git-p4 runs git-apply to test
the patch, git-apply rejects the patch due to abbreviated blob
object names. This is the error message git-apply emits in this
case:

error: cannot apply binary patch to '<filename>' without full index line
error: <filename>: patch does not apply

Signed-off-by: Tolga Ceylan <tolga.ceylan@gmail.com>
Acked-by: Pete Wyckoff <pw@padd.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-prompt.sh: don't put unsanitized branch names in... Richard Hansen Mon, 21 Apr 2014 23:53:09 +0000 (19:53 -0400)

git-prompt.sh: don't put unsanitized branch names in $PS1

Both bash and zsh subject the value of PS1 to parameter expansion,
command substitution, and arithmetic expansion. Rather than include
the raw, unescaped branch name in PS1 when running in two- or
three-argument mode, construct PS1 to reference a variable that holds
the branch name. Because the shells do not recursively expand, this
avoids arbitrary code execution by specially-crafted branch names such
as '$(IFS=_;cmd=sudo_rm_-rf_/;$cmd)'.

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

Revert "rebase: fix run_specific_rebase's use of "retur... Kyle J. McKay Fri, 11 Apr 2014 08:28:18 +0000 (01:28 -0700)

Revert "rebase: fix run_specific_rebase's use of "return" on FreeBSD"

This reverts commit 99855ddf4bd319cd06a0524e755ab1c1b7d39f3b.

The workaround 99855ddf introduced to deal with problematic
"return" statements in scripts run by "dot" commands located
inside functions only handles one part of the problem. The
issue has now been addressed by not using "return" statements
in this way in the git-rebase--*.sh scripts.

This workaround is therefore no longer necessary, so clean
up the code by reverting it.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
Acked-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

rebase: avoid non-function use of "return" on FreeBSDKyle J. McKay Fri, 11 Apr 2014 08:28:17 +0000 (01:28 -0700)

rebase: avoid non-function use of "return" on FreeBSD

Since a1549e10, 15d4bf2e and 01a1e646 (first appearing in v1.8.4)
the git-rebase--*.sh scripts have used a "return" to stop execution
of the dot-sourced file and return to the "dot" command that
dot-sourced it. The /bin/sh utility on FreeBSD however behaves
poorly under some circumstances when such a "return" is executed.

In particular, if the "dot" command is contained within a function,
then when a "return" is executed by the script it runs (that is not
itself inside a function), control will return from the function
that contains the "dot" command skipping any statements that might
follow the dot command inside that function. Commit 99855ddf (first
appearing in v1.8.4.1) addresses this by making the "dot" command
the last line in the function.

Unfortunately the FreeBSD /bin/sh may also execute some statements
in the script run by the "dot" command that appear after the
troublesome "return". The fix in 99855ddf does not address this
problem.

For example, if you have script1.sh with these contents:

run_script2() {
. "$(dirname -- "$0")/script2.sh"
_e=$?
echo only this line should show
[ $_e -eq 5 ] || echo expected status 5 got $_e
return 3
}
run_script2
e=$?
[ $e -eq 3 ] || { echo expected status 3 got $e; exit 1; }

And script2.sh with these contents:

if [ 5 -gt 3 ]; then
return 5
fi
case bad in *)
echo always shows
esac
echo should not get here
! :

When running script1.sh (e.g. '/bin/sh script1.sh' or './script1.sh'
after making it executable), the expected output from a POSIX shell
is simply the single line:

only this line should show

However, when run using FreeBSD's /bin/sh, the following output
appears instead:

should not get here
expected status 3 got 1

Not only did the lines following the "dot" command in the run_script2
function in script1.sh get skipped, but additional lines in script2.sh
following the "return" got executed -- but not all of them (e.g. the
"echo always shows" line did not run).

These issues can be avoided by not using a top-level "return" in
script2.sh. If script2.sh is changed to this:

main() {
if [ 5 -gt 3 ]; then
return 5
fi
case bad in *)
echo always shows
esac
echo should not get here
! :
}
main

Then it behaves the same when using FreeBSD's /bin/sh as when using
other more POSIX compliant /bin/sh implementations.

We fix the git-rebase--*.sh scripts in a similar fashion by moving
the top-level code that contains "return" statements into its own
function and then calling that as the last line in the script.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
Acked-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

test: fix t5560 on FreeBSDKyle J. McKay Fri, 11 Apr 2014 08:28:19 +0000 (01:28 -0700)

test: fix t5560 on FreeBSD

Since fd0a8c2e (first appearing in v1.7.0), the
t/t5560-http-backend-noserver.sh test has used a backslash escape
inside a ${} expansion in order to specify a literal '?' character.

Unfortunately the FreeBSD /bin/sh does not interpret this correctly.

In a POSIX compliant shell, the following:

x='one?two?three'
echo "${x#*\?}"

Would be expected to produce this:

two?three

When using the FreeBSD /bin/sh instead you get this:

one?two?three

In fact the FreeBSD /bin/sh treats the backslash as a literal
character to match so that this:

y='one\two\three'
echo "${y#*\?}"

Produces this unexpected value:

wo\three

In this case the backslash is not only treated literally, it also
fails to defeat the special meaning of the '?' character.

Instead, we can use the [...] construct to defeat the special meaning
of the '?' character and match it exactly in a way that works for the
FreeBSD /bin/sh as well as other POSIX /bin/sh implementations.

Changing the example like so:

x='one?two?three'
echo "${x#*[?]}"

Produces the expected output using the FreeBSD /bin/sh.

Therefore, change the use of \? to [?] in order to be compatible with
the FreeBSD /bin/sh which allows t/t5560-http-backend-noserver.sh to
pass on FreeBSD again.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

test: fix t7001 cp to use POSIX optionsKyle J. McKay Fri, 11 Apr 2014 08:24:02 +0000 (01:24 -0700)

test: fix t7001 cp to use POSIX options

Since 11502468 and 04c1ee57 (both first appearing in v1.8.5), the
t7001-mv test has used "cp -a" to perform a copy in several of the
tests.

However, the "-a" option is not required for a POSIX cp utility and
some platforms' cp utilities do not support it.

The POSIX equivalent of -a is -R -P -p.

Change "cp -a" to "cp -R -P -p" so that the t7001-mv test works
on systems with a cp utility that only implements the POSIX
required set of options and not the "-a" option.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Git 1.9.2 v1.9.2Junio C Hamano Wed, 9 Apr 2014 19:04:34 +0000 (12:04 -0700)

Git 1.9.2

The second maintenance release for Git 1.9; contains all the fixes
that are scheduled to appear in Git 2.0.

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

Merge branch 'jl/nor-or-nand-and' into maintJunio C Hamano Wed, 9 Apr 2014 19:03:26 +0000 (12:03 -0700)

Merge branch 'jl/nor-or-nand-and' into maint

* jl/nor-or-nand-and:
code and test: fix misuses of "nor"
comments: fix misuses of "nor"
contrib: fix misuses of "nor"
Documentation: fix misuses of "nor"

Merge branch 'cn/fetch-prune-overlapping-destination... Junio C Hamano Wed, 9 Apr 2014 19:02:41 +0000 (12:02 -0700)

Merge branch 'cn/fetch-prune-overlapping-destination' into maint

* cn/fetch-prune-overlapping-destination:
fetch: handle overlaping refspecs on --prune
fetch: add a failing test for prunning with overlapping refspecs

Merge branch 'mh/update-ref-batch-create-fix' into... Junio C Hamano Wed, 9 Apr 2014 19:01:28 +0000 (12:01 -0700)

Merge branch 'mh/update-ref-batch-create-fix' into maint

* mh/update-ref-batch-create-fix:
update-ref: fail create operation over stdin if ref already exists

Merge branch 'jk/commit-dates-parsing-fix' into maintJunio C Hamano Wed, 9 Apr 2014 18:59:38 +0000 (11:59 -0700)

Merge branch 'jk/commit-dates-parsing-fix' into maint

* jk/commit-dates-parsing-fix:
t4212: loosen far-in-future test for AIX
date: recognize bogus FreeBSD gmtime output

Merge branch 'jc/fix-diff-no-index-diff-opt-parse'... Junio C Hamano Wed, 9 Apr 2014 18:59:16 +0000 (11:59 -0700)

Merge branch 'jc/fix-diff-no-index-diff-opt-parse' into maint

* jc/fix-diff-no-index-diff-opt-parse:
diff-no-index: correctly diagnose error return from diff_opt_parse()

Merge commit 'doc/http-backend: missing accent grave... Junio C Hamano Wed, 9 Apr 2014 18:45:04 +0000 (11:45 -0700)

Merge commit 'doc/http-backend: missing accent grave in literal mark-up'

* commit '5df05146d5cb94628a3dfc53063c802ee1152cec':
doc/http-backend: missing accent grave in literal mark-up

doc/http-backend: missing accent grave in literal mark-upThomas Ackermann Wed, 9 Apr 2014 18:17:38 +0000 (20:17 +0200)

doc/http-backend: missing accent grave in literal mark-up

Signed-off-by: Thomas Ackermann <th.acker@arcor.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

utf8.c: partially update to version 6.3Torsten Bögershausen Mon, 7 Apr 2014 19:39:41 +0000 (21:39 +0200)

utf8.c: partially update to version 6.3

Unicode 6.3 defines more code points as combining or accents. For
example, the character "ö" could be expressed as an "o" followed by
U+0308 COMBINING DIARESIS (aka umlaut, double-dot-above). We should
consider that such a sequence of two codepoints occupies one display
column for the alignment purposes, and for that, git_wcwidth()
should return 0 for them. Affected codepoints are:

U+0358..U+035C
U+0487
U+05A2, U+05BA, U+05C5, U+05C7
U+0604, U+0616..U+061A, U+0659..U+065F

Earlier unicode standards had defined these as "reserved".

Only the range 0..U+07FF has been checked to see which codepoints
need to be marked as 0-width while preparing for this commit; more
updates may be needed.

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

Update draft release notes to 1.9.2Junio C Hamano Tue, 8 Apr 2014 19:08:34 +0000 (12:08 -0700)

Update draft release notes to 1.9.2

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

Merge branch 'mm/status-porcelain-format-i18n-fix'... Junio C Hamano Tue, 8 Apr 2014 19:07:06 +0000 (12:07 -0700)

Merge branch 'mm/status-porcelain-format-i18n-fix' into maint

* mm/status-porcelain-format-i18n-fix:
status: disable translation when --porcelain is used

Merge branch 'bp/commit-p-editor' into maintJunio C Hamano Tue, 8 Apr 2014 19:07:06 +0000 (12:07 -0700)

Merge branch 'bp/commit-p-editor' into maint

* bp/commit-p-editor:
run-command: mark run_hook_with_custom_index as deprecated
merge hook tests: fix and update tests
merge: fix GIT_EDITOR override for commit hook
commit: fix patch hunk editing with "commit -p -m"
test patch hunk editing with "commit -p -m"
merge hook tests: use 'test_must_fail' instead of '!'
merge hook tests: fix missing '&&' in test

Start preparing for 1.9.1Junio C Hamano Thu, 3 Apr 2014 20:37:29 +0000 (13:37 -0700)

Start preparing for 1.9.1

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

Merge branch 'jk/mv-submodules-fix' into maintJunio C Hamano Thu, 3 Apr 2014 20:39:06 +0000 (13:39 -0700)

Merge branch 'jk/mv-submodules-fix' into maint

* jk/mv-submodules-fix:
mv: prevent mismatched data when ignoring errors.
builtin/mv: fix out of bounds write

Conflicts:
t/t7001-mv.sh

Merge branch 'mh/remove-subtree-long-pathname-fix'... Junio C Hamano Thu, 3 Apr 2014 20:39:05 +0000 (13:39 -0700)

Merge branch 'mh/remove-subtree-long-pathname-fix' into maint

* mh/remove-subtree-long-pathname-fix:
entry.c: fix possible buffer overflow in remove_subtree()
checkout_entry(): use the strbuf throughout the function

Merge branch 'jk/lib-terminal-lazy' into maintJunio C Hamano Thu, 3 Apr 2014 20:39:04 +0000 (13:39 -0700)

Merge branch 'jk/lib-terminal-lazy' into maint

* jk/lib-terminal-lazy:
t/lib-terminal: make TTY a lazy prerequisite

Merge branch 'nd/index-pack-error-message' into maintJunio C Hamano Thu, 3 Apr 2014 20:39:04 +0000 (13:39 -0700)

Merge branch 'nd/index-pack-error-message' into maint

* nd/index-pack-error-message:
index-pack: report error using the correct variable

Merge branch 'us/printf-not-echo' into maintJunio C Hamano Thu, 3 Apr 2014 20:39:04 +0000 (13:39 -0700)

Merge branch 'us/printf-not-echo' into maint

* us/printf-not-echo:
test-lib.sh: do not "echo" caller-supplied strings
rebase -i: do not "echo" random user-supplied strings

Merge branch 'rr/doc-merge-strategies' into maintJunio C Hamano Thu, 3 Apr 2014 20:39:03 +0000 (13:39 -0700)

Merge branch 'rr/doc-merge-strategies' into maint

* rr/doc-merge-strategies:
Documentation/merge-strategies: avoid hyphenated commands

Merge branch 'jk/shallow-update-fix' into maintJunio C Hamano Thu, 3 Apr 2014 20:39:03 +0000 (13:39 -0700)

Merge branch 'jk/shallow-update-fix' into maint

* jk/shallow-update-fix:
shallow: verify shallow file after taking lock
shallow: automatically clean up shallow tempfiles
shallow: use stat_validity to check for up-to-date file

Merge branch 'jc/stash-pop-not-popped' into maintJunio C Hamano Thu, 3 Apr 2014 20:39:03 +0000 (13:39 -0700)

Merge branch 'jc/stash-pop-not-popped' into maint

* jc/stash-pop-not-popped:
stash pop: mention we did not drop the stash upon failing to apply

Merge branch 'jn/wt-status' into maintJunio C Hamano Thu, 3 Apr 2014 20:39:02 +0000 (13:39 -0700)

Merge branch 'jn/wt-status' into maint

* jn/wt-status:
wt-status: lift the artificual "at least 20 columns" floor
wt-status: i18n of section labels
wt-status: extract the code to compute width for labels
wt-status: make full label string to be subject to l10n

update-ref: fail create operation over stdin if ref... Aman Gupta Wed, 2 Apr 2014 08:09:54 +0000 (10:09 +0200)

update-ref: fail create operation over stdin if ref already exists

Signed-off-by: Aman Gupta <aman@tmm1.net>
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Acked-by: Brad King <brad.king@kitware.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t4212: loosen far-in-future test for AIXJeff King Tue, 1 Apr 2014 07:43:06 +0000 (03:43 -0400)

t4212: loosen far-in-future test for AIX

One of the tests in t4212 checks our behavior when we feed
gmtime a date so far in the future that it gives up and
returns NULL. Some implementations, like AIX, may actually
just provide us a bogus result instead.

It's not worth it for us to come up with heuristics that
guess whether the return value is sensible or not. On good
platforms where gmtime reports the problem to us with NULL,
we will print the epoch value. On bad platforms, we will
print garbage. But our test should be written for the
lowest common denominator so that it passes everywhere.

Reported-by: Charles Bailey <cbailey32@bloomberg.net>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

date: recognize bogus FreeBSD gmtime outputJeff King Tue, 1 Apr 2014 21:28:42 +0000 (17:28 -0400)

date: recognize bogus FreeBSD gmtime output

Most gmtime implementations return a NULL value when they
encounter an error (and this behavior is specified by ANSI C
and POSIX). FreeBSD's implementation, however, will simply
leave the "struct tm" untouched. Let's also recognize this
and convert it to a NULL (with this patch, t4212 should pass
on FreeBSD).

Reported-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

code and test: fix misuses of "nor"Justin Lebar Mon, 31 Mar 2014 22:11:47 +0000 (15:11 -0700)

code and test: fix misuses of "nor"

Signed-off-by: Justin Lebar <jlebar@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

comments: fix misuses of "nor"Justin Lebar Mon, 31 Mar 2014 22:11:46 +0000 (15:11 -0700)

comments: fix misuses of "nor"

Signed-off-by: Justin Lebar <jlebar@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

contrib: fix misuses of "nor"Justin Lebar Mon, 31 Mar 2014 22:11:45 +0000 (15:11 -0700)

contrib: fix misuses of "nor"

Signed-off-by: Justin Lebar <jlebar@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Documentation: fix misuses of "nor"Justin Lebar Mon, 31 Mar 2014 22:11:44 +0000 (15:11 -0700)

Documentation: fix misuses of "nor"

Signed-off-by: Justin Lebar <jlebar@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

diff-no-index: correctly diagnose error return from... Junio C Hamano Mon, 31 Mar 2014 18:47:17 +0000 (11:47 -0700)

diff-no-index: correctly diagnose error return from diff_opt_parse()

diff_opt_parse() returns the number of options parsed, or often
returns error() which is defined to return -1. Yes, return value of
0 is "I did not process that option at all", which should cause the
caller to say that, but negative return should not be forgotten.

This bug caused "diff --no-index" to infinitely show the same error
message because the returned value was used to decrement the loop
control variable, e.g.

$ git diff --no-index --color=words a b
error: option `color' expects "always", "auto", or "never"
error: option `color' expects "always", "auto", or "never"
...

Instead, make it act like so:

$ git diff --no-index --color=words a b
error: option `color' expects "always", "auto", or "never"
fatal: invalid diff option/value: --color=words

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

fetch: handle overlaping refspecs on --pruneCarlos Martín Nieto Thu, 27 Feb 2014 09:00:10 +0000 (10:00 +0100)

fetch: handle overlaping refspecs on --prune

We need to consider that a remote-tracking branch may match more than
one rhs of a fetch refspec. In such a case, it is not enough to stop at
the first match but look at all of the matches in order to determine
whether a head is stale.

To this goal, introduce a variant of query_refspecs which returns all of
the matching refspecs and loop over those answers to check for
staleness.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

status: disable translation when --porcelain is usedMatthieu Moy Thu, 20 Mar 2014 12:12:41 +0000 (13:12 +0100)

status: disable translation when --porcelain is used

"git status --branch --porcelain" displays the status of the branch
(ahead, behind, gone), and used gettext to translate the string.

Use hardcoded strings when --porcelain is used, but keep the gettext
translation for "git status --short" which is essentially the same, but
meant to be read by a human.

Reported-by: Anarky <ghostanarky@gmail.com>
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Git 1.9.1 v1.9.1Junio C Hamano Tue, 18 Mar 2014 21:06:49 +0000 (14:06 -0700)

Git 1.9.1

The version numbering scheme has changed since Git 1.9 and we
dropped the third dewey-decimal from the traditional numbering
(e.g. both 1.8.4 and 1.8.5 were major feature releases). This
release 1.9.1 is the first maintenance relase for Git 1.9.

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

Merge branch 'jk/clean-d-pathspec' into maintJunio C Hamano Tue, 18 Mar 2014 21:04:59 +0000 (14:04 -0700)

Merge branch 'jk/clean-d-pathspec' into maint

"git clean -d pathspec" did not use the given pathspec correctly
and ended up cleaning too much.

* jk/clean-d-pathspec:
clean: simplify dir/not-dir logic
clean: respect pathspecs with "-d"

Merge branch 'da/difftool-git-files' into maintJunio C Hamano Tue, 18 Mar 2014 21:04:36 +0000 (14:04 -0700)

Merge branch 'da/difftool-git-files' into maint

"git difftool" misbehaved when the repository is bound to the
working tree with the ".git file" mechanism, where a textual file
".git" tells us where it is.

* da/difftool-git-files:
t7800: add a difftool test for .git-files
difftool: support repositories with .git-files

Merge branch 'jk/remote-pushremote-config-reading'... Junio C Hamano Tue, 18 Mar 2014 21:04:16 +0000 (14:04 -0700)

Merge branch 'jk/remote-pushremote-config-reading' into maint

"git push" did not pay attention to branch.*.pushremote if it is
defined earlier than remote.pushdefault; the order of these two
variables in the configuration file should not matter, but it did by
mistake.

* jk/remote-pushremote-config-reading:
remote: handle pushremote config in any order

Merge branch 'jk/commit-dates-parsing-fix' into maintJunio C Hamano Tue, 18 Mar 2014 21:04:01 +0000 (14:04 -0700)

Merge branch 'jk/commit-dates-parsing-fix' into maint

Codepaths that parse timestamps in commit objects have been
tightened.

* jk/commit-dates-parsing-fix:
show_ident_date: fix tz range check
log: do not segfault on gmtime errors
log: handle integer overflow in timestamps
date: check date overflow against time_t
fsck: report integer overflow in author timestamps
t4212: test bogus timestamps with git-log

Merge branch 'tr/diff-submodule-no-reuse-worktree'... Junio C Hamano Tue, 18 Mar 2014 21:03:41 +0000 (14:03 -0700)

Merge branch 'tr/diff-submodule-no-reuse-worktree' into maint

"git diff --external-diff" incorrectly fed the submodule directory
in the working tree to the external diff driver when it knew it is
the same as one of the versions being compared.

* tr/diff-submodule-no-reuse-worktree:
diff: do not reuse_worktree_file for submodules

Merge branch 'nd/reset-setup-worktree' into maintJunio C Hamano Tue, 18 Mar 2014 21:03:24 +0000 (14:03 -0700)

Merge branch 'nd/reset-setup-worktree' into maint

"git reset" needs to refresh the index when working in a working
tree (it can also be used to match the index to the HEAD in an
otherwise bare repository), but it failed to set up the working
tree properly, causing GIT_WORK_TREE to be ignored.

* nd/reset-setup-worktree:
reset: optionally setup worktree and refresh index on --mixed

Merge branch 'jc/check-attr-honor-working-tree' into... Junio C Hamano Tue, 18 Mar 2014 21:03:03 +0000 (14:03 -0700)

Merge branch 'jc/check-attr-honor-working-tree' into maint

"git check-attr" when working on a repository with a working tree
did not work well when the working tree was specified via the
--work-tree (and obviously with --git-dir) option.

* jc/check-attr-honor-working-tree:
check-attr: move to the top of working tree when in non-bare repository
t0003: do not chdir the whole test process

Merge branch 'bk/refresh-missing-ok-in-merge-recursive... Junio C Hamano Tue, 18 Mar 2014 21:02:37 +0000 (14:02 -0700)

Merge branch 'bk/refresh-missing-ok-in-merge-recursive' into maint

"merge-recursive" was broken in 1.7.7 era and stopped working in an
empty (temporary) working tree, when there are renames involved.
This has been corrected.

* bk/refresh-missing-ok-in-merge-recursive:
merge-recursive.c: tolerate missing files while refreshing index
read-cache.c: extend make_cache_entry refresh flag with options
read-cache.c: refactor --ignore-missing implementation
t3030-merge-recursive: test known breakage with empty work tree

Merge branch 'ds/rev-parse-required-args' into maintJunio C Hamano Tue, 18 Mar 2014 21:01:05 +0000 (14:01 -0700)

Merge branch 'ds/rev-parse-required-args' into maint

"git rev-parse" was loose in rejecting command line arguments that
do not make sense, e.g. "--default" without the required value for
that option.

* ds/rev-parse-required-args:
rev-parse: check i before using argv[i] against argc

Merge branch 'jk/config-path-include-fix' into maintJunio C Hamano Tue, 18 Mar 2014 21:00:15 +0000 (14:00 -0700)

Merge branch 'jk/config-path-include-fix' into maint

include.path variable (or any variable that expects a path that can
use ~username expansion) in the configuration file is not a boolean,
but the code failed to check it.

* jk/config-path-include-fix:
handle_path_include: don't look at NULL value
expand_user_path: do not look at NULL path

Merge branch 'nd/diff-quiet-stat-dirty' into maintJunio C Hamano Tue, 18 Mar 2014 20:59:55 +0000 (13:59 -0700)

Merge branch 'nd/diff-quiet-stat-dirty' into maint

"git diff --quiet -- pathspec1 pathspec2" sometimes did not return
correct status value.

* nd/diff-quiet-stat-dirty:
diff: do not quit early on stat-dirty files
diff.c: move diffcore_skip_stat_unmatch core logic out for reuse later

Merge branch 'nd/http-fetch-shallow-fix' into maintJunio C Hamano Tue, 18 Mar 2014 20:59:37 +0000 (13:59 -0700)

Merge branch 'nd/http-fetch-shallow-fix' into maint

Attempting to deepen a shallow repository by fetching over smart
HTTP transport failed in the protocol exchange, when no-done
extension was used. The fetching side waited for the list of
shallow boundary commits after the sending end stopped talking to
it.

* nd/http-fetch-shallow-fix:
t5537: move http tests out to t5539
fetch-pack: fix deepen shallow over smart http with no-done cap
protocol-capabilities.txt: document no-done
protocol-capabilities.txt: refer multi_ack_detailed back to pack-protocol.txt
pack-protocol.txt: clarify 'obj-id' in the last ACK after 'done'
test: rename http fetch and push test files
tests: auto-set LIB_HTTPD_PORT from test name

Merge branch 'nd/submodule-pathspec-ending-with-slash... Junio C Hamano Tue, 18 Mar 2014 20:58:58 +0000 (13:58 -0700)

Merge branch 'nd/submodule-pathspec-ending-with-slash' into maint

Allow "git cmd path/", when the 'path' is where a submodule is
bound to the top-level working tree, to match 'path', despite the
extra and unnecessary trailing slash (such a slash is often
given by command line completion).

* nd/submodule-pathspec-ending-with-slash:
clean: use cache_name_is_other()
clean: replace match_pathspec() with dir_path_match()
pathspec: pass directory indicator to match_pathspec_item()
match_pathspec: match pathspec "foo/" against directory "foo"
dir.c: prepare match_pathspec_item for taking more flags
pathspec: rename match_pathspec_depth() to match_pathspec()
pathspec: convert some match_pathspec_depth() to dir_path_match()
pathspec: convert some match_pathspec_depth() to ce_path_match()

test-lib.sh: do not "echo" caller-supplied stringsUwe Storbeck Tue, 18 Mar 2014 00:14:11 +0000 (01:14 +0100)

test-lib.sh: do not "echo" caller-supplied strings

In some places we "echo" a string that is supplied by the calling
test script and may contain backslash sequences. The echo command
of some shells, most notably "dash", interprets these backslash
sequences (POSIX.1 allows this) which may scramble the test
output.

Signed-off-by: Uwe Storbeck <uwe@ibr.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

run-command: mark run_hook_with_custom_index as deprecatedBenoit Pierre Tue, 18 Mar 2014 10:00:56 +0000 (11:00 +0100)

run-command: mark run_hook_with_custom_index as deprecated

Signed-off-by: Benoit Pierre <benoit.pierre@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge hook tests: fix and update testsBenoit Pierre Tue, 18 Mar 2014 10:00:55 +0000 (11:00 +0100)

merge hook tests: fix and update tests

- update 'no editor' hook test and add 'editor' hook test
- make sure the tree is reset to a clean state after running a test
(using test_when_finished) so later tests are not impacted

Signed-off-by: Benoit Pierre <benoit.pierre@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge: fix GIT_EDITOR override for commit hookBenoit Pierre Tue, 18 Mar 2014 10:00:54 +0000 (11:00 +0100)

merge: fix GIT_EDITOR override for commit hook

Don't set GIT_EDITOR to ":" when calling prepare-commit-msg hook if the
editor is going to be called (e.g. with "merge -e").

Signed-off-by: Benoit Pierre <benoit.pierre@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

commit: fix patch hunk editing with "commit -p -m"Benoit Pierre Tue, 18 Mar 2014 10:00:53 +0000 (11:00 +0100)

commit: fix patch hunk editing with "commit -p -m"

Don't change git environment: move the GIT_EDITOR=":" override to the
hook command subprocess, like it's already done for GIT_INDEX_FILE.

Signed-off-by: Benoit Pierre <benoit.pierre@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

test patch hunk editing with "commit -p -m"Benoit Pierre Tue, 18 Mar 2014 10:00:52 +0000 (11:00 +0100)

test patch hunk editing with "commit -p -m"

Add (failing) tests: with commit changing the environment to let hooks
know that no editor will be used (by setting GIT_EDITOR to ":"), the
"edit hunk" functionality does not work (no editor is launched and the
whole hunk is committed).

Signed-off-by: Benoit Pierre <benoit.pierre@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Documentation/merge-strategies: avoid hyphenated commandsRamkumar Ramachandra Sun, 16 Mar 2014 22:54:56 +0000 (18:54 -0400)

Documentation/merge-strategies: avoid hyphenated commands

Replace git-pull and git-merge with the corresponding un-hyphenated
versions. While at it, use ` to mark it up instead of '.

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

index-pack: report error using the correct variableJunio C Hamano Mon, 17 Mar 2014 22:08:36 +0000 (15:08 -0700)

index-pack: report error using the correct variable

We feed a string pointer that is potentially NULL to die() when
showing the message. Don't.

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

shallow: verify shallow file after taking lockJeff King Sat, 15 Mar 2014 03:47:06 +0000 (23:47 -0400)

shallow: verify shallow file after taking lock

Before writing the shallow file, we stat() the existing file
to make sure it has not been updated since our operation
began. However, we do not do so under a lock, so there is a
possible race:

1. Process A takes the lock.

2. Process B calls check_shallow_file_for_update and finds
no update.

3. Process A commits the lockfile.

4. Process B takes the lock, then overwrite's process A's
changes.

We can fix this by doing our check while we hold the lock.

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

rebase -i: do not "echo" random user-supplied stringsUwe Storbeck Fri, 14 Mar 2014 23:56:43 +0000 (00:56 +0100)

rebase -i: do not "echo" random user-supplied strings

In some places we "echo" a string that comes from a commit log
message, which may have a backslash sequence that is interpreted by
the command (POSIX.1 allows this), most notably "dash"'s built-in
'echo'.

A commit message which contains the string '\n' (or ends with the
string '\c') may result in a garbage line in the todo list of an
interactive rebase which causes the rebase to fail.

To reproduce the behavior (with dash as /bin/sh):

mkdir test && cd test && git init
echo 1 >foo && git add foo
git commit -m"this commit message ends with '\n'"
echo 2 >foo && git commit -a --fixup HEAD
git rebase -i --autosquash --root

Now the editor opens with garbage in line 3 which has to be
removed or the rebase fails.

Signed-off-by: Uwe Storbeck <uwe@ibr.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

mv: prevent mismatched data when ignoring errors.brian m. carlson Sat, 15 Mar 2014 18:56:52 +0000 (18:56 +0000)

mv: prevent mismatched data when ignoring errors.

We shrink the source and destination arrays, but not the modes or
submodule_gitfile arrays, resulting in potentially mismatched data. Shrink
all the arrays at the same time to prevent this. Add tests to ensure the
problem does not recur.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t/lib-terminal: make TTY a lazy prerequisiteJeff King Fri, 14 Mar 2014 21:57:23 +0000 (17:57 -0400)

t/lib-terminal: make TTY a lazy prerequisite

When lib-terminal.sh is sourced by a test script, we
immediately set up the TTY prerequisite. We do so inside a
test_expect_success, because that nicely isolates any
generated output.

However, this early test can interfere with a script that
later wants to skip all tests (e.g., t5541 then goes on to
set up the httpd server, and wants to skip_all if that
fails). TAP output doesn't let us skip everything after we
have already run at least one test.

We could fix this by reordering the inclusion of
lib-terminal.sh in t5541 to go after the httpd setup. That
solves this case, but we might eventually hit a case with
circular dependencies, where either lib-*.sh include might
want to skip_all after the other has run a test. So
instead, let's just remove the ordering constraint entirely
by doing the setup inside a test_lazy_prereq construct,
rather than in a regular test. We never cared about the
test outcome anyway (it was written to always succeed).

Note that in addition to setting up the prerequisite, the
current test also defines test_terminal. Since we can't
affect the environment from a lazy_prereq, we have to hoist
that out. We previously depended on it _not_ being defined
when the TTY prereq isn't set as a way to ensure that tests
properly declare their dependency on TTY. However, we still
cover the case (see the in-code comment for details).

Reported-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

entry.c: fix possible buffer overflow in remove_subtree()Michael Haggerty Thu, 13 Mar 2014 09:19:08 +0000 (10:19 +0100)

entry.c: fix possible buffer overflow in remove_subtree()

remove_subtree() manipulated path in a fixed-size buffer even though
the length of the input, let alone the length of entries within the
directory, were not known in advance. Change the function to take a
strbuf argument and use that object as its scratch space.

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

checkout_entry(): use the strbuf throughout the functionMichael Haggerty Thu, 13 Mar 2014 09:19:07 +0000 (10:19 +0100)

checkout_entry(): use the strbuf throughout the function

There is no need to break out the "buf" and "len" members into
separate temporary variables. Rename path_buf to path and use
path.buf and path.len directly. This makes it easier to reason about
the data flow in the function.

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

wt-status: lift the artificual "at least 20 columns... Junio C Hamano Wed, 12 Mar 2014 20:43:51 +0000 (13:43 -0700)

wt-status: lift the artificual "at least 20 columns" floor

When we show unmerged paths, we had an artificial 20 columns floor
for the width of labels (e.g. "both deleted:") shown next to the
pathnames. Depending on the locale, this may result in a label that
is too wide when all the label strings are way shorter than 20
columns, or no-op when a label string is longer than 20 columns.

Just drop the artificial floor. The screen real estate is better
utilized this way when all the strings are shorter.

Adjust the tests to this change.

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

wt-status: i18n of section labelsJonathan Nieder Thu, 19 Dec 2013 19:43:19 +0000 (11:43 -0800)

wt-status: i18n of section labels

The original code assumes that:

(1) the number of bytes written is the width of a string, so they
can line up;

(2) the "how" string is always <= 19 bytes.

Neither of which we should assume.

Using the same approach as the earlier 3651e45c (wt-status: take the
alignment burden off translators, 2013-11-05), compute the necessary
column width to hold the longest label and use that for alignment.

cf. http://bugs.debian.org/725777

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Helped-by: Sandy Carter
Signed-off-by: Junio C Hamano <gitster@pobox.com>

wt-status: extract the code to compute width for labelsJonathan Nieder Thu, 19 Dec 2013 19:43:19 +0000 (11:43 -0800)

wt-status: extract the code to compute width for labels

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

wt-status: make full label string to be subject to... Junio C Hamano Wed, 12 Mar 2014 20:51:22 +0000 (13:51 -0700)

wt-status: make full label string to be subject to l10n

Earlier in 3651e45c (wt-status: take the alignment burden off
translators, 2013-11-05), we assumed that it is OK to make the
string before the colon in a label string we give as the section
header of various kinds of changes (e.g. "new file:") translatable.

This assumption apparently does not hold for some languages,
e.g. ones that want to have spaces around the colon.

Also introduce a static label_width to avoid having to run
strlen(padding) over and over.

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

builtin/mv: fix out of bounds writeJohn Keeping Sat, 8 Mar 2014 19:29:17 +0000 (19:29 +0000)

builtin/mv: fix out of bounds write

When commit a88c915 (mv: move submodules using a gitfile, 2013-07-30)
added the submodule_gitfile array, it was not added to the block that
enlarges the arrays when we are moving a directory so that we do not
have to worry about it being a directory when we perform the actual
move. After this, the loop continues over the enlarged set of sources.

Since we assume that submodule_gitfile has size argc, if any of the
items in the source directory are submodules we are guaranteed to write
beyond the end of submodule_gitfile.

Fix this by realloc'ing submodule_gitfile at the same time as the other
arrays.

Reported-by: Guillaume Gelin <contact@ramnes.eu>
Signed-off-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge hook tests: use 'test_must_fail' instead of '!'Benoit Pierre Mon, 10 Mar 2014 18:49:32 +0000 (19:49 +0100)

merge hook tests: use 'test_must_fail' instead of '!'

Signed-off-by: Benoit Pierre <benoit.pierre@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge hook tests: fix missing '&&' in testBenoit Pierre Mon, 10 Mar 2014 18:49:31 +0000 (19:49 +0100)

merge hook tests: fix missing '&&' in test

Signed-off-by: Benoit Pierre <benoit.pierre@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

clean: simplify dir/not-dir logicJeff King Mon, 10 Mar 2014 17:24:47 +0000 (13:24 -0400)

clean: simplify dir/not-dir logic

When we get a list of paths from read_directory, we further
prune it to create the final list of items to remove. The
code paths for directories and non-directories repeat the
same "add to list" code.

This patch restructures the code so that we don't repeat
ourselves. Also, by following a "if (condition) continue"
pattern like the pathspec check above, it makes it more
obvious that the conditional is about excluding directories
under certain circumstances.

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

clean: respect pathspecs with "-d"Jeff King Mon, 10 Mar 2014 20:37:30 +0000 (16:37 -0400)

clean: respect pathspecs with "-d"

git-clean uses read_directory to fill in a `struct dir` with
potential hits. However, read_directory does not actually
check against our pathspec. It uses a simplified version
that may turn up false positives. As a result, we need to
check that any hits match our pathspec. We do so reliably
for non-directories. For directories, if "-d" is not given
we check that the pathspec matched exactly (i.e., we are
even stricter, and require an explicit "git clean foo" to
clean "foo/"). But if "-d" is given, rather than relaxing
the exact match to allow a recursive match, we do not check
the pathspec at all.

This regression was introduced in 113f10f (Make git-clean a
builtin, 2007-11-11).

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

show_ident_date: fix tz range checkJeff King Fri, 7 Mar 2014 17:15:01 +0000 (12:15 -0500)

show_ident_date: fix tz range check

Commit 1dca155fe3fa (log: handle integer overflow in
timestamps, 2014-02-24) tried to catch integer overflow
coming from strtol() on the timezone field by comparing against
LONG_MIN/LONG_MAX. However, the intermediate "tz" variable
is an "int", which means it can never be LONG_MAX on LP64
systems; we would truncate the output from strtol before the
comparison.

Clang's -Wtautological-constant-out-of-range-compare notices
this and rightly complains.

Let's instead store the result of strtol in a long, and then
compare it against INT_MIN/INT_MAX. This will catch overflow
from strtol, and also overflow when we pass the result as an
int to show_date.

Reported-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t7800: add a difftool test for .git-filesJunio C Hamano Wed, 5 Mar 2014 09:23:35 +0000 (01:23 -0800)

t7800: add a difftool test for .git-files

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

i18n: proposed command missing leading dashSandy Carter Mon, 3 Mar 2014 14:55:53 +0000 (09:55 -0500)

i18n: proposed command missing leading dash

Add missing leading dash to proposed commands in french output when
using the command:
git branch --set-upstream remotename/branchname
and when upstream is gone

Signed-off-by: Sandy Carter <sandy.carter@savoirfairelinux.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

fetch: add a failing test for prunning with overlapping... Carlos Martín Nieto Thu, 27 Feb 2014 09:00:09 +0000 (10:00 +0100)

fetch: add a failing test for prunning with overlapping refspecs

When a remote has multiple fetch refspecs and these overlap in the
target namespace, fetch may prune a remote-tracking branch which still
exists in the remote. The test uses a popular form of this, by putting
pull requests as stored in a popular hosting platform alongside "real"
remote-tracking branches.

The fetch command makes a decision of whether to prune based
on the first matching refspec, which in this case is insufficient, as it
covers the pull request names. This pair of refspecs does work as
expected if the more "specific" refspec is the first in the list.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

shallow: automatically clean up shallow tempfilesJeff King Thu, 27 Feb 2014 11:25:20 +0000 (06:25 -0500)

shallow: automatically clean up shallow tempfiles

We sometimes write tempfiles of the form "shallow_XXXXXX"
during fetch/push operations with shallow repositories.
Under normal circumstances, we clean up the result when we
are done. However, we do no take steps to clean up after
ourselves when we exit due to die() or signal death.

This patch teaches the tempfile creation code to register
handlers to clean up after ourselves. To handle this, we
change the ownership semantics of the filename returned by
setup_temporary_shallow. It now keeps a copy of the filename
itself, and returns only a const pointer to it.

We can also do away with explicit tempfile removal in the
callers. They all exit not long after finishing with the
file, so they can rely on the auto-cleanup, simplifying the
code.

Note that we keep things simple and maintain only a single
filename to be cleaned. This is sufficient for the current
caller, but we future-proof it with a die("BUG").

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

shallow: use stat_validity to check for up-to-date... Jeff King Thu, 27 Feb 2014 10:56:31 +0000 (05:56 -0500)

shallow: use stat_validity to check for up-to-date file

When we are about to write the shallow file, we check that
it has not changed since we last read it. Instead of
hand-rolling this, we can use stat_validity. This is built
around the index stat-check, so it is more robust than just
checking the mtime, as we do now (it uses the same check as
we do for index files).

The new code also handles the case of a shallow file
appearing unexpectedly. With the current code, two
simultaneous processes making us shallow (e.g., two "git
fetch --depth=1" running at the same time in a non-shallow
repository) can race to overwrite each other.

As a bonus, we also remove a race in determining the stat
information of what we read (we stat and then open, leaving
a race window; instead we should open and then fstat the
descriptor).

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

stash pop: mention we did not drop the stash upon faili... Junio C Hamano Wed, 26 Feb 2014 22:18:54 +0000 (14:18 -0800)

stash pop: mention we did not drop the stash upon failing to apply

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

diff: do not quit early on stat-dirty filesNguyễn Thái Ngọc Duy Sat, 25 Jan 2014 06:46:50 +0000 (13:46 +0700)

diff: do not quit early on stat-dirty files

When QUICK is set (i.e. with --quiet) we try to do as little work as
possible, stopping after seeing the first change. stat-dirty is
considered a "change" but it may turn out not, if no actual content is
changed. The actual content test is performed too late in the process
and the shortcut may be taken prematurely, leading to incorrect return
code.

Assume we do "git diff --quiet". If we have a stat-dirty file "a" and
a really dirty file "b". We break the loop in run_diff_files() and
stop after "a" because we have got a "change". Later in
diffcore_skip_stat_unmatch() we find out "a" is actually not
changed. But there's nothing else in the diff queue, we incorrectly
declare "no change", ignoring the fact that "b" is changed.

This also happens to "git diff --quiet HEAD" when it hits
diff_can_quit_early() in oneway_diff().

This patch does the content test earlier in order to keep going if "a"
is unchanged. The test result is cached so that when
diffcore_skip_stat_unmatch() is done in the end, we spend no cycles on
re-testing "a".

Reported-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>