git
7 years agocombine-diff: replace malloc/snprintf with xstrfmt
Jeff King [Tue, 28 Mar 2017 19:46:53 +0000 (15:46 -0400)] 
combine-diff: replace malloc/snprintf with xstrfmt

There's no need to use the magic "100" when a strbuf can do
it for us.

Signed-off-by: Jeff King <peff@peff.net>
7 years agoreplace unchecked snprintf calls with heap buffers
Jeff King [Tue, 28 Mar 2017 19:46:50 +0000 (15:46 -0400)] 
replace unchecked snprintf calls with heap buffers

We'd prefer to avoid unchecked snprintf calls because
truncation can lead to unexpected results.

These are all cases where truncation shouldn't ever happen,
because the input to snprintf is fixed in size. That makes
them candidates for xsnprintf(), but it's simpler still to
just use the heap, and then nobody has to wonder if "100" is
big enough.

We'll use xstrfmt() where possible, and a strbuf when we need
the resulting size or to reuse the same buffer in a loop.

Signed-off-by: Jeff King <peff@peff.net>
7 years agoreceive-pack: print --pack-header directly into argv array
Jeff King [Tue, 28 Mar 2017 19:46:47 +0000 (15:46 -0400)] 
receive-pack: print --pack-header directly into argv array

After receive-pack reads the pack header from the client, it
feeds the already-read part to index-pack and unpack-objects
via their --pack-header command-line options.  To do so, we
format it into a fixed buffer, then duplicate it into the
child's argv_array.

Our buffer is long enough to handle any possible input, so
this isn't wrong. But it's more complicated than it needs to
be; we can just argv_array_pushf() the final value and avoid
the intermediate copy. This drops the magic number and is
more efficient, too.

Note that we need to push to the argv_array in order, which
means we can't do the push until we are in the "unpack-objects
versus index-pack" conditional.  Rather than duplicate the
slightly complicated format specifier, I pushed it into a
helper function.

Signed-off-by: Jeff King <peff@peff.net>
7 years agoname-rev: replace static buffer with strbuf
Jeff King [Tue, 28 Mar 2017 19:46:44 +0000 (15:46 -0400)] 
name-rev: replace static buffer with strbuf

When name-rev needs to format an actual name, we do so into
a fixed-size buffer. That includes the actual ref tip, as
well as any traversal information. Since refs can exceed
1024 bytes, this means you can get a bogus result. E.g.,
doing:

   git tag $(perl -e 'print join("/", 1..1024)')
   git describe --contains HEAD^

results in ".../282/283", when it should be
".../1023/1024~1".

We can solve this by using a heap buffer. We'll use a
strbuf, which lets us write into the same buffer from our
loop without having to reallocate.

Signed-off-by: Jeff King <peff@peff.net>
7 years agocreate_branch: use xstrfmt for reflog message
Jeff King [Tue, 28 Mar 2017 19:46:40 +0000 (15:46 -0400)] 
create_branch: use xstrfmt for reflog message

We generate a reflog message that contains some fixed text
plus a branch name, and use a buffer of size PATH_MAX + 20.
This mostly works if you assume that refnames are shorter
than PATH_MAX, but:

  1. That's not necessarily true. PATH_MAX is not always the
     filesystem's limit.

  2. The "20" is not sufficiently large for the fixed text
     anyway.

Let's just switch to a heap buffer so we don't have to even
care.

Signed-off-by: Jeff King <peff@peff.net>
7 years agocreate_branch: move msg setup closer to point of use
Jeff King [Tue, 28 Mar 2017 19:46:36 +0000 (15:46 -0400)] 
create_branch: move msg setup closer to point of use

In create_branch() we write the reflog msg into a buffer in
the main function, but then use it only inside a
conditional. If you carefully follow the logic, you can
confirm that we never use the buffer uninitialized nor write
when it would not be used. But we can make this a lot more
obvious by simply moving the write step inside the
conditional.

Signed-off-by: Jeff King <peff@peff.net>
7 years agoavoid using mksnpath for refs
Jeff King [Tue, 28 Mar 2017 19:46:33 +0000 (15:46 -0400)] 
avoid using mksnpath for refs

