OSDN Git Service

git-core/git.git
7 years agoGit 2.11.2 v2.11.2
Junio C Hamano [Fri, 5 May 2017 04:29:43 +0000 (13:29 +0900)]
Git 2.11.2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'maint-2.10' into maint-2.11
Junio C Hamano [Fri, 5 May 2017 04:26:31 +0000 (13:26 +0900)]
Merge branch 'maint-2.10' into maint-2.11

7 years agoGit 2.10.3 v2.10.3
Junio C Hamano [Fri, 5 May 2017 04:24:10 +0000 (13:24 +0900)]
Git 2.10.3

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'maint-2.9' into maint-2.10
Junio C Hamano [Fri, 5 May 2017 04:21:52 +0000 (13:21 +0900)]
Merge branch 'maint-2.9' into maint-2.10

7 years agoGit 2.9.4 v2.9.4
Junio C Hamano [Fri, 5 May 2017 04:18:23 +0000 (13:18 +0900)]
Git 2.9.4

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'maint-2.8' into maint-2.9
Junio C Hamano [Fri, 5 May 2017 04:13:48 +0000 (13:13 +0900)]
Merge branch 'maint-2.8' into maint-2.9

7 years agoGit 2.8.5 v2.8.5
Junio C Hamano [Fri, 5 May 2017 04:08:54 +0000 (13:08 +0900)]
Git 2.8.5

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'maint-2.7' into maint-2.8
Junio C Hamano [Fri, 5 May 2017 04:05:03 +0000 (13:05 +0900)]
Merge branch 'maint-2.7' into maint-2.8

7 years agoGit 2.7.5 v2.7.5
Junio C Hamano [Fri, 5 May 2017 04:03:40 +0000 (13:03 +0900)]
Git 2.7.5

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'maint-2.6' into maint-2.7
Junio C Hamano [Fri, 5 May 2017 03:59:16 +0000 (12:59 +0900)]
Merge branch 'maint-2.6' into maint-2.7

7 years agoGit 2.6.7 v2.6.7
Junio C Hamano [Fri, 5 May 2017 03:56:19 +0000 (12:56 +0900)]
Git 2.6.7

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'maint-2.5' into maint-2.6
Junio C Hamano [Fri, 5 May 2017 03:52:26 +0000 (12:52 +0900)]
Merge branch 'maint-2.5' into maint-2.6

7 years agoGit 2.5.6 v2.5.6
Junio C Hamano [Fri, 5 May 2017 03:49:00 +0000 (12:49 +0900)]
Git 2.5.6

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'maint-2.4' into maint-2.5
Junio C Hamano [Fri, 5 May 2017 03:46:53 +0000 (12:46 +0900)]
Merge branch 'maint-2.4' into maint-2.5

7 years agoGit 2.4.12 v2.4.12
Junio C Hamano [Fri, 5 May 2017 03:25:09 +0000 (12:25 +0900)]
Git 2.4.12

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'jk/shell-no-repository-that-begins-with-dash' into maint-2.4
Junio C Hamano [Fri, 5 May 2017 03:17:55 +0000 (12:17 +0900)]
Merge branch 'jk/shell-no-repository-that-begins-with-dash' into maint-2.4

* jk/shell-no-repository-that-begins-with-dash:
  shell: disallow repo names beginning with dash

7 years agoshell: disallow repo names beginning with dash
Jeff King [Sat, 29 Apr 2017 12:36:44 +0000 (08:36 -0400)]
shell: disallow repo names beginning with dash

When a remote server uses git-shell, the client side will
connect to it like:

  ssh server "git-upload-pack 'foo.git'"

and we literally exec ("git-upload-pack", "foo.git"). In
early versions of upload-pack and receive-pack, we took a
repository argument and nothing else. But over time they
learned to accept dashed options. If the user passes a
repository name that starts with a dash, the results are
confusing at best (we complain of a bogus option instead of
a non-existent repository) and malicious at worst (the user
can start an interactive pager via "--help").

We could pass "--" to the sub-process to make sure the
user's argument is interpreted as a branch name. I.e.:

  git-upload-pack -- -foo.git

But adding "--" automatically would make us inconsistent
with a normal shell (i.e., when git-shell is not in use),
where "-foo.git" would still be an error. For that case, the
client would have to specify the "--", but they can't do so
reliably, as existing versions of git-shell do not allow
more than a single argument.

The simplest thing is to simply disallow "-" at the start of
the repo name argument. This hasn't worked either with or
without git-shell since version 1.0.0, and nobody has
complained.

