git
6 years agoshell: drop git-cvsserver support by default
Jeff King [Mon, 11 Sep 2017 15:27:51 +0000 (11:27 -0400)] 
shell: drop git-cvsserver support by default

The git-cvsserver script is old and largely unmaintained
these days. But git-shell allows untrusted users to run it
out of the box, significantly increasing its attack surface.

Let's drop it from git-shell's list of internal handlers so
that it cannot be run by default.  This is not backwards
compatible. But given the age and development activity on
CVS-related parts of Git, this is likely to impact very few
users, while helping many more (i.e., anybody who runs
git-shell and had no intention of supporting CVS).

There's no configuration mechanism in git-shell for us to
add a boolean and flip it to "off". But there is a mechanism
for adding custom commands, and adding CVS support here is
fairly trivial. Let's document it to give guidance to
anybody who really is still running cvsserver.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocvsserver: use safe_pipe_capture for `constant commands` as well
Junio C Hamano [Mon, 11 Sep 2017 05:45:54 +0000 (14:45 +0900)] 
cvsserver: use safe_pipe_capture for `constant commands` as well

This is not strictly necessary, but it is a good code hygiene.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocvsserver: use safe_pipe_capture instead of backticks
joernchen [Mon, 11 Sep 2017 05:45:09 +0000 (14:45 +0900)] 
cvsserver: use safe_pipe_capture instead of backticks

This makes the script pass arguments that are derived from end-user
input in safer way when invoking subcommands.

Reported-by: joernchen <joernchen@phenoelit.de>
Signed-off-by: joernchen <joernchen@phenoelit.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocvsserver: move safe_pipe_capture() to the main package
Junio C Hamano [Mon, 11 Sep 2017 05:44:24 +0000 (14:44 +0900)] 
cvsserver: move safe_pipe_capture() to the main package

As a preparation for replacing `command` with a call to this
function from outside GITCVS::updater package, move it to the main
package.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosubprocess: loudly die when subprocess asks for an unsupported capability
Junio C Hamano [Mon, 11 Sep 2017 03:21:29 +0000 (12:21 +0900)] 
subprocess: loudly die when subprocess asks for an unsupported capability

The handshake_capabilities() function first advertises the set of
capabilities it supports, so that the other side can pick and choose
which ones to use and ask us to enable in its response.  Then we
read the response that tells us what choice the other side made.  If
we saw something that we never advertised, that indicates one of two
things.  The other side, i.e. the "upgraded" filter, is not paying
attention of the capabilities advertisement, and asking something
its correct operation relies on, but we are not capable of giving
that unknown feature and operate without it, so after that point the
exchange of data is a garbage-in-garbage-out.  Or the other side
wanted to ask for one of the capabilities we advertised, but the
code has typo and their wish to enable a capability that its correct
operation relies on is not understood on this end.  The result is
the same garbage-in-garbage-out.

Instead of sweeping such a potential bug under the rug, die loudly
when we see a request for an unsupported capability in order to
force sloppily-written filter scripts to get corrected.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoRelNotes: further fixes for 2.14.2 from the master front
Junio C Hamano [Sun, 10 Sep 2017 08:06:09 +0000 (17:06 +0900)] 
RelNotes: further fixes for 2.14.2 from the master front

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge branch 'jt/doc-pack-objects-fix' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:03:10 +0000 (17:03 +0900)] 
Merge branch 'jt/doc-pack-objects-fix' into maint

Doc updates.

* jt/doc-pack-objects-fix:
  Doc: clarify that pack-objects makes packs, plural

6 years agoMerge branch 'jn/vcs-svn-cleanup' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:03:09 +0000 (17:03 +0900)] 
Merge branch 'jn/vcs-svn-cleanup' into maint

Code clean-up.

* jn/vcs-svn-cleanup:
  vcs-svn: move remaining repo_tree functions to fast_export.h
  vcs-svn: remove repo_delete wrapper function
  vcs-svn: remove custom mode constants
  vcs-svn: remove more unused prototypes and declarations

6 years agoMerge branch 'bc/vcs-svn-cleanup' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:03:08 +0000 (17:03 +0900)] 
Merge branch 'bc/vcs-svn-cleanup' into maint

Code clean-up.

* bc/vcs-svn-cleanup:
  vcs-svn: rename repo functions to "svn_repo"
  vcs-svn: remove unused prototypes

6 years agoMerge branch 'jk/doc-the-this' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:03:07 +0000 (17:03 +0900)] 
Merge branch 'jk/doc-the-this' into maint

Doc clean-up.

* jk/doc-the-this:
  doc: fix typo in sendemail.identity

6 years agoMerge branch 'rs/commit-h-single-parent-cleanup' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:03:07 +0000 (17:03 +0900)] 
Merge branch 'rs/commit-h-single-parent-cleanup' into maint

Code clean-up.

* rs/commit-h-single-parent-cleanup:
  commit: remove unused inline function single_parent()

6 years agoMerge branch 'mg/format-ref-doc-fix' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:03:06 +0000 (17:03 +0900)] 
Merge branch 'mg/format-ref-doc-fix' into maint

Doc fix.

* mg/format-ref-doc-fix:
  Documentation/git-for-each-ref: clarify peeling of tags for --format
  Documentation: use proper wording for ref format strings

6 years agoMerge branch 'sb/submodule-parallel-update' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:03:06 +0000 (17:03 +0900)] 
Merge branch 'sb/submodule-parallel-update' into maint

Code clean-up.

* sb/submodule-parallel-update:
  submodule.sh: remove unused variable

6 years agoMerge branch 'hv/t5526-andand-chain-fix' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:03:05 +0000 (17:03 +0900)] 
Merge branch 'hv/t5526-andand-chain-fix' into maint

Test fix.

* hv/t5526-andand-chain-fix:
  t5526: fix some broken && chains

6 years agoMerge branch 'sb/sha1-file-cleanup' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:03:04 +0000 (17:03 +0900)] 
Merge branch 'sb/sha1-file-cleanup' into maint

Code clean-up.

* sb/sha1-file-cleanup:
  sha1_file: make read_info_alternates static

6 years agoMerge branch 'rs/t1002-do-not-use-sum' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:03:04 +0000 (17:03 +0900)] 
Merge branch 'rs/t1002-do-not-use-sum' into maint