Like the previous commit, we'd like to avoid the assumption
that refs fit into PATH_MAX-sized buffers. These callsites
have an extra twist, though: they write the refnames using
mksnpath. This does two things beyond a regular snprintf:

  1. It quietly writes "/bad-path/" when truncation occurs.
     This saves the caller having to check the error code,
     but if you aren't actually feeding the result to a
     system call (and we aren't here), it's questionable.

  2. It calls cleanup_path(), which removes leading
     instances of "./".  That's questionable when dealing
     with refnames, as we could silently canonicalize a
     syntactically bogus refname into a valid one.

Let's convert each case to use a strbuf. This is preferable
to xstrfmt() because we can reuse the same buffer as we
loop.

Signed-off-by: Jeff King <peff@peff.net>
7 years agoavoid using fixed PATH_MAX buffers for refs
Jeff King [Tue, 28 Mar 2017 19:46:30 +0000 (15:46 -0400)] 
avoid using fixed PATH_MAX buffers for refs

Many functions which handle refs use a PATH_MAX-sized buffer
to do so. This is mostly reasonable as we have to write
loose refs into the filesystem, and at least on Linux the 4K
PATH_MAX is big enough that nobody would care. But:

  1. The static PATH_MAX is not always the filesystem limit.

  2. On other platforms, PATH_MAX may be much smaller.

  3. As we move to alternate ref storage, we won't be bound
     by filesystem limits.

Let's convert these to heap buffers so we don't have to
worry about truncation or size limits.

We may want to eventually constrain ref lengths for sanity
and to prevent malicious names, but we should do so
consistently across all platforms, and in a central place
(like the ref code).

Signed-off-by: Jeff King <peff@peff.net>
7 years agofetch: use heap buffer to format reflog
Jeff King [Tue, 28 Mar 2017 19:46:26 +0000 (15:46 -0400)] 
fetch: use heap buffer to format reflog

Part of the reflog content comes from the environment, which
can be much larger than our fixed buffer. Let's use a heap
buffer so we avoid truncating it.

Signed-off-by: Jeff King <peff@peff.net>
7 years agotag: use strbuf to format tag header
Jeff King [Tue, 28 Mar 2017 19:46:23 +0000 (15:46 -0400)] 
tag: use strbuf to format tag header

We format the tag header into a fixed 1024-byte buffer. But
since the tag-name and tagger ident can be arbitrarily
large, we may unceremoniously die with "tag header too big".
Let's just use a strbuf instead.

Note that it looks at first glance like we can just format
this directly into the "buf" strbuf where it will ultimately
go. But that buffer may already contain the tag message, and
we have no easy way to prepend formatted data to a strbuf
(we can only splice in an already-generated buffer). This
isn't a performance-critical path, so going through an extra
buffer isn't a big deal.

Signed-off-by: Jeff King <peff@peff.net>
7 years agodiff: avoid fixed-size buffer for patch-ids
Jeff King [Thu, 30 Mar 2017 18:26:05 +0000 (14:26 -0400)] 
diff: avoid fixed-size buffer for patch-ids

To generate a patch id, we format the diff header into a
fixed-size buffer, and then feed the result to our sha1
computation. The fixed buffer has size '4*PATH_MAX + 20',
which in theory accommodates the four filenames plus some
extra data. Except:

  1. The filenames may not be constrained to PATH_MAX. The
     static value may not be a real limit on the current
     filesystem. Moreover, we may compute patch-ids for
     names stored only in git, without touching the current
     filesystem at all.

  2. The 20 bytes is not nearly enough to cover the
     extra content we put in the buffer.

As a result, the data we feed to the sha1 computation may be
truncated, and it's possible that a commit with a very long
filename could erroneously collide in the patch-id space
with another commit. For instance, if one commit modified
"really-long-filename/foo" and another modified "bar" in the
same directory.

In practice this is unlikely. Because the filenames are
repeated, and because there's a single cutoff at the end of
the buffer, the offending filename would have to be on the
order of four times larger than PATH_MAX.

We could fix this by moving to a strbuf. However, we can
observe that the purpose of formatting this in the first
place is to feed it to git_SHA1_Update(). So instead, let's
just feed each part of the formatted string directly. This
actually ends up more readable, and we can even factor out
some duplicated bits from the various conditional branches.

Technically this may change the output of patch-id for very
long filenames, but it's not worth making an exception for
this in the --stable output. It was a bug, and one that only
affected an unlikely set of paths.  And anyway, the exact
value would have varied from platform to platform depending
on the value of PATH_MAX, so there is no "stable" value.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoSync with master
Junio C Hamano [Thu, 30 Mar 2017 21:26:03 +0000 (14:26 -0700)] 
Sync with master

* master:
  Tenth batch for 2.13

7 years agoMerge branch 'cc/untracked' into next
Junio C Hamano [Thu, 30 Mar 2017 21:25:56 +0000 (14:25 -0700)] 
Merge branch 'cc/untracked' into next

* cc/untracked:
  update-index: fix xgetcwd() related memory leak

7 years agoMerge branch 'jk/make-coccicheck-detect-errors' into next
Junio C Hamano [Thu, 30 Mar 2017 21:25:55 +0000 (14:25 -0700)] 
Merge branch 'jk/make-coccicheck-detect-errors' into next

Build fix.

* jk/make-coccicheck-detect-errors:
  Makefile: detect errors in running spatch

7 years agoMerge branch 'bc/push-cert-receive-fix' into next
Junio C Hamano [Thu, 30 Mar 2017 21:25:55 +0000 (14:25 -0700)] 
Merge branch 'bc/push-cert-receive-fix' into next

"git receive-pack" could have been forced to die by attempting
allocate an unreasonably large amount of memory with a crafted push
certificate; this has been fixed.

* bc/push-cert-receive-fix:
  builtin/receive-pack: fix incorrect pointer arithmetic

7 years agoMerge branch 'mh/notes-tree-consolidate-fix' into next
Junio C Hamano [Thu, 30 Mar 2017 21:25:54 +0000 (14:25 -0700)] 
Merge branch 'mh/notes-tree-consolidate-fix' into next

Removing an entry from a notes tree and then looking another note
entry from the resulting tree using the internal notes API
functions did not work as expected.  No in-tree users of the API
has such access pattern, but it still is worth fixing.

* mh/notes-tree-consolidate-fix:
  notes: do not break note_tree structure in note_tree_consolidate()

7 years agoTenth batch for 2.13
Junio C Hamano [Thu, 30 Mar 2017 21:14:32 +0000 (14:14 -0700)] 
Tenth batch for 2.13

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'jk/make-coccicheck-detect-errors'
Junio C Hamano [Thu, 30 Mar 2017 21:07:19 +0000 (14:07 -0700)] 
Merge branch 'jk/make-coccicheck-detect-errors'

Build fix.

* jk/make-coccicheck-detect-errors:
  Makefile: detect errors in running spatch

7 years agoMerge branch 'bc/push-cert-receive-fix'
Junio C Hamano [Thu, 30 Mar 2017 21:07:18 +0000 (14:07 -0700)] 
Merge branch 'bc/push-cert-receive-fix'

"git receive-pack" could have been forced to die by attempting
allocate an unreasonably large amount of memory with a crafted push
certificate; this has been fixed.

* bc/push-cert-receive-fix:
  builtin/receive-pack: fix incorrect pointer arithmetic

7 years agoMerge branch 'mh/notes-tree-consolidate-fix'
Junio C Hamano [Thu, 30 Mar 2017 21:07:17 +0000 (14:07 -0700)] 
Merge branch 'mh/notes-tree-consolidate-fix'

Removing an entry from a notes tree and then looking another note
entry from the resulting tree using the internal notes API
functions did not work as expected.  No in-tree users of the API
has such access pattern, but it still is worth fixing.

* mh/notes-tree-consolidate-fix:
  notes: do not break note_tree structure in note_tree_consolidate()

7 years agoMerge branch 'js/rebase-i-reword-to-run-hooks'
Junio C Hamano [Thu, 30 Mar 2017 21:07:17 +0000 (14:07 -0700)] 
Merge branch 'js/rebase-i-reword-to-run-hooks'

A recent update to "rebase -i" stopped running hooks for the "git
commit" command during "reword" action, which has been fixed.

* js/rebase-i-reword-to-run-hooks:
  sequencer: allow the commit-msg hooks to run during a `reword`
  sequencer: make commit options more extensible
  t7504: document regression: reword no longer calls commit-msg

7 years agoMerge branch 'mg/describe-debug-l10n'
Junio C Hamano [Thu, 30 Mar 2017 21:07:17 +0000 (14:07 -0700)] 
Merge branch 'mg/describe-debug-l10n'

Some debugging output from "git describe" were marked for l10n,
but some weren't.  Mark missing ones for l10n.

* mg/describe-debug-l10n:
  l10n: de: translate describe debug terms
  describe: localize debug output fully

7 years agoMerge branch 'ab/case-insensitive-upstream-and-push-marker'
Junio C Hamano [Thu, 30 Mar 2017 21:07:16 +0000 (14:07 -0700)] 
Merge branch 'ab/case-insensitive-upstream-and-push-marker'

On many keyboards, typing "@{" involves holding down SHIFT key and
one can easily end up with "@{Up..." when typing "@{upstream}".  As
the upstream/push keywords do not appear anywhere else in the syntax,
we can safely accept them case insensitively without introducing
ambiguity or confusion  to solve this.

* ab/case-insensitive-upstream-and-push-marker:
  rev-parse: match @{upstream}, @{u} and @{push} case-insensitively

7 years agoMerge branch 'ab/doc-submitting'
Junio C Hamano [Thu, 30 Mar 2017 21:07:16 +0000 (14:07 -0700)] 
Merge branch 'ab/doc-submitting'

Doc update.

* ab/doc-submitting:
  doc/SubmittingPatches: show how to get a CLI commit summary
  doc/SubmittingPatches: clarify the casing convention for "area: change..."

7 years agoMerge branch 'ab/test-readme-updates'
Junio C Hamano [Thu, 30 Mar 2017 21:07:16 +0000 (14:07 -0700)] 
Merge branch 'ab/test-readme-updates'

Doc updates.

* ab/test-readme-updates:
  t/README: clarify the test_have_prereq documentation
  t/README: change "Inside <X> part" to "Inside the <X> part"
  t/README: link to metacpan.org, not search.cpan.org

7 years agoMerge branch 'rs/freebsd-getcwd-workaround'
Junio C Hamano [Thu, 30 Mar 2017 21:07:15 +0000 (14:07 -0700)] 
Merge branch 'rs/freebsd-getcwd-workaround'

FreeBSD implementation of getcwd(3) behaved differently when an
intermediate directory is unreadable/unsearchable depending on the
length of the buffer provided, which our strbuf_getcwd() was not
aware of.  strbuf_getcwd() has been taught to cope with it better.

* rs/freebsd-getcwd-workaround:
  strbuf: support long paths w/o read rights in strbuf_getcwd() on FreeBSD

7 years agoMerge branch 'bw/recurse-submodules-relative-fix'
Junio C Hamano [Thu, 30 Mar 2017 21:07:15 +0000 (14:07 -0700)] 
Merge branch 'bw/recurse-submodules-relative-fix'

A few commands that recently learned the "--recurse-submodule"
option misbehaved when started from a subdirectory of the
superproject.

* bw/recurse-submodules-relative-fix:
  ls-files: fix bug when recursing with relative pathspec
  ls-files: fix typo in variable name
  grep: fix bug when recursing with relative pathspec
  setup: allow for prefix to be passed to git commands
  grep: fix help text typo

7 years agoMerge branch 'sg/completion-ctags'
Junio C Hamano [Thu, 30 Mar 2017 21:07:15 +0000 (14:07 -0700)] 
Merge branch 'sg/completion-ctags'

Command line completion updates.

* sg/completion-ctags:
  completion: offer ctags symbol names for 'git log -S', '-G' and '-L:'
  completion: extract completing ctags symbol names into helper function
  completion: put matching ctags symbol names directly into COMPREPLY

7 years agoMerge branch 'sg/completion-refs-speedup'
Junio C Hamano [Thu, 30 Mar 2017 21:07:14 +0000 (14:07 -0700)] 
Merge branch 'sg/completion-refs-speedup'

The refs completion for large number of refs has been sped up,
partly by giving up disambiguating ambiguous refs and partly by
eliminating most of the shell processing between 'git for-each-ref'
and 'ls-remote' and Bash's completion facility.

* sg/completion-refs-speedup:
  completion: speed up branch and tag completion
  completion: fill COMPREPLY directly when completing fetch refspecs
  completion: fill COMPREPLY directly when completing refs
  completion: let 'for-each-ref' sort remote branches for 'checkout' DWIMery
  completion: let 'for-each-ref' filter remote branches for 'checkout' DWIMery
  completion: let 'for-each-ref' strip the remote name from remote branches
  completion: let 'for-each-ref' and 'ls-remote' filter matching refs
  completion: don't disambiguate short refs
  completion: don't disambiguate tags and branches
  completion: support excluding full refs
  completion: support completing fully qualified non-fast-forward refspecs
  completion: support completing full refs after '--option=refs/<TAB>'
  completion: wrap __git_refs() for better option parsing
  completion: remove redundant __gitcomp_nl() options from _git_commit()

7 years agoMerge branch 'bw/submodule-is-active'
Junio C Hamano [Thu, 30 Mar 2017 21:07:14 +0000 (14:07 -0700)] 
Merge branch 'bw/submodule-is-active'

"what URL do we want to update this submodule?" and "are we
interested in this submodule?" are split into two distinct
concepts, and then the way used to express the latter got extended,
paving a way to make it easier to manage a project with many
submodules and make it possible to later extend use of multiple
worktrees for a project with submodules.

* bw/submodule-is-active:
  submodule add: respect submodule.active and submodule.<name>.active
  submodule--helper init: set submodule.<name>.active
  clone: teach --recurse-submodules to optionally take a pathspec
  submodule init: initialize active submodules
  submodule: decouple url and submodule interest
  submodule--helper clone: check for configured submodules using helper
  submodule sync: use submodule--helper is-active
  submodule sync: skip work for inactive submodules
  submodule status: use submodule--helper is-active
  submodule--helper: add is-active subcommand

7 years agoMerge branch 'jk/no-looking-at-dotgit-outside-repo-final'
Junio C Hamano [Thu, 30 Mar 2017 21:07:13 +0000 (14:07 -0700)] 
Merge branch 'jk/no-looking-at-dotgit-outside-repo-final'

This is the endgame of the topic to avoid blindly falling back to
".git" when the setup sequence said we are _not_ in Git repository.
A corner case that happens to work right now may be broken by a
call to die("BUG").

* jk/no-looking-at-dotgit-outside-repo-final:
  setup_git_env: avoid blind fall-back to ".git"

7 years agoMerge branch 'jc/merge-drop-old-syntax'
Junio C Hamano [Thu, 30 Mar 2017 21:07:13 +0000 (14:07 -0700)] 
Merge branch 'jc/merge-drop-old-syntax'

Stop supporting "git merge <message> HEAD <commit>" syntax that has
been deprecated since October 2007, and issues a deprecation
warning message since v2.5.0.

* jc/merge-drop-old-syntax:
  merge: drop 'git merge <message> HEAD <commit>' syntax

7 years agodifftool: avoid strcpy
Jeff King [Thu, 30 Mar 2017 10:35:50 +0000 (06:35 -0400)] 
difftool: avoid strcpy

In order to checkout files, difftool reads "diff --raw"
output and feeds the names to checkout_entry(). That
function requires us to have a "struct cache_entry". And
because that struct uses a FLEX_ARRAY for the name field, we
have to actually copy in our new name.

The current code allocates a single re-usable cache_entry
that can hold a name up to PATH_MAX, and then copies
filenames into it using strcpy(). But there's no guarantee
that incoming names are smaller than PATH_MAX. They've come
from "diff --raw" output which might be diffing between two
trees (and hence we'd be subject to the PATH_MAX of some
other system, or even none at all if they were created
directly via "update-index").

We can fix this by using make_cache_entry() to create a
correctly-sized cache_entry for each name. This incurs an
extra allocation per file, but this is negligible compared
to actually writing out the file contents.

To make this simpler, we can push this procedure into a new
helper function. Note that we can also get rid of the "len"
variables for src_path and dst_path (and in fact we must, as
the compiler complains that they are unused).

Signed-off-by: Jeff King <peff@peff.net>
Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoupdate-index: fix xgetcwd() related memory leak
Christian Couder [Thu, 30 Mar 2017 06:22:08 +0000 (08:22 +0200)] 
update-index: fix xgetcwd() related memory leak

As xgetcwd() returns an allocated buffer, we should free this
buffer when we don't need it any more.

This was found by Coverity.

Reported-by: Jeff King <peff@peff.net>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosubmodule.c: correctly handle nested submodules in is_submodule_modified
Stefan Beller [Wed, 29 Mar 2017 22:26:16 +0000 (15:26 -0700)] 
submodule.c: correctly handle nested submodules in is_submodule_modified

Suppose I have a superproject 'super', with two submodules 'super/sub'
and 'super/sub1'. 'super/sub' itself contains a submodule
'super/sub/subsub'. Now suppose I run, from within 'super':

    echo hi >sub/subsub/stray-file
    echo hi >sub1/stray-file

Currently we get would see the following output in git-status:

    git status --short
     m sub
     ? sub1

With this patch applied, the untracked file in the nested submodule is
displayed as an untracked file on the 'super' level as well.

    git status --short
     ? sub
     ? sub1

This doesn't change the output of 'git status --porcelain=1' for nested
submodules, because its output is always ' M' for either untracked files
or local modifications no matter the nesting level of the submodule.

'git status --porcelain=2' is affected by this change in a nested
submodule, though. Without this patch it would report the direct submodule
as modified and having no untracked files. With this patch it would report
untracked files. Chalk this up as a bug fix.

This bug fix also affects the default output (non-short, non-porcelain)
of git-status, which is not tested here.

Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agounpack-trees.c: align submodule error message to the other error messages
Stefan Beller [Wed, 29 Mar 2017 22:34:24 +0000 (15:34 -0700)] 
unpack-trees.c: align submodule error message to the other error messages

As the place holder in the error message is for multiple submodules,
we don't want to encapsulate the string place holder in single quotes.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoshort status: improve reporting for submodule changes
Stefan Beller [Wed, 29 Mar 2017 22:26:15 +0000 (15:26 -0700)] 
short status: improve reporting for submodule changes

If I add an untracked file to a submodule or modify a tracked file,
currently "git status --short" treats the change in the same way as
changes to the current HEAD of the submodule:

        $ git clone --quiet --recurse-submodules https://gerrit.googlesource.com/gerrit
        $ echo hello >gerrit/plugins/replication/stray-file
        $ sed -i -e 's/.*//' gerrit/plugins/replication/.mailmap
        $ git -C gerrit status --short
         M plugins/replication

This is by analogy with ordinary files, where "M" represents a change
that has not been added yet to the index.  But this change cannot be
added to the index without entering the submodule, "git add"-ing it,
and running "git commit", so the analogy is counterproductive.

Introduce new status letters " ?" and " m" for this.  These are similar
to the existing "??" and " M" but mean that the submodule (not the
parent project) has new untracked files and modified files, respectively.
The user can use "git add" and "git commit" from within the submodule to
add them.

Changes to the submodule's HEAD commit can be recorded in the index with
a plain "git add -u" and are shown with " M", like today.

To avoid excessive clutter, show at most one of " ?", " m", and " M" for
the submodule.  They represent increasing levels of change --- the last
one that applies is shown (e.g., " m" if there are both modified files
and untracked files in the submodule, or " M" if the submodule's HEAD
has been modified and it has untracked files).

While making these changes, we need to make sure to not break porcelain
level 1, which shares code with "status --short".  We only change
"git status --short".

Non-short "git status" and "git status --porcelain=2" already handle
these cases by showing more detail:

        $ git -C gerrit status --porcelain=2
        1 .M S.MU 160000 160000 160000 305c864db28eb0c77c8499bc04c87de3f849cf3c 305c864db28eb0c77c8499bc04c87de3f849cf3c plugins/replication
        $ git -C gerrit status
[...]
        modified:   plugins/replication (modified content, untracked content)

Scripts caring about these distinctions should use --porcelain=2.

Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoperl: regenerate perl.mak if perl -V changes
Ævar Arnfjörð Bjarmason [Wed, 29 Mar 2017 13:57:03 +0000 (13:57 +0000)] 
perl: regenerate perl.mak if perl -V changes

Change the perl/perl.mak build process so that the file is regenerated
if the output of "perl -V" changes.

Before this change updating e.g. /usr/bin/perl to a new major version
would cause the next "make" command to fail, since perl.mak has
hardcoded paths to perl library paths retrieved from its first run.

Now the logic added in commit ee9be06770 ("perl: detect new files in
MakeMaker builds", 2012-07-27) is extended to regenerate
perl/perl.mak if there's any change to "perl -V".

This will in some cases redundantly trigger perl/perl.mak to be
re-made, e.g. if @INC is modified in ways the build process doesn't
care about through sitecustomize.pl, but the common case is that we
just do the right thing and re-generate perl/perl.mak when needed.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMakefile: detect errors in running spatch
Jeff King [Fri, 10 Mar 2017 08:31:18 +0000 (03:31 -0500)] 
Makefile: detect errors in running spatch

The "make coccicheck" target runs spatch against each source
file. But it does so in a for loop, so "make" never sees the
exit code of spatch. Worse, it redirects stderr to a log
file, so the user has no indication of any failure. And then
to top it all off, because we touched the patch file's
mtime, make will refuse to repeat the command because it
think the target is up-to-date.

So for example:

  $ make coccicheck SPATCH=does-not-exist
      SPATCH contrib/coccinelle/free.cocci
      SPATCH contrib/coccinelle/qsort.cocci
      SPATCH contrib/coccinelle/xstrdup_or_null.cocci
      SPATCH contrib/coccinelle/swap.cocci
      SPATCH contrib/coccinelle/strbuf.cocci
      SPATCH contrib/coccinelle/object_id.cocci
      SPATCH contrib/coccinelle/array.cocci
  $ make coccicheck SPATCH=does-not-exist
  make: Nothing to be done for 'coccicheck'.

With this patch, you get:

  $ make coccicheck SPATCH=does-not-exist
       SPATCH contrib/coccinelle/free.cocci
  /bin/sh: 4: does-not-exist: not found
  Makefile:2338: recipe for target 'contrib/coccinelle/free.cocci.patch' failed
  make: *** [contrib/coccinelle/free.cocci.patch] Error 1

It also dumps the log on failure, so any errors from spatch
itself (like syntax errors in our .cocci files) will be seen
by the user.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoodb_mkstemp: use git_path_buf
Jeff King [Tue, 28 Mar 2017 19:45:52 +0000 (15:45 -0400)] 
odb_mkstemp: use git_path_buf

Since git_path_buf() is smart enough to replace "objects/"
with the correct object path, we can use it instead of
manually assembling the path. That's slightly shorter, and
will clean up any non-canonical bits in the path.

Signed-off-by: Jeff King <peff@peff.net>
7 years agoodb_mkstemp: write filename into strbuf
Jeff King [Tue, 28 Mar 2017 19:45:43 +0000 (15:45 -0400)] 
odb_mkstemp: write filename into strbuf

The odb_mkstemp() function expects the caller to provide a
fixed buffer to write the resulting tempfile name into. But
it creates the template using snprintf without checking the
return value. This means we could silently truncate the
filename.

In practice, it's unlikely that the truncation would end in
the template-pattern that mkstemp needs to open the file. So
we'd probably end up failing either way, unless the path was
specially crafted.

The simplest fix would be to notice the truncation and die.
However, we can observe that most callers immediately
xstrdup() the result anyway. So instead, let's switch to
using a strbuf, which is easier for them (and isn't a big
deal for the other 2 callers, who can just strbuf_release
when they're done with it).

Note that many of the callers used static buffers, but this
was purely to avoid putting a large buffer on the stack. We
never passed the static buffers out of the function, so
there's no complicated memory handling we need to change.

Signed-off-by: Jeff King <peff@peff.net>
7 years agodo not check odb_mkstemp return value for errors
Jeff King [Tue, 28 Mar 2017 19:45:25 +0000 (15:45 -0400)] 
do not check odb_mkstemp return value for errors

The odb_mkstemp function does not return an error; it dies
on failure instead. But many of its callers compare the
resulting descriptor against -1 and die themselves.

Mostly this is just pointless, but it does raise a question
when looking at the callers: if they show the results of the
"template" buffer after a failure, what's in it? The answer
is: it doesn't matter, because it cannot happen.

So let's make that clear by removing the bogus error checks.
In bitmap_writer_finish(), we can drop the error-handling
code entirely. In the other two cases, it's shared with the
open() in another code path; we can just move the
error-check next to that open() call.

And while we're at it, let's flesh out the function's
docstring a bit to make the error behavior clear.

Signed-off-by: Jeff King <peff@peff.net>
7 years agoSync with master
Junio C Hamano [Tue, 28 Mar 2017 21:24:42 +0000 (14:24 -0700)] 
Sync with master

7 years agoMerge branch 'js/rebase-i-reword-to-run-hooks' into next
Junio C Hamano [Tue, 28 Mar 2017 21:24:28 +0000 (14:24 -0700)] 
Merge branch 'js/rebase-i-reword-to-run-hooks' into next

A recent update to "rebase -i" stopped running hooks for the "git
commit" command during "reword" action, which has been fixed.

* js/rebase-i-reword-to-run-hooks:
  sequencer: allow the commit-msg hooks to run during a `reword`
  sequencer: make commit options more extensible
  t7504: document regression: reword no longer calls commit-msg

7 years agoMerge branch 'mg/describe-debug-l10n' into next
Junio C Hamano [Tue, 28 Mar 2017 21:24:28 +0000 (14:24 -0700)] 
Merge branch 'mg/describe-debug-l10n' into next

Some debugging output from "git describe" were marked for l10n,
but some weren't.  Mark missing ones for l10n.

* mg/describe-debug-l10n:
  l10n: de: translate describe debug terms
  describe: localize debug output fully

7 years agoMerge branch 'ab/case-insensitive-upstream-and-push-marker' into next
Junio C Hamano [Tue, 28 Mar 2017 21:24:28 +0000 (14:24 -0700)] 
Merge branch 'ab/case-insensitive-upstream-and-push-marker' into next

On many keyboards, typing "@{" involves holding down SHIFT key and
one can easily end up with "@{Up..." when typing "@{upstream}".  As
the upstream/push keywords do not appear anywhere else in the syntax,
we can safely accept them case insensitively without introducing
ambiguity or confusion  to solve this.

* ab/case-insensitive-upstream-and-push-marker:
  rev-parse: match @{upstream}, @{u} and @{push} case-insensitively

7 years agoMerge branch 'ab/doc-submitting' into next
Junio C Hamano [Tue, 28 Mar 2017 21:24:27 +0000 (14:24 -0700)] 
Merge branch 'ab/doc-submitting' into next

Doc update.

* ab/doc-submitting:
  doc/SubmittingPatches: show how to get a CLI commit summary
  doc/SubmittingPatches: clarify the casing convention for "area: change..."

7 years agoMerge branch 'ab/test-readme-updates' into next
Junio C Hamano [Tue, 28 Mar 2017 21:24:27 +0000 (14:24 -0700)] 
Merge branch 'ab/test-readme-updates' into next

Doc updates.

* ab/test-readme-updates:
  t/README: clarify the test_have_prereq documentation
  t/README: change "Inside <X> part" to "Inside the <X> part"
  t/README: link to metacpan.org, not search.cpan.org

7 years agoMerge branch 'rs/freebsd-getcwd-workaround' into next
Junio C Hamano [Tue, 28 Mar 2017 21:24:27 +0000 (14:24 -0700)] 
Merge branch 'rs/freebsd-getcwd-workaround' into next

FreeBSD implementation of getcwd(3) behaved differently when an
intermediate directory is unreadable/unsearchable depending on the
length of the buffer provided, which our strbuf_getcwd() was not
aware of.  strbuf_getcwd() has been taught to cope with it better.

* rs/freebsd-getcwd-workaround:
  strbuf: support long paths w/o read rights in strbuf_getcwd() on FreeBSD

7 years agoMerge branch 'ab/ref-filter-no-contains' into next
Junio C Hamano [Tue, 28 Mar 2017 21:24:26 +0000 (14:24 -0700)] 
Merge branch 'ab/ref-filter-no-contains' into next

"git tag/branch/for-each-ref" family of commands long allowed to
filter the refs by "--contains X" (show only the refs that are
descendants of X), "--merged X" (show only the refs that are
ancestors of X), "--no-merged X" (show only the refs that are not
ancestors of X).  One curious omission, "--no-contains X" (show
only the refs that are not descendants of X) has been added to
them.

* ab/ref-filter-no-contains:
  tag: add tests for --with and --without
  ref-filter: reflow recently changed branch/tag/for-each-ref docs
  ref-filter: add --no-contains option to tag/branch/for-each-ref
  tag: change --point-at to default to HEAD
  tag: implicitly supply --list given another list-like option
  tag: change misleading --list <pattern> documentation
  parse-options: add OPT_NONEG to the "contains" option
  tag: add more incompatibles mode tests
  for-each-ref: partly change <object> to <commit> in help
  tag tests: fix a typo in a test description
  tag: remove a TODO item from the test suite
  ref-filter: add test for --contains on a non-commit
  ref-filter: make combining --merged & --no-merged an error
  tag doc: reword --[no-]merged to talk about commits, not tips
  tag doc: split up the --[no-]merged documentation
  tag doc: move the description of --[no-]merged earlier

7 years agoMerge branch 'bw/recurse-submodules-relative-fix' into next
Junio C Hamano [Tue, 28 Mar 2017 21:24:26 +0000 (14:24 -0700)] 
Merge branch 'bw/recurse-submodules-relative-fix' into next

A few commands that recently learned the "--recurse-submodule"
option misbehaved when started from a subdirectory of the
superproject.

* bw/recurse-submodules-relative-fix:
  ls-files: fix bug when recursing with relative pathspec
  ls-files: fix typo in variable name
  grep: fix bug when recursing with relative pathspec
  setup: allow for prefix to be passed to git commands
  grep: fix help text typo

7 years agoNinth batch for 2.13
Junio C Hamano [Tue, 28 Mar 2017 21:14:56 +0000 (14:14 -0700)] 
Ninth batch for 2.13

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoSync with 'maint'
Junio C Hamano [Tue, 28 Mar 2017 21:14:24 +0000 (14:14 -0700)] 
Sync with 'maint'

7 years agoMerge branch 'jk/sha1dc'
Junio C Hamano [Tue, 28 Mar 2017 21:06:00 +0000 (14:06 -0700)] 
Merge branch 'jk/sha1dc'

sha1dc/sha1.c wanted to check the endianness of the target platform
at compilation time and used a CPP macro with a rather overly
generic name, "BIGENDIAN", to pass the result of the check around
in the file.  It wasn't prepared for the same macro set to 0
(false) by the platform to signal that the target is _not_ a big
endian box, and assumed that the endianness detection logic it has
alone would be the one that is setting the macro, resulting in a
breakage on Windows.  This has been fixed by using a bit less
generic name for the same purpose.

* jk/sha1dc:
  sha1dc: avoid CPP macro collisions

7 years agoMerge branch 'jh/memihash-opt'
Junio C Hamano [Tue, 28 Mar 2017 21:06:00 +0000 (14:06 -0700)] 
Merge branch 'jh/memihash-opt'

The name-hash used for detecting paths that are different only in
cases (which matter on case insensitive filesystems) has been
optimized to take advantage of multi-threading when it makes sense.

* jh/memihash-opt:
  name-hash: add test-lazy-init-name-hash to .gitignore
  name-hash: add perf test for lazy_init_name_hash
  name-hash: add test-lazy-init-name-hash
  name-hash: perf improvement for lazy_init_name_hash
  hashmap: document memihash_cont, hashmap_disallow_rehash api
  hashmap: add disallow_rehash setting
  hashmap: allow memihash computation to be continued
  name-hash: specify initial size for istate.dir_hash table

7 years agoMerge branch 'jk/fast-import-cleanup'
Junio C Hamano [Tue, 28 Mar 2017 21:05:59 +0000 (14:05 -0700)] 
Merge branch 'jk/fast-import-cleanup'

Code clean-up.

* jk/fast-import-cleanup:
  pack.h: define largest possible encoded object size
  encode_in_pack_object_header: respect output buffer length
  fast-import: use xsnprintf for formatting headers
  fast-import: use xsnprintf for writing sha1s

7 years agoMerge branch 'sg/skip-prefix-in-prettify-refname'
Junio C Hamano [Tue, 28 Mar 2017 21:05:59 +0000 (14:05 -0700)] 
Merge branch 'sg/skip-prefix-in-prettify-refname'

Code cleanup.

* sg/skip-prefix-in-prettify-refname:
  refs.c: use skip_prefix() in prettify_refname()

7 years agoMerge branch 'ab/branch-list-doc'
Junio C Hamano [Tue, 28 Mar 2017 21:05:59 +0000 (14:05 -0700)] 
Merge branch 'ab/branch-list-doc'

Doc update.

* ab/branch-list-doc:
  branch doc: update description for `--list`
  branch doc: change `git branch <pattern>` to use `<branchname>`

7 years agoMerge branch 'jk/pager-in-use'
Junio C Hamano [Tue, 28 Mar 2017 21:05:58 +0000 (14:05 -0700)] 
Merge branch 'jk/pager-in-use'

Code clean-up.

* jk/pager-in-use:
  pager_in_use: use git_env_bool()

7 years agoMerge branch 'tg/stash-push-fixup'
Junio C Hamano [Tue, 28 Mar 2017 21:05:58 +0000 (14:05 -0700)] 
Merge branch 'tg/stash-push-fixup'

Recent enhancement to "git stash push" command to support pathspec
to allow only a subset of working tree changes to be stashed away
was found to be too chatty and exposed the internal implementation
detail (e.g. when it uses reset to match the index to HEAD before
doing other things, output from reset seeped out).  These, and
other chattyness has been fixed.

* tg/stash-push-fixup:
  stash: keep untracked files intact in stash -k
  stash: pass the pathspec argument to git reset
  stash: don't show internal implementation details

7 years agoMerge branch 'sb/checkout-recurse-submodules'
Junio C Hamano [Tue, 28 Mar 2017 21:05:58 +0000 (14:05 -0700)] 
Merge branch 'sb/checkout-recurse-submodules'

"git checkout" is taught the "--recurse-submodules" option.

* sb/checkout-recurse-submodules:
  builtin/read-tree: add --recurse-submodules switch
  builtin/checkout: add --recurse-submodules switch
  entry.c: create submodules when interesting
  unpack-trees: check if we can perform the operation for submodules
  unpack-trees: pass old oid to verify_clean_submodule
  update submodules: add submodule_move_head
  submodule.c: get_super_prefix_or_empty
  update submodules: move up prepare_submodule_repo_env
  submodules: introduce check to see whether to touch a submodule
  update submodules: add a config option to determine if submodules are updated
  update submodules: add submodule config parsing
  make is_submodule_populated gently
  lib-submodule-update.sh: define tests for recursing into submodules
  lib-submodule-update.sh: replace sha1 by hash
  lib-submodule-update: teach test_submodule_content the -C <dir> flag
  lib-submodule-update.sh: do not use ./. as submodule remote
  lib-submodule-update.sh: reorder create_lib_submodule_repo
  submodule--helper.c: remove duplicate code
  connect_work_tree_and_git_dir: safely create leading directories

7 years agoMerge branch 'bw/grep-recurse-submodules'
Junio C Hamano [Tue, 28 Mar 2017 21:05:57 +0000 (14:05 -0700)] 
Merge branch 'bw/grep-recurse-submodules'

Build fix for NO_PTHREADS build.

* bw/grep-recurse-submodules:
  grep: fix builds with with no thread support
  grep: set default output method

7 years agoPrepare for 2.12.3
Junio C Hamano [Tue, 28 Mar 2017 20:54:14 +0000 (13:54 -0700)] 
Prepare for 2.12.3

7 years agoMerge branch 'km/config-grammofix' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:29 +0000 (13:52 -0700)] 
Merge branch 'km/config-grammofix' into maint

Doc update.

* km/config-grammofix:
  doc/config: grammar fixes for core.{editor,commentChar}

7 years agoMerge branch 'sb/t3600-rephrase' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:29 +0000 (13:52 -0700)] 
Merge branch 'sb/t3600-rephrase' into maint

A test retitling.

* sb/t3600-rephrase:
  t3600: rename test to describe its functionality

7 years agoMerge branch 'sb/submodule-update-initial-runs-custom-script' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:29 +0000 (13:52 -0700)] 
Merge branch 'sb/submodule-update-initial-runs-custom-script' into maint