Note that this patch just applies to do_generic_cmd(), which
runs upload-pack, receive-pack, and upload-archive. There
are two other types of commands that git-shell runs:

  - do_cvs_cmd(), but this already restricts the argument to
    be the literal string "server"

  - admin-provided commands in the git-shell-commands
    directory. We'll pass along arbitrary arguments there,
    so these commands could have similar problems. But these
    commands might actually understand dashed arguments, so
    we cannot just block them here. It's up to the writer of
    the commands to make sure they are safe. With great
    power comes great responsibility.

Reported-by: Timo Schmid <tschmid@ernw.de>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoGit 2.11.1 v2.11.1
Junio C Hamano [Thu, 2 Feb 2017 21:21:27 +0000 (13:21 -0800)]
Git 2.11.1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'ws/request-pull-code-cleanup' into maint
Junio C Hamano [Thu, 2 Feb 2017 21:20:30 +0000 (13:20 -0800)]
Merge branch 'ws/request-pull-code-cleanup' into maint

Code clean-up.

* ws/request-pull-code-cleanup:
  request-pull: drop old USAGE stuff

7 years agoMerge branch 'jk/execv-dashed-external' into maint
Junio C Hamano [Thu, 2 Feb 2017 21:20:29 +0000 (13:20 -0800)]
Merge branch 'jk/execv-dashed-external' into maint

Typing ^C to pager, which usually does not kill it, killed Git and
took the pager down as a collateral damage in certain process-tree
structure.  This has been fixed.

* jk/execv-dashed-external:
  execv_dashed_external: wait for child on signal death
  execv_dashed_external: stop exiting with negative code
  execv_dashed_external: use child_process struct

7 years agoReady for 2.11.1
Junio C Hamano [Tue, 31 Jan 2017 21:34:48 +0000 (13:34 -0800)]
Ready for 2.11.1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'sb/in-core-index-doc' into maint
Junio C Hamano [Tue, 31 Jan 2017 21:32:11 +0000 (13:32 -0800)]
Merge branch 'sb/in-core-index-doc' into maint

Documentation and in-code comments updates.

* sb/in-core-index-doc:
  documentation: retire unfinished documentation
  cache.h: document add_[file_]to_index
  cache.h: document remove_index_entry_at
  cache.h: document index_name_pos

7 years agoMerge branch 'js/mingw-isatty' into maint
Junio C Hamano [Tue, 31 Jan 2017 21:32:11 +0000 (13:32 -0800)]
Merge branch 'js/mingw-isatty' into maint

An update to a topic that is already in 'master'.

* js/mingw-isatty:
  mingw: follow-up to "replace isatty() hack"

7 years agoMerge branch 'jk/coding-guidelines-update' into maint
Junio C Hamano [Tue, 31 Jan 2017 21:32:11 +0000 (13:32 -0800)]
Merge branch 'jk/coding-guidelines-update' into maint

Developer doc update.

* jk/coding-guidelines-update:
  CodingGuidelines: clarify multi-line brace style

7 years agoMerge branch 'js/exec-path-coverity-workaround' into maint
Junio C Hamano [Tue, 31 Jan 2017 21:32:10 +0000 (13:32 -0800)]
Merge branch 'js/exec-path-coverity-workaround' into maint

Code cleanup.

* js/exec-path-coverity-workaround:
  git_exec_path: do not return the result of getenv()
  git_exec_path: avoid Coverity warning about unfree()d result

7 years agoMerge branch 'ad/bisect-terms' into maint
Junio C Hamano [Tue, 31 Jan 2017 21:32:10 +0000 (13:32 -0800)]
Merge branch 'ad/bisect-terms' into maint

Documentation fix.

* ad/bisect-terms:
  Documentation/bisect: improve on (bad|new) and (good|bad)

7 years agoMerge branch 'jk/grep-e-could-be-extended-beyond-posix' into maint
Junio C Hamano [Tue, 31 Jan 2017 21:32:09 +0000 (13:32 -0800)]
Merge branch 'jk/grep-e-could-be-extended-beyond-posix' into maint

Tighten a test to avoid mistaking an extended ERE regexp engine as
a PRE regexp engine.

* jk/grep-e-could-be-extended-beyond-posix:
  t7810: avoid assumption about invalid regex syntax

7 years agoMerge branch 'km/branch-get-push-while-detached' into maint
Junio C Hamano [Tue, 31 Jan 2017 21:32:08 +0000 (13:32 -0800)]
Merge branch 'km/branch-get-push-while-detached' into maint

"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 maint
Junio C Hamano [Tue, 31 Jan 2017 21:32:07 +0000 (13:32 -0800)]
Merge branch 'jk/rebase-i-squash-count-fix' into maint

"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 maint
Junio C Hamano [Tue, 31 Jan 2017 21:32:07 +0000 (13:32 -0800)]
Merge branch 'jk/blame-fixes' into maint