Test simplification.

* rs/t1002-do-not-use-sum:
  t1002: stop using sum(1)

6 years agoMerge branch 'ah/doc-empty-string-is-false' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:03:03 +0000 (17:03 +0900)] 
Merge branch 'ah/doc-empty-string-is-false' into maint

Doc update.

* ah/doc-empty-string-is-false:
  doc: clarify "config --bool" behaviour with empty string

6 years agoMerge branch 'rs/merge-microcleanup' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:03:02 +0000 (17:03 +0900)] 
Merge branch 'rs/merge-microcleanup' into maint

Code clean-up.

* rs/merge-microcleanup:
  merge: use skip_prefix()

6 years agoMerge branch 'rs/find-pack-entry-bisection' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:03:02 +0000 (17:03 +0900)] 
Merge branch 'rs/find-pack-entry-bisection' into maint

Code clean-up.

* rs/find-pack-entry-bisection:
  sha1_file: avoid comparison if no packed hash matches the first byte

6 years agoMerge branch 'rs/apply-lose-prefix-length' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:03:01 +0000 (17:03 +0900)] 
Merge branch 'rs/apply-lose-prefix-length' into maint

Code clean-up.

* rs/apply-lose-prefix-length:
  apply: remove prefix_length member from apply_state

6 years agoMerge branch 'rj/add-chmod-error-message' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:03:00 +0000 (17:03 +0900)] 
Merge branch 'rj/add-chmod-error-message' into maint

Message fix.

* rj/add-chmod-error-message:
  builtin/add: add detail to a 'cannot chmod' error message

6 years agoMerge branch 'jk/hashcmp-memcmp' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:59 +0000 (17:02 +0900)] 
Merge branch 'jk/hashcmp-memcmp' into maint

Code clean-up.

* jk/hashcmp-memcmp:
  hashcmp: use memcmp instead of open-coded loop

6 years agoMerge branch 'rs/t3700-clean-leftover' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:58 +0000 (17:02 +0900)] 
Merge branch 'rs/t3700-clean-leftover' into maint

A test fix.

* rs/t3700-clean-leftover:
  t3700: fix broken test under !POSIXPERM

6 years agoMerge branch 'jc/perl-git-comment-typofix' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:57 +0000 (17:02 +0900)] 
Merge branch 'jc/perl-git-comment-typofix' into maint

A comment fix.

* jc/perl-git-comment-typofix:
  perl/Git.pm: typofix in a comment

6 years agoMerge branch 'mf/no-dashed-subcommands' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:56 +0000 (17:02 +0900)] 
Merge branch 'mf/no-dashed-subcommands' into maint

Code clean-up.

* mf/no-dashed-subcommands:
  scripts: use "git foo" not "git-foo"

6 years agoMerge branch 'ab/ref-filter-no-contains' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:56 +0000 (17:02 +0900)] 
Merge branch 'ab/ref-filter-no-contains' into maint

A test fix.

* ab/ref-filter-no-contains:
  tests: don't give unportable ">" to "test" built-in, use -gt

6 years agoMerge branch 'rs/archive-excluded-directory' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:55 +0000 (17:02 +0900)] 
Merge branch 'rs/archive-excluded-directory' into maint

"git archive" did not work well with pathspecs and the
export-ignore attribute.

We may want to resurrect the "we don't archive an empty directory"
bonus patch, but I do not mind merging the above early to 'next'
and leave it as a separate follow-up enhancement.
cf. <20170820090629.tumvqwzkromcykjf@sigill.intra.peff.net>

* rs/archive-excluded-directory:
  archive: don't queue excluded directories
  archive: factor out helper functions for handling attributes
  t5001: add tests for export-ignore attributes and exclude pathspecs

6 years agoMerge branch 'mg/killed-merge' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:55 +0000 (17:02 +0900)] 
Merge branch 'mg/killed-merge' into maint

Killing "git merge --edit" before the editor returns control left
the repository in a state with MERGE_MSG but without MERGE_HEAD,
which incorrectly tells the subsequent "git commit" that there was
a squash merge in progress.  This has been fixed.

* mg/killed-merge:
  merge: save merge state earlier
  merge: split write_merge_state in two
  merge: clarify call chain
  Documentation/git-merge: explain --continue

6 years agoMerge branch 'tb/apply-with-crlf' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:55 +0000 (17:02 +0900)] 
Merge branch 'tb/apply-with-crlf' into maint

"git apply" that is used as a better "patch -p1" failed to apply a
taken from a file with CRLF line endings to a file with CRLF line
endings.  The root cause was because it misused convert_to_git()
that tried to do "safe-crlf" processing by looking at the index
entry at the same path, which is a nonsense---in that mode, "apply"
is not working on the data in (or derived from) the index at all.
This has been fixed.

* tb/apply-with-crlf:
  apply: file commited with CRLF should roundtrip diff and apply
  convert: add SAFE_CRLF_KEEP_CRLF

6 years agoMerge branch 'cc/subprocess-handshake-missing-capabilities' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:55 +0000 (17:02 +0900)] 
Merge branch 'cc/subprocess-handshake-missing-capabilities' into maint

When handshake with a subprocess filter notices that the process
asked for an unknown capability, Git did not report what program
the offending subprocess was running.  This has been corrected.

We may want a follow-up fix to tighten the error checking, though.

* cc/subprocess-handshake-missing-capabilities:
  sub-process: print the cmd when a capability is unsupported

6 years agoMerge branch 'as/grep-quiet-no-match-exit-code-fix' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:55 +0000 (17:02 +0900)] 
Merge branch 'as/grep-quiet-no-match-exit-code-fix' into maint

"git grep -L" and "git grep --quiet -L" reported different exit
codes; this has been corrected.

* as/grep-quiet-no-match-exit-code-fix:
  git-grep: correct exit code with --quiet and -L

6 years agoMerge branch 'kd/stash-with-bash-4.4' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:54 +0000 (17:02 +0900)] 
Merge branch 'kd/stash-with-bash-4.4' into maint

bash 4.4 or newer gave a warning on NUL byte in command
substitution done in "git stash"; this has been squelched.