A test fix.

* sb/submodule-update-initial-runs-custom-script:
  t7406: correct test case for submodule-update initial population

7 years agoMerge branch 'jk/quote-env-path-list-component' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:28 +0000 (13:52 -0700)] 
Merge branch 'jk/quote-env-path-list-component' into maint

A test fix.

* jk/quote-env-path-list-component:
  t5615: fix a here-doc syntax error

7 years agoMerge branch 'rs/update-hook-optim' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:28 +0000 (13:52 -0700)] 
Merge branch 'rs/update-hook-optim' into maint

Code clean-up.

* rs/update-hook-optim:
  receive-pack: simplify run_update_post_hook()

7 years agoMerge branch 'rs/shortlog-cleanup' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:27 +0000 (13:52 -0700)] 
Merge branch 'rs/shortlog-cleanup' into maint

Code clean-up.

* rs/shortlog-cleanup:
  shortlog: don't set after_subject to an empty string

7 years agoMerge branch 'rs/path-name-safety-cleanup' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:27 +0000 (13:52 -0700)] 
Merge branch 'rs/path-name-safety-cleanup' into maint

Code clean-up.

* rs/path-name-safety-cleanup:
  revision: remove declaration of path_name()

7 years agoMerge branch 'rs/http-push-cleanup' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:26 +0000 (13:52 -0700)] 
Merge branch 'rs/http-push-cleanup' into maint