"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 maint
Junio C Hamano [Tue, 31 Jan 2017 21:32:07 +0000 (13:32 -0800)]
Merge branch 'jk/archive-zip-userdiff-config' into maint

"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 maint
Junio C Hamano [Tue, 31 Jan 2017 21:32:06 +0000 (13:32 -0800)]
Merge branch 'dt/disable-bitmap-in-auto-gc' into maint

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 'nd/config-misc-fixes' into maint
Junio C Hamano [Tue, 31 Jan 2017 21:32:06 +0000 (13:32 -0800)]
Merge branch 'nd/config-misc-fixes' into maint

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 maint
Junio C Hamano [Tue, 31 Jan 2017 21:32:06 +0000 (13:32 -0800)]
Merge branch 'jc/abbrev-autoscale-config' into maint

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 maint
Junio C Hamano [Tue, 31 Jan 2017 21:32:05 +0000 (13:32 -0800)]
Merge branch 'mh/fast-import-notes-fix-new' into maint

"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/compression-config' into maint
Junio C Hamano [Tue, 31 Jan 2017 21:32:05 +0000 (13:32 -0800)]
Merge branch 'jc/compression-config' into maint

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 'ew/svn-fixes' into maint
Junio C Hamano [Tue, 31 Jan 2017 21:32:05 +0000 (13:32 -0800)]
Merge branch 'ew/svn-fixes' into maint

Meant eventually for 'maint'.

* ew/svn-fixes:
  git-svn: document useLogAuthor and addAuthorFrom config keys
  git-svn: allow "0" in SVN path components

7 years agoMerge branch 'ls/travis-p4-on-macos' into maint
Junio C Hamano [Tue, 31 Jan 2017 21:32:04 +0000 (13:32 -0800)]
Merge branch 'ls/travis-p4-on-macos' into maint

Update the definition of the MacOSX test environment used by
TravisCI.

* ls/travis-p4-on-macos:
  travis-ci: fix Perforce install on macOS

7 years agoMerge branch 'jk/make-tags-find-sources-tweak' into maint
Junio C Hamano [Tue, 31 Jan 2017 21:32:04 +0000 (13:32 -0800)]
Merge branch 'jk/make-tags-find-sources-tweak' into maint

Update the procedure to generate "tags" for developer support.

* jk/make-tags-find-sources-tweak:
  Makefile: exclude contrib from FIND_SOURCE_FILES
  Makefile: match shell scripts in FIND_SOURCE_FILES
  Makefile: exclude test cruft from FIND_SOURCE_FILES
  Makefile: reformat FIND_SOURCE_FILES

7 years agoMerge branch 'jc/latin-1' into maint
Junio C Hamano [Tue, 31 Jan 2017 21:32:04 +0000 (13:32 -0800)]
Merge branch 'jc/latin-1' into maint

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 agotravis-ci: fix Perforce install on macOS
Lars Schneider [Sun, 22 Jan 2017 22:55:50 +0000 (23:55 +0100)]
travis-ci: fix Perforce install on macOS

The `perforce` and `perforce-server` package were moved from brew [1][2]
to cask [3]. Teach TravisCI the new location.

Perforce updates their binaries without version bumps. That made the
brew install (legitimately!) fail due to checksum mismatches. The
workaround is not necessary anymore as Cask [4] allows to disable the
checksum test for individual formulas.

[1] https://github.com/Homebrew/homebrew-binary/commit/1394e42de04d07445f82f9512627e864ff4ca4c6
[2] https://github.com/Homebrew/homebrew-binary/commit/f8da22d6b8dbcfcfdb2dfa9ac1a5e5d8e05aac2b
[3] https://github.com/caskroom/homebrew-cask/pull/29180
[4] https://caskroom.github.io/

Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agodocumentation: retire unfinished documentation
Stefan Beller [Thu, 19 Jan 2017 03:18:54 +0000 (19:18 -0800)]
documentation: retire unfinished documentation

When looking for documentation for a specific function, you may be tempted
to run

  git -C Documentation grep index_name_pos

only to find the file technical/api-in-core-index.txt, which doesn't
help for understanding the given function. It would be better to not find
these functions in the documentation, such that people directly dive into
the code instead.

In the previous patches we have documented
* index_name_pos()
* remove_index_entry_at()
* add_[file_]to_index()
in cache.h

We already have documentation for:
* add_index_entry()
* read_index()

Which leaves us with a TODO for:
* cache -> the_index macros
* refresh_index()
* discard_index()
* ie_match_stat() and ie_modified(); how they are different and when to
  use which.