* kd/stash-with-bash-4.4:
  stash: prevent warning about null bytes in input

6 years agoMerge branch 'rs/win32-syslog-leakfix' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:54 +0000 (17:02 +0900)] 
Merge branch 'rs/win32-syslog-leakfix' into maint

Memory leak in an error codepath has been plugged.

* rs/win32-syslog-leakfix:
  win32: plug memory leak on realloc() failure in syslog()

6 years agoMerge branch 'rs/unpack-entry-leakfix' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:53 +0000 (17:02 +0900)] 
Merge branch 'rs/unpack-entry-leakfix' into maint

Memory leak in an error codepath has been plugged.

* rs/unpack-entry-leakfix:
  sha1_file: release delta_stack on error in unpack_entry()

6 years agoMerge branch 'rs/fsck-obj-leakfix' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:52 +0000 (17:02 +0900)] 
Merge branch 'rs/fsck-obj-leakfix' into maint

Memory leak in an error codepath has been plugged.

* rs/fsck-obj-leakfix:
  fsck: free buffers on error in fsck_obj()

6 years agoMerge branch 'ur/svn-local-zone' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:52 +0000 (17:02 +0900)] 
Merge branch 'ur/svn-local-zone' into maint

"git svn" used with "--localtime" option did not compute the tz
offset for the timestamp in question and instead always used the
current time, which has been corrected.

* ur/svn-local-zone:
  git svn fetch: Create correct commit timestamp when using --localtime

6 years agoMerge branch 'pw/am-signoff' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:51 +0000 (17:02 +0900)] 
Merge branch 'pw/am-signoff' into maint

"git am -s" has been taught that some input may end with a trailer
block that is not Signed-off-by: and it should refrain from adding
an extra blank line before adding a new sign-off in such a case.

* pw/am-signoff:
  am: fix signoff when other trailers are present

6 years agoMerge branch 'rs/in-obsd-basename-dirname-take-const' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:51 +0000 (17:02 +0900)] 
Merge branch 'rs/in-obsd-basename-dirname-take-const' into maint

Portability fix.

* rs/in-obsd-basename-dirname-take-const:
  test-path-utils: handle const parameter of basename and dirname

6 years agoMerge branch 'rs/t4062-obsd' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:51 +0000 (17:02 +0900)] 
Merge branch 'rs/t4062-obsd' into maint

Test portability fix.

* rs/t4062-obsd:
  t4062: use less than 256 repetitions in regex

6 years agoMerge branch 'rs/obsd-getcwd-workaround' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:50 +0000 (17:02 +0900)] 
Merge branch 'rs/obsd-getcwd-workaround' into maint

Test portability fix for BSDs.

* rs/obsd-getcwd-workaround:
  t0001: skip test with restrictive permissions if getpwd(3) respects them

6 years agoMerge branch 'bw/clone-recursive-quiet' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:49 +0000 (17:02 +0900)] 
Merge branch 'bw/clone-recursive-quiet' into maint

"git clone --recurse-submodules --quiet" did not pass the quiet
option down to submodules.

* bw/clone-recursive-quiet:
  clone: teach recursive clones to respect -q

6 years agoMerge branch 'pw/sequence-rerere-autoupdate' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:49 +0000 (17:02 +0900)] 
Merge branch 'pw/sequence-rerere-autoupdate' into maint

Commands like "git rebase" accepted the --rerere-autoupdate option
from the command line, but did not always use it.  This has been
fixed.

* pw/sequence-rerere-autoupdate:
  cherry-pick/revert: reject --rerere-autoupdate when continuing
  cherry-pick/revert: remember --rerere-autoupdate
  t3504: use test_commit
  rebase -i: honor --rerere-autoupdate
  rebase: honor --rerere-autoupdate
  am: remember --rerere-autoupdate setting

6 years agoMerge branch 'bw/push-options-recursively-to-submodules' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:49 +0000 (17:02 +0900)] 
Merge branch 'bw/push-options-recursively-to-submodules' into maint

"git push --recurse-submodules $there HEAD:$target" was not
propagated down to the submodules, but now it is.

* bw/push-options-recursively-to-submodules:
  submodule--helper: teach push-check to handle HEAD

6 years agoMerge branch 'ma/pager-per-subcommand-action' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:48 +0000 (17:02 +0900)] 
Merge branch 'ma/pager-per-subcommand-action' into maint

The "tag.pager" configuration variable was useless for those who
actually create tag objects, as it interfered with the use of an
editor.  A new mechanism has been introduced for commands to enable
pager depending on what operation is being carried out to fix this,
and then "git tag -l" is made to run pager by default.

If this works out OK, I think there are low-hanging fruits in
other commands like "git branch" that outputs long list in one mode
while taking input in another.

* ma/pager-per-subcommand-action:
  git.c: ignore pager.* when launching builtin as dashed external
  tag: change default of `pager.tag` to "on"
  tag: respect `pager.tag` in list-mode only
  t7006: add tests for how git tag paginates
  git.c: provide setup_auto_pager()
  git.c: let builtins opt for handling `pager.foo` themselves
  builtin.h: take over documentation from api-builtin.txt

6 years agoMerge branch 'jk/rev-list-empty-input' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:48 +0000 (17:02 +0900)] 
Merge branch 'jk/rev-list-empty-input' into maint

"git log --tag=no-such-tag" showed log starting from HEAD, which
has been fixed---it now shows nothing.

* jk/rev-list-empty-input:
  revision: do not fallback to default when rev_input_given is set
  rev-list: don't show usage when we see empty ref patterns
  revision: add rev_input_given flag
  t6018: flesh out empty input/output rev-list tests

6 years agoMerge branch 'st/lib-gpg-kill-stray-agent' into maint
Junio C Hamano [Sun, 10 Sep 2017 08:02:48 +0000 (17:02 +0900)] 
Merge branch 'st/lib-gpg-kill-stray-agent' into maint

Some versions of GnuPG fails to kill gpg-agent it auto-spawned
and such a left-over agent can interfere with a test.  Work it
around by attempting to kill one before starting a new test.

* st/lib-gpg-kill-stray-agent:
  t: lib-gpg: flush gpg agent on startup