Code clean-up.

* rs/http-push-cleanup:
  http-push: don't check return value of lookup_unknown_object()

7 years agoMerge branch 'sb/wt-status-cleanup' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:26 +0000 (13:52 -0700)] 
Merge branch 'sb/wt-status-cleanup' into maint

Code clean-up.

* sb/wt-status-cleanup:
  wt-status: simplify by using for_each_string_list_item

7 years agoMerge branch 'jk/pack-name-cleanups' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:25 +0000 (13:52 -0700)] 
Merge branch 'jk/pack-name-cleanups' into maint

Code clean-up.

* jk/pack-name-cleanups:
  index-pack: make pointer-alias fallbacks safer
  replace snprintf with odb_pack_name()
  odb_pack_keep(): stop generating keepfile name
  sha1_file.c: make pack-name helper globally accessible
  move odb_* declarations out of git-compat-util.h

7 years agoMerge branch 'jk/rev-parse-cleanup' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:25 +0000 (13:52 -0700)] 
Merge branch 'jk/rev-parse-cleanup' into maint

Code clean-up.

* jk/rev-parse-cleanup:
  rev-parse: simplify parsing of ref options
  rev-parse: add helper for parsing "--foo/--foo="
  rev-parse: use skip_prefix when parsing options

7 years agoMerge branch 'rs/blame-code-cleanup' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:25 +0000 (13:52 -0700)] 
Merge branch 'rs/blame-code-cleanup' into maint