* write_index() that was renamed to write_locked_index
* cache_tree_invalidate_path()
* cache_tree_update()

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agocache.h: document add_[file_]to_index
Stefan Beller [Thu, 19 Jan 2017 03:18:53 +0000 (19:18 -0800)]
cache.h: document add_[file_]to_index

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 agocache.h: document remove_index_entry_at
Stefan Beller [Thu, 19 Jan 2017 03:18:52 +0000 (19:18 -0800)]
cache.h: document remove_index_entry_at

Do this by moving the existing documentation from
read-cache.c to cache.h.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agocache.h: document index_name_pos
Stefan Beller [Thu, 19 Jan 2017 03:18:51 +0000 (19:18 -0800)]
cache.h: document index_name_pos

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agomingw: follow-up to "replace isatty() hack"
Johannes Schindelin [Wed, 18 Jan 2017 12:14:35 +0000 (13:14 +0100)]
mingw: follow-up to "replace isatty() hack"

The version of the "replace isatty() hack" that got merged a few
weeks ago did not actually reflect the latest iteration of the patch
series: v3 was sent out with these changes, as requested by the
reviewer Johannes Sixt:

- reworded the comment about "recycling handles"

- moved the reassignment of the `console` variable before the dup2()
  call so that it is valid at all times

- removed the "handle = INVALID_HANDLE_VALUE" assignment, as the local
  variable `handle` is not used afterwards anyway

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Reviewed-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoAlmost ready for 2.11.1
Junio C Hamano [Tue, 17 Jan 2017 22:48:44 +0000 (14:48 -0800)]
Almost ready for 2.11.1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'mm/gc-safety-doc' into maint
Junio C Hamano [Tue, 17 Jan 2017 23:19:11 +0000 (15:19 -0800)]
Merge branch 'mm/gc-safety-doc' into maint

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' into maint
Junio C Hamano [Tue, 17 Jan 2017 23:19:10 +0000 (15:19 -0800)]
Merge branch 'mm/push-social-engineering-attack-doc' into maint

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' into maint
Junio C Hamano [Tue, 17 Jan 2017 23:19:09 +0000 (15:19 -0800)]
Merge branch 'jt/fetch-no-redundant-tag-fetch-map' into maint

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 'ls/filter-process' into maint
Junio C Hamano [Tue, 17 Jan 2017 23:19:08 +0000 (15:19 -0800)]
Merge branch 'ls/filter-process' into maint

Doc update.

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

7 years agoMerge branch 'kh/tutorial-grammofix' into maint
Junio C Hamano [Tue, 17 Jan 2017 23:19:08 +0000 (15:19 -0800)]
Merge branch 'kh/tutorial-grammofix' into maint

* kh/tutorial-grammofix:
  doc: omit needless "for"
  doc: make the intent of sentence clearer
  doc: add verb in front of command to run
  doc: add articles (grammar)

7 years agoMerge branch 'lr/doc-fix-cet' into maint
Junio C Hamano [Tue, 17 Jan 2017 23:19:07 +0000 (15:19 -0800)]
Merge branch 'lr/doc-fix-cet' into maint

* lr/doc-fix-cet:
  date-formats.txt: Typo fix

7 years agoMerge branch 'sb/t3600-cleanup' into maint
Junio C Hamano [Tue, 17 Jan 2017 23:19:06 +0000 (15:19 -0800)]
Merge branch 'sb/t3600-cleanup' into maint

Code cleanup.

* sb/t3600-cleanup:
  t3600: slightly modernize style
  t3600: remove useless redirect

7 years agoMerge branch 'jk/readme-gmane-is-no-more' into maint
Junio C Hamano [Tue, 17 Jan 2017 23:19:05 +0000 (15:19 -0800)]
Merge branch 'jk/readme-gmane-is-no-more' into maint

* jk/readme-gmane-is-no-more:
  README: replace gmane link with public-inbox

7 years agoMerge branch 'sb/unpack-trees-grammofix' into maint
Junio C Hamano [Tue, 17 Jan 2017 23:19:05 +0000 (15:19 -0800)]
Merge branch 'sb/unpack-trees-grammofix' into maint

* sb/unpack-trees-grammofix:
  unpack-trees: fix grammar for untracked files in directories

7 years agoMerge branch 'ls/t0021-fixup' into maint
Junio C Hamano [Tue, 17 Jan 2017 23:19:04 +0000 (15:19 -0800)]
Merge branch 'ls/t0021-fixup' into maint

* ls/t0021-fixup:
  t0021: minor filter process test cleanup

7 years agoMerge branch 'ak/lazy-prereq-mktemp' into maint
Junio C Hamano [Tue, 17 Jan 2017 23:19:04 +0000 (15:19 -0800)]
Merge branch 'ak/lazy-prereq-mktemp' into maint

Test code clean-up.

* ak/lazy-prereq-mktemp:
  t7610: clean up foo.XXXXXX tmpdir