6 years agocommit-tree: do not complete line in -F input
Ross Kabus [Thu, 7 Sep 2017 14:41:11 +0000 (10:41 -0400)] 
commit-tree: do not complete line in -F input

"git commit-tree -F <file>", unlike "cat <file> | git
commit-tree" (i.e. feeding the same contents from the standard
input), added a missing final newline when the input ended in an
incomplete line.

Correct this inconsistency by leaving the incomplete line as-is,
as erring on the side of not touching the input is preferrable
and expected for a plumbing command like "commit-tree".

Signed-off-by: Ross Kabus <rkabus@aerotech.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agogit_extract_argv0_path: do nothing without RUNTIME_PREFIX
Jeff King [Wed, 6 Sep 2017 12:32:10 +0000 (08:32 -0400)] 
git_extract_argv0_path: do nothing without RUNTIME_PREFIX

When the RUNTIME_PREFIX compile-time knob isn't set, we
never look at the argv0_path we extract. We can push its
declaration inside the #ifdef to make it more clear that the
extract code is effectively a noop.

This also un-confuses leak-checking of the argv0_path
variable when RUNTIME_PREFIX isn't set. The compiler is free
to drop this static variable that we set but never look at
(and "gcc -O2" does so).  But the compiler still must call
strbuf_detach(), since it doesn't know whether that function
has side effects; it just throws away the result rather than
putting it into the global.

Leak-checkers which work by scanning the data segment for
pointers to heap blocks would normally consider the block
as reachable at program end. But if the compiler removes the
variable entirely, there's nothing to find.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosystem_path: move RUNTIME_PREFIX to a sub-function
Jeff King [Wed, 6 Sep 2017 12:30:28 +0000 (08:30 -0400)] 
system_path: move RUNTIME_PREFIX to a sub-function

The system_path() function has an #ifdef in the middle of
it. Let's move the conditional logic into a sub-function.
This isolates it more, which will make it easier to change
and add to.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoDocumentation: mention that `eol` can change the dirty status of paths
Ben Boeckel [Thu, 31 Aug 2017 13:19:36 +0000 (09:19 -0400)] 
Documentation: mention that `eol` can change the dirty status of paths

When setting the `eol` attribute, paths can change their dirty status
without any change in the working directory. This can cause confusion
and should at least be mentioned with a remedy.

Signed-off-by: Ben Boeckel <mathstuf@gmail.com>
Reviewed-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agorev-parse: don't trim bisect refnames
Jeff King [Wed, 6 Sep 2017 11:53:10 +0000 (07:53 -0400)] 
rev-parse: don't trim bisect refnames

Using for_each_ref_in() with a full refname has always been
a questionable practice, but it became an error with
b9c8e7f2fb (prefix_ref_iterator: don't trim too much,
2017-05-22), making "git rev-parse --bisect" pretty reliably
show a BUG.

Commit 03df567fbf (for_each_bisect_ref(): don't trim
refnames, 2017-06-18) fixed this case for revision.c, but
rev-parse handles this option on its own. We can use the
same solution here (and piggy-back on its test).

Signed-off-by: Jeff King <peff@peff.net>
Acked-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agopkt-line: re-'static'-ify buffer in packet_write_fmt_1()
Martin Ågren [Sun, 27 Aug 2017 07:37:32 +0000 (09:37 +0200)] 
pkt-line: re-'static'-ify buffer in packet_write_fmt_1()