Code clean-up.

* rs/blame-code-cleanup:
  blame: move blame_entry duplication to add_blame_entry()

7 years agoMerge branch 'st/verify-tag' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:24 +0000 (13:52 -0700)] 
Merge branch 'st/verify-tag' into maint

A few unterminated here documents in tests were fixed, which in
turn revealed incorrect expectations the tests make. These tests
have been updated.

* st/verify-tag:
  t7004, t7030: fix here-doc syntax errors

7 years agoMerge branch 'js/regexec-buf' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:24 +0000 (13:52 -0700)] 
Merge branch 'js/regexec-buf' into maint

Fix for potential segv introduced in v2.11.0 and later (also
v2.10.2).

* js/regexec-buf:
  pickaxe: fix segfault with '-S<...> --pickaxe-regex'

7 years agoMerge branch 'jk/execv-dashed-external' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:23 +0000 (13:52 -0700)] 
Merge branch 'jk/execv-dashed-external' into maint

Fix for NO_PTHREADS build.

* jk/execv-dashed-external:
  run-command: fix segfault when cleaning forked async process

7 years agoMerge branch 'ew/http-alternates-as-redirects-warning' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:23 +0000 (13:52 -0700)] 
Merge branch 'ew/http-alternates-as-redirects-warning' into maint