7 years agoMerge branch 'nd/qsort-in-merge-recursive' into maint
Junio C Hamano [Tue, 17 Jan 2017 23:19:03 +0000 (15:19 -0800)]
Merge branch 'nd/qsort-in-merge-recursive' into maint

Code simplification.

* nd/qsort-in-merge-recursive:
  merge-recursive.c: use string_list_sort instead of qsort

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

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 'mk/mingw-winansi-ttyname-termination-fix' into maint
Junio C Hamano [Tue, 17 Jan 2017 23:19:03 +0000 (15:19 -0800)]
Merge branch 'mk/mingw-winansi-ttyname-termination-fix' into maint

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' into maint
Junio C Hamano [Tue, 17 Jan 2017 23:19:02 +0000 (15:19 -0800)]
Merge branch 'gv/p4-multi-path-commit-fix' into maint

"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' into maint
Junio C Hamano [Tue, 17 Jan 2017 23:11:08 +0000 (15:11 -0800)]
Merge branch 'jk/difftool-in-subdir' into maint

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' into maint
Junio C Hamano [Tue, 17 Jan 2017 23:11:07 +0000 (15:11 -0800)]
Merge branch 'ld/p4-compare-dir-vs-symlink' into maint

"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 'jc/push-default-explicit' into maint
Junio C Hamano [Tue, 17 Jan 2017 23:11:07 +0000 (15:11 -0800)]
Merge branch 'jc/push-default-explicit' into maint

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 agoMerge branch 'jt/mailinfo-fold-in-body-headers' into maint
Junio C Hamano [Tue, 17 Jan 2017 23:11:06 +0000 (15:11 -0800)]
Merge branch 'jt/mailinfo-fold-in-body-headers' into maint

Fix for NDEBUG builds.

* jt/mailinfo-fold-in-body-headers:
  mailinfo.c: move side-effects outside of assert

7 years agoMerge branch 'jk/index-pack-wo-repo-from-stdin' into maint
Junio C Hamano [Tue, 17 Jan 2017 23:11:06 +0000 (15:11 -0800)]
Merge branch 'jk/index-pack-wo-repo-from-stdin' into maint

"git index-pack --stdin" needs an access to an existing repository,
but "git index-pack file.pack" to generate an .idx file that
corresponds to a packfile does not.

* jk/index-pack-wo-repo-from-stdin:
  index-pack: skip collision check when not in repository
  t: use nongit() function where applicable
  index-pack: complain when --stdin is used outside of a repo
  t5000: extract nongit function to test-lib-functions.sh

7 years agoMerge branch 'jk/parseopt-usage-msg-opt' into maint
Junio C Hamano [Tue, 17 Jan 2017 23:11:06 +0000 (15:11 -0800)]
Merge branch 'jk/parseopt-usage-msg-opt' into maint

The function usage_msg_opt() has been updated to say "fatal:"
before the custom message programs give, when they want to die
with a message about wrong command line options followed by the
standard usage string.

* jk/parseopt-usage-msg-opt:
  parse-options: print "fatal:" before usage_msg_opt()

7 years agoMerge branch 'jk/quote-env-path-list-component' into maint
Junio C Hamano [Tue, 17 Jan 2017 23:11:06 +0000 (15:11 -0800)]
Merge branch 'jk/quote-env-path-list-component' into maint

A recent update to receive-pack to make it easier to drop garbage
objects made it clear that GIT_ALTERNATE_OBJECT_DIRECTORIES cannot
have a pathname with a colon in it (no surprise!), and this in turn
made it impossible to push into a repository at such a path.  This
has been fixed by introducing a quoting mechanism used when
appending such a path to the colon-separated list.

* jk/quote-env-path-list-component:
  t5615-alternate-env: double-quotes in file names do not work on Windows
  t5547-push-quarantine: run the path separator test on Windows, too
  tmp-objdir: quote paths we add to alternates
  alternates: accept double-quoted paths

7 years agoMerge branch 'nd/shallow-fixup' into maint
Junio C Hamano [Tue, 17 Jan 2017 23:11:05 +0000 (15:11 -0800)]
Merge branch 'nd/shallow-fixup' into maint

Code cleanup in shallow boundary computation.

* nd/shallow-fixup:
  shallow.c: remove useless code
  shallow.c: bit manipulation tweaks
  shallow.c: avoid theoretical pointer wrap-around
  shallow.c: make paint_alloc slightly more robust
  shallow.c: stop abusing COMMIT_SLAB_SIZE for paint_info's memory pools
  shallow.c: rename fields in paint_info to better express their purposes

7 years agoMerge branch 'sb/sequencer-abort-safety' into maint
Junio C Hamano [Tue, 17 Jan 2017 23:11:05 +0000 (15:11 -0800)]
Merge branch 'sb/sequencer-abort-safety' into maint

