git
9 years agoMerge branch 'ab/merge-file-prefix' into maint
Junio C Hamano [Thu, 5 Mar 2015 21:13:10 +0000 (13:13 -0800)] 
Merge branch 'ab/merge-file-prefix' into maint

"git merge-file" did not work correctly in a subdirectory.

* ab/merge-file-prefix:
  merge-file: correctly open files when in a subdir

9 years agoMerge branch 'ps/submodule-sanitize-path-upon-add' into maint
Junio C Hamano [Thu, 5 Mar 2015 21:13:09 +0000 (13:13 -0800)] 
Merge branch 'ps/submodule-sanitize-path-upon-add' into maint

"git submodule add" failed to squash "path/to/././submodule" to
"path/to/submodule".

* ps/submodule-sanitize-path-upon-add:
  git-submodule.sh: fix '/././' path normalization

9 years agoMerge branch 'jk/prune-mtime' into maint
Junio C Hamano [Thu, 5 Mar 2015 21:13:08 +0000 (13:13 -0800)] 
Merge branch 'jk/prune-mtime' into maint

In v2.2.0, we broke "git prune" that runs in a repository that
borrows from an alternate object store.

* jk/prune-mtime:
  sha1_file: fix iterating loose alternate objects
  for_each_loose_file_in_objdir: take an optional strbuf path

9 years agoMerge branch 'tc/curl-vernum-output-broken-in-7.11' into maint
Junio C Hamano [Thu, 5 Mar 2015 21:13:07 +0000 (13:13 -0800)] 
Merge branch 'tc/curl-vernum-output-broken-in-7.11' into maint

Certain older vintages of cURL give irregular output from
"curl-config --vernum", which confused our build system.

* tc/curl-vernum-output-broken-in-7.11:
  Makefile: handle broken curl version number in version check

9 years agoMerge branch 'es/squelch-openssl-warnings-on-macosx' into maint
Junio C Hamano [Thu, 5 Mar 2015 21:13:06 +0000 (13:13 -0800)] 
Merge branch 'es/squelch-openssl-warnings-on-macosx' into maint

An earlier workaround to squelch unhelpful deprecation warnings
from the complier on Mac OSX unnecessarily set minimum required
version of the OS, which the user might want to raise (or lower)
for other reasons.

* es/squelch-openssl-warnings-on-macosx:
  git-compat-util: do not step on MAC_OS_X_VERSION_MIN_REQUIRED

9 years agoMerge branch 'jc/conf-var-doc' into maint
Junio C Hamano [Thu, 5 Mar 2015 21:13:05 +0000 (13:13 -0800)] 
Merge branch 'jc/conf-var-doc' into maint

Longstanding configuration variable naming rules has been added to
the documentation.

* jc/conf-var-doc:
  CodingGuidelines: describe naming rules for configuration variables
  config.txt: mark deprecated variables more prominently
  config.txt: clarify that add.ignore-errors is deprecated

9 years agoMerge branch 'av/wincred-with-at-in-username-fix' into maint
Junio C Hamano [Thu, 5 Mar 2015 21:13:04 +0000 (13:13 -0800)] 
Merge branch 'av/wincred-with-at-in-username-fix' into maint

The credential helper for Windows (in contrib/) used to mishandle
a user name with an at-sign in it.

* av/wincred-with-at-in-username-fix:
  wincred: fix get credential if username has "@"

9 years agoMerge branch 'ch/new-gpg-drops-rfc-1991' into maint
Junio C Hamano [Thu, 5 Mar 2015 21:13:03 +0000 (13:13 -0800)] 
Merge branch 'ch/new-gpg-drops-rfc-1991' into maint

Older GnuPG implementations may not correctly import the keyring
material we prepare for the tests to use.

* ch/new-gpg-drops-rfc-1991:
  t/lib-gpg: sanity-check that we can actually sign
  t/lib-gpg: include separate public keys in keyring.gpg

9 years agoMerge branch 'jc/remote-set-url-doc' into maint
Junio C Hamano [Thu, 5 Mar 2015 21:13:03 +0000 (13:13 -0800)] 
Merge branch 'jc/remote-set-url-doc' into maint

Clarify in the documentation that "remote.<nick>.pushURL" and
"remote.<nick>.URL" are there to name the same repository accessed
via different transports, not two separate repositories.

* jc/remote-set-url-doc:
  Documentation/git-remote.txt: stress that set-url is not for triangular

9 years agoMerge branch 'jk/pack-bitmap' into maint
Junio C Hamano [Thu, 5 Mar 2015 21:13:02 +0000 (13:13 -0800)] 
Merge branch 'jk/pack-bitmap' into maint

The pack bitmap support did not build with older versions of GCC.

* jk/pack-bitmap:
  ewah: fix building with gcc < 3.4.0

9 years agoMerge branch 'jk/config-no-ungetc-eof' into maint
Junio C Hamano [Thu, 5 Mar 2015 21:13:00 +0000 (13:13 -0800)] 
Merge branch 'jk/config-no-ungetc-eof' into maint

Reading configuration from a blob object, when it ends with a lone
CR, use to confuse the configuration parser.

* jk/config-no-ungetc-eof:
  config_buf_ungetc: warn when pushing back a random character
  config: do not ungetc EOF

9 years agoMerge branch 'jk/decimal-width-for-uintmax' into maint
Junio C Hamano [Thu, 5 Mar 2015 21:12:59 +0000 (13:12 -0800)] 
Merge branch 'jk/decimal-width-for-uintmax' into maint

We didn't format an integer that wouldn't fit in "int" but in
"uintmax_t" correctly.

* jk/decimal-width-for-uintmax:
  decimal_width: avoid integer overflow

9 years agoMerge branch 'jc/push-cert' into maint
Junio C Hamano [Thu, 5 Mar 2015 21:12:58 +0000 (13:12 -0800)] 
Merge branch 'jc/push-cert' into maint

"git push --signed" gave an incorrectly worded error message when
the other side did not support the capability.

* jc/push-cert:
  transport-helper: fix typo in error message when --signed is not supported

9 years agoMerge branch 'mh/deref-symref-over-helper-transport' into maint
Junio C Hamano [Thu, 5 Mar 2015 21:12:57 +0000 (13:12 -0800)] 
Merge branch 'mh/deref-symref-over-helper-transport' into maint

"git fetch" over a remote-helper that cannot respond to "list"
command could not fetch from a symbolic reference e.g. HEAD.

* mh/deref-symref-over-helper-transport:
  transport-helper: do not request symbolic refs to remote helpers

9 years agoMerge branch 'ks/rebase-i-abbrev' into maint
Junio C Hamano [Thu, 5 Mar 2015 21:12:56 +0000 (13:12 -0800)] 
Merge branch 'ks/rebase-i-abbrev' into maint

The insn sheet "git rebase -i" creates did not fully honor
core.abbrev settings.

* ks/rebase-i-abbrev:
  rebase -i: use full object name internally throughout the script

9 years agoMerge branch 'dp/remove-duplicated-header-inclusion' into maint
Junio C Hamano [Thu, 5 Mar 2015 21:12:55 +0000 (13:12 -0800)] 
Merge branch 'dp/remove-duplicated-header-inclusion' into maint

Code clean-up.

* dp/remove-duplicated-header-inclusion:
  do not include the same header twice