The static-ness was silently dropped in commit 70428d1a5 ("pkt-line: add
packet_write_fmt_gently()", 2016-10-16). As a result, for each call to
packet_write_fmt_1, we allocate and leak a buffer.

We could keep the strbuf non-static and instead make sure we always
release it before returning (but not before we die, so that we don't
touch errno). That would also prepare us for threaded use. But until
that needs to happen, let's just restore the static-ness so that we get
back to a situation where we (eventually) do not continuosly keep
allocating memory.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoconfig: use a static lock_file struct
Jeff King [Tue, 29 Aug 2017 18:58:50 +0000 (14:58 -0400)] 
config: use a static lock_file struct

When modifying git config, we xcalloc() a struct lock_file
but never free it. This is necessary because the tempfile
code (upon which the locking code is built) requires that
the resulting struct remain valid through the life of the
program. However, it also confuses leak-checkers like
valgrind because only the inner "struct tempfile" is still
reachable; no pointer to the outer lock_file is kept.

Other code paths solve this by using a single static lock
struct. We can do the same here, because we know that we'll
only lock and modify one config file at a time (and
assertions within the lockfile code will ensure that this
remains the case).

That removes a real leak (when we fail to free the struct
after locking fails) as well as removes the valgrind false
positive. It also means that doing N sequential
config-writes will use a constant amount of memory, rather
than leaving stale lock_files for each.

Note that since "lock" is no longer a pointer, it can't be
NULL anymore. But that's OK. We used that feature only to
avoid calling rollback_lock_file() on an already-committed
lock. Since the lockfile code keeps its own "active" flag,
it's a noop to rollback an inactive lock, and we don't have
to worry about this ourselves.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agodiff-highlight: add clean target to Makefile
Daniel Watkins [Tue, 29 Aug 2017 11:23:11 +0000 (12:23 +0100)] 
diff-highlight: add clean target to Makefile

Now that `make` produces a file, we should have a clean target to remove
it.

Signed-off-by: Daniel Watkins <daniel@daniel-watkins.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoname-rev: change ULONG_MAX to TIME_MAX
Michael J Gruber [Wed, 30 Aug 2017 09:46:06 +0000 (11:46 +0200)] 
name-rev: change ULONG_MAX to TIME_MAX

Earlier, dddbad728c ("timestamp_t: a new data type for timestamps",
2017-04-26) changed several types to timestamp_t.

5589e87fd8 ("name-rev: change a "long" variable to timestamp_t",
2017-05-20) cleaned up a missed variable, but both missed a _MAX
constant.

Change the remaining constant to the one appropriate for the current
type

Signed-off-by: Michael J Gruber <git@grubix.eu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosha1-lookup: remove sha1_entry_pos() from header file
Christian Couder [Fri, 25 Aug 2017 07:36:13 +0000 (09:36 +0200)] 
sha1-lookup: remove sha1_entry_pos() from header file

Since f1068efefe (sha1_file: drop experimental GIT_USE_LOOKUP search, 2017-08-09)
the definition of sha1_entry_pos() has been removed from "sha1-lookup.c", so
there is no need anymore for its declaration in "sha1-lookup.h".

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosend-email: don't use Mail::Address, even if available
Matthieu Moy [Wed, 23 Aug 2017 10:21:02 +0000 (12:21 +0200)] 
send-email: don't use Mail::Address, even if available

Using Mail::Address made sense when we didn't have a proper parser. We
now have a reasonable address parser, and using Mail::Address
_if available_ causes much more trouble than it gives benefits:

* Developers typically test one version, not both.

* Users may not be aware that installing Mail::Address will change the
  behavior. They may complain about the behavior in one case without
  knowing that Mail::Address is involved.

* Having this optional Mail::Address makes it tempting to anwser "please
  install Mail::Address" to users instead of fixing our own code. We've
  reached the stage where bugs in our parser should be fixed, not worked
  around.

Signed-off-by: Matthieu Moy <git@matthieu-moy.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosend-email: fix garbage removal after address
Matthieu Moy [Wed, 23 Aug 2017 10:21:01 +0000 (12:21 +0200)] 
send-email: fix garbage removal after address

This is a followup over 9d33439 (send-email: only allow one address
per body tag, 2017-02-20). The first iteration did allow writting

Cc: <foo@example.com> # garbage
but did so by matching the regex ([^>]*>?), i.e. stop after the first
instance of '>'. However, it did not properly deal with

Cc: foo@example.com # garbage
Fix this using a new function strip_garbage_one_address, which does
essentially what the old ([^>]*>?) was doing, but dealing with more
corner-cases. Since we've allowed

Cc: "Foo # Bar" <foobar@example.com>
in previous versions, it makes sense to continue allowing it (but we
still remove any garbage after it). OTOH, when an address is given
without quoting, we just take the first word and ignore everything
after.

Signed-off-by: Matthieu Moy <git@matthieu-moy.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoPrepare for 2.14.2
Junio C Hamano [Wed, 23 Aug 2017 21:36:03 +0000 (14:36 -0700)] 
Prepare for 2.14.2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge branch 'jt/t1450-fsck-corrupt-packfile' into maint
Junio C Hamano [Wed, 23 Aug 2017 21:33:52 +0000 (14:33 -0700)] 
Merge branch 'jt/t1450-fsck-corrupt-packfile' into maint

A test update.

* jt/t1450-fsck-corrupt-packfile:
  tests: ensure fsck fails on corrupt packfiles

6 years agoMerge branch 'jb/t8008-cleanup' into maint
Junio C Hamano [Wed, 23 Aug 2017 21:33:52 +0000 (14:33 -0700)] 
Merge branch 'jb/t8008-cleanup' into maint

Code clean-up.

* jb/t8008-cleanup:
  t8008: rely on rev-parse'd HEAD instead of sha1 value

6 years agoMerge branch 'jt/subprocess-handshake' into maint
Junio C Hamano [Wed, 23 Aug 2017 21:33:52 +0000 (14:33 -0700)] 
Merge branch 'jt/subprocess-handshake' into maint

Code cleanup.

* jt/subprocess-handshake:
  sub-process: refactor handshake to common function
  Documentation: migrate sub-process docs to header
  convert: add "status=delayed" to filter process protocol
  convert: refactor capabilities negotiation
  convert: move multiple file filter error handling to separate function
  convert: put the flags field before the flag itself for consistent style
  t0021: write "OUT <size>" only on success
  t0021: make debug log file name configurable
  t0021: keep filter log files on comparison

6 years agoMerge branch 'dc/fmt-merge-msg-microcleanup' into maint
Junio C Hamano [Wed, 23 Aug 2017 21:33:52 +0000 (14:33 -0700)] 
Merge branch 'dc/fmt-merge-msg-microcleanup' into maint

Code cleanup.

* dc/fmt-merge-msg-microcleanup:
  fmt-merge-msg: fix coding style

6 years agoMerge branch 'ah/doc-wserrorhighlight' into maint
Junio C Hamano [Wed, 23 Aug 2017 21:33:51 +0000 (14:33 -0700)] 
Merge branch 'ah/doc-wserrorhighlight' into maint

Doc update.

* ah/doc-wserrorhighlight:
  doc: add missing values "none" and "default" for diff.wsErrorHighlight

6 years agoMerge branch 'cc/ref-is-hidden-microcleanup' into maint
Junio C Hamano [Wed, 23 Aug 2017 21:33:50 +0000 (14:33 -0700)] 
Merge branch 'cc/ref-is-hidden-microcleanup' into maint

Code cleanup.

* cc/ref-is-hidden-microcleanup:
  refs: use skip_prefix() in ref_is_hidden()

6 years agoMerge branch 'js/run-process-parallel-api-fix' into maint
Junio C Hamano [Wed, 23 Aug 2017 21:33:49 +0000 (14:33 -0700)] 
Merge branch 'js/run-process-parallel-api-fix' into maint

API fix.

* js/run-process-parallel-api-fix:
  run_processes_parallel: change confusing task_cb convention

6 years agoMerge branch 'rs/pack-objects-pbase-cleanup' into maint
Junio C Hamano [Wed, 23 Aug 2017 21:33:48 +0000 (14:33 -0700)] 
Merge branch 'rs/pack-objects-pbase-cleanup' into maint

Code clean-up.

* rs/pack-objects-pbase-cleanup:
  pack-objects: remove unnecessary NULL check

6 years agoMerge branch 'jt/fsck-code-cleanup' into maint
Junio C Hamano [Wed, 23 Aug 2017 21:33:48 +0000 (14:33 -0700)] 
Merge branch 'jt/fsck-code-cleanup' into maint

Code clean-up.

* jt/fsck-code-cleanup:
  fsck: cleanup unused variable
  object: remove "used" field from struct object
  fsck: remove redundant parse_tree() invocation

6 years agoMerge branch 'rs/stat-data-unaligned-reads-fix' into maint
Junio C Hamano [Wed, 23 Aug 2017 21:33:47 +0000 (14:33 -0700)] 
Merge branch 'rs/stat-data-unaligned-reads-fix' into maint

Code clean-up.

* rs/stat-data-unaligned-reads-fix:
  dir: support platforms that require aligned reads

6 years agoMerge branch 'rs/move-array' into maint
Junio C Hamano [Wed, 23 Aug 2017 21:33:46 +0000 (14:33 -0700)] 
Merge branch 'rs/move-array' into maint

Code clean-up.

* rs/move-array:
  ls-files: don't try to prune an empty index
  apply: use COPY_ARRAY and MOVE_ARRAY in update_image()
  use MOVE_ARRAY
  add MOVE_ARRAY

6 years agoMerge branch 'rs/bswap-ubsan-fix' into maint
Junio C Hamano [Wed, 23 Aug 2017 21:33:46 +0000 (14:33 -0700)] 
Merge branch 'rs/bswap-ubsan-fix' into maint

Code clean-up.

* rs/bswap-ubsan-fix:
  bswap: convert get_be16, get_be32 and put_be32 to inline functions
  bswap: convert to unsigned before shifting in get_be32

6 years agoMerge branch 'dl/credential-cache-socket-in-xdg-cache' into maint
Junio C Hamano [Wed, 23 Aug 2017 21:33:45 +0000 (14:33 -0700)] 
Merge branch 'dl/credential-cache-socket-in-xdg-cache' into maint

A recently added test for the "credential-cache" helper revealed
that EOF detection done around the time the connection to the cache
daemon is torn down were flaky.  This was fixed by reacting to
ECONNRESET and behaving as if we got an EOF.

* dl/credential-cache-socket-in-xdg-cache:
  credential-cache: interpret an ECONNRESET as an EOF

6 years agoMerge branch 'hb/gitweb-project-list' into maint
Junio C Hamano [Wed, 23 Aug 2017 21:33:44 +0000 (14:33 -0700)] 
Merge branch 'hb/gitweb-project-list' into maint

When a directory is not readable, "gitweb" fails to build the
project list.  Work this around by skipping such a directory.

It might end up hiding a problem under the rug and a better
solution might be to loudly complain to the administrator pointing
out the problematic directory, but this will at least make it
"work".

* hb/gitweb-project-list:
  gitweb: skip unreadable subdirectories

6 years agoMerge branch 'ks/commit-abort-on-empty-message-fix' into maint
Junio C Hamano [Wed, 23 Aug 2017 21:33:44 +0000 (14:33 -0700)] 
Merge branch 'ks/commit-abort-on-empty-message-fix' into maint

"git commit" when seeing an totally empty message said "you did not
edit the message", which is clearly wrong.  The message has been
corrected.

* ks/commit-abort-on-empty-message-fix:
  commit: check for empty message before the check for untouched template

6 years agoMerge branch 'jk/reflog-walk' into maint
Junio C Hamano [Wed, 23 Aug 2017 21:33:43 +0000 (14:33 -0700)] 
Merge branch 'jk/reflog-walk' into maint

Numerous bugs in walking of reflogs via "log -g" and friends have
been fixed.

* jk/reflog-walk:
  reflog-walk: apply --since/--until to reflog dates
  reflog-walk: stop using fake parents
  rev-list: check reflog_info before showing usage
  get_revision_1(): replace do-while with an early return
  log: do not free parents when walking reflog
  log: clarify comment about reflog cycles
  revision: disallow reflog walking with revs->limited
  t1414: document some reflog-walk oddities

6 years agoMerge branch 'jc/http-sslkey-and-ssl-cert-are-paths' into maint
Junio C Hamano [Wed, 23 Aug 2017 21:33:43 +0000 (14:33 -0700)] 
Merge branch 'jc/http-sslkey-and-ssl-cert-are-paths' into maint

The http.{sslkey,sslCert} configuration variables are to be
interpreted as a pathname that honors "~[username]/" prefix, but
weren't, which has been fixed.

* jc/http-sslkey-and-ssl-cert-are-paths:
  http.c: http.sslcert and http.sslkey are both pathnames

6 years agoMerge branch 'jk/ref-filter-colors' into maint
Junio C Hamano [Wed, 23 Aug 2017 21:33:42 +0000 (14:33 -0700)] 
Merge branch 'jk/ref-filter-colors' into maint

"%C(color name)" in the pretty print format always produced ANSI
color escape codes, which was an early design mistake.  They now
honor the configuration (e.g. "color.ui = never") and also tty-ness
of the output medium.

* jk/ref-filter-colors:
  ref-filter: consult want_color() before emitting colors
  pretty: respect color settings for %C placeholders
  rev-list: pass diffopt->use_colors through to pretty-print
  for-each-ref: load config earlier
  color: check color.ui in git_default_config()
  ref-filter: pass ref_format struct to atom parsers
  ref-filter: factor out the parsing of sorting atoms
  ref-filter: make parse_ref_filter_atom a private function
  ref-filter: provide a function for parsing sort options
  ref-filter: move need_color_reset_at_eol into ref_format
  ref-filter: abstract ref format into its own struct
  ref-filter: simplify automatic color reset
  t: use test_decode_color rather than literal ANSI codes
  docs/for-each-ref: update pointer to color syntax
  check return value of verify_ref_format()

6 years agoMerge branch 'js/git-gui-msgfmt-on-windows' into maint
Junio C Hamano [Wed, 23 Aug 2017 21:33:42 +0000 (14:33 -0700)] 
Merge branch 'js/git-gui-msgfmt-on-windows' into maint

Because recent Git for Windows do come with a real msgfmt, the
build procedure for git-gui has been updated to use it instead of a
hand-rolled substitute.

* js/git-gui-msgfmt-on-windows:
  git-gui (MinGW): make use of MSys2's msgfmt
  git gui: allow for a long recentrepo list
  git gui: de-dup selected repo from recentrepo history
  git gui: cope with duplicates in _get_recentrepo
  git-gui: remove duplicate entries from .gitconfig's gui.recentrepo

6 years agovcs-svn: move remaining repo_tree functions to fast_export.h
Jonathan Nieder [Wed, 23 Aug 2017 00:04:47 +0000 (17:04 -0700)] 
vcs-svn: move remaining repo_tree functions to fast_export.h

These used to be for manipulating the in-memory repo_tree structure,
but nowadays they are convenience wrappers to handle a few git-vs-svn
mismatches:

 1. Git does not track empty directories but Subversion does.  When
    looking up a path in git that Subversion thinks exists and finding
    nothing, we can safely assume that the path represents a
    directory.  This is needed when a later Subversion revision
    modifies that directory.

 2. Subversion allows deleting a file by copying.  In Git fast-import
    we have to handle that more explicitly as a deletion.

These are details of the tool's interaction with git fast-import.
Move them to fast_export.c, where other such details are handled.

This way the function names do not start with a repo_ prefix that
would clash with the repository object introduced in
v2.14.0-rc0~38^2~16 (repository: introduce the repository object,
2017-06-22) or an svn_ prefix that would clash with libsvn (in case
someone wants to link this code with libsvn some day).

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agovcs-svn: remove repo_delete wrapper function
Jonathan Nieder [Wed, 23 Aug 2017 00:02:15 +0000 (17:02 -0700)] 
vcs-svn: remove repo_delete wrapper function

Since v1.7.10-rc0~118^2~4^2~4^2~3 (vcs-svn: pass paths through to
fast-import, 2010-12-13) this is an alias for fast_export_delete.
Remove the unnecessary layer of indirection.

No functional change intended.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agovcs-svn: remove custom mode constants
Jonathan Nieder [Wed, 23 Aug 2017 00:01:34 +0000 (17:01 -0700)] 
vcs-svn: remove custom mode constants

In the rest of Git, these modes are spelled as S_IFDIR,
S_IFREG | 0644, S_IFREG | 0755, and S_IFLNK.  Use the same constants
in svn-fe for simplicity and consistency.

No functional change intended.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agovcs-svn: remove more unused prototypes and declarations
Jonathan Nieder [Wed, 23 Aug 2017 00:00:57 +0000 (17:00 -0700)] 
vcs-svn: remove more unused prototypes and declarations

I forgot to remove these in v1.7.10-rc0~118^2~4^2~5^2~4 (vcs-svn:
eliminate repo_tree structure, 2010-12-10).

This finishes what was started in commit 36f63b50 (vcs-svn: remove
unused prototypes, 2017-08-21).

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoDoc: clarify that pack-objects makes packs, plural
Jonathan Tan [Wed, 23 Aug 2017 00:40:10 +0000 (17:40 -0700)] 
Doc: clarify that pack-objects makes packs, plural

The documentation for pack-objects describes that it creates "a packed
archive of objects", which is confusing because it may create multiple
packs if --max-pack-size is set. Update the documentation to clarify
this, and explaining in which cases such a feature would be useful.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agomerge: save merge state earlier
Michael J Gruber [Wed, 23 Aug 2017 12:10:45 +0000 (14:10 +0200)] 
merge: save merge state earlier

If the `git merge` process is killed while waiting for the editor to
finish, the merge state is lost but the prepared merge msg and tree is kept.
So, a subsequent `git commit` creates a squashed merge even when the
user asked for proper merge commit originally.

Demonstrate the problem with a test crafted after the in t7502. The test
requires EXECKEEPSPID (thus does not run under MINGW).

Save the merge state earlier (in the non-squash case) so that it does
not get lost. This makes the test pass.

Reported-by: hIpPy <hippy2981@gmail.com>
Signed-off-by: Michael J Gruber <git@grubix.eu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agomerge: split write_merge_state in two
Michael J Gruber [Wed, 23 Aug 2017 12:10:44 +0000 (14:10 +0200)] 
merge: split write_merge_state in two

write_merge_state() writes out the merge heads, mode, and msg. But we
may want to write out heads, mode without the msg. So, split out heads
(+mode) into a separate function write_merge_heads() that is called by
write_merge_state().

No funtional change so far, except when these non-atomic writes are
interrupted: we write heads-mode-msg now when we used to write
heads-msg-mode.

Signed-off-by: Michael J Gruber <git@grubix.eu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agomerge: clarify call chain
Michael J Gruber [Wed, 23 Aug 2017 12:10:43 +0000 (14:10 +0200)] 
merge: clarify call chain

prepare_to_commit() cannot be reached in the non-squash case:
It is called by merge_trivial() and finish_automerge() only, but the
calls to the latter are somewhat hard to track:

If option_commit is not set, the code in cmd_merge() uses a fake
conflict return code (ret=1) to avoid writing the tree, which also
avoids setting automerge_was_ok (just as in the proper ret==1 case), so
that finish_automerge() is not called.

To ensure that no code change breaks that assumption, safe-guard
prepare_to_commit() by a BUG() statement.

Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Michael J Gruber <git@grubix.eu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoDocumentation/git-merge: explain --continue
Michael J Gruber [Mon, 21 Aug 2017 12:53:14 +0000 (14:53 +0200)] 
Documentation/git-merge: explain --continue

Currently, 'git merge --continue' is mentioned but not explained.

Explain it.

Signed-off-by: Michael J Gruber <git@grubix.eu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agovcs-svn: rename repo functions to "svn_repo"
brian m. carlson [Mon, 21 Aug 2017 00:00:18 +0000 (00:00 +0000)] 
vcs-svn: rename repo functions to "svn_repo"

There were several functions in the Subversion code that started with
"repo_".  This namespace is also used by the Git struct repository code.
Rename these functions to start with "svn_repo" to avoid any future
conflicts.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agovcs-svn: remove unused prototypes
brian m. carlson [Mon, 21 Aug 2017 00:00:17 +0000 (00:00 +0000)] 
vcs-svn: remove unused prototypes

The Subversion code had prototypes for several functions which were not
ever defined or used.  These functions all had names starting with
"repo_", some of which conflict with those in repository.h.  To avoid
the conflict, remove those unused prototypes.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agodoc: fix typo in sendemail.identity
Jeff King [Sun, 20 Aug 2017 09:46:57 +0000 (05:46 -0400)] 
doc: fix typo in sendemail.identity

Saying "the this" is an obvious typo. But while we're here,
let's polish the English on the second half of the sentence,
too.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoapply: file commited with CRLF should roundtrip diff and apply
Torsten Bögershausen [Sat, 19 Aug 2017 11:28:01 +0000 (13:28 +0200)] 
apply: file commited with CRLF should roundtrip diff and apply

When a file had been commited with CRLF but now .gitattributes say
"* text=auto" (or core.autocrlf is true), the following does not
roundtrip, `git apply` fails:

    printf "Added line\r\n" >>file &&
    git diff >patch &&
    git checkout -- . &&
    git apply patch

Before applying the patch, the file from working tree is converted
into the index format (clean filter, CRLF conversion, ...).  Here,
when commited with CRLF, the line endings should not be converted.

Note that `git apply --index` or `git apply --cache` doesn't call
convert_to_git() because the source material is already in index
format.

Analyze the patch if there is a) any context line with CRLF, or b)
if any line with CRLF is to be removed.  In this case the patch file
`patch` has mixed line endings, for a) it looks like this:

    diff --git a/one b/one
    index 533790e..c30dea8 100644
    --- a/one
    +++ b/one
    @@ -1 +1,2 @@
     a\r
    +b\r