Unlike "git am --abort", "git cherry-pick --abort" moved HEAD back
to where cherry-pick started while picking multiple changes, when
the cherry-pick stopped to ask for help from the user, and the user
did "git reset --hard" to a different commit in order to re-attempt
the operation.

* sb/sequencer-abort-safety:
  Revert "sequencer: remove useless get_dir() function"
  sequencer: remove useless get_dir() function
  sequencer: make sequencer abort safer
  t3510: test that cherry-pick --abort does not unsafely change HEAD
  am: change safe_to_abort()'s not rewinding error into a warning
  am: fix filename in safe_to_abort() error message

7 years agoMerge branch 'da/mergetool-xxdiff-hotkey' into maint
Junio C Hamano [Tue, 17 Jan 2017 23:11:05 +0000 (15:11 -0800)]
Merge branch 'da/mergetool-xxdiff-hotkey' into maint

The way to specify hotkeys to "xxdiff" that is used by "git
mergetool" has been modernized to match recent versions of xxdiff.

* da/mergetool-xxdiff-hotkey:
  mergetools: fix xxdiff hotkeys

7 years agoMerge branch 'jc/pull-rebase-ff' into maint
Junio C Hamano [Tue, 17 Jan 2017 23:11:04 +0000 (15:11 -0800)]
Merge branch 'jc/pull-rebase-ff' into maint

"git pull --rebase", when there is no new commits on our side since
we forked from the upstream, should be able to fast-forward without
invoking "git rebase", but it didn't.

* jc/pull-rebase-ff:
  pull: fast-forward "pull --rebase=true"

7 years agoMerge branch 'js/normalize-path-copy-ceil' into maint
Junio C Hamano [Tue, 17 Jan 2017 23:11:03 +0000 (15:11 -0800)]
Merge branch 'js/normalize-path-copy-ceil' into maint

A pathname that begins with "//" or "\\" on Windows is special but
path normalization logic was unaware of it.

* js/normalize-path-copy-ceil:
  normalize_path_copy(): fix pushing to //server/share/dir on Windows

7 years agoMerge branch 'ak/commit-only-allow-empty' into maint
Junio C Hamano [Tue, 17 Jan 2017 23:11:03 +0000 (15:11 -0800)]
Merge branch 'ak/commit-only-allow-empty' into maint

"git commit --allow-empty --only" (no pathspec) with dirty index
ought to be an acceptable way to create a new commit that does not
change any paths, but it was forbidden, perhaps because nobody
needed it so far.

* ak/commit-only-allow-empty:
  commit: remove 'Clever' message for --only --amend
  commit: make --only --allow-empty work without paths

7 years agoMerge branch 'da/difftool-dir-diff-fix' into maint
Junio C Hamano [Tue, 17 Jan 2017 22:49:30 +0000 (14:49 -0800)]
Merge branch 'da/difftool-dir-diff-fix' into maint

"git difftool --dir-diff" had a minor regression when started from
a subdirectory, which has been fixed.

* da/difftool-dir-diff-fix:
  difftool: fix dir-diff index creation when in a subdirectory

7 years agoMerge branch 'jb/diff-no-index-no-abbrev' into maint
Junio C Hamano [Tue, 17 Jan 2017 22:49:30 +0000 (14:49 -0800)]
Merge branch 'jb/diff-no-index-no-abbrev' into maint

"git diff --no-index" did not take "--no-abbrev" option.

* jb/diff-no-index-no-abbrev:
  diff: handle --no-abbrev in no-index case

7 years agoMerge branch 'jk/stash-disable-renames-internally' into maint
Junio C Hamano [Tue, 17 Jan 2017 22:49:30 +0000 (14:49 -0800)]
Merge branch 'jk/stash-disable-renames-internally' into maint

When diff.renames configuration is on (and with Git 2.9 and later,
it is enabled by default, which made it worse), "git stash"
misbehaved if a file is removed and another file with a very
similar content is added.

* jk/stash-disable-renames-internally:
  stash: prefer plumbing over git-diff

7 years agoMerge branch 'jk/http-walker-limit-redirect' into maint
Junio C Hamano [Tue, 17 Jan 2017 22:49:29 +0000 (14:49 -0800)]
Merge branch 'jk/http-walker-limit-redirect' into maint

Update the error messages from the dumb-http client when it fails
to obtain loose objects; we used to give sensible error message
only upon 404 but we now forbid unexpected redirects that needs to
be reported with something sensible.

* jk/http-walker-limit-redirect:
  http-walker: complain about non-404 loose object errors
  http: treat http-alternates like redirects
  http: make redirects more obvious
  remote-curl: rename shadowed options variable
  http: always update the base URL for redirects
  http: simplify update_url_from_redirect

