git
7 years agoMerge branch 'ls/p4-retry-thrice' into next
Junio C Hamano [Tue, 10 Jan 2017 23:27:30 +0000 (15:27 -0800)] 
Merge branch 'ls/p4-retry-thrice' into next

A recent updates to "git p4" was not usable for older p4 but it
could be made to work with minimum changes.  Do so.

* ls/p4-retry-thrice:
  git-p4: do not pass '-r 0' to p4 commands

7 years agoMerge branch 'sb/submodule-rm-absorb' into next
Junio C Hamano [Tue, 10 Jan 2017 23:27:30 +0000 (15:27 -0800)] 
Merge branch 'sb/submodule-rm-absorb' into next

"git rm" used to refuse to remove a submodule when it has its own
git repository embedded in its working tree.  It learned to move
the repository away to $GIT_DIR/modules/ of the superproject
instead, and allow the submodule to be deleted (as long as there
will be no loss of local modifications, that is).

* sb/submodule-rm-absorb:
  rm: absorb a submodules git dir before deletion
  submodule: rename and add flags to ok_to_remove_submodule
  submodule: modernize ok_to_remove_submodule to use argv_array
  submodule.h: add extern keyword to functions

7 years agoMerge branch 'bw/realpath-wo-chdir' into next
Junio C Hamano [Tue, 10 Jan 2017 23:27:27 +0000 (15:27 -0800)] 
Merge branch 'bw/realpath-wo-chdir' into next

The implementation of "real_path()" was to go there with chdir(2)
and call getcwd(3), but this obviously wouldn't be usable in a
threaded environment.  Rewrite it to manually resolve relative
paths including symbolic links in path components.

* bw/realpath-wo-chdir:
  real_path: set errno when max number of symlinks is exceeded
  real_path: prevent redefinition of MAXSYMLINKS

7 years agoSync with master
Junio C Hamano [Tue, 10 Jan 2017 23:26:58 +0000 (15:26 -0800)] 
Sync with master

* master:
  Fifth batch 2.12

7 years agoFifth batch 2.12
Junio C Hamano [Tue, 10 Jan 2017 23:25:46 +0000 (15:25 -0800)] 
Fifth batch 2.12

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'sb/submodule-embed-gitdir'
Junio C Hamano [Tue, 10 Jan 2017 23:24:27 +0000 (15:24 -0800)] 
Merge branch 'sb/submodule-embed-gitdir'

A new submodule helper "git submodule embedgitdirs" to make it
easier to move embedded .git/ directory for submodules in a
superproject to .git/modules/ (and point the latter with the former
that is turned into a "gitdir:" file) has been added.

* sb/submodule-embed-gitdir:
  worktree: initialize return value for submodule_uses_worktrees
  submodule: add absorb-git-dir function
  move connect_work_tree_and_git_dir to dir.h
  worktree: check if a submodule uses worktrees
  test-lib-functions.sh: teach test_commit -C <dir>
  submodule helper: support super prefix
  submodule: use absolute path for computing relative path connecting

7 years agoMerge branch 'jc/retire-compaction-heuristics'
Junio C Hamano [Tue, 10 Jan 2017 23:24:27 +0000 (15:24 -0800)] 
Merge branch 'jc/retire-compaction-heuristics'

"git diff" and its family had two experimental heuristics to shift
the contents of a hunk to make the patch easier to read.  One of
them turns out to be better than the other, so leave only the
"--indent-heuristic" option and remove the other one.

* jc/retire-compaction-heuristics:
  diff: retire "compaction" heuristics

7 years agoMerge branch 'nd/config-misc-fixes'
Junio C Hamano [Tue, 10 Jan 2017 23:24:27 +0000 (15:24 -0800)] 
Merge branch 'nd/config-misc-fixes'

Leakage of lockfiles in the config subsystem has been fixed.

* nd/config-misc-fixes:
  config.c: handle lock file in error case in git_config_rename_...
  config.c: rename label unlock_and_out
  config.c: handle error case for fstat() calls

7 years agoMerge branch 'jc/abbrev-autoscale-config'
Junio C Hamano [Tue, 10 Jan 2017 23:24:26 +0000 (15:24 -0800)] 
Merge branch 'jc/abbrev-autoscale-config'

Recent update to the default abbreviation length that auto-scales
lacked documentation update, which has been corrected.

* jc/abbrev-autoscale-config:
  config.abbrev: document the new default that auto-scales

7 years agoMerge branch 'mh/fast-import-notes-fix-new'
Junio C Hamano [Tue, 10 Jan 2017 23:24:26 +0000 (15:24 -0800)] 
Merge branch 'mh/fast-import-notes-fix-new'

"git fast-import" sometimes mishandled while rebalancing notes
tree, which has been fixed.

* mh/fast-import-notes-fix-new:
  fast-import: properly fanout notes when tree is imported

7 years agoMerge branch 'jc/git-open-cloexec'
Junio C Hamano [Tue, 10 Jan 2017 23:24:26 +0000 (15:24 -0800)] 
Merge branch 'jc/git-open-cloexec'

The codeflow of setting NOATIME and CLOEXEC on file descriptors Git
opens has been simplified.
We may want to drop the tip one, but we'll see.

* jc/git-open-cloexec:
  sha1_file: stop opening files with O_NOATIME
  git_open_cloexec(): use fcntl(2) w/ FD_CLOEXEC fallback
  git_open(): untangle possible NOATIME and CLOEXEC interactions

7 years agoMerge branch 'jc/compression-config'
Junio C Hamano [Tue, 10 Jan 2017 23:24:25 +0000 (15:24 -0800)] 
Merge branch 'jc/compression-config'

Compression setting for producing packfiles were spread across
three codepaths, one of which did not honor any configuration.
Unify these so that all of them honor core.compression and
pack.compression variables the same way.

* jc/compression-config:
  compression: unify pack.compression configuration parsing

7 years agoMerge branch 'dt/smart-http-detect-server-going-away'
Junio C Hamano [Tue, 10 Jan 2017 23:24:25 +0000 (15:24 -0800)] 
Merge branch 'dt/smart-http-detect-server-going-away'

When the http server gives an incomplete response to a smart-http
rpc call, it could lead to client waiting for a full response that
will never come.  Teach the client side to notice this condition
and abort the transfer.

An improvement counterproposal has failed.
cf. <20161114194049.mktpsvgdhex2f4zv@sigill.intra.peff.net>

* dt/smart-http-detect-server-going-away:
  upload-pack: optionally allow fetching any sha1
  remote-curl: don't hang when a server dies before any output

7 years agoMerge branch 'mm/gc-safety-doc'
Junio C Hamano [Tue, 10 Jan 2017 23:24:25 +0000 (15:24 -0800)] 
Merge branch 'mm/gc-safety-doc'

Doc update.

* mm/gc-safety-doc:
  git-gc.txt: expand discussion of races with other processes

7 years agoMerge branch 'mm/push-social-engineering-attack-doc'
Junio C Hamano [Tue, 10 Jan 2017 23:24:24 +0000 (15:24 -0800)] 
Merge branch 'mm/push-social-engineering-attack-doc'

Doc update on fetching and pushing.

* mm/push-social-engineering-attack-doc:
  doc: mention transfer data leaks in more places