9 years agoMerge branch 'sb/hex-object-name-is-at-most-41-bytes-long' into maint
Junio C Hamano [Thu, 5 Mar 2015 21:12:54 +0000 (13:12 -0800)] 
Merge branch 'sb/hex-object-name-is-at-most-41-bytes-long' into maint

Code clean-up.

* sb/hex-object-name-is-at-most-41-bytes-long:
  hex.c: reduce memory footprint of sha1_to_hex static buffers

9 years agoMerge branch 'ak/git-pm-typofix' into maint
Junio C Hamano [Thu, 5 Mar 2015 21:12:53 +0000 (13:12 -0800)] 
Merge branch 'ak/git-pm-typofix' into maint

Typofix in comments.

* ak/git-pm-typofix:
  Git.pm: two minor typo fixes

9 years agoMerge branch 'jk/sanity' into maint
Junio C Hamano [Thu, 5 Mar 2015 21:12:52 +0000 (13:12 -0800)] 
Merge branch 'jk/sanity' into maint

The tests that wanted to see that file becomes unreadable after
running "chmod a-r file", and the tests that wanted to make sure it
is not run as root, we used "can we write into the / directory?" as
a cheap substitute, but on some platforms that is not a good
heuristics.  The tests and their prerequisites have been updated to
check what they really require.

* jk/sanity:
  test-lib.sh: set prerequisite SANITY by testing what we really need
  tests: correct misuses of POSIXPERM
  t/lib-httpd: switch SANITY check for NOT_ROOT

9 years agolog --decorate: do not leak "commit" color into the next item
Junio C Hamano [Wed, 4 Mar 2015 19:07:12 +0000 (11:07 -0800)] 
log --decorate: do not leak "commit" color into the next item

In "git log --decorate", you would see the commit header like this:

    commit ... (HEAD, jc/decorate-leaky-separator-color)

where "commit ... (" is painted in color.diff.commit, "HEAD" in
color.decorate.head, ", " in color.diff.commit, the branch name in
color.decorate.branch and then closing ")" in color.diff.commit.

If you wanted to paint the HEAD and local branch name in the same
color as the body text (perhaps because cyan and green are too faint
on a black-on-white terminal to be readable), you would not want to
have to say

    [color "decorate"]
        head = black
        branch = black

because that you would not be able to reuse same configuration on a
white-on-black terminal.  You would naively expect

    [color "decorate"]
        head = normal
branch = normal

to work, but unfortunately it does not.  It paints the string "HEAD"
and the branch name in the same color as the opening parenthesis or
comma between the decoration elements.  This is because the code
forgets to reset the color after printing the "prefix" in its own
color.

It theoretically is possible that some people were expecting and
relying on that the attribute set as the "diff.commit" color, which
is used to draw these opening parenthesis and inter-item comma, is
inherited by the drawing of branch names, but it is not how the
coloring works everywhere else.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoDocumentation/config.txt: simplify boolean description in the syntax section
Junio C Hamano [Wed, 4 Mar 2015 19:08:34 +0000 (11:08 -0800)] 
Documentation/config.txt: simplify boolean description in the syntax section

The 'true' short-hand doesn't deserve a separate sentence; even our own

    git config --bool foo.bar yes

would not produce it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoDocumentation/config.txt: describe 'color' value type in the "Values" section
Junio C Hamano [Wed, 4 Mar 2015 07:07:13 +0000 (23:07 -0800)] 
Documentation/config.txt: describe 'color' value type in the "Values" section

Instead of describing it for color.branch.<slot> and have everybody
else refer to it, explain how colors are spelled in "Values" section
upfront.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoDocumentation/config.txt: have a separate "Values" section
Junio C Hamano [Wed, 4 Mar 2015 18:57:43 +0000 (10:57 -0800)] 
Documentation/config.txt: have a separate "Values" section

The various types of values set to the configuration variables
deserve more than a brief footnote mention in the syntax section,
and it will be more so after the later steps of this clean up
effort.

Move the mention of booleans from the syntax section to this new
section, and describe how human-readble integers can be spelled with
scaling there.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoDocumentation/config.txt: describe the structure first and then meaning
Junio C Hamano [Wed, 4 Mar 2015 18:33:38 +0000 (10:33 -0800)] 
Documentation/config.txt: describe the structure first and then meaning

A line can be continued via a backquote-LF and can be chomped at a
comment character.  But that is not specific to string-typed values.
It is common to all, just like unquoted leading and trailing
whitespaces are stripped and inter-word spacing are retained.

Move the description around and desribe these structural rules
first, then introduce the double-quote facility as a way to override
them, and finally mention various types of values.

Note that these structural rules only apply to the value part of the
configuration file.  E.g.

    [aSection] \
        name \
= value

does not work, because the rules kick in only after seeing "name =".
Both the original and the updated text are phrased in an awkward way
by singling out the "value" part of the line because of this.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoDocumentation/config.txt: explain multi-valued variables once
Junio C Hamano [Wed, 4 Mar 2015 18:26:17 +0000 (10:26 -0800)] 
Documentation/config.txt: explain multi-valued variables once

The syntax section repeats what the preamble explained already.
That a variable can have multiple values is more about what a
variable is than the syntax of the file.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoDocumentation/config.txt: avoid unnecessary negation
Junio C Hamano [Wed, 4 Mar 2015 04:03:50 +0000 (20:03 -0800)] 
Documentation/config.txt: avoid unnecessary negation

Section names and variable names are both case-insensitive, but one
is described as "not case sensitive".  Use "case-insensitive" for
both.

Instead of saying "... have to be escaped" without telling what that
escaping achieves, state it in a more positive way, i.e. "... can be
included by escaping".

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agot5516: correct misspelled pushInsteadOf
Anders Kaseorg [Sun, 1 Mar 2015 04:18:14 +0000 (23:18 -0500)] 
t5516: correct misspelled pushInsteadOf

A future breakage to "git push" to make it incorrectly pay attention
to pushInsteadOf when it should not will be left uncaught without
this change.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agosubmodule: improve documentation of update subcommand
Michal Sojka [Mon, 2 Mar 2015 22:57:58 +0000 (23:57 +0100)] 
submodule: improve documentation of update subcommand

The documentation of 'git submodule update' has several problems:

1) It mentions that value 'none' of submodule.$name.update can be
   overridden by --checkout, but other combinations of configuration
   values and command line options are not mentioned.

2) The documentation of submodule.$name.update is scattered across three
   places, which is confusing.

3) The documentation of submodule.$name.update in gitmodules.txt is
   incorrect, because the code always uses the value from .git/config
   and never from .gitmodules.

4) Documentation of --force was incomplete, because it is only effective
   in case of checkout method of update.

Fix all these problems by documenting submodule.*.update in
git-submodule.txt and make everybody else refer to it.

Helped-by: Junio C Hamano <gitster@pobox.com>
Helped-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agogit-remote.txt: describe behavior without --tags and --no-tags
Michael J Gruber [Mon, 2 Mar 2015 13:08:09 +0000 (14:08 +0100)] 
git-remote.txt: describe behavior without --tags and --no-tags

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agokwset: use unsigned char to store values with high-bit set
Ben Walton [Mon, 2 Mar 2015 19:22:31 +0000 (19:22 +0000)] 
kwset: use unsigned char to store values with high-bit set

Sun Studio on Solaris issues warnings about improper initialization
values being used when defining tolower_trans_tbl[] in ctype.c.  The
array wants to store values with high-bit set and treat them as
values between 128 to 255.  Unlike the rest of the Git codebase
where we explicitly specify 'unsigned char' for such variables and
arrays, however, kwset code we borrowed from elsewhere uses 'char'
for this and other variables.