And for b) it looks like this:

    diff --git a/one b/one
    index 533790e..485540d 100644
    --- a/one
    +++ b/one
    @@ -1 +1 @@
    -a\r
    +b\r

If `git apply` detects that the patch itself has CRLF, (look at the
line " a\r" or "-a\r" above), the new flag crlf_in_old is set in
"struct patch" and two things will happen:

    - read_old_data() will not convert CRLF into LF by calling
      convert_to_git(..., SAFE_CRLF_KEEP_CRLF);
    - The WS_CR_AT_EOL bit is set in the "white space rule",
      CRLF are no longer treated as white space.

While at there, make it clear that read_old_data() in apply.c knows
what it wants convert_to_git() to do with respect to CRLF.  In fact,
this codepath is about applying a patch to a file in the filesystem,
which may not exist in the index, or may exist but may not match
what is recorded in the index, or in the extreme case, we may not
even be in a Git repository.  If convert_to_git() peeked at the
index while doing its work, it *would* be a bug.

Pass NULL instead of &the_index to convert_to_git() to make sure we
catch future bugs to clarify this.

Update the test in t4124: split one test case into 3:

    - Detect the " a\r" line in the patch
    - Detect the "-a\r" line in the patch
    - Use LF in repo and CLRF in the worktree.

Reported-by: Anthony Sottile <asottile@umich.edu>
Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocommit: remove unused inline function single_parent()
René Scharfe [Sat, 19 Aug 2017 08:12:45 +0000 (10:12 +0200)] 
commit: remove unused inline function single_parent()