7 years agoMerge branch 'jt/fetch-no-redundant-tag-fetch-map'
Junio C Hamano [Tue, 10 Jan 2017 23:24:23 +0000 (15:24 -0800)] 
Merge branch 'jt/fetch-no-redundant-tag-fetch-map'

Code cleanup to avoid using redundant refspecs while fetching with
the --tags option.

* jt/fetch-no-redundant-tag-fetch-map:
  fetch: do not redundantly calculate tag refmap

7 years agoMerge branch 'jc/latin-1'
Junio C Hamano [Tue, 10 Jan 2017 23:24:22 +0000 (15:24 -0800)] 
Merge branch 'jc/latin-1'

Some platforms no longer understand "latin-1" that is still seen in
the wild in e-mail headers; replace them with "iso-8859-1" that is
more widely known when conversion fails from/to it.

* jc/latin-1:
  utf8: accept "latin-1" as ISO-8859-1
  utf8: refactor code to decide fallback encoding

7 years agomergetool: fix running in subdir when rerere enabled
Richard Hansen [Tue, 10 Jan 2017 20:42:02 +0000 (15:42 -0500)] 
mergetool: fix running in subdir when rerere enabled

"git mergetool" (without any pathspec on the command line) that is
not run from the top-level of the working tree no longer works in
Git v2.11, failing to get the list of unmerged paths from the output
of "git rerere remaining".  This regression was introduced by
57937f70a0 ("mergetool: honor diff.orderFile", 2016-10-07).

This is because the pathnames output by the 'git rerere remaining'
command are relative to the top-level directory but the 'git diff
--name-only' command expects its pathname arguments to be relative
to the current working directory.  To make everything consistent,
cd_to_toplevel before running 'git diff --name-only' and adjust any
relative pathnames.

Signed-off-by: Richard Hansen <hansenr@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agomergetool: take the "-O" out of $orderfile
Richard Hansen [Tue, 10 Jan 2017 20:42:01 +0000 (15:42 -0500)] 
mergetool: take the "-O" out of $orderfile

This will make it easier for a future commit to convert a relative
orderfile pathname to either absolute or relative to the top-level
directory.  It also improves code readability.

Signed-off-by: Richard Hansen <hansenr@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot7610: add test case for rerere+mergetool+subdir bug
Richard Hansen [Tue, 10 Jan 2017 20:42:00 +0000 (15:42 -0500)] 
t7610: add test case for rerere+mergetool+subdir bug

If rerere is enabled and mergetool is run from a subdirectory,
mergetool always prints "No files need merging".  Add an expected
failure test case for this situation.

Signed-off-by: Richard Hansen <hansenr@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot7610: spell 'git reset --hard' consistently
Richard Hansen [Tue, 10 Jan 2017 20:41:59 +0000 (15:41 -0500)] 
t7610: spell 'git reset --hard' consistently

Signed-off-by: Richard Hansen <hansenr@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot7610: don't assume the checked-out commit
Richard Hansen [Tue, 10 Jan 2017 20:41:58 +0000 (15:41 -0500)] 
t7610: don't assume the checked-out commit

Always check out the required commit at the beginning of the test so
that a failure in a previous test does not cause the test to work off
of the wrong commit.

This is a step toward making the tests more independent so that if one
test fails it doesn't cause subsequent tests to fail.

Signed-off-by: Richard Hansen <hansenr@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot7610: always work on a test-specific branch
Richard Hansen [Tue, 10 Jan 2017 20:41:57 +0000 (15:41 -0500)] 
t7610: always work on a test-specific branch

Create and use a test-specific branch when the test might create a
commit.  This is not always necessary for correctness, but it improves
debuggability by ensuring a commit created by test #N shows up on the
testN branch, not the branch for test #N-1.

Signed-off-by: Richard Hansen <hansenr@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot7610: delete some now-unnecessary 'git reset --hard' lines
Richard Hansen [Tue, 10 Jan 2017 20:41:56 +0000 (15:41 -0500)] 
t7610: delete some now-unnecessary 'git reset --hard' lines

Tests now always run 'git reset --hard' at the end (even if they
fail), so it's no longer necessary to run 'git reset --hard' at the
beginning of a test.

Signed-off-by: Richard Hansen <hansenr@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot7610: run 'git reset --hard' after each test to clean up
Richard Hansen [Tue, 10 Jan 2017 20:41:55 +0000 (15:41 -0500)] 
t7610: run 'git reset --hard' after each test to clean up

Use test_when_finished to run 'git reset --hard' after each test so
that the repository is left in a saner state for the next test.

This is a step toward making the tests more independent so that if one
test fails it doesn't cause subsequent tests to fail.

Signed-off-by: Richard Hansen <hansenr@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot7610: don't rely on state from previous test
Richard Hansen [Tue, 10 Jan 2017 20:41:54 +0000 (15:41 -0500)] 
t7610: don't rely on state from previous test

If the repository must be in a particular state (beyond what is
already done by the 'setup' test case) before the test can run, make
the necessary repository changes in the test script even if it means
duplicating some lines of code from the previous test case.

This is a step toward making the tests more independent so that if one
test fails it doesn't cause subsequent tests to fail.

Signed-off-by: Richard Hansen <hansenr@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot7610: use test_when_finished for cleanup tasks
Richard Hansen [Tue, 10 Jan 2017 20:41:53 +0000 (15:41 -0500)] 
t7610: use test_when_finished for cleanup tasks

This is a step toward making the tests more independent so that if one
test fails it doesn't cause subsequent tests to fail.

Signed-off-by: Richard Hansen <hansenr@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot7610: move setup code to the 'setup' test case
Richard Hansen [Tue, 10 Jan 2017 20:41:52 +0000 (15:41 -0500)] 
t7610: move setup code to the 'setup' test case

Multiple test cases depend on these hunks, so move them to the 'setup'
test case.  This is a step toward making the tests more independent so
that if one test fails it doesn't cause subsequent tests to fail.

Signed-off-by: Richard Hansen <hansenr@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot7610: update branch names to match test number
Richard Hansen [Tue, 10 Jan 2017 20:41:51 +0000 (15:41 -0500)] 
t7610: update branch names to match test number

Rename the testNN branches so that NN matches the test number.  This
should make it easier to troubleshoot test issues.  Use $test_count to
keep this future-proof.

Signed-off-by: Richard Hansen <hansenr@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agorev-parse doc: pass "--" to rev-parse in the --prefix example
Richard Hansen [Tue, 10 Jan 2017 20:41:50 +0000 (15:41 -0500)] 
rev-parse doc: pass "--" to rev-parse in the --prefix example

The "--" argument avoids "ambiguous argument: unknown revision or
path not in the working tree" errors when a pathname argument refers
to a non-existent file.

The "--" passed explicitly to set was removed because rev-parse
outputs the "--" argument that it is given.

Signed-off-by: Richard Hansen <hansenr@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agounpack-trees: factor progress setup out of check_updates
Stefan Beller [Mon, 9 Jan 2017 19:46:19 +0000 (11:46 -0800)] 
unpack-trees: factor progress setup out of check_updates