Fix the declarations to explicitly use 'unsigned char' where
necessary to bring it in line with the rest of the Git.

Signed-off-by: Ben Walton <bdwalton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agodiff --shortstat --dirstat: remove duplicate output
Mårten Kongstad [Mon, 2 Mar 2015 15:05:39 +0000 (16:05 +0100)] 
diff --shortstat --dirstat: remove duplicate output

When --shortstat is used in conjunction with --dirstat=changes, git diff will
output the dirstat information twice: first as calculated by the 'lines'
algorithm, then as calculated by the 'changes' algorithm:

    $ git diff --dirstat=changes,10 --shortstat v2.2.0..v2.2.1
     23 files changed, 453 insertions(+), 54 deletions(-)
      33.5% Documentation/RelNotes/
      26.2% t/
      46.6% Documentation/RelNotes/
      16.6% t/

The same duplication happens for --shortstat together with --dirstat=files, but
not for --shortstat together with --dirstat=lines.

Limit output to only include one dirstat part, calculated as specified
by the --dirstat parameter. Also, add test for this.

Signed-off-by: Mårten Kongstad <marten.kongstad@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agodiffcore-rename: avoid processing duplicate destinations
Jeff King [Fri, 27 Feb 2015 01:42:27 +0000 (20:42 -0500)] 
diffcore-rename: avoid processing duplicate destinations

The rename code cannot handle an input where we have
duplicate destinations (i.e., more than one diff_filepair in
the queue with the same string in its pair->two->path). We
end up allocating only one slot in the rename_dst mapping.
If we fill in the diff_filepair for that slot, when we
re-queue the results, we may queue that filepair multiple
times. When the diff is finally flushed, the filepair is
processed and free()d multiple times, leading to heap
corruption.

This situation should only happen when a tree diff sees
duplicates in one of the trees (see the added test for a
detailed example). Rather than handle it, the sanest thing
is just to turn off rename detection altogether for the
diff.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agodiffcore-rename: split locate_rename_dst into two functions
Jeff King [Fri, 27 Feb 2015 01:39:48 +0000 (20:39 -0500)] 
diffcore-rename: split locate_rename_dst into two functions

This function manages the mapping of destination pathnames
to filepairs, and it handles both insertion and lookup. This
makes the return value a bit confusing, as we return a newly
created entry (even though no caller cares), and have no
room to indicate to the caller that an entry already
existed.

Instead, let's break this up into two distinct functions,
both backed by a common binary search. The binary search
will use our normal "return the index if we found something,
or negative index minus one to show where it would have
gone" semantics.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agogrep: correct help string for --exclude-standard
Nguyễn Thái Ngọc Duy [Fri, 27 Feb 2015 14:01:58 +0000 (21:01 +0700)] 
grep: correct help string for --exclude-standard

The current help string is about --no-exclude-standard. But "git grep -h"
would show --exclude-standard instead. Flip the string. See 0a93fb8
(grep: teach --untracked and --exclude-standard options - 2011-09-27)
for more info about these options.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoGit::SVN::*: avoid premature FileHandle closure
Kyle J. McKay [Thu, 26 Feb 2015 13:49:34 +0000 (05:49 -0800)] 
Git::SVN::*: avoid premature FileHandle closure

Since b19138b (git-svn: Make it incrementally faster by minimizing temp
files, v1.6.0), git-svn has been using the Git.pm temp_acquire and
temp_release mechanism to avoid unnecessary temp file churn and provide
a speed boost.

However, that change introduced a call to temp_acquire inside the
Git::SVN::Fetcher::close_file function for an 'svn_hash' temp file.
Because an SVN::Pool is active at the time this function is called, if
the Git::temp_acquire function ends up actually creating a new
FileHandle for the temp file (which it will the first time it's called
with the name 'svn_hash') that FileHandle will end up in the SVN::Pool
and should that pool have SVN::Pool::clear called on it that FileHandle
will be closed out from under Git::temp_acquire.

Since the only call site to Git::temp_acquire with the name 'svn_hash'
is inside the close_file function, if an 'svn_hash' temp file is ever
created its FileHandle is guaranteed to be created in the active
SVN::Pool.

This has not been a problem in the past because the SVN::Pool was not
being cleared.  However, since dfa72fdb (git-svn: reload RA every
log-window-size, v2.2.0) the pool has been getting cleared periodically
at which point the FileHandle for the 'svn_hash' temp file gets closed.
Any subsequent calls to Git::temp_acquire for 'svn_hash', however,
succeed without creating/opening a new temporary file since it still has
the now invalid FileHandle in its cache.  Callers that then attempt to
use that FileHandle fail with an error.

