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

Code clean-up in the pathspec API.

* bw/pathspec-cleanup:
  pathspec: rename prefix_pathspec to init_pathspec_item
  pathspec: small readability changes
  pathspec: create strip submodule slash helpers
  pathspec: create parse_element_magic helper
  pathspec: create parse_long_magic function
  pathspec: create parse_short_magic function
  pathspec: factor global magic into its own function
  pathspec: simpler logic to prefix original pathspec elements
  pathspec: always show mnemonic and name in unsupported_magic
  pathspec: remove unused variable from unsupported_magic
  pathspec: copy and free owned memory
  pathspec: remove the deprecated get_pathspec function
  ls-tree: convert show_recursive to use the pathspec struct interface
  dir: convert fill_directory to use the pathspec struct interface
  dir: remove struct path_simplify
  mv: remove use of deprecated 'get_pathspec()'

7 years agoMerge branch 'js/mingw-test-push-unc-path' into next
Junio C Hamano [Tue, 10 Jan 2017 23:27:33 +0000 (15:27 -0800)] 
Merge branch 'js/mingw-test-push-unc-path' into next

"git push \\server\share\dir" has recently regressed and then
fixed.  A test has retroactively been added for this breakage.

* js/mingw-test-push-unc-path:
  mingw: add a regression test for pushing to UNC paths

7 years agoMerge branch 'sb/submodule-cleanup-export-git-dir-env' into next
Junio C Hamano [Tue, 10 Jan 2017 23:27:33 +0000 (15:27 -0800)] 
Merge branch 'sb/submodule-cleanup-export-git-dir-env' into next

Code cleanup.

* sb/submodule-cleanup-export-git-dir-env:
  submodule.c: use GIT_DIR_ENVIRONMENT consistently

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

* sb/remove-gitview:
  contrib: remove gitview

7 years agoMerge branch 'km/branch-get-push-while-detached' into next
Junio C Hamano [Tue, 10 Jan 2017 23:27:32 +0000 (15:27 -0800)] 
Merge branch 'km/branch-get-push-while-detached' into next

"git <cmd> @{push}" on a detached HEAD used to segfault; it has
been corrected to error out with a message.

* km/branch-get-push-while-detached:
  branch_get_push: do not segfault when HEAD is detached

7 years agoMerge branch 'jk/rebase-i-squash-count-fix' into next
Junio C Hamano [Tue, 10 Jan 2017 23:27:31 +0000 (15:27 -0800)] 
Merge branch 'jk/rebase-i-squash-count-fix' into next

"git rebase -i" with a recent update started showing an incorrect
count when squashing more than 10 commits.

* jk/rebase-i-squash-count-fix:
  rebase--interactive: count squash commits above 10 correctly

7 years agoMerge branch 'jk/blame-fixes' into next
Junio C Hamano [Tue, 10 Jan 2017 23:27:31 +0000 (15:27 -0800)] 
Merge branch 'jk/blame-fixes' into next

"git blame --porcelain" misidentified the "previous" <commit, path>
pair (aka "source") when contents came from two or more files.

* jk/blame-fixes:
  blame: output porcelain "previous" header for each file
  blame: handle --no-abbrev
  blame: fix alignment with --abbrev=40

7 years agoMerge branch 'jk/archive-zip-userdiff-config' into next
Junio C Hamano [Tue, 10 Jan 2017 23:27:31 +0000 (15:27 -0800)] 
Merge branch 'jk/archive-zip-userdiff-config' into next

"git archive" did not read the standard configuration files, and
failed to notice a file that is marked as binary via the userdiff
driver configuration.

* jk/archive-zip-userdiff-config:
  archive-zip: load userdiff config

7 years agoMerge branch 'dt/disable-bitmap-in-auto-gc' into next
Junio C Hamano [Tue, 10 Jan 2017 23:27:30 +0000 (15:27 -0800)] 
Merge branch 'dt/disable-bitmap-in-auto-gc' into next

It is natural that "git gc --auto" may not attempt to pack
everything into a single pack, and there is no point in warning
when the user has configured the system to use the pack bitmap,
leading to disabling further "gc".

* dt/disable-bitmap-in-auto-gc:
  repack: die on incremental + write-bitmap-index
  auto gc: don't write bitmaps for incremental repacks

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 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 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 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 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 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

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

"git merge --continue" has been added as a synonym to "git commit"
to conclude a merge that has stopped due to conflicts.

* cp/merge-continue:
  merge: mark usage error strings for translation
  merge: ensure '--abort' option takes no arguments
  completion: add --continue option for merge
  merge: add '--continue' option as a synonym for 'git commit'

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

Porcelain scripts written in Perl are getting internationalized.