This makes check_updates shorter and easier to understand.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agounpack-trees: remove unneeded continue
Stefan Beller [Mon, 9 Jan 2017 19:46:18 +0000 (11:46 -0800)] 
unpack-trees: remove unneeded continue

The continue is the last statement in the loop, so not needed.
This situation arose in 700e66d66 (2010-07-30, unpack-trees: let
read-tree -u remove index entries outside sparse area) when statements
after the continue were removed.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agounpack-trees: move checkout state into check_updates
Stefan Beller [Mon, 9 Jan 2017 19:46:17 +0000 (11:46 -0800)] 
unpack-trees: move checkout state into check_updates

The checkout state was introduced via 16da134b1f9
(read-trees: refactor the unpack_trees() part, 2006-07-30). An attempt to
refactor the checkout state was done in b56aa5b268e (unpack-trees: pass
checkout state explicitly to check_updates(), 2016-09-13), but we can
go even further.

The `struct checkout state` is not used in unpack_trees apart from
initializing it, so move it into the function that makes use of it,
which is `check_updates`.

Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years ago.mailmap: record canonical email for Richard Hansen
Richard Hansen [Mon, 9 Jan 2017 23:29:28 +0000 (18:29 -0500)] 
.mailmap: record canonical email for Richard Hansen

When I changed employers my work address changed from rhansen@bbn.com
to hansenr@google.com.  Rather than map my old work address to my new,
map them both to my permanent personal email address.  (I will still
use my work address in commits I submit so that my employer gets some
credit.)

Signed-off-by: Richard Hansen <hansenr@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agopathspec: give better message for submodule related pathspec error
Stefan Beller [Mon, 9 Jan 2017 23:16:50 +0000 (15:16 -0800)] 
pathspec: give better message for submodule related pathspec error

Every once in a while someone complains to the mailing list to have
run into this weird assertion[1]. The usual response from the mailing
list is link to old discussions[2], and acknowledging the problem
stating it is known.

This patch accomplishes two things:

  1. Switch assert() to die("BUG") to give a more readable message.

  2. Take one of the cases where we hit a BUG and turn it into a normal
     "there was something wrong with the input" message.

     This assertion triggered for cases where there wasn't a programming
     bug, but just bogus input. In particular, if the user asks for a
     pathspec that is inside a submodule, we shouldn't assert() or
     die("BUG"); we should tell the user their request is bogus.

     The only reason we did not check for it, is the expensive nature
     of such a check, so callers avoid setting the flag
     PATHSPEC_STRIP_SUBMODULE_SLASH_EXPENSIVE. However when we die due
     to bogus input, the expense of CPU cycles spent outweighs the user
     wondering what went wrong, so run that check unconditionally before
     dying with a more generic error message.

Note: There is a case (e.g. "git -C submodule add .") in which we call
strip_submodule_slash_expensive, as git-add requests it via the flag
PATHSPEC_STRIP_SUBMODULE_SLASH_EXPENSIVE, but the assert used to
trigger nevertheless, because the flag PATHSPEC_LITERAL was not set,
such that we executed

if (item->nowildcard_len < prefixlen)
item->nowildcard_len = prefixlen;

and prefixlen was not adapted (e.g. it was computed from "submodule/")
So in the die_inside_submodule_path function we also need handle paths,
that were stripped before, i.e. are the exact submodule path. This
is why the conditions in die_inside_submodule_path are slightly
different than in strip_submodule_slash_expensive.

[1] https://www.google.com/search?q=item-%3Enowildcard_len
[2] http://git.661346.n2.nabble.com/assert-failed-in-submodule-edge-case-td7628687.html
    https://www.spinics.net/lists/git/msg249473.html

Helped-by: Jeff King <peff@peff.net>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoexecv_dashed_external: wait for child on signal death
Jeff King [Sat, 7 Jan 2017 01:22:23 +0000 (20:22 -0500)] 
execv_dashed_external: wait for child on signal death

When you hit ^C to interrupt a git command going to a pager,
this usually leaves the pager running. But when a dashed
external is in use, the pager ends up in a funny state and
quits (but only after eating one more character from the
terminal!). This fixes it.

Explaining the reason will require a little background.

When git runs a pager, it's important for the git process to
hang around and wait for the pager to finish, even though it
has no more data to feed it. This is because git spawns the
pager as a child, and thus the git process is the session
leader on the terminal. After it dies, the pager will finish
its current read from the terminal (eating the one
character), and then get EIO trying to read again.

When you hit ^C, that sends SIGINT to git and to the pager,
and it's a similar situation.  The pager ignores it, but the
git process needs to hang around until the pager is done. We
addressed that long ago in a3da882120 (pager: do
wait_for_pager on signal death, 2009-01-22).

But when you have a dashed external (or an alias pointing to
a builtin, which will re-exec git for the builtin), there's
an extra process in the mix. For instance, running:

  $ git -c alias.l=log l

will end up with a process tree like:

  git (parent)
    \
     git-log (child)
      \
       less (pager)

If you hit ^C, SIGINT goes to all of them. The pager ignores
it, and the child git process will end up in wait_for_pager().
But the parent git process will die, and the usual EIO
trouble happens.

So we really want the parent git process to wait_for_pager(),
but of course it doesn't know anything about the pager at
all, since it was started by the child.  However, we can
have it wait on the git-log child, which in turn is waiting
on the pager. And that's what this patch does.

There are a few design decisions here worth explaining:

  1. The new feature is attached to run-command's
     clean_on_exit feature. Partly this is convenience,
     since that feature already has a signal handler that
     deals with child cleanup.

     But it's also a meaningful connection. The main reason
     that dashed externals use clean_on_exit is to bind the
     two processes together. If somebody kills the parent
     with a signal, we propagate that to the child (in this
     instance with SIGINT, we do propagate but it doesn't
     matter because the original signal went to the whole
     process group). Likewise, we do not want the parent
     to go away until the child has done so.

     In a traditional Unix world, we'd probably accomplish
     this binding by just having the parent execve() the
     child directly. But since that doesn't work on Windows,
     everything goes through run_command's more spawn-like
     interface.

  2. We do _not_ automatically waitpid() on any
     clean_on_exit children. For dashed externals this makes
     sense; we know that the parent is doing nothing but
     waiting for the child to exit anyway. But with other
     children, it's possible that the child, after getting
     the signal, could be waiting on the parent to do
     something (like closing a descriptor). If we were to
     wait on such a child, we'd end up in a deadlock. So
     this errs on the side of caution, and lets callers
     enable the feature explicitly.

  3. When we send children the cleanup signal, we send all
     the signals first, before waiting on any children. This
     is to avoid the case where one child might be waiting
     on another one to exit, causing a deadlock. We inform
     all of them that it's time to die before reaping any.

     In practice, there is only ever one dashed external run
     from a given process, so this doesn't matter much now.
     But it future-proofs us if other callers start using
     the wait_after_clean mechanism.

There's no automated test here, because it would end up racy
and unportable. But it's easy to reproduce the situation by
running the log command given above and hitting ^C.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoexecv_dashed_external: stop exiting with negative code
Jeff King [Sat, 7 Jan 2017 01:17:48 +0000 (20:17 -0500)] 
execv_dashed_external: stop exiting with negative code