53b2c823f6 (revision walker: mini clean-up) added the function in 2007,
but it was never used, so we should be able to get rid of it now.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoarchive: don't queue excluded directories
René Scharfe [Sat, 19 Aug 2017 05:32:37 +0000 (07:32 +0200)] 
archive: don't queue excluded directories

Reject directories with the attribute export-ignore already while
queuing them.  This prevents read_tree_recursive() from descending into
them and this avoids write_archive_entry() rejecting them later on,
which queue_or_write_archive_entry() is not prepared for.

Borrow the existing strbuf to build the full path to avoid string
copies and extra allocations; just make sure we restore the original
value before moving on.

Keep checking any other attributes in write_archive_entry() as before,
but avoid checking them twice.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoarchive: factor out helper functions for handling attributes
René Scharfe [Sat, 19 Aug 2017 05:29:43 +0000 (07:29 +0200)] 
archive: factor out helper functions for handling attributes

Add helpers for accessing attributes that encapsulate the details of how
to retrieve their values.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot5001: add tests for export-ignore attributes and exclude pathspecs
René Scharfe [Sat, 19 Aug 2017 05:28:54 +0000 (07:28 +0200)] 
t5001: add tests for export-ignore attributes and exclude pathspecs

Demonstrate mishandling of the attribute export-ignore by git archive
when used together with pathspecs.  Wildcard pathspecs can even cause it
to abort.  And a directory excluded without a wildcard is still included
as an empty folder in the archive.