We avoid this problem by making sure the 'svn_hash' temp file is created
in the same place the 'svn_delta_...' and 'git_blob_...' temp files are
(and then temp_release'd) so that it can be safely used inside the
close_file function without having its FileHandle end up in an SVN::Pool
that gets cleared.

Additionally the Git.pm cat_blob function creates a bidirectional pipe
FileHandle using the IPC::Open2::open2 function.  If that handle is
created too late, it also gets caught up in the SVN::Pool and incorrectly
closed by the SVN::Pool::clear call.  But this only seems to happen with
more recent versions of Perl and svn.

To avoid this problem we add an explicit call to _open_cat_blob_if_needed
before the first call to SVN::Pool->new_default to make sure the open2
handle does not end up in the SVN::Pool.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agogit-svn: fix localtime=true on non-glibc environments
Ryuichi Kokubo [Wed, 25 Feb 2015 16:04:41 +0000 (01:04 +0900)] 
git-svn: fix localtime=true on non-glibc environments

git svn uses POSIX::strftime('%s', $sec, $min, ...) to make unix epoch time.
But lowercase %s formatting character is a GNU extention. This causes problem
in git svn fetch --localtime on non-glibc systems, such as msys or cygwin.
Using Time::Local::timelocal($sec, $min, ...) fixes it.

Signed-off-by: Ryuichi Kokubo <ryu1kkb@gmail.com>
Signed-off-by: Eric Wong <normalperson@yhbt.net>
Notes:
    lowercase %s format character in strftime is a GNU extension and not widely supported.
    POSIX::strftime affected by underlying crt's strftime because POSIX::strftime just calls crt's one.
    Time::Local is good function to replace POSIX::strftime because it's a perl core module function.

    Document about Time::Local.
     http://perldoc.perl.org/Time/Local.html

    These are specifications of strftime.

    The GNU C Library Reference Manual.
     http://www.gnu.org/software/libc/manual/html_node/Formatting-Calendar-Time.html

    perl POSIX module's strftime document. It does not have '%s'.
     http://perldoc.perl.org/POSIX.html

    strftime document of Microsort Windows C Run-Time library.
     https://msdn.microsoft.com/en-us/library/fe06s4ak.aspx

    The Open Group's old specification does not have '%s' too.
     http://pubs.opengroup.org/onlinepubs/007908799/xsh/strftime.html

    On my environment, following problems happened.
    - msys   : git svn fetch does not progress at all with perl.exe consuming CPU.
    - cygwin : git svn fetch progresses but time stamp information is dropped.
       Every commits have unix epoch timestamp.

    I would like to thank git developer and contibutors.
    git helps me so much everyday.
    Thank you.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoDocumentation/git-clean.txt: document that -f may need to be given twice
Mikko Rapeli [Thu, 26 Feb 2015 13:16:49 +0000 (15:16 +0200)] 
Documentation/git-clean.txt: document that -f may need to be given twice

This is needed in build automation where the tree really needs to
be reset to known state.

Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoGit 2.3.1 v2.3.1
Junio C Hamano [Wed, 25 Feb 2015 06:14:42 +0000 (22:14 -0800)] 
Git 2.3.1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoMerge branch 'ak/add-i-empty-candidates' into maint
Junio C Hamano [Wed, 25 Feb 2015 06:10:42 +0000 (22:10 -0800)] 
Merge branch 'ak/add-i-empty-candidates' into maint

The interactive "show a list and let the user choose from it"
interface "add -i" used showed and prompted to the user even when
the candidate list was empty, against which the only "choice" the
user could have made was to choose nothing.

* ak/add-i-empty-candidates:
  add -i: return from list_and_choose if there is no candidate

9 years agoMerge branch 'jc/apply-ws-fix-expands' into maint
Junio C Hamano [Wed, 25 Feb 2015 06:10:41 +0000 (22:10 -0800)] 
Merge branch 'jc/apply-ws-fix-expands' into maint

"git apply --whitespace=fix" used to under-allocate the memory
when the fix resulted in a longer text than the original patch.

* jc/apply-ws-fix-expands:
  apply: count the size of postimage correctly
  apply: make update_pre_post_images() sanity check the given postlen
  apply.c: typofix

9 years agoMerge branch 'jc/doc-log-rev-list-options' into maint
Junio C Hamano [Wed, 25 Feb 2015 06:10:39 +0000 (22:10 -0800)] 
Merge branch 'jc/doc-log-rev-list-options' into maint

"git log --help" used to show rev-list options that are irrelevant
to the "log" command.

* jc/doc-log-rev-list-options:
  Documentation: what does "git log --indexed-objects" even mean?

9 years agoMerge branch 'mg/commit-author-no-match-malformed-message' into maint
Junio C Hamano [Wed, 25 Feb 2015 06:10:38 +0000 (22:10 -0800)] 
Merge branch 'mg/commit-author-no-match-malformed-message' into maint

The error message from "git commit", when a non-existing author
name was given as value to the "--author=" parameter, has been
reworded to avoid misunderstanding.

* mg/commit-author-no-match-malformed-message:
  commit: reword --author error message

9 years agoMerge branch 'jk/dumb-http-idx-fetch-fix' into maint
Junio C Hamano [Wed, 25 Feb 2015 06:10:37 +0000 (22:10 -0800)] 
Merge branch 'jk/dumb-http-idx-fetch-fix' into maint

A broken pack .idx file in the receiving repository prevented the
dumb http transport from fetching a good copy of it from the other
side.

* jk/dumb-http-idx-fetch-fix:
  dumb-http: do not pass NULL path to parse_pack_index

9 years agoMerge branch 'jc/diff-format-doc' into maint
Junio C Hamano [Wed, 25 Feb 2015 06:10:36 +0000 (22:10 -0800)] 
Merge branch 'jc/diff-format-doc' into maint

The documentation incorrectly said that C(opy) and R(ename) are the
only ones that can be followed by the score number in the output in
the --raw format.

* jc/diff-format-doc:
  diff-format doc: a score can follow M for rewrite

9 years agoMerge branch 'jk/remote-curl-an-array-in-struct-cannot-be-null' into maint
Junio C Hamano [Wed, 25 Feb 2015 06:10:35 +0000 (22:10 -0800)] 
Merge branch 'jk/remote-curl-an-array-in-struct-cannot-be-null' into maint

Fix a misspelled conditional that is always true.

* jk/remote-curl-an-array-in-struct-cannot-be-null:
  do not check truth value of flex arrays

9 years agoMerge branch 'jk/status-read-branch-name-fix' into maint
Junio C Hamano [Wed, 25 Feb 2015 06:10:21 +0000 (22:10 -0800)] 
Merge branch 'jk/status-read-branch-name-fix' into maint

Code to read branch name from various files in .git/ directory
would have misbehaved if the code to write them left an empty file.

* jk/status-read-branch-name-fix:
  read_and_strip_branch: fix typo'd address-of operator

9 years agoMerge branch 'mg/push-repo-option-doc' into maint
Junio C Hamano [Wed, 25 Feb 2015 06:10:19 +0000 (22:10 -0800)] 
Merge branch 'mg/push-repo-option-doc' into maint

The "git push" documentation made the "--repo=<there>" option
easily misunderstood.

* mg/push-repo-option-doc:
  git-push.txt: document the behavior of --repo

9 years agoMerge branch 'bc/http-fallback-to-password-after-krb-fails' into maint
Junio C Hamano [Wed, 25 Feb 2015 06:10:17 +0000 (22:10 -0800)] 
Merge branch 'bc/http-fallback-to-password-after-krb-fails' into maint

After attempting and failing a password-less authentication
(e.g. kerberos), libcURL refuses to fall back to password based
Basic authentication without a bit of help/encouragement.

* bc/http-fallback-to-password-after-krb-fails:
  remote-curl: fall back to Basic auth if Negotiate fails

9 years agoMerge branch 'dk/format-patch-ignore-diff-submodule' into maint
Junio C Hamano [Wed, 25 Feb 2015 06:10:15 +0000 (22:10 -0800)] 
Merge branch 'dk/format-patch-ignore-diff-submodule' into maint

Setting diff.submodule to 'log' made "git format-patch" produce
broken patches.

* dk/format-patch-ignore-diff-submodule:
  format-patch: ignore diff.submodule setting
  t4255: test am submodule with diff.submodule

9 years agoMerge branch 'jn/rerere-fail-on-auto-update-failure' into maint
Junio C Hamano [Wed, 25 Feb 2015 06:10:13 +0000 (22:10 -0800)] 
Merge branch 'jn/rerere-fail-on-auto-update-failure' into maint

"git rerere" (invoked internally from many mergy operations) did
not correctly signal errors when told to update the working tree
files and failed to do so for whatever reason.

* jn/rerere-fail-on-auto-update-failure:
  rerere: error out on autoupdate failure

9 years agoMerge branch 'jk/blame-commit-label' into maint
Junio C Hamano [Wed, 25 Feb 2015 06:09:54 +0000 (22:09 -0800)] 
Merge branch 'jk/blame-commit-label' into maint

"git blame HEAD -- missing" failed to correctly say "HEAD" when it
tried to say "No such path 'missing' in HEAD".

* jk/blame-commit-label:
  blame.c: fix garbled error message
  use xstrdup_or_null to replace ternary conditionals
  builtin/commit.c: use xstrdup_or_null instead of envdup
  builtin/apply.c: use xstrdup_or_null instead of null_strdup
  git-compat-util: add xstrdup_or_null helper

9 years agotest_ln_s_add: refresh stat info of fake symbolic links
Johannes Sixt [Mon, 23 Feb 2015 18:14:47 +0000 (19:14 +0100)] 
test_ln_s_add: refresh stat info of fake symbolic links

We have a helper function test_ln_s_add that inserts a symbolic link
into the index even if the file system does not support symbolic links.
There is a small flaw in the emulation path: the added entry does not
pick up stat information of the fake symbolic link from the file system,
as a consequence, the index is not exactly the same as for the "regular"
path (where symbolic links are available). To fix this, just call
git update-index again.

This flaw was revealed by the earlier change that tightened
compare_diff_raw(), because a test case in t4008 depends on the
correctly updated index.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agogit-compat-util.h: remove redundant code
Ramsay Jones [Mon, 23 Feb 2015 00:07:14 +0000 (00:07 +0000)] 
git-compat-util.h: remove redundant code

Since commit 3a0a3a89 ("git-compat-util.h: don't define _XOPEN_SOURCE
on cygwin", 23-11-2014) removed the definition of _XOPEN_SOURCE on
cygwin, the code within a pre-processor conditional further down the
file became redundant. Remove the redundant code.

This effectively reverts commit 41b20017 ("Fix an "implicit function
definition" warning", 03-03-2007).

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agot5500: show user name and host in diag-url
Torsten Bögershausen [Sat, 21 Feb 2015 15:52:55 +0000 (16:52 +0100)] 
t5500: show user name and host in diag-url

The URL for ssh may have include a username before the hostname,
like ssh://user@host/repo.
When literal IPV6 addresses are used together with a username,
the substring "user@[::1]" must be converted into "user@::1".

Make that conversion visible for the user, and write userandhost
in the diagnostics

Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agot5601: add more test cases for IPV6
Torsten Bögershausen [Sat, 21 Feb 2015 15:53:01 +0000 (16:53 +0100)] 
t5601: add more test cases for IPV6

Test the parsing of literall IPV6 addresses more systematically:
- with and without brackets (e.g. ::1 [::1])
- with brackets and port number: (e.g. [::1]:22)
- with username (e.g. user@::1)
- with username and brackets:
  Because user@[::1] was not supported on older Git version,
  [user@::1] had to be used as a workaround.
  Test that user@::1 user@[::1] and [user@::1] all do the same.

Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoconnect.c: allow ssh://user@[2001:db8::1]/repo.git
Torsten Bögershausen [Sat, 21 Feb 2015 15:52:48 +0000 (16:52 +0100)] 
connect.c: allow ssh://user@[2001:db8::1]/repo.git

The ssh:// syntax was added in 2386d658 (Add first cut at "git
protocol" connect logic., 2005-07-13), it accepted
ssh://user@2001:db8::1/repo.git, which is now legacy.

Over the years the parser was improved to support [] and port numbers,
but the combination of ssh://user@[2001:db8::1]:222/repo.git did
never work.

The only only way to use a user name, a literall IPV6 address and a port
number was ssh://[user@2001:db8::1]:222/repo.git

(Thanks to Christian Taube <lists@hcf.yourweb.de> for reporting this long
standing issue)

New users would use ssh://user@[2001:db8::1]:222/repo.git,
so change the parser to handle it correctly.

Support the old legacy URLs as well, to be backwards compatible,
and avoid regressions for users which upgrade an existing installation
to a later Git version.

Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agosha1_name: use strlcpy() to copy strings
René Scharfe [Sat, 21 Feb 2015 19:55:22 +0000 (20:55 +0100)] 
sha1_name: use strlcpy() to copy strings

Use strlcpy() instead of calling strncpy() and then setting the last
byte of the target buffer to NUL explicitly.  This shortens and
simplifies the code a bit.

Signed-of-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agopretty: use starts_with() to check for a prefix
René Scharfe [Sat, 21 Feb 2015 19:53:09 +0000 (20:53 +0100)] 
pretty: use starts_with() to check for a prefix

Simplify the code and avoid duplication by using starts_with() instead
of strlen() and strncmp() to check if a line starts with "encoding ".

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agofor-each-ref: use skip_prefix() to avoid duplicate string comparison
René Scharfe [Sat, 21 Feb 2015 19:51:28 +0000 (20:51 +0100)] 
for-each-ref: use skip_prefix() to avoid duplicate string comparison

Use skip_prefix() to get the part after "color:" (if present) and only
compare it with "reset" instead of comparing the whole string again.
This gets rid of the duplicate "color:" part of the string constant.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoconnect: use strcmp() for string comparison
René Scharfe [Sat, 21 Feb 2015 19:49:58 +0000 (20:49 +0100)] 
connect: use strcmp() for string comparison

Get rid of magic string length constants and simply compare the strings
using strcmp().  This makes the intent of the code a bit clearer.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoDocumentation/git-am.txt: mention mailinfo.scissors config variable
Matthieu Moy [Fri, 20 Feb 2015 19:32:21 +0000 (20:32 +0100)] 
Documentation/git-am.txt: mention mailinfo.scissors config variable

It was already documented, but the user had to follow the link to
git-mailinfo.txt to find it.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoDocumentation/config.txt: document mailinfo.scissors
Matthieu Moy [Fri, 20 Feb 2015 19:32:20 +0000 (20:32 +0100)] 
Documentation/config.txt: document mailinfo.scissors

The variable was documented in git-mailinfo.txt, but not in config.txt.
The detailed documentation is still the one of --scissors in
git-mailinfo.txt, but we give enough information here to let the user
understand what it is about, and to make it easy to find it (e.g.
searching ">8" and "8<" finds it).

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoGit.pm: two minor typo fixes
Alexander Kuleshov [Wed, 18 Feb 2015 17:32:20 +0000 (23:32 +0600)] 
Git.pm: two minor typo fixes

Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agodaemon: use callback to build interpolated path
René Scharfe [Sun, 15 Feb 2015 18:33:52 +0000 (19:33 +0100)] 
daemon: use callback to build interpolated path

Provide a callback function for strbuf_expand() instead of using the
helper strbuf_expand_dict_cb().  While the resulting code is longer, it
only looks up the canonical hostname and IP address if at least one of
the placeholders %CH and %IP are used with --interpolated-path.

Use a struct for passing the directory to the callback function instead
of passing it directly to avoid having to cast away its const qualifier.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agodaemon: look up client-supplied hostname lazily
René Scharfe [Sun, 15 Feb 2015 18:31:41 +0000 (19:31 +0100)] 
daemon: look up client-supplied hostname lazily

Look up canonical hostname and IP address using getaddrinfo(3) or
gethostbyname(3) only if --interpolated-path or --access-hook were
specified.

Do that by introducing getter functions for canon_hostname and
ip_address and using them for all read accesses.  These wrappers call
the new helper lookup_hostname(), which sets the variables only at its
first call.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agodaemon: sanitize incoming virtual hostname
Jeff King [Tue, 17 Feb 2015 19:09:24 +0000 (14:09 -0500)] 
daemon: sanitize incoming virtual hostname

We use the daemon_avoid_alias function to make sure that the
pathname the user gives us is sane. However, after applying
that check, we might then interpolate the path using a
string given by the server admin, but which may contain more
untrusted data from the client. We should be sure to
sanitize this data, as well.

We cannot use daemon_avoid_alias here, as it is more strict
than we need in requiring a leading '/'. At the same time,
we can be much more strict here. We are interpreting a
hostname, which should not contain slashes or excessive runs
of dots, as those things are not allowed in DNS names.

Note that in addition to cleansing the hostname field, we
must check the "canonical hostname" (%CH) as well as the
port (%P), which we take as a raw string.  For the canonical
hostname, this comes from an actual DNS lookup on the
accessed IP, which makes it a much less likely vector for
problems. But it does not hurt to sanitize it in the same
way. Unfortunately we cannot test this case easily, as it
would involve a custom hostname lookup.

We do not need to check %IP, as it comes straight from
inet_ntop, so must have a sane form.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agot5570: test git-daemon's --interpolated-path option
Jeff King [Tue, 17 Feb 2015 08:40:57 +0000 (03:40 -0500)] 
t5570: test git-daemon's --interpolated-path option

We did not test this at all; let's just give a basic sanity
check that we can find a path based on virtual hosting, and
that the downcase canonicalization works.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agogit_connect: let user override virtual-host we send to daemon
Jeff King [Tue, 17 Feb 2015 08:37:35 +0000 (03:37 -0500)] 
git_connect: let user override virtual-host we send to daemon

When we connect to a git-daemon at a given host and port, we
actually send the string "localhost:9418" to the other side,
which allows it to do virtual-hosting lookups. For testing
and debugging, we'd like to be able to send arbitrary
strings, rather than the hostname we actually connected to.

Using "insteadOf" config does not work for this purpose, as
the hostname determination happens at a very low level,
right before we feed the hostname to our lookup routines.
You could use /etc/hosts or similar to get around this, but
we cannot do that portably from our test suite.

Instead, this patch provides an environment variable that
can be used to send an arbitrary string.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoread-cache.c: free cache entry when refreshing fails
Stefan Beller [Tue, 17 Feb 2015 18:06:14 +0000 (10:06 -0800)] 
read-cache.c: free cache entry when refreshing fails

This fixes a memory leak when building the cache entries as
refresh_cache_entry may decide to return NULL, but it does not
free the cache entry structure which was passed in as an argument.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agogit-send-email.perl: support no- prefix with older GetOptions
Kyle J. McKay [Sat, 31 Jan 2015 02:40:17 +0000 (18:40 -0800)] 
git-send-email.perl: support no- prefix with older GetOptions

Only Perl version 5.8.0 or later is required, but that comes with
an older Getopt::Long (2.32) that does not support the 'no-'
prefix.  Support for that was added in Getopt::Long version 2.33.

Since the help only mentions the 'no-' prefix and not the 'no'
prefix, add explicit support for the 'no-' prefix to support
older GetOptions versions.

Reported-by: Tom G. Christensen <tgc@statsbiblioteket.dk>
Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
Tested-by: Tom G. Christensen <tgc@statsbiblioteket.dk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agotest-lib.sh: set prerequisite SANITY by testing what we really need
Torsten Bögershausen [Tue, 27 Jan 2015 15:39:01 +0000 (16:39 +0100)] 
test-lib.sh: set prerequisite SANITY by testing what we really need

What we wanted out of the SANITY precondition is that the filesystem
behaves sensibly with permission bits settings.

 - You should not be able to remove a file in a read-only directory,

 - You should not be able to tell if a file in a directory exists if
   the directory lacks read or execute permission bits.

We used to cheat by approximating that condition with "is the /
writable?" test and/or "are we running as root?" test.  Neither test
is sufficient or appropriate in environments like Cygwin.

Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agot4008: modernise style
Junio C Hamano [Sun, 15 Feb 2015 22:21:04 +0000 (14:21 -0800)] 
t4008: modernise style

Update this ancient test script to a more modern style in which the
expected result is prepared inside the body of the test that uses
it.  Also, instead of using $tree, a shell variable, throughout the
test script, create a tag that points at it, to make it easier to
manually debug the test script in its trash directory.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agot/diff-lib: check exact object names in compare_diff_raw
Junio C Hamano [Sun, 15 Feb 2015 21:47:36 +0000 (13:47 -0800)] 
t/diff-lib: check exact object names in compare_diff_raw

The "sanitize" helper wanted to strip the similarity and
dissimilarity scores when making comparison, but it was
stripping away the object names as well.

While we do not want to require the exact object names the tests
expect to be maintained, as it would be seen as an extra burden,
this would have prevented us catching a silly bug such as showing
non 0{40} object name on the preimage side of an addition or on the
postimage side of a deletion, because all [0-9a-f]{40} strings were
considered equally OK.

In the longer term, when a test only wants to see the status of the
change without having to worry about object names, it should be
rewritten not to inspect the raw format.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agotests: do not borrow from COPYING and README from the real source
Junio C Hamano [Sun, 15 Feb 2015 21:44:24 +0000 (13:44 -0800)] 
tests: do not borrow from COPYING and README from the real source

These two files have been modified since the tests started using
as test input, making the exact object names they expect to be
different from what actually happens in the trash repository they
use to run tests.

Instead, take a snapshot of these two files and keep them in
t/diff-lib/ so that we can update the real ones without having to
worry about breaking tests.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agot4010: correct expected object names
Junio C Hamano [Sun, 15 Feb 2015 21:35:19 +0000 (13:35 -0800)] 
t4010: correct expected object names

The output the test expects is bogus.

It was left unnoticed only because compare_diff_raw, which only
cares about the add/delete/rename/copy was used to check the result.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agot9300: correct expected object names
Junio C Hamano [Sun, 15 Feb 2015 21:35:19 +0000 (13:35 -0800)] 
t9300: correct expected object names

The output the test #36 expects is bogus.  There are no blob objects
whose names are 36a590... or 046d037... when this test was run.

It was left unnoticed only because compare_diff_raw, which only
cares about the add/delete/rename/copy was used to check the result.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agot4008: correct stale comments
Junio C Hamano [Sun, 15 Feb 2015 20:42:59 +0000 (12:42 -0800)] 
t4008: correct stale comments

A complete rewrite of a single file was originally designed to be
expressed as a deletion immediately followed by a creation of the
same file, and the comments in the test updated here were written to
reflect that design decision made in f345b0a0 (Add -B flag to diff-*
brothers., 2005-05-30).  However, we later realized that a complete
rewrite is merely how a textual diff should be represented at
366175ef (Rework -B output., 2005-06-19), and updated the actual
tests.  But we forgot to update the introductory text while doing
so.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agohex.c: reduce memory footprint of sha1_to_hex static buffers
Stefan Beller [Fri, 13 Feb 2015 21:18:49 +0000 (13:18 -0800)] 
hex.c: reduce memory footprint of sha1_to_hex static buffers

41 bytes is the exact number of bytes needed for having the returned
hex string represented. 50 seems to be an arbitrary number, such
that there are no benefits from alignment to certain address boundaries.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agodo not include the same header twice
Дилян Палаузов [Fri, 13 Feb 2015 14:47:39 +0000 (14:47 +0000)] 
do not include the same header twice

A few files include the same header file directly more than once.

As all these headers protect themselves against repeated inclusion
by the "#ifndef FOO_H / #define FOO_H / ... / #endif" idiom, leave
only the first inclusion and remove the later inclusion as a no-op
clean-up.

Signed-off-by: Дилян Палаузов <git-dpa@aegee.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agotransport-helper: fix typo in error message when --signed is not supported
Mike Hommey [Thu, 12 Feb 2015 10:10:01 +0000 (19:10 +0900)] 
transport-helper: fix typo in error message when --signed is not supported

Signed-off-by: Mike Hommey <mh@glandium.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agomerge-file: correctly open files when in a subdir
Aleksander Boruch-Gruszecki [Sun, 8 Feb 2015 16:53:53 +0000 (17:53 +0100)] 
merge-file: correctly open files when in a subdir

run_setup_gently() is called before merge-file. This may result in changing
current working directory, which wasn't taken into account when opening a file
for writing.

Fix by prepending the passed prefix. Previous var is left so that error
messages keep referring to the file from the user's working directory
perspective.

Signed-off-by: Aleksander Boruch-Gruszecki <aleksander.boruchgruszecki@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoapply: do not touch a file beyond a symbolic link
Junio C Hamano [Thu, 29 Jan 2015 20:41:22 +0000 (12:41 -0800)] 
apply: do not touch a file beyond a symbolic link

Because Git tracks symbolic links as symbolic links, a path that
has a symbolic link in its leading part (e.g. path/to/dir/file,
where path/to/dir is a symbolic link to somewhere else, be it
inside or outside the working tree) can never appear in a patch
that validly applies, unless the same patch first removes the
symbolic link to allow a directory to be created there.

Detect and reject such a patch.

Things to note:

 - Unfortunately, we cannot reuse the has_symlink_leading_path()
   from dir.c, as that is only about the working tree, but "git
   apply" can be told to apply the patch only to the index or to
   both the index and to the working tree.

 - We cannot directly use has_symlink_leading_path() even when we
   are applying only to the working tree, as an early patch of a
   valid input may remove a symbolic link path/to/dir and then a
   later patch of the input may create a path path/to/dir/file, but
   "git apply" first checks the input without touching either the
   index or the working tree.  The leading symbolic link check must
   be done on the interim result we compute in-core (i.e. after the
   first patch, there is no path/to/dir symbolic link and it is
   perfectly valid to create path/to/dir/file).

   Similarly, when an input creates a symbolic link path/to/dir and
   then creates a file path/to/dir/file, we need to flag it as an
   error without actually creating path/to/dir symbolic link in the
   filesystem.

Instead, for any patch in the input that leaves a path (i.e. a non
deletion) in the result, we check all leading paths against the
resulting tree that the patch would create by inspecting all the
patches in the input and then the target of patch application
(either the index or the working tree).

This way, we catch a mischief or a mistake to add a symbolic link
path/to/dir and a file path/to/dir/file at the same time, while
allowing a valid patch that removes a symbolic link path/to/dir and
then adds a file path/to/dir/file.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoapply: do not read from beyond a symbolic link
Junio C Hamano [Fri, 30 Jan 2015 23:34:13 +0000 (15:34 -0800)] 
apply: do not read from beyond a symbolic link

We should reject a patch, whether it renames/copies dir/file to
elsewhere with or without modificiation, or updates dir/file in
place, if "dir/" part is actually a symbolic link to elsewhere,
by making sure that the code to read the preimage does not read
from a path that is beyond a symbolic link.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoapply: do not read from the filesystem under --index
Junio C Hamano [Fri, 30 Jan 2015 23:15:59 +0000 (15:15 -0800)] 
apply: do not read from the filesystem under --index

We currently read the preimage to apply a patch from the index only
when the --cached option is given.  Do so also when the command is
running under the --index option.  With --index, the index entry and
the working tree file for a path that is involved in a patch must be
identical, so this should not affect the result, but by reading from
the index, we will get the protection to avoid reading an unintended
path beyond a symbolic link automatically.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoapply: reject input that touches outside the working area
Junio C Hamano [Thu, 29 Jan 2015 23:35:24 +0000 (15:35 -0800)] 
apply: reject input that touches outside the working area

By default, a patch that affects outside the working area (either a
Git controlled working tree, or the current working directory when
"git apply" is used as a replacement of GNU patch) is rejected as a
mistake (or a mischief).  Git itself does not create such a patch,
unless the user bends over backwards and specifies a non-standard
prefix to "git diff" and friends.

When `git apply` is used as a "better GNU patch", the user can pass
the `--unsafe-paths` option to override this safety check. This
option has no effect when `--index` or `--cached` is in use.

The new test was stolen from Jeff King with slight enhancements.
Note that a few new tests for touching outside the working area by
following a symbolic link are still expected to fail at this step,
but will be fixed in later steps.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agofast-import: avoid running end_packfile recursively
Jeff King [Tue, 10 Feb 2015 01:07:19 +0000 (20:07 -0500)] 
fast-import: avoid running end_packfile recursively

When an import has finished, we run end_packfile() to
finalize the data and move the packfile into place. If this
process fails, we call die() and end up in our die_nicely()
handler.  Which unfortunately includes running end_packfile
to save any progress we made. We enter the function again,
and start operating on the pack_data struct while it is in
an inconsistent state, leading to a segfault.

One way to trigger this is to simply start two identical
fast-imports at the same time. They will both create the
same packfiles, which will then try to create identically
named ".keep" files. One will win the race, and the other
will die(), and end up with the segfault.

Since 3c078b9, we already reset the pack_data pointer to
NULL at the end of end_packfile. That covers the case of us
calling die() right after end_packfile, before we have
reinitialized the pack_data pointer. This new problem is
quite similar, except that we are worried about calling
die() _during_ end_packfile, not right after. Ideally we
would simply set pack_data to NULL as soon as we enter the
function, and operate on a copy of the pointer.

Unfortunately, it is not so easy. pack_data is a global, and
end_packfile calls into other functions which operate on the
global directly. We would have to teach each of these to
take an argument, and there is no guarantee that we would
catch all of the spots.

Instead, we can simply use a static flag to avoid
recursively entering the function. This is a little less
elegant, but it's short and fool-proof.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agobuiltin/blame: destroy initialized commit_info only
Eric Sunshine [Mon, 9 Feb 2015 21:28:07 +0000 (16:28 -0500)] 
builtin/blame: destroy initialized commit_info only

Since ea02ffa3 (mailmap: simplify map_user() interface, 2013-01-05),
find_alignment() has been invoking commit_info_destroy() on an
uninitialized auto 'struct commit_info' (when METAINFO_SHOWN is not
set). commit_info_destroy() calls strbuf_release() for each
'commit_info' strbuf member, which randomly invokes free() on
whatever random stack value happens to reside in strbuf.buf, thus
leading to periodic crashes.

Reported-by: Dilyan Palauzov <dilyan.palauzov@aegee.org>
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agosha1_file: fix iterating loose alternate objects
Jonathon Mah [Mon, 9 Feb 2015 01:15:39 +0000 (20:15 -0500)] 
sha1_file: fix iterating loose alternate objects

The string in 'base' contains a path suffix to a specific object;
when its value is used, the suffix must either be filled (as in
stat_sha1_file, open_sha1_file, check_and_freshen_nonlocal) or
cleared (as in prepare_packed_git) to avoid junk at the end.

660c889e (sha1_file: add for_each iterators for loose and packed
objects, 2014-10-15) introduced loose_from_alt_odb(), but this did
neither and treated 'base' as a complete path to the "base" object
directory, instead of a pointer to the "base" of the full path
string.

The trailing path after 'base' is still initialized to NUL, hiding
the bug in some common cases.  Additionally the descendent
for_each_file_in_obj_subdir() function swallows ENOENT, so an error
only shows if the alternate's path was last filled with a valid
object (where statting /path/to/existing/00/0bjectfile/00 fails).

Signed-off-by: Jonathon Mah <me@JonathonMah.com>
Helped-by: Kyle J. McKay <mackyle@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agofor_each_loose_file_in_objdir: take an optional strbuf path
Jeff King [Mon, 9 Feb 2015 01:13:22 +0000 (20:13 -0500)] 
for_each_loose_file_in_objdir: take an optional strbuf path

We feed a root "objdir" path to this iterator function,
which then copies the result into a strbuf, so that it can
repeatedly append the object sub-directories to it. Let's
make it easy for callers to just pass us a strbuf in the
first place.

We leave the original interface as a convenience for callers
who want to just pass a const string like the result of
get_object_directory().

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agogit-compat-util: do not step on MAC_OS_X_VERSION_MIN_REQUIRED
Kyle J. McKay [Fri, 6 Feb 2015 09:35:31 +0000 (01:35 -0800)] 
git-compat-util: do not step on MAC_OS_X_VERSION_MIN_REQUIRED

MAC_OS_X_VERSION_MIN_REQUIRED may be defined by the builder to a
specific version in order to produce compatible binaries for a
particular system.  Blindly defining it to MAC_OS_X_VERSION_10_6
is bad.

Additionally MAC_OS_X_VERSION_10_6 will not be defined on older
systems and should AvailabilityMacros.h be included on such as
system an error will result.  However, using the explicit value
of 1060 (which is what MAC_OS_X_VERSION_10_6 is defined to) does
not solve the problem.

The changes that introduced stepping on MAC_OS_X_VERSION_MIN were
made in b195aa00 (git-compat-util: suppress unavoidable
Apple-specific deprecation warnings) to avoid deprecation
warnings.

Instead of blindly setting MAC_OS_X_VERSION_MIN to 1060 change
the definition of DEPRECATED_ATTRIBUTE to empty to avoid the
warnings.  This preserves any MAC_OS_X_VERSION_MIN_REQUIRED
setting while avoiding the warnings as intended by b195aa00.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoGit 2.3 v2.3.0
Junio C Hamano [Thu, 5 Feb 2015 21:23:56 +0000 (13:23 -0800)] 
Git 2.3

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoconfig_buf_ungetc: warn when pushing back a random character
Jeff King [Thu, 5 Feb 2015 21:00:24 +0000 (16:00 -0500)] 
config_buf_ungetc: warn when pushing back a random character

Our config code simulates a stdio stream around a buffer,
but our fake ungetc() does not behave quite like the real
one. In particular, we only rewind the position by one
character, but do _not_ actually put the character from the
caller into position.

It turns out that this does not matter, because we only ever
push back the character we just read. In other words, such
an assignment would be a noop. But because the function is
called ungetc, and because it takes a character parameter,
it is a mistake waiting to happen.

Actually assigning the character into the buffer would be
ideal, but our pointer is actually a "const" copy of the
buffer. We do not know who the real owner of the buffer is
in this code, and would not want to munge their contents.

Instead, we can simply add an assertion that matches what
the current caller does, and will let us know if new callers
are added that violate the contract.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agodecimal_width: avoid integer overflow
Jeff King [Thu, 5 Feb 2015 08:14:19 +0000 (03:14 -0500)] 
decimal_width: avoid integer overflow

The decimal_width function originally appeared in blame.c as
"lineno_width", and was designed for calculating the
print-width of small-ish integer values (line numbers in
text files). In ec7ff5b, it was made into a reusable
function, and in dc801e7, we started using it to align
diffstats.

Binary files in a diffstat show byte counts rather than line
numbers, meaning they can be quite large (e.g., consider
adding or removing a 2GB file). decimal_width is not up to
the challenge for two reasons:

  1. It takes the value as an "int", whereas large files may
     easily surpass this. The value may be truncated, in
     which case we will produce an incorrect value.

  2. It counts "up" by repeatedly multiplying another
     integer by 10 until it surpasses the value.  This can
     cause an infinite loop when the value is close to the
     largest representable integer.

     For example, consider using a 32-bit signed integer,
     and a value of 2,140,000,000 (just shy of 2^31-1).
     We will count up and eventually see that 1,000,000,000
     is smaller than our value. The next step would be to
     multiply by 10 and see that 10,000,000,000 is too
     large, ending the loop. But we can't represent that
     value, and we have signed overflow.

     This is technically undefined behavior, but a common
     behavior is to lose the high bits, in which case our
     iterator will certainly be less than the number. So
     we'll keep multiplying, overflow again, and so on.

This patch changes the argument to a uintmax_t (the same
type we use to store the diffstat information for binary
filese), and counts "down" by repeatedly dividing our value
by 10.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoconfig: do not ungetc EOF
Jeff King [Thu, 5 Feb 2015 06:53:28 +0000 (01:53 -0500)] 
config: do not ungetc EOF

When we are parsing a config value, if we see a carriage
return, we fgetc the next character to see if it is a
line feed (in which case we silently drop the CR). If it
isn't, we then ungetc the character, and take the literal
CR.

But we never check whether we in fact got a character at
all. If the config file ends in CR, we will get EOF here,
and try to ungetc EOF. This works OK for a real stdio
stream. The ungetc returns an error, and the next fgetc will
then return EOF again.

However, our custom buffer-based stream is not so fortunate.
It happily rewinds the position of the stream by one
character, ignoring the fact that we fed it EOF. The next
fgetc call returns the final CR again, over and over, and we
end up in an infinite loop.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoewah: fix building with gcc < 3.4.0
Tom G. Christensen [Wed, 4 Feb 2015 08:23:16 +0000 (09:23 +0100)] 
ewah: fix building with gcc < 3.4.0

The __builtin_ctzll function was added in gcc 3.4.0.
This extends the check for gcc so that use of __builtin_ctzll is only
enabled if gcc >= 3.4.0.

Signed-off-by: Tom G. Christensen <tgc@statsbiblioteket.dk>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoMakefile: handle broken curl version number in version check
Tom G. Christensen [Fri, 30 Jan 2015 09:52:34 +0000 (10:52 +0100)] 
Makefile: handle broken curl version number in version check

curl 7.11.0 through 7.12.2 when built from their official release
archives will present a 5 digit version number instead of the documented
6 digits which breaks the version check in the Makefile.
Correct these broken version numbers on the fly when extracting them to
ensure the comparison works correctly.

[jc: shortened the new sed scripts a bit]

Signed-off-by: Tom G. Christensen <tgc@statsbiblioteket.dk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agogit-submodule.sh: fix '/././' path normalization
Patrick Steinhardt [Fri, 30 Jan 2015 15:14:03 +0000 (16:14 +0100)] 
git-submodule.sh: fix '/././' path normalization

When we add a new submodule the path of the submodule is being
normalized. We fail to normalize multiple adjacent '/./', though.
Thus 'path/to/././submodule' will become 'path/to/./submodule' where
it should be 'path/to/submodule' instead.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Acked-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agoMerge git://github.com/git-l10n/git-po
Junio C Hamano [Mon, 2 Feb 2015 20:05:56 +0000 (12:05 -0800)] 
Merge git://github.com/git-l10n/git-po

* git://github.com/git-l10n/git-po:
  l10n: ca.po: Fix trailing whitespace

9 years agoCodingGuidelines: describe naming rules for configuration variables
Junio C Hamano [Tue, 27 Jan 2015 20:26:03 +0000 (12:26 -0800)] 
CodingGuidelines: describe naming rules for configuration variables

We may want to say something about command line option names in the
new section as well, but for now, let's make sure everybody is clear
on how to structure and name their configuration variables.

The text for the rules are partly taken from the log message of
Jonathan's 6b3020a2 (add: introduce add.ignoreerrors synonym for
add.ignore-errors, 2010-12-01).

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 years agol10n: ca.po: Fix trailing whitespace
Alex Henrie [Fri, 30 Jan 2015 22:02:34 +0000 (15:02 -0700)] 
l10n: ca.po: Fix trailing whitespace

Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>