When we try to exec a git sub-command, we pass along the
status code from run_command(). But that may return -1 if we
ran into an error with pipe() or execve(). This tends to
work (and end up as 255 due to twos-complement wraparound
and truncation), but in general it's probably a good idea to
avoid negative exit codes for portability.

We can easily translate to the normal generic "128" code we
get when syscalls cause us to die.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoexecv_dashed_external: use child_process struct
Jeff King [Sat, 7 Jan 2017 01:16:24 +0000 (20:16 -0500)] 
execv_dashed_external: use child_process struct

When we run a dashed external, we use the one-liner
run_command_v_opt() to do so. Let's switch to using a
child_process struct, which has two advantages:

  1. We can drop all of the allocation and cleanup code for
     building our custom argv array, and just rely on the
     builtin argv_array (at the minor cost of doing a few
     extra mallocs).

  2. We have access to the complete range of child_process
     options, not just the ones that the "_opt()" form can
     forward.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoreal_path: set errno when max number of symlinks is exceeded
Brandon Williams [Mon, 9 Jan 2017 18:50:24 +0000 (10:50 -0800)] 
real_path: set errno when max number of symlinks is exceeded

Set errno to ELOOP when the maximum number of symlinks is exceeded, as
would be done by other symlink-resolving functions.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoreal_path: prevent redefinition of MAXSYMLINKS
Brandon Williams [Mon, 9 Jan 2017 18:50:23 +0000 (10:50 -0800)] 
real_path: prevent redefinition of MAXSYMLINKS

The macro 'MAXSYMLINKS' is already defined on macOS and Linux in
<sys/param.h>.  If 'MAXSYMLINKS' has already been defined, use the value
defined by the OS otherwise default to a value of 32 which is more
inline with what is allowed by many systems.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMakefile: put LIBS after LDFLAGS for imap-send
Steven Penny [Sun, 8 Jan 2017 06:12:38 +0000 (00:12 -0600)] 
Makefile: put LIBS after LDFLAGS for imap-send

This matches up with the targets git-%, git-http-fetch, git-http-push
and git-remote-testsvn. It must be done this way in Cygwin else lcrypto
cannot find lgdi32 and lws2_32.

Signed-off-by: Steven Penny <svnpenn@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMakefile: POSIX windres
Steven Penny [Sat, 7 Jan 2017 21:41:10 +0000 (15:41 -0600)] 
Makefile: POSIX windres

When environment variable POSIXLY_CORRECT is set, the
"input -o output" syntax is not supported.

  http://cygwin.com/ml/cygwin/2017-01/msg00036.html

Use "-i input -o output" syntax instead.

Signed-off-by: Steven Penny <svnpenn@gmail.com>
Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot9813: avoid using pipes
Pranit Bauva [Tue, 3 Jan 2017 19:57:08 +0000 (01:27 +0530)] 
t9813: avoid using pipes

The exit code of the upstream in a pipe is ignored thus we should avoid
using it. By writing out the output of the git command to a file, we can
test the exit codes of both the commands.

Signed-off-by: Pranit Bauva <pranit.bauva@gmail.com>
Acked-by: Luke Diamand <luke@diamand.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agopathspec: rename prefix_pathspec to init_pathspec_item
Brandon Williams [Wed, 4 Jan 2017 18:04:11 +0000 (10:04 -0800)] 
pathspec: rename prefix_pathspec to init_pathspec_item

Give a more relevant name to the prefix_pathspec function as it does
more than just prefix a pathspec element.

Signed-off-by: Brandon Williams <bmwill@google.com>
Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agopathspec: small readability changes
Brandon Williams [Wed, 4 Jan 2017 18:04:10 +0000 (10:04 -0800)] 
pathspec: small readability changes

A few small changes to improve readability.  This is done by grouping related
assignments, adding blank lines, ensuring lines are <80 characters, and
adding additional comments.

Signed-off-by: Brandon Williams <bmwill@google.com>
Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agopathspec: create strip submodule slash helpers
Brandon Williams [Wed, 4 Jan 2017 18:04:09 +0000 (10:04 -0800)] 
pathspec: create strip submodule slash helpers

Factor out the logic responsible for stripping the trailing slash on
pathspecs referencing submodules into its own function.

Signed-off-by: Brandon Williams <bmwill@google.com>
Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agopathspec: create parse_element_magic helper
Brandon Williams [Wed, 4 Jan 2017 18:04:08 +0000 (10:04 -0800)] 
pathspec: create parse_element_magic helper

Factor out the logic responsible for the magic in a pathspec element
into its own function.

Also avoid calling into the parsing functions when
`PATHSPEC_LITERAL_PATH` is specified since it causes magic to be
ignored and all paths to be treated as literals.

Signed-off-by: Brandon Williams <bmwill@google.com>
Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agopathspec: create parse_long_magic function
Brandon Williams [Wed, 4 Jan 2017 18:04:07 +0000 (10:04 -0800)] 
pathspec: create parse_long_magic function

Factor out the logic responsible for parsing long magic into its own
function.  As well as hoist the prefix check logic outside of the inner
loop as there isn't anything that needs to be done after matching
"prefix:".

Signed-off-by: Brandon Williams <bmwill@google.com>
Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agopathspec: create parse_short_magic function
Brandon Williams [Wed, 4 Jan 2017 18:04:06 +0000 (10:04 -0800)] 
pathspec: create parse_short_magic function

Factor out the logic responsible for parsing short magic into its own
function.

Signed-off-by: Brandon Williams <bmwill@google.com>
Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agopathspec: factor global magic into its own function
Brandon Williams [Wed, 4 Jan 2017 18:04:05 +0000 (10:04 -0800)] 
pathspec: factor global magic into its own function

Create helper functions to read the global magic environment variables
in additon to factoring out the global magic gathering logic into its
own function.

Signed-off-by: Brandon Williams <bmwill@google.com>
Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agopathspec: simpler logic to prefix original pathspec elements
Brandon Williams [Wed, 4 Jan 2017 18:04:04 +0000 (10:04 -0800)] 
pathspec: simpler logic to prefix original pathspec elements

The logic used to prefix an original pathspec element with 'prefix'
magic is more general purpose and can be used for more than just short
magic.  Remove the extra code paths and rename 'prefix_short_magic' to
'prefix_magic' to better indicate that it can be used in more general
situations.

Also, slightly change the logic which decides when to prefix the
original element in order to prevent a pathspec of "." from getting
converted to "" (empty string).

Signed-off-by: Brandon Williams <bmwill@google.com>
Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agopathspec: always show mnemonic and name in unsupported_magic
Brandon Williams [Wed, 4 Jan 2017 18:04:03 +0000 (10:04 -0800)] 
pathspec: always show mnemonic and name in unsupported_magic

For better clarity, always show the mnemonic and name of the unsupported
magic being used.  This lets users have a more clear understanding of
what magic feature isn't supported.  And if they supplied a mnemonic,
the user will be told what its corresponding name is which will allow
them to more easily search the man pages for that magic type.

This also avoids passing an extra parameter around the pathspec
initialization code.

Signed-off-by: Brandon Williams <bmwill@google.com>
Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agopathspec: remove unused variable from unsupported_magic
Brandon Williams [Wed, 4 Jan 2017 18:04:02 +0000 (10:04 -0800)] 
pathspec: remove unused variable from unsupported_magic