Test-case-by: David Adam <zanchey@ucc.gu.uwa.edu.au>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoDocumentation/git-for-each-ref: clarify peeling of tags for --format
Michael J Gruber [Fri, 18 Aug 2017 14:51:23 +0000 (16:51 +0200)] 
Documentation/git-for-each-ref: clarify peeling of tags for --format

`*` in format strings means peeling of tag objects so that object field
names refer to the object that the tag object points at, instead of the
tag object itself.

Currently, this is documented using grammar that is clearly inspired by
classical latin, though missing more than an article in order to be
classical english.

Try and straighten that explanation out a bit.

Signed-off-by: Michael J Gruber <git@grubix.eu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoDocumentation: use proper wording for ref format strings
Michael J Gruber [Fri, 18 Aug 2017 14:51:22 +0000 (16:51 +0200)] 
Documentation: use proper wording for ref format strings

Various commands list refs and allow to use a format string for the
output that interpolates from the ref as well as the object it points
at (for-each-ref; branch and tag in list mode).

Currently, the documentation talks about interpolating from the object.
This is confusing because a ref points to an object but not vice versa,
so the object cannot possible know %(refname), for example. Thus, this is
wrong independent of refs being objects (one day, maybe) or not.

Change the wording to make this clearer (and distinguish it from formats
for the log family).

Signed-off-by: Michael J Gruber <git@grubix.eu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agogit-grep: correct exit code with --quiet and -L
Anthony Sottile [Fri, 18 Aug 2017 01:38:51 +0000 (18:38 -0700)] 
git-grep: correct exit code with --quiet and -L

The handling of `status_only` no longer interferes with the handling of
`unmatch_name_only`.  `--quiet` no longer affects the exit code when using
`-L`/`--files-without-match`.

Signed-off-by: Anthony Sottile <asottile@umich.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot5526: fix some broken && chains
Heiko Voigt [Thu, 17 Aug 2017 10:36:13 +0000 (12:36 +0200)] 
t5526: fix some broken && chains

Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosubmodule.sh: remove unused variable
Stefan Beller [Wed, 16 Aug 2017 22:50:42 +0000 (15:50 -0700)] 
submodule.sh: remove unused variable

This could have been part of 48308681b0 (git submodule update: have a
dedicated helper for cloning, 2016-02-29).

Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>