]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
6 years agogrep: remove regflags from the public grep_opt API
Ævar Arnfjörð Bjarmason [Thu, 29 Jun 2017 22:22:21 +0000 (22:22 +0000)] 
grep: remove regflags from the public grep_opt API

Refactor calls to the grep machinery to always pass opt.ignore_case &
opt.extended_regexp_option instead of setting the equivalent regflags
bits.

The bug fixed when making -i work with -P in commit 9e3cbc59d5 ("log:
make --regexp-ignore-case work with --perl-regexp", 2017-05-20) was
really just plastering over the code smell which this change fixes.

The reason for adding the extensive commentary here is that I
discovered some subtle complexity in implementing this that really
should be called out explicitly to future readers.

Before this change we'd rely on the difference between
`extended_regexp_option` and `regflags` to serve as a membrane between
our preliminary parsing of grep.extendedRegexp and grep.patternType,
and what we decided to do internally.

Now that those two are the same thing, it's necessary to unset
`extended_regexp_option` just before we commit in cases where both of
those config variables are set. See 84befcd0a4 ("grep: add a
grep.patternType configuration setting", 2012-08-03) for the code and
documentation related to that.

The explanation of why the if/else branches in
grep_commit_pattern_type() are ordered the way they are exists in that
commit message, but I think it's worth calling this subtlety out
explicitly with a comment for future readers.

Even though grep_commit_pattern_type() is the only caller of
grep_set_pattern_type_option() it's simpler to reset the
extended_regexp_option flag in the latter, since 2/3 branches in the
former would otherwise need to reset it, this way we can do it in one
place.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agogrep: remove redundant and verbose re-assignments to 0
Ævar Arnfjörð Bjarmason [Thu, 29 Jun 2017 22:22:20 +0000 (22:22 +0000)] 
grep: remove redundant and verbose re-assignments to 0

Remove the redundant re-assignments of the fixed/pcre1/pcre2 fields to
zero right after the entire struct has been set to zero via
memset(...).

See an earlier related cleanup commit e0b9f8ae09 ("grep: remove
redundant regflags assignments", 2017-05-25) for an explanation of why
the code was structured like this to begin with.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agogrep: remove redundant "fixed" field re-assignment to 0
Ævar Arnfjörð Bjarmason [Thu, 29 Jun 2017 22:22:19 +0000 (22:22 +0000)] 
grep: remove redundant "fixed" field re-assignment to 0

Remove the redundant re-assignment of the fixed field to zero right
after the entire struct has been set to zero via memset(...).

Unlike some nearby commits this pattern doesn't date back to the
pattern described in e0b9f8ae09 ("grep: remove redundant regflags
assignments", 2017-05-25), instead it was apparently cargo-culted in
9eceddeec6 ("Use kwset in grep", 2011-08-21).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agogrep: adjust a redundant grep pattern type assignment
Ævar Arnfjörð Bjarmason [Thu, 29 Jun 2017 22:22:18 +0000 (22:22 +0000)] 
grep: adjust a redundant grep pattern type assignment

Adjust a now-redundant assignment to extended_regexp_option to make it
zero if grep.extendedRegexp is not set. This is always called right
after init_grep_defaults() which memsets the entire structure to 0, so
there's no need to set it again to zero.

However the reason for the if/else pattern is a holdover from[1] where
this was adjusted from a bitfield assignment to a boolean. Rather than
getting rid of the assignment to 0 in all cases, let's just use the
value returned by git_config_bool(), which is more idiomatic and in
sync with the rest of the boolean handling in this function.

This is a logical follow-up to my commit to remove redundant regflags
assignments[2]. This logic was originally introduced in [3], but as
explained in the former commit it's working around a pattern in our
code that no longer exists, and is now confusing as it leads the
reader to think that this needs to be flipped back & forth.

1. 84befcd0a4 ("grep: add a grep.patternType configuration setting",
   2012-08-03)
2. e0b9f8ae09 ("grep: remove redundant regflags assignments",
   2017-05-25)
3. b22520a37c ("grep: allow -E and -n to be turned on by default via
   configuration", 2011-03-30)

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agogrep: remove redundant double assignment to 0
Ævar Arnfjörð Bjarmason [Thu, 29 Jun 2017 22:22:17 +0000 (22:22 +0000)] 
grep: remove redundant double assignment to 0

Stop assigning 0 to the extended_regexp_option field right after we've
zeroed out the entire struct with memset() just a few lines earlier.

Unlike some of the code being refactored in subsequent commits, this
was always completely redundant. See the original code introduced in
84befcd0a4 ("grep: add a grep.patternType configuration setting",
2012-08-03).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoTwelfth batch for 2.14
Junio C Hamano [Mon, 26 Jun 2017 21:12:46 +0000 (14:12 -0700)] 
Twelfth batch for 2.14

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge branch 'mb/reword-autocomplete-message'
Junio C Hamano [Mon, 26 Jun 2017 21:09:33 +0000 (14:09 -0700)] 
Merge branch 'mb/reword-autocomplete-message'

Message update.

* mb/reword-autocomplete-message:
  auto-correct: tweak phrasing

6 years agoMerge branch 'ks/t7508-indent-fix'
Junio C Hamano [Mon, 26 Jun 2017 21:09:32 +0000 (14:09 -0700)] 
Merge branch 'ks/t7508-indent-fix'

Cosmetic update to a test.

* ks/t7508-indent-fix:
  t7508: fix a broken indentation

6 years agoMerge branch 'jk/add-p-commentchar-fix'
Junio C Hamano [Mon, 26 Jun 2017 21:09:31 +0000 (14:09 -0700)] 
Merge branch 'jk/add-p-commentchar-fix'

"git add -p" were updated in 2.12 timeframe to cope with custom
core.commentchar but the implementation was buggy and a
metacharacter like $ and * did not work.

* jk/add-p-commentchar-fix:
  add--interactive: quote commentChar regex
  add--interactive: handle EOF in prompt_yesno

6 years agoMerge branch 'dt/raise-core-packed-git-limit'
Junio C Hamano [Mon, 26 Jun 2017 21:09:30 +0000 (14:09 -0700)] 
Merge branch 'dt/raise-core-packed-git-limit'

Doc update for a topic already in 'master'.

* dt/raise-core-packed-git-limit:
  docs: update 64-bit core.packedGitLimit default

6 years agoMerge branch 'mh/packed-ref-store-prep'
Junio C Hamano [Mon, 26 Jun 2017 21:09:29 +0000 (14:09 -0700)] 
Merge branch 'mh/packed-ref-store-prep'

Bugfix for a topic that is (only) in 'master'.

* mh/packed-ref-store-prep:
  for_each_bisect_ref(): don't trim refnames
  lock_packed_refs(): fix cache validity check

6 years agoMerge branch 'lb/status-stash-count'
Junio C Hamano [Mon, 26 Jun 2017 21:09:29 +0000 (14:09 -0700)] 
Merge branch 'lb/status-stash-count'

"git status" learned to optionally give how many stash entries the
user has in its output.

* lb/status-stash-count:
  glossary: define 'stash entry'
  status: add optional stash count information
  stash: update documentation to use 'stash entry'

6 years agoSync with 2.13.2
Junio C Hamano [Sat, 24 Jun 2017 22:34:14 +0000 (15:34 -0700)] 
Sync with 2.13.2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoGit 2.13.2 v2.13.2
Junio C Hamano [Sat, 24 Jun 2017 22:31:36 +0000 (15:31 -0700)] 
Git 2.13.2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge branch 'sn/reset-doc-typofix' into maint
Junio C Hamano [Sat, 24 Jun 2017 22:29:35 +0000 (15:29 -0700)] 
Merge branch 'sn/reset-doc-typofix' into maint

Doc update.

* sn/reset-doc-typofix:
  doc: git-reset: fix a trivial typo

6 years agoMerge branch 'sg/doc-pretty-formats' into maint
Junio C Hamano [Sat, 24 Jun 2017 22:29:35 +0000 (15:29 -0700)] 
Merge branch 'sg/doc-pretty-formats' into maint

Doc update.

* sg/doc-pretty-formats:
  docs/pretty-formats: stress that %- removes all preceding line-feeds

6 years agoMerge branch 'sd/t3200-branch-m-test' into maint
Junio C Hamano [Sat, 24 Jun 2017 22:29:34 +0000 (15:29 -0700)] 
Merge branch 'sd/t3200-branch-m-test' into maint

New test.

* sd/t3200-branch-m-test:
  t3200: add test for single parameter passed to -m option

6 years agoMerge branch 'sg/revision-parser-skip-prefix' into maint
Junio C Hamano [Sat, 24 Jun 2017 22:29:34 +0000 (15:29 -0700)] 
Merge branch 'sg/revision-parser-skip-prefix' into maint

Code clean-up.

* sg/revision-parser-skip-prefix:
  revision.c: use skip_prefix() in handle_revision_pseudo_opt()
  revision.c: use skip_prefix() in handle_revision_opt()
  revision.c: stricter parsing of '--early-output'
  revision.c: stricter parsing of '--no-{min,max}-parents'
  revision.h: turn rev_info.early_output back into an unsigned int

6 years agoMerge branch 'km/test-mailinfo-b-failure' into maint
Junio C Hamano [Sat, 24 Jun 2017 22:29:33 +0000 (15:29 -0700)] 
Merge branch 'km/test-mailinfo-b-failure' into maint

New tests.

* km/test-mailinfo-b-failure:
  t5100: add some more mailinfo tests

6 years agoMerge branch 'sb/submodule-rm-absorb' into maint
Junio C Hamano [Sat, 24 Jun 2017 22:29:32 +0000 (15:29 -0700)] 
Merge branch 'sb/submodule-rm-absorb' into maint

Doc update to a recently graduated topic.

* sb/submodule-rm-absorb:
  Documentation/git-rm: correct submodule description

6 years agoMerge branch 'jc/diff-tree-stale-comment' into maint
Junio C Hamano [Sat, 24 Jun 2017 22:29:31 +0000 (15:29 -0700)] 
Merge branch 'jc/diff-tree-stale-comment' into maint

Comment fix.

* jc/diff-tree-stale-comment:
  diff-tree: update stale in-code comments

6 years agoMerge branch 'ps/stash-push-pathspec-fix' into maint
Junio C Hamano [Sat, 24 Jun 2017 22:29:30 +0000 (15:29 -0700)] 
Merge branch 'ps/stash-push-pathspec-fix' into maint

"git stash push <pathspec>" did not work from a subdirectory at all.
Bugfix for a topic in v2.13

* ps/stash-push-pathspec-fix:
  git-stash: fix pushing stash with pathspec from subdir

6 years agoMerge branch 'ls/github' into maint
Junio C Hamano [Sat, 24 Jun 2017 22:29:29 +0000 (15:29 -0700)] 
Merge branch 'ls/github' into maint

Help contributors that visit us at GitHub.

* ls/github:
  Configure Git contribution guidelines for github.com

6 years agoMerge branch 'jk/pack-idx-corruption-safety' into maint
Junio C Hamano [Sat, 24 Jun 2017 22:29:29 +0000 (15:29 -0700)] 
Merge branch 'jk/pack-idx-corruption-safety' into maint

A flaky test has been corrected.

* jk/pack-idx-corruption-safety:
  t5313: make extended-table test more deterministic

6 years agoMerge branch 'jk/diff-blob' into maint
Junio C Hamano [Sat, 24 Jun 2017 22:29:28 +0000 (15:29 -0700)] 
Merge branch 'jk/diff-blob' into maint

The result from "git diff" that compares two blobs, e.g. "git diff
$commit1:$path $commit2:$path", used to be shown with the full
object name as given on the command line, but it is more natural to
use the $path in the output and use it to look up .gitattributes.

* jk/diff-blob:
  diff: use blob path for blob/file diffs
  diff: use pending "path" if it is available
  diff: use the word "path" instead of "name" for blobs
  diff: pass whole pending entry in blobinfo
  handle_revision_arg: record paths for pending objects
  handle_revision_arg: record modes for "a..b" endpoints
  t4063: add tests of direct blob diffs
  get_sha1_with_context: dynamically allocate oc->path
  get_sha1_with_context: always initialize oc->symlink_path
  sha1_name: consistently refer to object_context as "oc"
  handle_revision_arg: add handle_dotdot() helper
  handle_revision_arg: hoist ".." check out of range parsing
  handle_revision_arg: stop using "dotdot" as a generic pointer
  handle_revision_arg: simplify commit reference lookups
  handle_revision_arg: reset "dotdot" consistently

6 years agoMerge branch 'jc/name-rev-lw-tag' into maint
Junio C Hamano [Sat, 24 Jun 2017 22:29:27 +0000 (15:29 -0700)] 
Merge branch 'jc/name-rev-lw-tag' into maint

"git describe --contains" penalized light-weight tags so much that
they were almost never considered.  Instead, give them about the
same chance to be considered as an annotated tag that is the same
age as the underlying commit would.

* jc/name-rev-lw-tag:
  name-rev: favor describing with tags and use committer date to tiebreak
  name-rev: refactor logic to see if a new candidate is a better name

6 years agoEleventh batch for 2.14
Junio C Hamano [Sat, 24 Jun 2017 21:34:11 +0000 (14:34 -0700)] 
Eleventh batch for 2.14

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge branch 'ab/free-and-null'
Junio C Hamano [Sat, 24 Jun 2017 21:28:41 +0000 (14:28 -0700)] 
Merge branch 'ab/free-and-null'

A common pattern to free a piece of memory and assign NULL to the
pointer that used to point at it has been replaced with a new
FREE_AND_NULL() macro.

* ab/free-and-null:
  *.[ch] refactoring: make use of the FREE_AND_NULL() macro
  coccinelle: make use of the "expression" FREE_AND_NULL() rule
  coccinelle: add a rule to make "expression" code use FREE_AND_NULL()
  coccinelle: make use of the "type" FREE_AND_NULL() rule
  coccinelle: add a rule to make "type" code use FREE_AND_NULL()
  git-compat-util: add a FREE_AND_NULL() wrapper around free(ptr); ptr = NULL

6 years agoMerge branch 'jk/warn-add-gitlink'
Junio C Hamano [Sat, 24 Jun 2017 21:28:41 +0000 (14:28 -0700)] 
Merge branch 'jk/warn-add-gitlink'

Using "git add d/i/r" when d/i/r is the top of the working tree of
a separate repository would create a gitlink in the index, which
would appear as a not-quite-initialized submodule to others.  We
learned to give warnings when this happens.

* jk/warn-add-gitlink:
  t: move "git add submodule" into test blocks
  add: warn when adding an embedded repository

6 years agoMerge branch 'bw/config-h'
Junio C Hamano [Sat, 24 Jun 2017 21:28:40 +0000 (14:28 -0700)] 
Merge branch 'bw/config-h'

Fix configuration codepath to pay proper attention to commondir
that is used in multi-worktree situation, and isolate config API
into its own header file.

* bw/config-h:
  config: don't implicitly use gitdir or commondir
  config: respect commondir
  setup: teach discover_git_directory to respect the commondir
  config: don't include config.h by default
  config: remove git_config_iter
  config: create config.h

6 years agoMerge branch 'bw/ls-files-sans-the-index'
Junio C Hamano [Sat, 24 Jun 2017 21:28:40 +0000 (14:28 -0700)] 
Merge branch 'bw/ls-files-sans-the-index'

Code clean-up.

* bw/ls-files-sans-the-index:
  ls-files: factor out tag calculation
  ls-files: factor out debug info into a function
  ls-files: convert show_files to take an index
  ls-files: convert show_ce_entry to take an index
  ls-files: convert prune_cache to take an index
  ls-files: convert ce_excluded to take an index
  ls-files: convert show_ru_info to take an index
  ls-files: convert show_other_files to take an index
  ls-files: convert show_killed_files to take an index
  ls-files: convert write_eolinfo to take an index
  ls-files: convert overlay_tree_on_cache to take an index
  tree: convert read_tree to take an index parameter
  convert: convert renormalize_buffer to take an index
  convert: convert convert_to_git to take an index
  convert: convert convert_to_git_filter_fd to take an index
  convert: convert crlf_to_git to take an index
  convert: convert get_cached_convert_stats_ascii to take an index

6 years agoMerge branch 'js/alias-early-config'
Junio C Hamano [Sat, 24 Jun 2017 21:28:39 +0000 (14:28 -0700)] 
Merge branch 'js/alias-early-config'

The code to pick up and execute command alias definition from the
configuration used to switch to the top of the working tree and
then come back when the expanded alias was executed, which was
unnecessarilyl complex.  Attempt to simplify the logic by using the
early-config mechanism that does not chdir around.

* js/alias-early-config:
  alias: use the early config machinery to expand aliases
  t7006: demonstrate a problem with aliases in subdirectories
  t1308: relax the test verifying that empty alias values are disallowed
  help: use early config when autocorrecting aliases
  config: report correct line number upon error
  discover_git_directory(): avoid setting invalid git_dir

6 years agoMerge branch 'sn/reset-doc-typofix'
Junio C Hamano [Sat, 24 Jun 2017 21:28:39 +0000 (14:28 -0700)] 
Merge branch 'sn/reset-doc-typofix'

Doc update.

* sn/reset-doc-typofix:
  doc: git-reset: fix a trivial typo

6 years agoMerge branch 'sg/doc-pretty-formats'
Junio C Hamano [Sat, 24 Jun 2017 21:28:39 +0000 (14:28 -0700)] 
Merge branch 'sg/doc-pretty-formats'

Doc update.

* sg/doc-pretty-formats:
  docs/pretty-formats: stress that %- removes all preceding line-feeds

6 years agoMerge branch 'rs/pretty-add-again'
Junio C Hamano [Sat, 24 Jun 2017 21:28:38 +0000 (14:28 -0700)] 
Merge branch 'rs/pretty-add-again'

The pretty-format specifiers like '%h', '%t', etc. had an
optimization that no longer works correctly.  In preparation/hope
of getting it correctly implemented, first discard the optimization
that is broken.

* rs/pretty-add-again:
  pretty: recalculate duplicate short hashes

6 years agoMerge branch 'jk/diff-highlight-module'
Junio C Hamano [Sat, 24 Jun 2017 21:28:37 +0000 (14:28 -0700)] 
Merge branch 'jk/diff-highlight-module'

The 'diff-highlight' program (in contrib/) has been restructured
for easier reuse by an external project 'diff-so-fancy'.

* jk/diff-highlight-module:
  diff-highlight: split code into module

6 years agoMerge branch 'ah/doc-gitattributes-empty-index'
Junio C Hamano [Sat, 24 Jun 2017 21:28:37 +0000 (14:28 -0700)] 
Merge branch 'ah/doc-gitattributes-empty-index'

An example in documentation that does not work in multi worktree
configuration has been corrected.

* ah/doc-gitattributes-empty-index:
  doc: do not use `rm .git/index` when normalizing line endings

6 years agoMerge branch 'ab/wildmatch-glob-slash-test'
Junio C Hamano [Sat, 24 Jun 2017 21:28:37 +0000 (14:28 -0700)] 
Merge branch 'ab/wildmatch-glob-slash-test'

A new test to show the interaction between the pattern [^a-z]
(which matches '/') and a slash in a path has been added.  The
pattern should not match the slash with "pathmatch", but should
with "wildmatch".

* ab/wildmatch-glob-slash-test:
  wildmatch test: cover a blind spot in "/" matching

6 years agoMerge branch 'ab/pcre-v2'
Junio C Hamano [Sat, 24 Jun 2017 21:28:36 +0000 (14:28 -0700)] 
Merge branch 'ab/pcre-v2'

Hotfix for a topic already in 'master'.

* ab/pcre-v2:
  grep: fix erroneously copy/pasted variable in check/assert pattern

6 years agoMerge branch 'da/mergetools-meld-output-opt-on-macos'
Junio C Hamano [Sat, 24 Jun 2017 21:28:36 +0000 (14:28 -0700)] 
Merge branch 'da/mergetools-meld-output-opt-on-macos'

"git mergetool" learned to work around a wrapper MacOS X adds
around underlying meld.

* da/mergetools-meld-output-opt-on-macos:
  mergetools/meld: improve compatibiilty with Meld on macOS X

6 years agoMerge branch 'nd/split-index-unshare'
Junio C Hamano [Sat, 24 Jun 2017 19:04:25 +0000 (12:04 -0700)] 
Merge branch 'nd/split-index-unshare'

* nd/split-index-unshare:
  Revert "split-index: add and use unshare_split_index()"

6 years agoRevert "split-index: add and use unshare_split_index()"
Junio C Hamano [Sat, 24 Jun 2017 19:02:39 +0000 (12:02 -0700)] 
Revert "split-index: add and use unshare_split_index()"

This reverts commit f9d7abec2ad2f9eb3d8873169cc28c34273df082;
see public-inbox.org/git/CAP8UFD0bOfzY-_hBDKddOcJdPUpP2KEVaX_SrCgvAMYAHtseiQ@mail.gmail.com

6 years agoTenth batch for 2.14
Junio C Hamano [Thu, 22 Jun 2017 21:18:02 +0000 (14:18 -0700)] 
Tenth batch for 2.14

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge branch 'rs/strbuf-addftime-zZ'
Junio C Hamano [Thu, 22 Jun 2017 21:15:25 +0000 (14:15 -0700)] 
Merge branch 'rs/strbuf-addftime-zZ'

As there is no portable way to pass timezone information to
strftime, some output format from "git log" and friends are
impossible to produce.  Teach our own strbuf_addftime to replace %z
and %Z with caller-supplied values to help working around this.

* rs/strbuf-addftime-zZ:
  date: use localtime() for "-local" time formats
  t0006: check --date=format zone offsets
  strbuf: let strbuf_addftime handle %z and %Z itself

6 years agoMerge branch 'sd/t3200-branch-m-test'
Junio C Hamano [Thu, 22 Jun 2017 21:15:25 +0000 (14:15 -0700)] 
Merge branch 'sd/t3200-branch-m-test'

New test.

* sd/t3200-branch-m-test:
  t3200: add test for single parameter passed to -m option

6 years agoMerge branch 'ps/stash-push-pathspec-fix'
Junio C Hamano [Thu, 22 Jun 2017 21:15:24 +0000 (14:15 -0700)] 
Merge branch 'ps/stash-push-pathspec-fix'

"git stash push <pathspec>" did not work from a subdirectory at all.
Bugfix for a topic in v2.13

* ps/stash-push-pathspec-fix:
  git-stash: fix pushing stash with pathspec from subdir

6 years agoMerge branch 'ls/github'
Junio C Hamano [Thu, 22 Jun 2017 21:15:24 +0000 (14:15 -0700)] 
Merge branch 'ls/github'

Help contributors that visit us at GitHub.

* ls/github:
  Configure Git contribution guidelines for github.com

6 years agoMerge branch 'sg/revision-parser-skip-prefix'
Junio C Hamano [Thu, 22 Jun 2017 21:15:23 +0000 (14:15 -0700)] 
Merge branch 'sg/revision-parser-skip-prefix'

Code clean-up.

* sg/revision-parser-skip-prefix:
  revision.c: use skip_prefix() in handle_revision_pseudo_opt()
  revision.c: use skip_prefix() in handle_revision_opt()
  revision.c: stricter parsing of '--early-output'
  revision.c: stricter parsing of '--no-{min,max}-parents'
  revision.h: turn rev_info.early_output back into an unsigned int

6 years agoMerge branch 'mh/fast-import-raise-default-depth'
Junio C Hamano [Thu, 22 Jun 2017 21:15:23 +0000 (14:15 -0700)] 
Merge branch 'mh/fast-import-raise-default-depth'

"fast-import" uses a default pack chain depth that is consistent
with other parts of the system.

* mh/fast-import-raise-default-depth:
  fast-import: increase the default pack depth to 50

6 years agoMerge branch 'km/test-mailinfo-b-failure'
Junio C Hamano [Thu, 22 Jun 2017 21:15:22 +0000 (14:15 -0700)] 
Merge branch 'km/test-mailinfo-b-failure'

New tests.

* km/test-mailinfo-b-failure:
  t5100: add some more mailinfo tests

6 years agoMerge branch 'ah/filter-branch-setup'
Junio C Hamano [Thu, 22 Jun 2017 21:15:21 +0000 (14:15 -0700)] 
Merge branch 'ah/filter-branch-setup'

"filter-branch" learned a pseudo filter "--setup" that can be used
to define a common function/variable that can be used by other
filters.

* ah/filter-branch-setup:
  filter-branch: add [--] to usage
  filter-branch: add `--setup` step

6 years agoMerge branch 'pc/dir-count-slashes'
Junio C Hamano [Thu, 22 Jun 2017 21:15:21 +0000 (14:15 -0700)] 
Merge branch 'pc/dir-count-slashes'

Three instances of the same helper function have been consolidated
to one.

* pc/dir-count-slashes:
  dir: create function count_slashes()

6 years agoMerge branch 'sb/t4005-modernize'
Junio C Hamano [Thu, 22 Jun 2017 21:15:21 +0000 (14:15 -0700)] 
Merge branch 'sb/t4005-modernize'

Test clean-up.

* sb/t4005-modernize:
  t4005: modernize style and drop hard coded sha1

6 years agoMerge branch 'nd/fopen-errors'
Junio C Hamano [Thu, 22 Jun 2017 21:15:20 +0000 (14:15 -0700)] 
Merge branch 'nd/fopen-errors'

Hotfix for a topic that is already in 'master'.

* nd/fopen-errors:
  configure.ac: loosen FREAD_READS_DIRECTORIES test program

6 years agoadd--interactive: quote commentChar regex
Jeff King [Wed, 21 Jun 2017 19:28:59 +0000 (15:28 -0400)] 
add--interactive: quote commentChar regex

Since c9d961647 (i18n: add--interactive: mark
edit_hunk_manually message for translation, 2016-12-14),
when the user asks to edit a hunk manually, we respect
core.commentChar in generating the edit instructions.
However, when we then strip out comment lines, we use a
simple regex like:

  /^$commentChar/

If your chosen comment character is a regex metacharacter,
then that will behave in a confusing manner ("$", for
instance, would only eliminate blank lines, not actual
comment lines).

We can fix that by telling perl not to respect
metacharacters.

Reported-by: Christian Rösch <christian@croesch.de>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoadd--interactive: handle EOF in prompt_yesno
Jeff King [Wed, 21 Jun 2017 19:26:36 +0000 (15:26 -0400)] 
add--interactive: handle EOF in prompt_yesno

The prompt_yesno function loops indefinitely waiting for a
"y" or "n" response. But it doesn't handle EOF, meaning
that we can end up in an infinite loop of reading EOF from
stdin. One way to simulate that is with:

  echo e | GIT_EDITOR='echo corrupt >' git add -p

Let's break out of the loop and propagate the undef to the
caller. Without modifying the callers that effectively turns
it into a "no" response. This is reasonable for both of the
current callers, and it leaves room for any future caller to
check for undef explicitly.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoauto-correct: tweak phrasing
Marc Branchaud [Wed, 21 Jun 2017 13:57:38 +0000 (09:57 -0400)] 
auto-correct: tweak phrasing

When help.autoCorrect is enabled, an invalid git command prints a
warning and a continuation message, which differs depending on
whether or not the value of help.autoCorrect is positive or
negative.

With help.autoCorrect = 15:

   WARNING: You called a Git command named 'lgo', which does not exist.
   Continuing under the assumption that you meant 'log'
   in 1.5 seconds automatically...

With help.autoCorrect < 0:

   WARNING: You called a Git command named 'lgo', which does not exist.
   Continuing under the assumption that you meant 'log'

The continuation message's phrasing is awkward.  This commit cleans it up.
As a bonus, we now use full-sentence strings which make translation easier.

With help.autoCorrect = 15:

   WARNING: You called a Git command named 'lgo', which does not exist.
   Continuing in 1.5 seconds, assuming that you meant 'log'.

With help.autoCorrect < 0:

   WARNING: You called a Git command named 'lgo', which does not exist.
   Continuing under the assumption that you meant 'log'.

Signed-off-by: Marc Branchaud <marcnarc@xiplink.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agodocs: update 64-bit core.packedGitLimit default
Jeff King [Wed, 21 Jun 2017 13:51:30 +0000 (09:51 -0400)] 
docs: update 64-bit core.packedGitLimit default

We bumped the default in be4ca2905 (Increase
core.packedGitLimit, 2017-04-20) but never adjusted the
documentation to match.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot7508: fix a broken indentation
Kaartic Sivaraam [Wed, 21 Jun 2017 12:31:45 +0000 (18:01 +0530)] 
t7508: fix a broken indentation

Change the indentation from "\t " to "\t". This indenting issue was
introduced when the test was added in commit 1d2f393ac9
("status/commit: show staged submodules regardless of ignore
config", 2014-04-05).

Helped-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agogrep: fix erroneously copy/pasted variable in check/assert pattern
Ævar Arnfjörð Bjarmason [Mon, 19 Jun 2017 22:01:48 +0000 (22:01 +0000)] 
grep: fix erroneously copy/pasted variable in check/assert pattern

Fix an erroneously copy/pasted check for the pcre2_jit_stack variable
to check pcre2_match_context instead. The former was already checked
in the preceding "if" statement.

This is a trivial and obvious error introduced in my commit
94da9193a6 ("grep: add support for PCRE v2", 2017-06-01).

In practice if pcre2_match_context_create() returned NULL we were
likely in a situation where malloc() was returning NULL, and were thus
screwed anyway, but if only the pcre2_match_context_create() call
returned NULL (through some transitory bug) PCRE v2 would just
allocate and supply its own context object when matching, and we'd run
normally at the trivial expense of not getting a slight speedup by
sharing the context object between successive matches.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoNinth batch for 2.14
Junio C Hamano [Mon, 19 Jun 2017 19:41:12 +0000 (12:41 -0700)] 
Ninth batch for 2.14

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge branch 'jk/consistent-h'
Junio C Hamano [Mon, 19 Jun 2017 19:38:45 +0000 (12:38 -0700)] 
Merge branch 'jk/consistent-h'

"git $cmd -h" for builtin commands calls the implementation of the
command (i.e. cmd_$cmd() function) without doing any repository
set-up, and the commands that expect RUN_SETUP is done by the Git
potty needs to be prepared to show the help text without barfing.

* jk/consistent-h:
  t0012: test "-h" with builtins
  git: add hidden --list-builtins option
  version: convert to parse-options
  diff- and log- family: handle "git cmd -h" early
  submodule--helper: show usage for "-h"
  remote-{ext,fd}: print usage message on invalid arguments
  upload-archive: handle "-h" option early
  credential: handle invalid arguments earlier

6 years agoMerge branch 'ab/perf-remove-index-lock'
Junio C Hamano [Mon, 19 Jun 2017 19:38:44 +0000 (12:38 -0700)] 
Merge branch 'ab/perf-remove-index-lock'

When an existing repository is used for t/perf testing, we first
create bit-for-bit copy of it, which may grab a transient state of
the repository and freeze it into the repository used for testing,
which then may cause Git operations to fail.  Single out "the index
being locked" case and forcibly drop the lock from the copy.

* ab/perf-remove-index-lock:
  perf: work around the tested repo having an index.lock

6 years agoMerge branch 'bw/object-id'
Junio C Hamano [Mon, 19 Jun 2017 19:38:44 +0000 (12:38 -0700)] 
Merge branch 'bw/object-id'

Conversion from uchar[20] to struct object_id continues.

* bw/object-id: (33 commits)
  diff: rename diff_fill_sha1_info to diff_fill_oid_info
  diffcore-rename: use is_empty_blob_oid
  tree-diff: convert path_appendnew to object_id
  tree-diff: convert diff_tree_paths to struct object_id
  tree-diff: convert try_to_follow_renames to struct object_id
  builtin/diff-tree: cleanup references to sha1
  diff-tree: convert diff_tree_sha1 to struct object_id
  notes-merge: convert write_note_to_worktree to struct object_id
  notes-merge: convert verify_notes_filepair to struct object_id
  notes-merge: convert find_notes_merge_pair_ps to struct object_id
  notes-merge: convert merge_from_diffs to struct object_id
  notes-merge: convert notes_merge* to struct object_id
  tree-diff: convert diff_root_tree_sha1 to struct object_id
  combine-diff: convert find_paths_* to struct object_id
  combine-diff: convert diff_tree_combined to struct object_id
  diff: convert diff_flush_patch_id to struct object_id
  patch-ids: convert to struct object_id
  diff: finish conversion for prepare_temp_file to struct object_id
  diff: convert reuse_worktree_file to struct object_id
  diff: convert fill_filespec to struct object_id
  ...

6 years agoMerge branch 'sb/submodule-rm-absorb'
Junio C Hamano [Mon, 19 Jun 2017 19:38:44 +0000 (12:38 -0700)] 
Merge branch 'sb/submodule-rm-absorb'

Doc update to a recently graduated topic.

* sb/submodule-rm-absorb:
  Documentation/git-rm: correct submodule description

6 years agoMerge branch 'ab/pcre-v2'
Junio C Hamano [Mon, 19 Jun 2017 19:38:43 +0000 (12:38 -0700)] 
Merge branch 'ab/pcre-v2'

Update "perl-compatible regular expression" support to enable JIT
and also allow linking with the newer PCRE v2 library.

* ab/pcre-v2:
  grep: add support for PCRE v2
  grep: un-break building with PCRE >= 8.32 without --enable-jit
  grep: un-break building with PCRE < 8.20
  grep: un-break building with PCRE < 8.32
  grep: add support for the PCRE v1 JIT API
  log: add -P as a synonym for --perl-regexp
  grep: skip pthreads overhead when using one thread
  grep: don't redundantly compile throwaway patterns under threading

6 years agoMerge branch 'jk/pathspec-magic-disambiguation'
Junio C Hamano [Mon, 19 Jun 2017 19:38:42 +0000 (12:38 -0700)] 
Merge branch 'jk/pathspec-magic-disambiguation'

The convention for a command line is to follow "git cmdname
--options" with revisions followed by an optional "--"
disambiguator and then finally pathspecs.  When "--" is not there,
we make sure early ones are all interpretable as revs (and do not
look like paths) and later ones are the other way around.  A
pathspec with "magic" (e.g. ":/p/a/t/h" that matches p/a/t/h from
the top-level of the working tree, no matter what subdirectory you
are working from) are conservatively judged as "not a path", which
required disambiguation more often.  The command line parser
learned to say "it's a pathspec" a bit more often when the syntax
looks like so.

* jk/pathspec-magic-disambiguation:
  verify_filename(): flip order of checks
  verify_filename(): treat ":(magic)" as a pathspec
  check_filename(): handle ":^" path magic
  check_filename(): use skip_prefix
  check_filename(): refactor ":/" handling
  t4208: add check for ":/" without matching file

6 years agoglossary: define 'stash entry'
Liam Beguin [Sat, 17 Jun 2017 22:30:52 +0000 (18:30 -0400)] 
glossary: define 'stash entry'

Signed-off-by: Liam Beguin <liambeguin@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agostatus: add optional stash count information
Liam Beguin [Sat, 17 Jun 2017 22:30:51 +0000 (18:30 -0400)] 
status: add optional stash count information

Introduce '--show-stash' and its configuration option 'status.showStash'
to allow git-status to show information about currently stashed entries.

Signed-off-by: Liam Beguin <liambeguin@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agostash: update documentation to use 'stash entry'
Liam Beguin [Sat, 17 Jun 2017 22:30:50 +0000 (18:30 -0400)] 
stash: update documentation to use 'stash entry'

Most of the time, a 'stash entry' is called a 'stash'. Lets try to make
this more consistent and use 'stash entry' instead.

Signed-off-by: Liam Beguin <liambeguin@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agofor_each_bisect_ref(): don't trim refnames
Michael Haggerty [Sun, 18 Jun 2017 13:39:41 +0000 (15:39 +0200)] 
for_each_bisect_ref(): don't trim refnames

`for_each_bisect_ref()` is called by `for_each_bad_bisect_ref()` with
a term "bad". This used to make it call `for_each_ref_in_submodule()`
with a prefix "refs/bisect/bad". But the latter is the name of the
reference that is being sought, so the empty string was being passed
to the callback as the trimmed refname. Moreover, this questionable
practice was turned into an error by

    b9c8e7f2fb prefix_ref_iterator: don't trim too much, 2017-05-22

It makes more sense (and agrees better with the documentation of
`--bisect`) for the callers to receive the full reference names. So

* Add a new function, `for_each_fullref_in_submodule()`, to the refs
  API. This plugs a gap in the existing functionality, analogous to
  `for_each_fullref_in()` but accepting a `submodule` argument.

* Change `for_each_bad_bisect_ref()` to call the new function rather
  than `for_each_ref_in_submodule()`.

* Add a test.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agomergetools/meld: improve compatibiilty with Meld on macOS X
David Aguilar [Mon, 19 Jun 2017 02:10:33 +0000 (19:10 -0700)] 
mergetools/meld: improve compatibiilty with Meld on macOS X

The macOS X fork of Meld[1] requires a "=" in the "--output"
argument, as it uses a wrapper[2] script that munges the
"--output" argument before calling into the common "meld"
script.

The macOS X wrapper script[2] accepts "--output=<filename>"
only, despite the fact that the underlying meld code accepts
both "--output <filename" and "--output=<filename>"[3].

All versions of meld which accept "--output" accept it in
the "--output=<filename>" form, so use "--output=<file>" for
maximum compatibility.

[1] https://github.com/yousseb/meld
[2] https://github.com/yousseb/meld/blob/master/osx/Meld
[3] https://github.com/yousseb/meld/issues/42

Reported-by: Matthew Groth <mgroth49@gmail.com>
Helped-by: Samuel Lijin <sxlijin@gmail.com>
Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years ago*.[ch] refactoring: make use of the FREE_AND_NULL() macro
Ævar Arnfjörð Bjarmason [Thu, 15 Jun 2017 23:15:49 +0000 (23:15 +0000)] 
*.[ch] refactoring: make use of the FREE_AND_NULL() macro

Replace occurrences of `free(ptr); ptr = NULL` which weren't caught by
the coccinelle rule. These fall into two categories:

 - free/NULL assignments one after the other which coccinelle all put
   on one line, which is functionally equivalent code, but very ugly.

 - manually spotted occurrences where the NULL assignment isn't right
   after the free() call.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agococcinelle: make use of the "expression" FREE_AND_NULL() rule
Ævar Arnfjörð Bjarmason [Thu, 15 Jun 2017 23:15:48 +0000 (23:15 +0000)] 
coccinelle: make use of the "expression" FREE_AND_NULL() rule

A follow-up to the existing "expression" rule added in an earlier
change. This manually excludes a few occurrences, mostly things that
resulted in many FREE_AND_NULL() on one line, that'll be manually
fixed in a subsequent change.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agococcinelle: add a rule to make "expression" code use FREE_AND_NULL()
Ævar Arnfjörð Bjarmason [Thu, 15 Jun 2017 23:15:47 +0000 (23:15 +0000)] 
coccinelle: add a rule to make "expression" code use FREE_AND_NULL()

A follow-up to the existing "type" rule added in an earlier
change. This catches some occurrences that are missed by the previous
rule.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agococcinelle: make use of the "type" FREE_AND_NULL() rule
Ævar Arnfjörð Bjarmason [Thu, 15 Jun 2017 23:15:46 +0000 (23:15 +0000)] 
coccinelle: make use of the "type" FREE_AND_NULL() rule

Apply the result of the just-added coccinelle rule. This manually
excludes a few occurrences, mostly things that resulted in many
FREE_AND_NULL() on one line, that'll be manually fixed in a subsequent
change.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agococcinelle: add a rule to make "type" code use FREE_AND_NULL()
Ævar Arnfjörð Bjarmason [Thu, 15 Jun 2017 23:15:45 +0000 (23:15 +0000)] 
coccinelle: add a rule to make "type" code use FREE_AND_NULL()

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agowildmatch test: cover a blind spot in "/" matching
Ævar Arnfjörð Bjarmason [Thu, 15 Jun 2017 21:10:41 +0000 (21:10 +0000)] 
wildmatch test: cover a blind spot in "/" matching

A negated character class that does not include '/', e.g. [^a-z]:

 - Should match '/' when doing "wildmatch"
 - Should not match '/' when doing "pathmatch"

Add two tests to cover these cases.

Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agogit-compat-util: add a FREE_AND_NULL() wrapper around free(ptr); ptr = NULL
Ævar Arnfjörð Bjarmason [Thu, 15 Jun 2017 21:06:59 +0000 (21:06 +0000)] 
git-compat-util: add a FREE_AND_NULL() wrapper around free(ptr); ptr = NULL

Add a FREE_AND_NULL() wrapper marco for the common pattern of freeing
a pointer and assigning NULL to it right afterwards.

The implementation is similar to the (currently unused) XDL_PTRFREE
macro in xdiff/xmacros.h added in commit 3443546f6e ("Use a *real*
built-in diff generator", 2006-03-24). The only difference is that
free() is called unconditionally, see [1].

See [2] for a suggested alternative which does this via a function
instead of a macro. As covered in replies to that message, while it's
a viable approach, it would introduce caveats which this approach
doesn't have, so that potential change is left to a future follow-up
change.

This merely allows us to translate exactly what we're doing now to a
less verbose & idiomatic form using a macro, while guaranteeing that
we don't introduce any functional changes.

1. <alpine.DEB.2.20.1608301948310.129229@virtualbox>
   (http://public-inbox.org/git/alpine.DEB.2.20.1608301948310.129229@virtualbox/)

2. <20170610032143.GA7880@starla>
   (https://public-inbox.org/git/20170610032143.GA7880@starla/)

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agodocs/pretty-formats: stress that %- removes all preceding line-feeds
SZEDER Gábor [Thu, 15 Jun 2017 10:36:07 +0000 (12:36 +0200)] 
docs/pretty-formats: stress that %- removes all preceding line-feeds

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agodate: use localtime() for "-local" time formats
Jeff King [Thu, 15 Jun 2017 13:52:17 +0000 (09:52 -0400)] 
date: use localtime() for "-local" time formats

When we convert seconds-since-epochs timestamps into a
broken-down "struct tm", we do so by adjusting the timestamp
according to the known offset and then using gmtime() to
break down the result. This means that the resulting struct
"knows" that it's in GMT, even though the time it represents
is adjusted for a different zone. The fields where it stores
this data are not portably accessible, so we have no way to
override them to tell them the real zone info.

For the most part, this works. Our date-formatting routines
don't pay attention to these inaccessible fields, and use
the same tz info we provided for adjustment. The one
exception is when we call strftime(), whose %Z format
reveals this hidden timezone data.

We solved that by always showing the empty string for %Z.
This is allowed by POSIX, but not very helpful to the user.
We can't make this work in the general case, as there's no
portable function for setting an arbitrary timezone (and
anyway, we don't have the zone name for the author zones,
only their offsets).

But for the special case of the "-local" formats, we can
just skip the adjustment and use localtime() instead of
gmtime(). This makes --date=format-local:%Z work correctly,
showing the local timezone instead of an empty string.

The new test checks the result for "UTC", our default
test-lib value for $TZ. Using something like EST5 might be
more interesting, but the actual zone string is
system-dependent (for instance, on my system it expands to
just EST). Hopefully "UTC" is vanilla enough that every
system treats it the same.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot0006: check --date=format zone offsets
Jeff King [Thu, 15 Jun 2017 13:51:22 +0000 (09:51 -0400)] 
t0006: check --date=format zone offsets

We already test that "%z" and "%Z" show the right thing, but
we don't actually check that the time we display is the
correct one. Let's add two new tests:

  1. Test that "format:" shows the time in the author's
     timezone, just like the other time formats.

  2. Test that "format-local:" shows time in the local
     timezone. We don't want to use our normal UTC for this,
     because its offset is zero (so the result would be
     "correct" even if the code forgot to apply the offset
     or applied it in the wrong direction).

     We'll use the EST5 zone, which is already used
     elsewhere in the script (and so is assumed to be
     available everywhere).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agostrbuf: let strbuf_addftime handle %z and %Z itself
René Scharfe [Thu, 15 Jun 2017 12:29:53 +0000 (14:29 +0200)] 
strbuf: let strbuf_addftime handle %z and %Z itself

There is no portable way to pass timezone information to strftime.  Add
parameters for timezone offset and name to strbuf_addftime and let it
handle the timezone-related format specifiers %z and %Z internally.

Callers can opt out for %Z by passing NULL as timezone name.  %z is
always handled internally -- this helps on Windows, where strftime would
expand it to a timezone name (same as %Z), in violation of POSIX.
Modifiers are not handled, e.g. %Ez is still passed to strftime.

Use an empty string as timezone name in show_date (the only current
caller) for now because we only have the timezone offset in non-local
mode.  POSIX allows %Z to resolve to an empty string in case of missing
information.

Helped-by: Ulrich Mueller <ulm@gentoo.org>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosub-process: correct path to API docs in a comment
Christian Couder [Wed, 14 Jun 2017 15:12:25 +0000 (17:12 +0200)] 
sub-process: correct path to API docs in a comment

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Acked-by: Ben Peart <peartben@gmail.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge branch 'svn-doc' of git://bogomips.org/git-svn
Junio C Hamano [Thu, 15 Jun 2017 21:15:03 +0000 (14:15 -0700)] 
Merge branch 'svn-doc' of git://bogomips.org/git-svn

* 'svn-doc' of git://bogomips.org/git-svn:
  git-svn: document special options for commit-diff

6 years agoconfigure.ac: loosen FREAD_READS_DIRECTORIES test program
Jeff King [Wed, 14 Jun 2017 05:30:18 +0000 (01:30 -0400)] 
configure.ac: loosen FREAD_READS_DIRECTORIES test program

We added an FREAD_READS_DIRECTORIES Makefile knob long ago
in cba22528f (Add compat/fopen.c which returns NULL on
attempt to open directory, 2008-02-08) to handle systems
where reading from a directory returned garbage. This works
by catching the problem at the fopen() stage and returning
NULL.

More recently, we found that there is a class of systems
(including Linux) where fopen() succeeds but fread() fails.
Since the solution is the same (having fopen return NULL),
they use the same Makefile knob as of e2d90fd1c
(config.mak.uname: set FREAD_READS_DIRECTORIES for Linux and
FreeBSD, 2017-05-03).

This works fine except for one thing: the autoconf test in
configure.ac to set FREAD_READS_DIRECTORIES actually checks
whether fread succeeds. Which means that on Linux systems,
the knob isn't set (and we even override the config.mak.uname
default). t1308 catches the failure.

We can fix this by tweaking the autoconf test to cover both
cases. In theory we might care about the distinction between
the traditional "fread reads directories" case and the new
"fopen opens directories". But since our solution catches
the problem at the fopen stage either way, we don't actually
need to know the difference. The "fopen" case is a superset.

This does mean the FREAD_READS_DIRECTORIES name is slightly
misleading. Probably FOPEN_OPENS_DIRECTORIES would be more
accurate. But it would be disruptive to simply change the
name (people's existing build configs would fail), and it's
not worth the complexity of handling both. Let's just add a
comment in the knob description.

Reported-by: Øyvind A. Holm <sunny@sunbase.org>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agodoc: git-reset: fix a trivial typo
Štěpán Němec [Wed, 14 Jun 2017 09:36:58 +0000 (11:36 +0200)] 
doc: git-reset: fix a trivial typo

Signed-off-by: Štěpán Němec <stepnem@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoconfig: don't implicitly use gitdir or commondir
Brandon Williams [Wed, 14 Jun 2017 18:07:39 +0000 (11:07 -0700)] 
config: don't implicitly use gitdir or commondir

'git_config_with_options()' takes a 'config_options' struct which
contains feilds for 'git_dir' and 'commondir'.  If those feilds happen
to be NULL the config machinery falls back to querying global repository
state.  Let's change this and instead use these fields in the
'config_options' struct explicilty all the time.  Since the API is
slightly changing to require these two fields to be set if callers want
the config machinery to load the repository's config, let's change the
name to 'config_with_optison()'.  This allows the config machinery to
not implicitly rely on any global repository state.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoconfig: respect commondir
Brandon Williams [Wed, 14 Jun 2017 18:07:38 +0000 (11:07 -0700)] 
config: respect commondir

Worktrees present an interesting problem when it comes to the config.
Historically we could assume that the per-repository config lives at
'gitdir/config', but since worktrees were introduced this isn't the case
anymore.  There is currently no way to specify per-worktree
configuration, and as such the repository config is shared with all
worktrees and is located at 'commondir/config'.

Many users of the config machinery correctly set
'config_options.git_dir' with the repository's commondir, allowing the
config to be properly loaded when operating in a worktree.  But other's,
like 'read_early_config()', set 'config_options.git_dir' with the
repository's gitdir which can be incorrect when using worktrees.

To fix this issue, and to make things less ambiguous, lets add a
'commondir' field to the 'config_options' struct and have all callers
properly set both the 'git_dir' and 'commondir' fields so that the
config machinery is able to properly find the repository's config.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosetup: teach discover_git_directory to respect the commondir
Brandon Williams [Wed, 14 Jun 2017 18:07:37 +0000 (11:07 -0700)] 
setup: teach discover_git_directory to respect the commondir

Currently 'discover_git_directory' only looks at the gitdir to determine
if a git directory was discovered.  This causes a problem in the event
that the gitdir which was discovered was in fact a per-worktree git
directory and not the common git directory.  This is because the
repository config, which is checked to verify the repository's format,
is stored in the commondir and not in the per-worktree gitdir.  Correct
this behavior by checking the config stored in the commondir.

It will also be of use for callers to have access to the commondir, so
lets also return that upon successfully discovering a git directory.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoconfig: don't include config.h by default
Brandon Williams [Wed, 14 Jun 2017 18:07:36 +0000 (11:07 -0700)] 
config: don't include config.h by default

Stop including config.h by default in cache.h.  Instead only include
config.h in those files which require use of the config system.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoconfig: remove git_config_iter
Brandon Williams [Wed, 14 Jun 2017 18:07:35 +0000 (11:07 -0700)] 
config: remove git_config_iter

Since there is no implementation of the function 'git_config_iter',
let's stop exporting it and remove the prototype from config.h.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoconfig: create config.h
Brandon Williams [Wed, 14 Jun 2017 18:07:34 +0000 (11:07 -0700)] 
config: create config.h

Move all config related declarations from cache.h to a new config.h
header file.  This makes cache.h smaller and allows for the opportunity
in a following patch to only include config.h when needed.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoalias: use the early config machinery to expand aliases
Johannes Schindelin [Wed, 14 Jun 2017 11:36:00 +0000 (13:36 +0200)] 
alias: use the early config machinery to expand aliases

Instead of discovering the .git/ directory, reading the config and then
trying to painstakingly reset all the global state if we did not find a
matching alias, let's use the early config machinery instead.

It may look like unnecessary work to discover the .git/ directory in the
early config machinery and then call setup_git_directory_gently() in the
case of a shell alias, repeating the very same discovery *again*.
However, we have to do this as the early config machinery takes pains
*not* to touch any global state, while shell aliases expect a possibly
changed working directory and at least the GIT_PREFIX and GIT_DIR
variables to be set.

This change also fixes a known issue where Git tried to read the pager
config from an incorrect path in a subdirectory of a Git worktree if an
alias expanded to a shell command.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot7006: demonstrate a problem with aliases in subdirectories
Johannes Schindelin [Wed, 14 Jun 2017 11:35:56 +0000 (13:35 +0200)] 
t7006: demonstrate a problem with aliases in subdirectories

When expanding aliases, the git_dir is set during the alias expansion
(by virtue of running setup_git_directory_gently()).

This git_dir may be relative to the current working directory, and
indeed often is simply ".git/".

When the alias expands to a shell command, we restore the original
working directory, though, yet we do not reset git_dir.

As a consequence, subsequent read_early_config() runs will mistake the
git_dir to be populated properly and not find the correct config.

Demonstrate this problem by adding a test case.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot1308: relax the test verifying that empty alias values are disallowed
Johannes Schindelin [Wed, 14 Jun 2017 11:35:53 +0000 (13:35 +0200)] 
t1308: relax the test verifying that empty alias values are disallowed

We are about to change the way aliases are expanded, to use the early
config machinery.

This machinery reports errors in a slightly different manner than the
cached config machinery.

Let's not get hung up by the precise wording of the message mentioning
the line number. It is really sufficient to verify that all the relevant
information is given to the user.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agohelp: use early config when autocorrecting aliases
Johannes Schindelin [Wed, 14 Jun 2017 11:35:50 +0000 (13:35 +0200)] 
help: use early config when autocorrecting aliases

Git has this feature which suggests similar commands (including aliases)
in case the user specified an unknown command.

This feature currently relies on a side effect of the way we expand
aliases right now: when a command is not a builtin, we use the regular
config machinery (meaning: discovering the .git/ directory and
initializing global state such as the config cache) to see whether the
command refers to an alias.

However, we will change the way aliases are expanded in the next
commits, to use the early config instead. That means that the
autocorrect feature can no longer discover the available aliases by
looking at the config cache (because it has not yet been initialized).

So let's just use the early config machinery instead.

This is slightly less performant than the previous way, as the early
config is used *twice*: once to see whether the command refers to an
alias, and then to see what aliases are most similar. However, this is
hardly a performance-critical code path, so performance is less important
here.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoconfig: report correct line number upon error
Johannes Schindelin [Wed, 14 Jun 2017 11:35:46 +0000 (13:35 +0200)] 
config: report correct line number upon error

When get_value() parses a key/value pair, it is possible that the line
number is decreased (because the \n has been consumed already) before the
key/value pair is passed to the callback function, to allow for the
correct line to be attributed in case of an error.

However, when git_parse_source() asks get_value() to parse the key/value
pair, the error reporting is performed *after* get_value() returns.

Which means that we have to be careful not to increase the line number
in get_value() after the callback function returned an error.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agodiscover_git_directory(): avoid setting invalid git_dir
Johannes Schindelin [Wed, 14 Jun 2017 11:35:26 +0000 (13:35 +0200)] 
discover_git_directory(): avoid setting invalid git_dir

When discovering a .git/ directory, we take pains to ensure that its
repository format version matches Git's expectations, and we return NULL
otherwise.

However, we still appended the invalid path to the strbuf passed as
argument.

Let's just reset the strbuf to the state before we appended the .git/
directory that was eventually rejected.

There is another early return path in that function, when
setup_git_directory_gently_1() returns GIT_DIR_NONE or an error. In that
case, the gitdir parameter has not been touched, therefore there is no
need for an equivalent change in that code path.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agodiff-highlight: split code into module
Jeff King [Thu, 15 Jun 2017 16:30:55 +0000 (12:30 -0400)] 
diff-highlight: split code into module

The diff-so-fancy project is also written in perl, and most
of its users pipe diffs through both diff-highlight and
diff-so-fancy. It would be nice if this could be done in a
single script. So let's pull most of diff-highlight's code
into its own module which can be used by diff-so-fancy.

In addition, we'll abstract a few basic items like reading
from stdio so that a script using the module can do more
processing before or after diff-highlight handles the lines.
See the README update for more details.

One small downside is that the diff-highlight script must
now be built using the Makefile. There are ways around this,
but it quickly gets into perl arcana. Let's go with the
simple solution. As a bonus, our Makefile now respects the
PERL_PATH variable if it is set.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>