Removed unused variable 'n' from the 'unsupported_magic()' function.

Signed-off-by: Brandon Williams <bmwill@google.com>
Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agopathspec: copy and free owned memory
Brandon Williams [Wed, 4 Jan 2017 18:04:01 +0000 (10:04 -0800)] 
pathspec: copy and free owned memory

The 'original' string entry in a pathspec_item is only duplicated some
of the time, instead always make a copy of the original and take
ownership of the memory.

Since both 'match' and 'original' string entries in a pathspec_item are
owned by the pathspec struct, they need to be freed when clearing the
pathspec struct (in 'clear_pathspec()') and duplicated when copying the
pathspec struct (in 'copy_pathspec()').

Also change the type of 'match' and 'original' to 'char *' in order to
more explicitly show the ownership of the memory.

Signed-off-by: Brandon Williams <bmwill@google.com>
Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agopathspec: remove the deprecated get_pathspec function
Brandon Williams [Wed, 4 Jan 2017 18:04:00 +0000 (10:04 -0800)] 
pathspec: remove the deprecated get_pathspec function

Now that all callers of the old 'get_pathspec' interface have been
migrated to use the new pathspec struct interface it can be removed
from the codebase.

Since there are no more users of the '_raw' field in the pathspec struct
it can also be removed.  This patch also removes the old functionality
of modifying the const char **argv array that was passed into
parse_pathspec.  Instead the constructed 'match' string (which is a
pathspec element with the prefix prepended) is only stored in its
corresponding pathspec_item entry.

Signed-off-by: Brandon Williams <bmwill@google.com>
Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agols-tree: convert show_recursive to use the pathspec struct interface
Brandon Williams [Wed, 4 Jan 2017 18:03:59 +0000 (10:03 -0800)] 
ls-tree: convert show_recursive to use the pathspec struct interface

Convert 'show_recursive()' to use the pathspec struct interface from
using the '_raw' entry in the pathspec struct.

Signed-off-by: Brandon Williams <bmwill@google.com>
Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agodir: convert fill_directory to use the pathspec struct interface
Brandon Williams [Wed, 4 Jan 2017 18:03:58 +0000 (10:03 -0800)] 
dir: convert fill_directory to use the pathspec struct interface

Convert 'fill_directory()' to use the pathspec struct interface from
using the '_raw' entry in the pathspec struct.

Signed-off-by: Brandon Williams <bmwill@google.com>
Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agodir: remove struct path_simplify
Brandon Williams [Wed, 4 Jan 2017 18:03:57 +0000 (10:03 -0800)] 
dir: remove struct path_simplify

Teach simplify_away() and exclude_matches_pathspec() to handle struct
pathspec directly, eliminating the need for the struct path_simplify.

Also renamed the len parameter to pathlen in exclude_matches_pathspec()
to match the parameter names used in simplify_away().

Signed-off-by: Brandon Williams <bmwill@google.com>
Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agomv: remove use of deprecated 'get_pathspec()'
Brandon Williams [Wed, 4 Jan 2017 18:03:56 +0000 (10:03 -0800)] 
mv: remove use of deprecated 'get_pathspec()'

Convert the 'internal_copy_pathspec()' function to 'prefix_path()'
instead of using the deprecated 'get_pathspec()' interface.  Also,
rename 'internal_copy_pathspec()' to 'internal_prefix_pathspec()' to be
more descriptive of what the funciton is actually doing.

In addition to this, fix a memory leak caused by only duplicating some
of the pathspec elements.  Instead always duplicate all of the the
pathspec elements as an intermediate step (with modificationed based on
the passed in flags).  This way the intermediate strings can then be
freed after getting the result from 'prefix_path()'.

Signed-off-by: Brandon Williams <bmwill@google.com>
Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoblame: output porcelain "previous" header for each file
Jeff King [Fri, 6 Jan 2017 04:20:51 +0000 (23:20 -0500)] 
blame: output porcelain "previous" header for each file

It's possible for content currently found in one file to
have originated in two separate files, each of which may
have been modified in some single older commit.  The
--porcelain output generates an incorrect "previous" header
in this case, whereas --line-porcelain gets it right.  The
problem is that the porcelain output tries to omit repeated
details of commits, and treats "previous" as a property of
the commit, when it is really a property of the blamed block
of lines.

Let's look at an example. In a case like this, you might see
this output from --line-porcelain:

  SOME_SHA1 1 1 1
  author ...
  committer ...
  previous SOME_SHA1^ file_one
  filename file_one
          ...some line content...
  SOME_SHA1 2 1 1
  author ...
  committer ...
  previous SOME_SHA1^ file_two
  filename file_two
          ...some different content....

The "filename" fields tell us that the two lines are from
two different files. But notice that the filename also
appears in the "previous" field, which tells us where to
start a re-blame. The second content line never appeared in
file_one at all, so we would obviously need to re-blame from
file_two (or possibly even some other file, if had just been
renamed to file_two in SOME_SHA1).

So far so good. Now here's what --porcelain looks like:

  SOME_SHA1 1 1 1
  author ...
  committer ...
  previous SOME_SHA1^ file_one
  filename file_one
          ...some line content...
  SOME_SHA1 2 1 1
  filename file_two
          ...some different content....

We've dropped the author and committer fields from the
second line, as they would just be repeats.  But we can't
omit "filename", because it depends on the actual block of
blamed lines, not just the commit. This is handled by
emit_porcelain_details(), which will show the filename
either if it is the first mention of the commit _or_ if the
commit has multiple paths in it.

But we don't give "previous" the same handling. It's written
inside emit_one_suspect_detail(), which bails early if we've
already seen that commit. And so the output above is wrong;
a reader would assume that the correct place to re-blame
line two is from file_one, but that's obviously nonsense.

Let's treat "previous" the same as "filename", and show it
fresh whenever we know we are in a confusing case like this.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoblame: handle --no-abbrev
Jeff King [Fri, 6 Jan 2017 04:18:08 +0000 (23:18 -0500)] 
blame: handle --no-abbrev

You can already ask blame for full sha1s with "-l" or with
"--abbrev=40". But for consistency with other parts of Git,
we should support "--no-abbrev".

Worse, blame already accepts --no-abbrev, but it's totally
broken. When we see --no-abbrev, the abbrev variable is set
to 0, which is then used as a printf precision. For regular
sha1s, that means we print nothing at all (which is very
wrong). For boundary commits we decrement it to "-1", which
printf interprets as "no limit" (which is almost correct,
except it misses the 39-length magic explained in the
previous commit).

Let's detect --no-abbrev and behave as if --abbrev=40 was
given.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoblame: fix alignment with --abbrev=40
Jeff King [Fri, 6 Jan 2017 04:17:40 +0000 (23:17 -0500)] 
blame: fix alignment with --abbrev=40

The blame command internally adds 1 to any requested sha1
abbreviation length, and then subtracts it when outputting a
boundary commit. This lets regular and boundary sha1s line
up visually, but it misses one corner case.

When the requested length is 40, we bump the value to 41.
But since we only have 40 characters, that's all we can show
(fortunately the truncation is done by a printf precision
field, so it never tries to read past the end of the
buffer).  So a normal sha1 shows 40 hex characters, and a
boundary sha1 shows "^" plus 40 hex characters. The result
is misaligned.