7 years agoMerge branch 'jc/renormalize-merge-kill-safer-crlf' into maint
Junio C Hamano [Tue, 17 Jan 2017 22:49:28 +0000 (14:49 -0800)]
Merge branch 'jc/renormalize-merge-kill-safer-crlf' into maint

Fix a corner case in merge-recursive regression that crept in
during 2.10 development cycle.

* jc/renormalize-merge-kill-safer-crlf:
  convert: git cherry-pick -Xrenormalize did not work
  merge-recursive: handle NULL in add_cacheinfo() correctly
  cherry-pick: demonstrate a segmentation fault

7 years agoMerge branch 'ls/p4-empty-file-on-lfs' into maint
Junio C Hamano [Tue, 17 Jan 2017 22:49:27 +0000 (14:49 -0800)]
Merge branch 'ls/p4-empty-file-on-lfs' into maint

"git p4" LFS support was broken when LFS stores an empty blob.

* ls/p4-empty-file-on-lfs:
  git-p4: fix empty file processing for large file system backend GitLFS

7 years agoMerge branch 'da/mergetool-trust-exit-code' into maint
Junio C Hamano [Tue, 17 Jan 2017 22:49:27 +0000 (14:49 -0800)]
Merge branch 'da/mergetool-trust-exit-code' into maint

mergetool.<tool>.trustExitCode configuration variable did not apply
to built-in tools, but now it does.

* da/mergetool-trust-exit-code:
  mergetools/vimdiff: trust Vim's exit code
  mergetool: honor mergetool.$tool.trustExitCode for built-in tools

7 years agoMerge branch 'nd/worktree-list-fixup' into maint
Junio C Hamano [Tue, 17 Jan 2017 22:49:27 +0000 (14:49 -0800)]
Merge branch 'nd/worktree-list-fixup' into maint

The output from "git worktree list" was made in readdir() order,
and was unstable.

* nd/worktree-list-fixup:
  worktree list: keep the list sorted
  worktree.c: get_worktrees() takes a new flag argument
  get_worktrees() must return main worktree as first item even on error
  worktree: reorder an if statement
  worktree.c: zero new 'struct worktree' on allocation

7 years agoMerge branch 'bw/push-dry-run' into maint
Junio C Hamano [Tue, 17 Jan 2017 22:49:27 +0000 (14:49 -0800)]
Merge branch 'bw/push-dry-run' into maint

"git push --dry-run --recurse-submodule=on-demand" wasn't
"--dry-run" in the submodules.

* bw/push-dry-run:
  push: fix --dry-run to not push submodules
  push: --dry-run updates submodules when --recurse-submodules=on-demand

7 years agoMerge branch 'hv/submodule-not-yet-pushed-fix' into maint
Junio C Hamano [Tue, 17 Jan 2017 22:49:26 +0000 (14:49 -0800)]
Merge branch 'hv/submodule-not-yet-pushed-fix' into maint

The code in "git push" to compute if any commit being pushed in the
superproject binds a commit in a submodule that hasn't been pushed
out was overly inefficient, making it unusable even for a small
project that does not have any submodule but have a reasonable
number of refs.

* hv/submodule-not-yet-pushed-fix:
  submodule_needs_pushing(): explain the behaviour when we cannot answer
  batch check whether submodule needs pushing into one call
  serialize collection of refs that contain submodule changes
  serialize collection of changed submodules

7 years agoMerge branch 'dt/empty-submodule-in-merge' into maint
Junio C Hamano [Tue, 17 Jan 2017 22:49:26 +0000 (14:49 -0800)]
Merge branch 'dt/empty-submodule-in-merge' into maint

An empty directory in a working tree that can simply be nuked used
to interfere while merging or cherry-picking a change to create a
submodule directory there, which has been fixed..

* dt/empty-submodule-in-merge:
  submodules: allow empty working-tree dirs in merge/cherry-pick

7 years agoMerge branch 'jk/rev-parse-symbolic-parents-fix' into maint
Junio C Hamano [Tue, 17 Jan 2017 22:49:26 +0000 (14:49 -0800)]
Merge branch 'jk/rev-parse-symbolic-parents-fix' into maint

"git rev-parse --symbolic" failed with a more recent notation like
"HEAD^-1" and "HEAD^!".

* jk/rev-parse-symbolic-parents-fix:
  rev-parse: fix parent shorthands with --symbolic

7 years agoMerge branch 'js/mingw-isatty' into maint
Junio C Hamano [Tue, 17 Jan 2017 22:49:25 +0000 (14:49 -0800)]
Merge branch 'js/mingw-isatty' into maint

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
  mingw: intercept isatty() to handle /dev/null as Git expects it