* va/i18n-perl-scripts:
  i18n: difftool: mark warnings for translation
  i18n: send-email: mark composing message for translation
  i18n: send-email: mark string with interpolation for translation
  i18n: send-email: mark warnings and errors for translation
  i18n: send-email: mark strings for translation
  i18n: add--interactive: mark status words for translation
  i18n: add--interactive: remove %patch_modes entries
  i18n: add--interactive: mark edit_hunk_manually message for translation
  i18n: add--interactive: i18n of help_patch_cmd
  i18n: add--interactive: mark patch prompt for translation
  i18n: add--interactive: mark plural strings
  i18n: clean.c: match string with git-add--interactive.perl
  i18n: add--interactive: mark strings with interpolation for translation
  i18n: add--interactive: mark simple here-documents for translation
  i18n: add--interactive: mark strings for translation
  Git.pm: add subroutines for commenting lines

7 years agoMerge branch 'sb/submodule-config-cleanup'
Junio C Hamano [Tue, 27 Dec 2016 08:11:40 +0000 (00:11 -0800)] 
Merge branch 'sb/submodule-config-cleanup'

Minor code clean-up.

* sb/submodule-config-cleanup:
  submodule-config: clarify parsing of null_sha1 element
  submodule-config: rename commit_sha1 to treeish_name
  submodule config: inline config_from_{name, path}

7 years agoMerge branch 'jc/push-default-explicit'
Junio C Hamano [Tue, 27 Dec 2016 08:11:40 +0000 (00:11 -0800)] 
Merge branch 'jc/push-default-explicit'

A lazy "git push" without refspec did not internally use a fully
specified refspec to perform 'current', 'simple', or 'upstream'
push, causing unnecessary "ambiguous ref" errors.

* jc/push-default-explicit:
  push: test pushing ambiguously named branches
  push: do not use potentially ambiguous default refspec

7 years agodiff: retire "compaction" heuristics
Junio C Hamano [Fri, 23 Dec 2016 20:32:22 +0000 (12:32 -0800)] 
diff: retire "compaction" heuristics

When a patch inserts a block of lines, whose last lines are the
same as the existing lines that appear before the inserted block,
"git diff" can choose any place between these existing lines as the
boundary between the pre-context and the added lines (adjusting the
end of the inserted block as appropriate) to come up with variants
of the same patch, and some variants are easier to read than others.

We have been trying to improve the choice of this boundary, and Git
2.11 shipped with an experimental "compaction-heuristic".  Since
then another attempt to improve the logic further resulted in a new
"indent-heuristic" logic.  It is agreed that the latter gives better
result overall, and the former outlived its usefulness.

Retire "compaction", and keep "indent" as an experimental feature.
The latter hopefully will be turned on by default in a future
release, but that should be done as a separate step.

Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoconfig.abbrev: document the new default that auto-scales
Junio C Hamano [Wed, 2 Nov 2016 01:34:07 +0000 (18:34 -0700)] 
config.abbrev: document the new default that auto-scales

We somehow forgot to update the "default is 7" in the
documentation.  Also give a way to explicitly ask the auto-scaling
by setting config.abbrev to "auto".

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoconfig.c: handle lock file in error case in git_config_rename_...
Nguyễn Thái Ngọc Duy [Tue, 20 Dec 2016 09:48:36 +0000 (16:48 +0700)] 
config.c: handle lock file in error case in git_config_rename_...

We could rely on atexit() to clean up everything, but let's be
explicit when we can. And it's good anyway because the function is
called the second time in the same process, we're in trouble.

This function should not affect the successful case because after
commit_lock_file() is called, rollback_lock_file() becomes no-op,
as long as it is initialized.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'bw/grep-recurse-submodules' into next
Junio C Hamano [Thu, 22 Dec 2016 20:09:53 +0000 (12:09 -0800)] 
Merge branch 'bw/grep-recurse-submodules' into next

"git grep" learns to optionally recurse into submodules.

* bw/grep-recurse-submodules:
  grep: search history of moved submodules
  grep: enable recurse-submodules to work on <tree> objects
  grep: optionally recurse into submodules
  grep: add submodules as a grep source type
  submodules: load gitmodules file from commit sha1
  submodules: add helper to determine if a submodule is initialized
  submodules: add helper to determine if a submodule is populated