Recent versions of Git treats http alternates (used in dumb http
transport) just like HTTP redirects and requires the client to
enable following it, due to security concerns.  But we forgot to
give a warning when we decide not to honor the alternates.

* ew/http-alternates-as-redirects-warning:
  http: release strbuf on disabled alternates
  http: inform about alternates-as-redirects behavior

7 years agoMerge branch 'dp/filter-branch-prune-empty' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:22 +0000 (13:52 -0700)] 
Merge branch 'dp/filter-branch-prune-empty' into maint

"git filter-branch --prune-empty" drops a single-parent commit that
becomes a no-op, but did not drop a root commit whose tree is empty.

* dp/filter-branch-prune-empty:
  p7000: add test for filter-branch with --prune-empty
  filter-branch: fix --prune-empty on parentless commits
  t7003: ensure --prune-empty removes entire branch when applicable
  t7003: ensure --prune-empty can prune root commit

7 years agoMerge branch 'mm/fetch-show-error-message-on-unadvertised-object' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:22 +0000 (13:52 -0700)] 
Merge branch 'mm/fetch-show-error-message-on-unadvertised-object' into maint

"git fetch" that requests a commit by object name, when the other
side does not allow such an request, failed without much
explanation.

* mm/fetch-show-error-message-on-unadvertised-object:
  fetch-pack: add specific error for fetching an unadvertised object
  fetch_refs_via_pack: call report_unmatched_refs
  fetch-pack: move code to report unmatched refs to a function