7 years agoMerge branch 'bb/unicode-9.0' into maint
Junio C Hamano [Tue, 17 Jan 2017 22:49:25 +0000 (14:49 -0800)]
Merge branch 'bb/unicode-9.0' into maint

The character width table has been updated to match Unicode 9.0

* bb/unicode-9.0:
  unicode_width.h: update the width tables to Unicode 9.0
  update_unicode.sh: remove the plane filter
  update_unicode.sh: automatically download newer definition files
  update_unicode.sh: pin the uniset repo to a known good commit
  update_unicode.sh: remove an unnecessary subshell level
  update_unicode.sh: move it into contrib/update-unicode

7 years agoMerge branch 'ls/travis-update-p4-and-lfs' into maint
Junio C Hamano [Tue, 17 Jan 2017 22:49:24 +0000 (14:49 -0800)]
Merge branch 'ls/travis-update-p4-and-lfs' into maint

The default Travis-CI configuration specifies newer P4 and GitLFS.

* ls/travis-update-p4-and-lfs:
  travis-ci: update P4 to 16.2 and GitLFS to 1.5.2 in Linux build

7 years agoCodingGuidelines: clarify multi-line brace style
Jeff King [Tue, 17 Jan 2017 20:05:04 +0000 (15:05 -0500)]
CodingGuidelines: clarify multi-line brace style

There are some "gray areas" around when to omit braces from
a conditional or loop body. Since that seems to have
resulted in some arguments, let's be a little more clear
about our preferred style.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agorequest-pull: drop old USAGE stuff
Wolfram Sang [Sun, 15 Jan 2017 17:46:35 +0000 (18:46 +0100)]
request-pull: drop old USAGE stuff

request-pull uses OPTIONS_SPEC, so no need for (meanwhile incomplete)
USAGE and LONG_USAGE anymore.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoDocumentation/bisect: improve on (bad|new) and (good|bad)
Christian Couder [Fri, 13 Jan 2017 14:44:05 +0000 (15:44 +0100)]
Documentation/bisect: improve on (bad|new) and (good|bad)

The following part of the description:

git bisect (bad|new) [<rev>]
git bisect (good|old) [<rev>...]

may be a bit confusing, as a reader may wonder if instead it should be:

git bisect (bad|good) [<rev>]
git bisect (old|new) [<rev>...]

Of course the difference between "[<rev>]" and "[<rev>...]" should hint
that there is a good reason for the way it is.

But we can further clarify and complete the description by adding
"<term-new>" and "<term-old>" to the "bad|new" and "good|old"
alternatives.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot7810: avoid assumption about invalid regex syntax
Jeff King [Wed, 11 Jan 2017 11:10:55 +0000 (06:10 -0500)]
t7810: avoid assumption about invalid regex syntax

A few of the tests want to check that "git grep -P -E" will
override -P with -E, and vice versa. To do so, we use a
regex with "\x{..}", which is valid in PCRE but not defined
by POSIX (for basic or extended regular expressions).

However, POSIX declares quite a lot of syntax, including
"\x", as "undefined". That leaves implementations free to
extend the standard if they choose. At least one, musl libc,
implements "\x" in the same way as PCRE.  Our tests check
that "-E" complains about "\x", which fails with musl.

We can fix this by finding some construct which behaves
reliably on both PCRE and POSIX, but differently in each
system.

One such construct is the use of backslash inside brackets.
In PCRE, "[\d]" interprets "\d" as it would outside the
brackets, matching a digit. Whereas in POSIX, the backslash
must be treated literally, and we match either it or a
literal "d".  Moreover, implementations are not free to
change this according to POSIX, so we should be able to rely
on it.

Signed-off-by: Jeff King <peff@peff.net>
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 agogit_exec_path: do not return the result of getenv()
Jeff King [Mon, 9 Jan 2017 06:00:12 +0000 (01:00 -0500)]
git_exec_path: do not return the result of getenv()

The result of getenv() is not guaranteed by POSIX to last
beyond another call to getenv(), or setenv(), etc.  We
should duplicate the string before returning to the caller
to avoid any surprises.

We already keep a cached pointer to avoid repeatedly leaking
the result of system_path(). We can use the same pointer
here to avoid allocating and leaking for each call.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agogit_exec_path: avoid Coverity warning about unfree()d result
Johannes Schindelin [Mon, 2 Jan 2017 16:22:33 +0000 (17:22 +0100)]
git_exec_path: avoid Coverity warning about unfree()d result

Technically, it is correct that git_exec_path() returns a possibly
malloc()ed string returned from system_path(), and it is sometimes
not allocated.  Cache the result in a static variable and make sure
that we call system_path() only once, which plugs a potential leak.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
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>