The "-l" option to show long sha1s gets around this by
skipping the "abbrev" variable entirely and just always
using GIT_SHA1_HEXSZ.  This avoids the "+1" issue, but it
does mean that boundary commits only have 39 characters
printed.  This is somewhat odd, but it does look good
visually: the results are aligned and left-justified. The
alternative would be to allocate an extra column that would
contain either an extra space or the "^" boundary marker.

As this is by definition the human-readable view, it's
probably not that big a deal either way (and of course
--porcelain, etc, correctly produce correct 40-hex sha1s).
But for consistency, this patch teaches --abbrev=40 to
produce the same output as "-l" (always left-aligned, with
40-hex for normal sha1s, and "^" plus 39-hex for
boundaries).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agorebase--interactive: count squash commits above 10 correctly
Jeff King [Sat, 7 Jan 2017 08:23:19 +0000 (03:23 -0500)] 
rebase--interactive: count squash commits above 10 correctly

We generate the squash commit message incrementally running
a sed script once for each commit. It parses "This is
a combination of <N> commits" from the first line of the
existing message, adds one to <N>, and uses the result as
the number of our current message.

Since f2d17068fd (i18n: rebase-interactive: mark comments of
squash for translation, 2016-06-17), the first line may be
localized, and sed uses a pretty liberal regex, looking for:

  /^#.*([0-9][0-9]*)/

The "[0-9][0-9]*" tries to match double digits, but it
doesn't quite work.  The first ".*" is greedy, so if you
have:

  This is a combination of 10 commits.

it will eat up "This is a combination of 1", leaving "0" to
match the first "[0-9]" digit, and then skipping the
optional match of "[0-9]*".

As a result, the count resets every 10 commits, and a
15-commit squash would end up as:

  # This is a combination of 5 commits.
  # This is the 1st commit message:
  ...
  # This is the commit message #2:
  ... and so on ..
  # This is the commit message #10:
  ...
  # This is the commit message #1:
  ...
  # This is the commit message #2:
  ... etc, up to 5 ...

We can fix this by making the ".*" less greedy. Instead of
depending on ".*?" working portably, we can just limit the
match to non-digit characters, which accomplishes the same
thing.

Reported-by: Brandon Tolsch <btolsch@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agobranch_get_push: do not segfault when HEAD is detached
Kyle Meyer [Sat, 7 Jan 2017 01:12:15 +0000 (20:12 -0500)] 
branch_get_push: do not segfault when HEAD is detached

Move the detached HEAD check from branch_get_push_1() to
branch_get_push() to avoid setting branch->push_tracking_ref when
branch is NULL.

Signed-off-by: Kyle Meyer <kyle@kyleam.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoarchive-zip: load userdiff config
Jeff King [Mon, 2 Jan 2017 22:25:09 +0000 (17:25 -0500)] 
archive-zip: load userdiff config

Since 4aff646d17 (archive-zip: mark text files in archives,
2015-03-05), the zip archiver will look at the userdiff
driver to decide whether a file is text or binary. This
usually doesn't need to look any further than the attributes
themselves (e.g., "-diff", etc). But if the user defines a
custom driver like "diff=foo", we need to look at
"diff.foo.binary" in the config. Prior to this patch, we
didn't actually load it.

Signed-off-by: Jeff King <peff@peff.net>
Acked-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agogiteveryday: unbreak rendering with AsciiDoctor
Johannes Schindelin [Mon, 2 Jan 2017 16:04:05 +0000 (17:04 +0100)] 
giteveryday: unbreak rendering with AsciiDoctor

The "giteveryday" document has a callout list that contains a code
block. This is not a problem for AsciiDoc, but AsciiDoctor sadly was
explicitly designed *not* to render this correctly [*1*]. The symptom is
an unhelpful

line 322: callout list item index: expected 1 got 12
line 325: no callouts refer to list item 1
line 325: callout list item index: expected 2 got 13
line 327: no callouts refer to list item 2

In Git for Windows, we rely on the speed improvement of AsciiDoctor (on
this developer's machine, `make -j15 html` takes roughly 30 seconds with
AsciiDoctor, 70 seconds with AsciiDoc), therefore we need a way to
render this correctly.

The easiest way out is to simplify the callout list, as suggested by
AsciiDoctor's author, even while one may very well disagree with him
that a code block hath no place in a callout list.

*1*: https://github.com/asciidoctor/asciidoctor/issues/1478

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agomingw: add a regression test for pushing to UNC paths
Johannes Schindelin [Mon, 2 Jan 2017 10:40:20 +0000 (11:40 +0100)] 
mingw: add a regression test for pushing to UNC paths

On Windows, there are "UNC paths" to access network (AKA shared)
folders, of the form \\server\sharename\directory. This provides a
convenient way for Windows developers to share their Git repositories
without having to have a dedicated server.

Git for Windows v2.11.0 introduced a regression where pushing to said
UNC paths no longer works, although fetching and cloning still does, as
reported here: https://github.com/git-for-windows/git/issues/979