7 years agoMerge branch 'bw/realpath-wo-chdir' into next
Junio C Hamano [Thu, 22 Dec 2016 20:09:52 +0000 (12:09 -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: canonicalize directory separators in root parts
  real_path: have callers use real_pathdup and strbuf_realpath
  real_path: create real_pathdup
  real_path: convert real_path_internal to strbuf_realpath
  real_path: resolve symlinks by hand

7 years agoMerge branch 'va/i18n-even-more' into next
Junio C Hamano [Thu, 22 Dec 2016 20:09:52 +0000 (12:09 -0800)] 
Merge branch 'va/i18n-even-more' into next

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

7 years agoMerge branch 'ls/p4-lfs' into next
Junio C Hamano [Thu, 22 Dec 2016 20:09:50 +0000 (12:09 -0800)] 
Merge branch 'ls/p4-lfs' into next

Update GitLFS integration with "git p4".

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

7 years agoMerge branch 'js/mingw-isatty' into next
Junio C Hamano [Thu, 22 Dec 2016 20:09:48 +0000 (12:09 -0800)] 
Merge branch 'js/mingw-isatty' into next

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 agogrep: search history of moved submodules
Brandon Williams [Fri, 16 Dec 2016 19:03:22 +0000 (11:03 -0800)] 
grep: search history of moved submodules

If a submodule was renamed at any point since it's inception then if you
were to try and grep on a commit prior to the submodule being moved, you
wouldn't be able to find a working directory for the submodule since the
path in the past is different from the current path.

This patch teaches grep to find the .git directory for a submodule in
the parents .git/modules/ directory in the event the path to the
submodule in the commit that is being searched differs from the state of
the currently checked out commit.  If found, the child process that is
spawned to grep the submodule will chdir into its gitdir instead of a
working directory.

In order to override the explicit setting of submodule child process's
gitdir environment variable (which was introduced in '10f5c526')
`GIT_DIR_ENVIORMENT` needs to be pushed onto child process's env_array.
This allows the searching of history from a submodule's gitdir, rather
than from a working directory.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agogrep: enable recurse-submodules to work on <tree> objects
Brandon Williams [Fri, 16 Dec 2016 19:03:21 +0000 (11:03 -0800)] 
grep: enable recurse-submodules to work on <tree> objects

Teach grep to recursively search in submodules when provided with a
<tree> object. This allows grep to search a submodule based on the state
of the submodule that is present in a commit of the super project.

When grep is provided with a <tree> object, the name of the object is
prefixed to all output.  In order to provide uniformity of output
between the parent and child processes the option `--parent-basename`
has been added so that the child can preface all of it's output with the
name of the parent's object instead of the name of the commit SHA1 of
the submodule. This changes output from the command
`git grep -e. -l --recurse-submodules HEAD` from:

      HEAD:file
      <commit sha1 of submodule>:sub/file

to:

      HEAD:file
      HEAD:sub/file

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agogrep: optionally recurse into submodules
Brandon Williams [Fri, 16 Dec 2016 19:03:20 +0000 (11:03 -0800)] 
grep: optionally recurse into submodules

Allow grep to recognize submodules and recursively search for patterns in
each submodule.  This is done by forking off a process to recursively
call grep on each submodule.  The top level --super-prefix option is
used to pass a path to the submodule which can in turn be used to
prepend to output or in pathspec matching logic.

Recursion only occurs for submodules which have been initialized and
checked out by the parent project.  If a submodule hasn't been
initialized and checked out it is simply skipped.

In order to support the existing multi-threading infrastructure in grep,
output from each child process is captured in a strbuf so that it can be
later printed to the console in an ordered fashion.

To limit the number of theads that are created, each child process has
half the number of threads as its parents (minimum of 1), otherwise we
potentailly have a fork-bomb.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agogrep: add submodules as a grep source type
Brandon Williams [Fri, 16 Dec 2016 19:03:19 +0000 (11:03 -0800)] 
grep: add submodules as a grep source type

Add `GREP_SOURCE_SUBMODULE` as a grep_source type and cases for this new
type in the various switch statements in grep.c.

When initializing a grep_source with type `GREP_SOURCE_SUBMODULE` the
identifier can either be NULL (to indicate that the working tree will be
used) or a SHA1 (the REV of the submodule to be grep'd).  If the
identifier is a SHA1 then we want to fall through to the
`GREP_SOURCE_SHA1` case to handle the copying of the SHA1.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosubmodules: load gitmodules file from commit sha1
Brandon Williams [Fri, 16 Dec 2016 19:03:18 +0000 (11:03 -0800)] 
submodules: load gitmodules file from commit sha1

teach submodules to load a '.gitmodules' file from a commit sha1.  This
enables the population of the submodule_cache to be based on the state
of the '.gitmodules' file from a particular commit.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosubmodules: add helper to determine if a submodule is initialized
Brandon Williams [Fri, 16 Dec 2016 19:03:17 +0000 (11:03 -0800)] 
submodules: add helper to determine if a submodule is initialized

Add the `is_submodule_initialized()` helper function to submodules.c.
`is_submodule_initialized()` performs a check to determine if the
submodule at the given path has been initialized.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>