7 years agoMerge branch 'jk/interpret-branch-name' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:22 +0000 (13:52 -0700)] 
Merge branch 'jk/interpret-branch-name' into maint

"git branch @" created refs/heads/@ as a branch, and in general the
code that handled @{-1} and @{upstream} was a bit too loose in
disambiguating.

* jk/interpret-branch-name:
  checkout: restrict @-expansions when finding branch
  strbuf_check_ref_format(): expand only local branches
  branch: restrict @-expansions when deleting
  t3204: test git-branch @-expansion corner cases
  interpret_branch_name: allow callers to restrict expansions
  strbuf_branchname: add docstring
  strbuf_branchname: drop return value
  interpret_branch_name: move docstring to header file
  interpret_branch_name(): handle auto-namelen for @{-1}

7 years agoMerge branch 'ab/cond-skip-tests' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:21 +0000 (13:52 -0700)] 
Merge branch 'ab/cond-skip-tests' into maint

A few tests were run conditionally under (rare) conditions where
they cannot be run (like running cvs tests under 'root' account).

* ab/cond-skip-tests:
  gitweb tests: skip tests when we don't have Time::HiRes
  gitweb tests: change confusing "skip_all" phrasing
  cvs tests: skip tests that call "cvs commit" when running as root

7 years agoMerge branch 'jk/ident-empty' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:21 +0000 (13:52 -0700)] 
Merge branch 'jk/ident-empty' into maint

user.email that consists of only cruft chars should consistently
error out, but didn't.

* jk/ident-empty:
  ident: do not ignore empty config name/email
  ident: reject all-crud ident name
  ident: handle NULL email when complaining of empty name
  ident: mark error messages for translation

7 years agoMerge branch 'jk/delta-chain-limit' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:20 +0000 (13:52 -0700)] 
Merge branch 'jk/delta-chain-limit' into maint

"git repack --depth=<n>" for a long time busted the specified depth
when reusing delta from existing packs.  This has been corrected.

* jk/delta-chain-limit:
  pack-objects: convert recursion to iteration in break_delta_chain()
  pack-objects: enforce --depth limit in reused deltas

7 years agoMerge branch 'sg/test-with-stdin' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:20 +0000 (13:52 -0700)] 
Merge branch 'sg/test-with-stdin' into maint

Teach the "debug" helper used in the test framework that allows a
command to run under "gdb" to make the session interactive.

* sg/test-with-stdin:
  tests: make the 'test_pause' helper work in non-verbose mode
  tests: create an interactive gdb session with the 'debug' helper

7 years agoMerge branch 'jk/interop-test' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:20 +0000 (13:52 -0700)] 
Merge branch 'jk/interop-test' into maint

Picking two versions of Git and running tests to make sure the
older one and the newer one interoperate happily has now become
possible.