This regression was fixed in 7814fbe3f1 (normalize_path_copy(): fix
pushing to //server/share/dir on Windows, 2016-12-14).

Let's make sure that it does not regress again, by introducing a test
that uses so-called "administrative shares": disk volumes are
automatically shared under certain circumstances, e.g.  the C: drive is
shared as \\localhost\c$. The test needs to be skipped if the current
directory is inaccessible via said administrative share, of course.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agocontrib: remove gitview
Stefan Beller [Wed, 28 Dec 2016 17:28:37 +0000 (09:28 -0800)] 
contrib: remove gitview

gitview did not have meaningful contributions since 2007, which gives the
impression it is either a mature or dead project.

In both cases we should not carry it in git.git as the README for contrib
states we only want to carry experimental things to give early exposure.

Recently a security vulnerability was reported by Javantea, so the decision
to either fix the issue or remove the code in question becomes a bit
more urgent.

Reported-by: Javantea <jvoss@altsci.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
Acked-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agodon't use test_must_fail with grep
Pranit Bauva [Tue, 3 Jan 2017 19:57:07 +0000 (01:27 +0530)] 
don't use test_must_fail with grep

test_must_fail should only be used for testing git commands. To test the
failure of other commands use `!`.

Reported-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Pranit Bauva <pranit.bauva@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosubmodule.c: use GIT_DIR_ENVIRONMENT consistently
Stefan Beller [Tue, 3 Jan 2017 18:30:47 +0000 (10:30 -0800)] 
submodule.c: use GIT_DIR_ENVIRONMENT consistently

In C code we have the luxury of having constants for all the important
things that are hard coded. This is the only place in C that hard codes
the git directory environment variable, so fix it.

Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agogitk: ru.po: Update Russian translation
Dimitriy Ryazantcev [Wed, 14 Dec 2016 22:34:26 +0000 (00:34 +0200)] 
gitk: ru.po: Update Russian translation

Signed-off-by: Dimitriy Ryazantcev <dimitriy.ryazantcev@gmail.com>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
7 years agogit-p4: do not pass '-r 0' to p4 commands
Igor Kushnir [Thu, 29 Dec 2016 10:22:23 +0000 (12:22 +0200)] 
git-p4: do not pass '-r 0' to p4 commands

git-p4 crashes when used with a very old p4 client version
that does not support the '-r <number>' option in its commands.

Allow making git-p4 work with old p4 clients by setting git-p4.retries to 0.

Alternatively git-p4.retries could be made opt-in.
But since only very old, barely maintained p4 versions don't support
the '-r' option, the setting-retries-to-0 workaround would do.

The "-r retries" option is present in Perforce 2012.2 Command Reference,
but absent from Perforce 2012.1 Command Reference.

Signed-off-by: Igor Kushnir <igorkuo@gmail.com>
Acked-by: Lars Schneider <larsxschneider@gmail.com>
Reviewed-by: Luke Diamand <luke@diamand.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agorepack: die on incremental + write-bitmap-index
David Turner [Wed, 28 Dec 2016 22:45:42 +0000 (17:45 -0500)] 
repack: die on incremental + write-bitmap-index

The bitmap index only works for single packs, so requesting an
incremental repack with bitmap indexes makes no sense.

Signed-off-by: David Turner <dturner@twosigma.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoauto gc: don't write bitmaps for incremental repacks
David Turner [Wed, 28 Dec 2016 22:45:41 +0000 (17:45 -0500)] 
auto gc: don't write bitmaps for incremental repacks

When git gc --auto does an incremental repack of loose objects, we do
not expect to be able to write a bitmap; it is very likely that
objects in the new pack will have references to objects outside of the
pack.  So we shouldn't try to write a bitmap, because doing so will
likely issue a warning.

This warning was making its way into gc.log.  When the gc.log was
present, future auto gc runs would refuse to run.

Patch by Jeff King.
Bug report, test, and commit message by David Turner.

Signed-off-by: David Turner <dturner@twosigma.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'jc/retire-compaction-heuristics' into next
Junio C Hamano [Tue, 27 Dec 2016 23:00:31 +0000 (15:00 -0800)] 
Merge branch 'jc/retire-compaction-heuristics' into next

"git diff" and its family had two experimental heuristics to shift
the contents of a hunk to make the patch easier to read.  One of
them turns out to be better than the other, so leave only the
"--indent-heuristic" option and remove the other one.

* jc/retire-compaction-heuristics:
  diff: retire "compaction" heuristics

7 years agoMerge branch 'nd/config-misc-fixes' into next
Junio C Hamano [Tue, 27 Dec 2016 23:00:31 +0000 (15:00 -0800)] 
Merge branch 'nd/config-misc-fixes' into next

Leakage of lockfiles in the config subsystem has been fixed.

* nd/config-misc-fixes:
  config.c: handle lock file in error case in git_config_rename_...
  config.c: rename label unlock_and_out
  config.c: handle error case for fstat() calls

7 years agoMerge branch 'jc/abbrev-autoscale-config' into next
Junio C Hamano [Tue, 27 Dec 2016 23:00:31 +0000 (15:00 -0800)] 
Merge branch 'jc/abbrev-autoscale-config' into next

Recent update to the default abbreviation length that auto-scales
lacked documentation update, which has been corrected.

* jc/abbrev-autoscale-config:
  config.abbrev: document the new default that auto-scales

7 years agoMerge branch 'mh/fast-import-notes-fix-new' into next
Junio C Hamano [Tue, 27 Dec 2016 23:00:30 +0000 (15:00 -0800)] 
Merge branch 'mh/fast-import-notes-fix-new' into next

"git fast-import" sometimes mishandled while rebalancing notes
tree, which has been fixed.

* mh/fast-import-notes-fix-new:
  fast-import: properly fanout notes when tree is imported

7 years agoMerge branch 'jc/git-open-cloexec' into next
Junio C Hamano [Tue, 27 Dec 2016 23:00:30 +0000 (15:00 -0800)] 
Merge branch 'jc/git-open-cloexec' into next

The codeflow of setting NOATIME and CLOEXEC on file descriptors Git
opens has been simplified.

* jc/git-open-cloexec:
  sha1_file: stop opening files with O_NOATIME
  git_open_cloexec(): use fcntl(2) w/ FD_CLOEXEC fallback
  git_open(): untangle possible NOATIME and CLOEXEC interactions

7 years agoSync with master
Junio C Hamano [Tue, 27 Dec 2016 22:25:16 +0000 (14:25 -0800)] 
Sync with master

* master:
  Fourth batch for 2.12

7 years agorm: absorb a submodules git dir before deletion
Stefan Beller [Tue, 27 Dec 2016 19:03:14 +0000 (11:03 -0800)] 
rm: absorb a submodules git dir before deletion

When deleting a submodule, we need to keep the actual git directory around,
such that we do not lose local changes in there and at a later checkout
of the submodule we don't need to clone it again.

Now that the functionality is available to absorb the git directory of a
submodule, rewrite the checking in git-rm to not complain, but rather
relocate the git directories inside the superproject.

An alternative solution was discussed to have a function
`depopulate_submodule`. That would couple the check for its git directory
and possible relocation before the the removal, such that it is less
likely to miss the check in the future.  But the indirection with such
a function added seemed also complex. The reason for that was that this
possible move of the git directory was also implemented in
`ok_to_remove_submodule`, such that this function could truthfully
answer whether it is ok to remove the submodule.

The solution proposed here defers all these checks to the caller.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosubmodule: rename and add flags to ok_to_remove_submodule
Stefan Beller [Tue, 20 Dec 2016 23:20:11 +0000 (15:20 -0800)] 
submodule: rename and add flags to ok_to_remove_submodule

In different contexts the question "Is it ok to delete a submodule?"
may be answered differently.

In 293ab15eea (submodule: teach rm to remove submodules unless they
contain a git directory, 2012-09-26) a case was made that we can safely
ignore ignored untracked files for removal as we explicitely ask for the
removal of the submodule.

In a later patch we want to remove submodules even when the user doesn't
explicitly ask for it (e.g. checking out a tree-ish in which the submodule
doesn't exist).  In that case we want to be more careful when it comes
to deletion of untracked files. As of this patch it is unclear how this
will be implemented exactly, so we'll offer flags in which the caller
can specify how the different untracked files ought to be handled.

As the flags allow the function to not die on an error when spawning
a child process, we need to find an appropriate return code for the
case when the child process could not be started. As in that case we
cannot tell if the submodule is ok to remove, we'd want to return 'false'.

As only 0 is understood as false, rename the function to invert the
meaning, i.e. the return code of 0 signals the removal of the submodule
is fine, and other values can be used to return a more precise answer
what went wrong.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosubmodule: modernize ok_to_remove_submodule to use argv_array
Stefan Beller [Tue, 20 Dec 2016 23:20:10 +0000 (15:20 -0800)] 
submodule: modernize ok_to_remove_submodule to use argv_array

Instead of constructing the NULL terminated array ourselves, we
should make use of the argv_array infrastructure.

While at it, adapt the error messages to reflect the actual invocation.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosubmodule.h: add extern keyword to functions
Stefan Beller [Tue, 20 Dec 2016 23:20:09 +0000 (15:20 -0800)] 
submodule.h: add extern keyword to functions

As the upcoming series will add a lot of functions to the submodule
header, let's first make the header consistent to the rest of the project
by adding the extern keyword to functions.

As per the CodingGuidelines we try to stay below 80 characters per line,
so adapt all those functions to stay below 80 characters that are already
using more than one line.  Those function using just one line are better
kept in one line than breaking them up into multiple lines just for the
goal of staying below the character limit as it makes grepping
for functions easier if they are one liners.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'sb/submodule-embed-gitdir' into next
Junio C Hamano [Tue, 27 Dec 2016 22:00:54 +0000 (14:00 -0800)] 
Merge branch 'sb/submodule-embed-gitdir' into next

A new submodule helper "git submodule embedgitdirs" to make it
easier to move embedded .git/ directory for submodules in a
superproject to .git/modules/ (and point the latter with the former
that is turned into a "gitdir:" file) has been added.

* sb/submodule-embed-gitdir:
  worktree: initialize return value for submodule_uses_worktrees

7 years agoworktree: initialize return value for submodule_uses_worktrees
Stefan Beller [Tue, 27 Dec 2016 17:50:13 +0000 (09:50 -0800)] 
worktree: initialize return value for submodule_uses_worktrees

When the worktrees directory is empty, the `ret` will be returned
uninitialized. Fix it by initializing the value.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'jc/lock-report-on-error' into next
Junio C Hamano [Tue, 27 Dec 2016 21:41:06 +0000 (13:41 -0800)] 
Merge branch 'jc/lock-report-on-error' into next

Git 2.11 had a minor regression in "merge --ff-only" that competed
with another process that simultanously attempted to update the
index. We used to explain what went wrong with an error message,
but the new code silently failed.  The error message has been
resurrected.

* jc/lock-report-on-error:
  lockfile: move REPORT_ON_ERROR bit elsewhere

7 years agoFourth batch for 2.12
Junio C Hamano [Tue, 27 Dec 2016 17:17:51 +0000 (09:17 -0800)] 
Fourth batch for 2.12

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'jc/lock-report-on-error'
Junio C Hamano [Tue, 27 Dec 2016 17:17:32 +0000 (09:17 -0800)] 
Merge branch 'jc/lock-report-on-error'

* jc/lock-report-on-error:
  lockfile: move REPORT_ON_ERROR bit elsewhere

7 years agolockfile: move REPORT_ON_ERROR bit elsewhere
Junio C Hamano [Tue, 27 Dec 2016 17:12:09 +0000 (09:12 -0800)] 
lockfile: move REPORT_ON_ERROR bit elsewhere

There was LOCK_NO_DEREF defined as 2 = 1<<1 with the same value,
which was missed due to a huge comment block.  Deconflict by moving
the new one to 4 = 1<<2 for now.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'js/mingw-isatty'
Junio C Hamano [Tue, 27 Dec 2016 08:11:46 +0000 (00:11 -0800)] 
Merge branch 'js/mingw-isatty'

Update the isatty() emulation for Windows by updating the previous
hack that depended on internals of (older) MSVC runtime.

* js/mingw-isatty:
  mingw: replace isatty() hack
  mingw: fix colourization on Cygwin pseudo terminals
  mingw: adjust is_console() to work with stdin

7 years agoMerge branch 'ls/p4-lfs'
Junio C Hamano [Tue, 27 Dec 2016 08:11:46 +0000 (00:11 -0800)] 
Merge branch 'ls/p4-lfs'

Update GitLFS integration with "git p4".

* ls/p4-lfs:
  git-p4: add diff/merge properties to .gitattributes for GitLFS files

7 years agoMerge branch 'va/i18n-even-more'
Junio C Hamano [Tue, 27 Dec 2016 08:11:45 +0000 (00:11 -0800)] 
Merge branch 'va/i18n-even-more'

* va/i18n-even-more:
  i18n: fix misconversion in shell scripts

7 years agoMerge branch 'lt/shortlog-by-committer'
Junio C Hamano [Tue, 27 Dec 2016 08:11:44 +0000 (00:11 -0800)] 
Merge branch 'lt/shortlog-by-committer'

"git shortlog" learned "--committer" option to group commits by
committer, instead of author.

* lt/shortlog-by-committer:
  t4201: make tests work with and without the MINGW prerequiste
  shortlog: test and document --committer option
  shortlog: group by committer information

7 years agoMerge branch 'mk/mingw-winansi-ttyname-termination-fix'
Junio C Hamano [Tue, 27 Dec 2016 08:11:44 +0000 (00:11 -0800)] 
Merge branch 'mk/mingw-winansi-ttyname-termination-fix'

A potential but unlikely buffer overflow in Windows port has been
fixed.

* mk/mingw-winansi-ttyname-termination-fix:
  mingw: consider that UNICODE_STRING::Length counts bytes

7 years agoMerge branch 'gv/p4-multi-path-commit-fix'
Junio C Hamano [Tue, 27 Dec 2016 08:11:43 +0000 (00:11 -0800)] 
Merge branch 'gv/p4-multi-path-commit-fix'

"git p4" that tracks multile p4 paths imported a single changelist
that touches files in these multiple paths as one commit, followed
by many empty commits.  This has been fixed.

* gv/p4-multi-path-commit-fix:
  git-p4: fix multi-path changelist empty commits

7 years agoMerge branch 'jk/difftool-in-subdir'
Junio C Hamano [Tue, 27 Dec 2016 08:11:43 +0000 (00:11 -0800)] 
Merge branch 'jk/difftool-in-subdir'

Even though an fix was attempted in Git 2.9.3 days, but running
"git difftool --dir-diff" from a subdirectory never worked. This
has been fixed.

* jk/difftool-in-subdir:
  difftool: rename variables for consistency
  difftool: chdir as early as possible
  difftool: sanitize $workdir as early as possible
  difftool: fix dir-diff index creation when in a subdirectory

7 years agoMerge branch 'ld/p4-compare-dir-vs-symlink'
Junio C Hamano [Tue, 27 Dec 2016 08:11:42 +0000 (00:11 -0800)] 
Merge branch 'ld/p4-compare-dir-vs-symlink'

"git p4" misbehaved when swapping a directory and a symbolic link.

* ld/p4-compare-dir-vs-symlink:
  git-p4: avoid crash adding symlinked directory

7 years agoMerge branch 'ls/filter-process'
Junio C Hamano [Tue, 27 Dec 2016 08:11:42 +0000 (00:11 -0800)] 
Merge branch 'ls/filter-process'

Doc update.

* ls/filter-process:
  t0021: fix flaky test
  docs: warn about possible '=' in clean/smudge filter process values

7 years agoMerge branch 'bw/transport-protocol-policy'
Junio C Hamano [Tue, 27 Dec 2016 08:11:41 +0000 (00:11 -0800)] 
Merge branch 'bw/transport-protocol-policy'

Finer-grained control of what protocols are allowed for transports
during clone/fetch/push have been enabled via a new configuration
mechanism.

* bw/transport-protocol-policy:
  http: respect protocol.*.allow=user for http-alternates
  transport: add from_user parameter to is_transport_allowed
  http: create function to get curl allowed protocols
  transport: add protocol policy config option
  http: always warn if libcurl version is too old
  lib-proto-disable: variable name fix