* jk/interop-test:
  t/interop: add test of old clients against modern git-daemon
  t: add an interoperability test harness

7 years agoMerge branch 'jt/perf-updates' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:19 +0000 (13:52 -0700)] 
Merge branch 'jt/perf-updates' into maint

The t/perf performance test suite was not prepared to test not so
old versions of Git, but now it covers versions of Git that are not
so ancient.

* jt/perf-updates:
  t/perf: add fallback for pre-bin-wrappers versions of git
  t/perf: use $MODERN_GIT for all repo-copying steps
  t/perf: export variable used in other blocks

7 years agoMerge branch 'rs/strbuf-add-real-path' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:19 +0000 (13:52 -0700)] 
Merge branch 'rs/strbuf-add-real-path' into maint

An helper function to make it easier to append the result from
real_path() to a strbuf has been added.

* rs/strbuf-add-real-path:
  strbuf: add strbuf_add_real_path()
  cocci: use ALLOC_ARRAY

7 years agoMerge branch 'jk/parse-config-key-cleanup' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:18 +0000 (13:52 -0700)] 
Merge branch 'jk/parse-config-key-cleanup' into maint

The "parse_config_key()" API function has been cleaned up.

* jk/parse-config-key-cleanup:
  parse_hide_refs_config: tell parse_config_key we don't want a subsection
  parse_config_key: allow matching single-level config
  parse_config_key: use skip_prefix instead of starts_with
  refs: parse_hide_refs_config to use parse_config_key

7 years agotravis-ci: build and test Git on Windows
Lars Schneider [Fri, 24 Mar 2017 11:37:47 +0000 (12:37 +0100)] 
travis-ci: build and test Git on Windows

Most Git developers work on Linux and they have no way to know if their
changes would break the Git for Windows build. Let's fix that by adding
a job to TravisCI that builds and tests Git on Windows. Unfortunately,
TravisCI does not support Windows.

Therefore, we did the following:
* Johannes Schindelin set up a Visual Studio Team Services build
  sponsored by Microsoft and made it accessible via an Azure Function
  that speaks a super-simple API. We made TravisCI use this API to
  trigger a build, wait until its completion, and print the build and
  test results.
* A Windows build and test run takes up to 3h and TravisCI has a timeout
  after 50min for Open Source projects. Since the TravisCI job does not
  use heavy CPU/memory/etc. resources, the friendly TravisCI folks
  extended the job timeout for git/git to 3h.

Things, that would need to be done:
* Someone with write access to https://travis-ci.org/git/git would need
  to add the secret token as "GFW_CI_TOKEN" variable in the TravisCI
  repository setting [1]. Afterwards the build should just work.

Things, that might need to be done:
* The Windows box can only process a single build at a time. A second
  Windows build would need to wait until the first finishes. This
  waiting time and the build time after the wait could exceed the 3h
  threshold. If this is a problem, then it is likely to happen every day
  as usually multiple branches are pushed at the same time (pu/next/
  master/maint). I cannot test this as my TravisCI account has the 50min
  timeout. One solution could be to limit the number of concurrent
  TravisCI jobs [2].

[1] https://docs.travis-ci.com/user/environment-variables#Defining-Variables-in-Repository-Settings
[2] https://docs.travis-ci.com/user/customizing-the-build#Limiting-Concurrent-Builds

Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosha1-array: convert internal storage for struct sha1_array to object_id
brian m. carlson [Sun, 26 Mar 2017 16:01:37 +0000 (16:01 +0000)] 
sha1-array: convert internal storage for struct sha1_array to object_id

Make the internal storage for struct sha1_array use an array of struct
object_id internally.  Update the users of this struct which inspect its
internals.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agobuiltin/pull: convert to struct object_id
brian m. carlson [Sun, 26 Mar 2017 16:01:36 +0000 (16:01 +0000)] 
builtin/pull: convert to struct object_id

Convert virtually all uses of unsigned char [20] to struct object_id.
Leave all the arguments that come from struct sha1_array, as these will
be converted in a later patch.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosubmodule: convert check_for_new_submodule_commits to object_id
brian m. carlson [Sun, 26 Mar 2017 16:01:35 +0000 (16:01 +0000)] 
submodule: convert check_for_new_submodule_commits to object_id

All of the callers of this function have been converted, so convert this
function and update the callers.  This function also calls
sha1_array_append, which we'll convert shortly.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosha1_name: convert disambiguate_hint_fn to take object_id
brian m. carlson [Sun, 26 Mar 2017 16:01:34 +0000 (16:01 +0000)] 
sha1_name: convert disambiguate_hint_fn to take object_id

Convert this function pointer type and the functions that implement it
to take a struct object_id.  Introduce a temporary in
show_ambiguous_object to avoid having to convert for_each_abbrev at this
point.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosha1_name: convert struct disambiguate_state to object_id
brian m. carlson [Sun, 26 Mar 2017 16:01:33 +0000 (16:01 +0000)] 
sha1_name: convert struct disambiguate_state to object_id

Convert struct disambiguate_state to use struct object_id by changing
the structure definition and applying the following semantic patch:

@@
struct disambiguate_state E1;
@@
- E1.bin_pfx
+ E1.bin_pfx.hash

@@
struct disambiguate_state *E1;
@@
- E1->bin_pfx
+ E1->bin_pfx.hash

@@
struct disambiguate_state E1;
@@
- E1.candidate
+ E1.candidate.hash

@@
struct disambiguate_state *E1;
@@
- E1->candidate
+ E1->candidate.hash

This conversion is needed so we can convert disambiguate_hint_fn later.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agotest-sha1-array: convert most code to struct object_id
brian m. carlson [Sun, 26 Mar 2017 16:01:32 +0000 (16:01 +0000)] 
test-sha1-array: convert most code to struct object_id

This helper is very small, so convert the entire thing.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoparse-options-cb: convert sha1_array_append caller to struct object_id
brian m. carlson [Sun, 26 Mar 2017 16:01:31 +0000 (16:01 +0000)] 
parse-options-cb: convert sha1_array_append caller to struct object_id

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agofsck: convert init_skiplist to struct object_id
brian m. carlson [Sun, 26 Mar 2017 16:01:30 +0000 (16:01 +0000)] 
fsck: convert init_skiplist to struct object_id

Convert a hardcoded constant buffer size to a use of GIT_MAX_HEXSZ, and
use parse_oid_hex to reduce the dependency on the size of the hash.
This function is a caller of sha1_array_append, which will be converted
later.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agobuiltin/receive-pack: convert portions to struct object_id
brian m. carlson [Sun, 26 Mar 2017 16:01:29 +0000 (16:01 +0000)] 
builtin/receive-pack: convert portions to struct object_id

Convert some hardcoded constants into uses of parse_oid_hex.
Additionally, convert all uses of struct command, and miscellaneous
other functions necessary for that.  This work is necessary to be able
to convert sha1_array_append later on.

To avoid needing to specify a constant, reject shallow lines with the
wrong length instead of simply ignoring them.

Note that in queue_command we are guaranteed to have a NUL-terminated
buffer or at least one byte of overflow that we can safely read, so the
linelen check can be elided.  We would die in such a case, but not read
invalid memory.

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