git
6 years agot4205: refactor %(trailers) tests
Jeff King [Tue, 15 Aug 2017 10:24:39 +0000 (06:24 -0400)] 
t4205: refactor %(trailers) tests

We currently have one test for %(trailers). In preparation
for more, let's refactor a few bits:

  - move the commit creation to its own setup step so it can
    be reused by multiple tests

  - add a trailer with whitespace continuation (to confirm
    that it is left untouched)

  - fix the sample text which claims the placeholder is %bT.
    This was switched long ago to %(trailers)

  - replace one "cat" with an "echo" when generating the
    expected output. This saves a process (and sets a better
    pattern for future tests to follow).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agopretty: move trailer formatting to trailer.c
Jeff King [Tue, 15 Aug 2017 10:23:56 +0000 (06:23 -0400)] 
pretty: move trailer formatting to trailer.c

The next commit will add many features to the %(trailer)
placeholder in pretty.c. We'll need to access some internal
functions of trailer.c for that, so our options are either:

  1. expose those functions publicly

or

  2. make an entry point into trailer.c to do the formatting

Doing (2) ends up exposing less surface area, though do note
that caveats in the docstring of the new function.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agointerpret-trailers: add --parse convenience option
Jeff King [Tue, 15 Aug 2017 10:23:34 +0000 (06:23 -0400)] 
interpret-trailers: add --parse convenience option

The last few commits have added command line options that
can turn interpret-trailers into a parsing tool. Since
they'd most often be used together, let's provide a
convenient single option for callers to invoke this mode.

This is implemented as a callback rather than a boolean so
that its effect is applied immediately, as if those options
had been specified. Later options can then override them.
E.g.:

  git interpret-trailers --parse --no-unfold

would work.

Let's also update the documentation to make clear that this
parsing mode behaves quite differently than the normal
"add trailers to the input" mode.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agointerpret-trailers: add an option to unfold values
Jeff King [Tue, 15 Aug 2017 10:23:29 +0000 (06:23 -0400)] 
interpret-trailers: add an option to unfold values

The point of "--only-trailers" is to give a caller an output
that's easy for them to parse. Getting rid of the
non-trailer material helps, but we still may see more
complicated syntax like whitespace continuation. Let's add
an option to unfold any continuation, giving the output as a
single "key: value" line per trailer.

As a bonus, this could be used even without --only-trailers
to clean up unusual formatting in the incoming data.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agointerpret-trailers: add an option to show only existing trailers
Jeff King [Tue, 15 Aug 2017 10:23:25 +0000 (06:23 -0400)] 
interpret-trailers: add an option to show only existing trailers

It can be useful to invoke interpret-trailers for the
primary purpose of parsing existing trailers. But in that
case, we don't want to apply existing ifMissing or ifExists
rules from the config. Let's add a special mode where we
avoid applying those rules. Coupled with --only-trailers,
this gives us a reasonable parsing tool.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agointerpret-trailers: add an option to show only the trailers
Jeff King [Tue, 15 Aug 2017 10:23:21 +0000 (06:23 -0400)] 
interpret-trailers: add an option to show only the trailers

In theory it's easy for any reader who wants to parse
trailers to do so. But there are a lot of subtle corner
cases around what counts as a trailer, when the trailer
block begins and ends, etc. Since interpret-trailers already
has our parsing logic, let's let callers ask it to just
output the trailers.

They still have to parse the "key: value" lines, but at
least they can ignore all of the other corner cases.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agodoc: clarify "config --bool" behaviour with empty string
Andreas Heiduk [Mon, 14 Aug 2017 22:12:18 +0000 (00:12 +0200)] 
doc: clarify "config --bool" behaviour with empty string

`git config --bool xxx.yyy` returns `true` for `[xxx]yyy` but
`false` for `[xxx]yyy=` or `[xxx]yyy=""`.  This is tested in
t1300-repo-config.sh since 09bc098c2.

Signed-off-by: Andreas Heiduk <asheiduk@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agostash: prevent warning about null bytes in input
Kevin Daudt [Mon, 14 Aug 2017 21:43:33 +0000 (23:43 +0200)] 
stash: prevent warning about null bytes in input

The `no_changes` function calls the `untracked_files` function through
command substitution. `untracked_files` will return null bytes because it
runs ls-files with the '-z' option.

Bash since version 4.4 warns about these null bytes. As they are not
required for the test that is being done, make sure `untracked_files`
does not output null bytes when not required.

This is achieved by adding a parameter to the `untracked_files` function to
specify wither `-z` should be passed to ls-files or not.

This warning is triggered when running git stash save -u resulting in
two warnings:

    git-stash: line 43: warning: command substitution: ignored null byte
    in input

Signed-off-by: Kevin Daudt <me@ikke.info>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agorebase: turn on progress option by default for format-patch
Kevin Willford [Thu, 10 Aug 2017 18:32:56 +0000 (14:32 -0400)] 
rebase: turn on progress option by default for format-patch

Pass the "--progress" option to format-patch when the standard error
stream is connected to the terminal and "--quiet" is not given.

Signed-off-by: Kevin Willford <kewillf@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoformat-patch: have progress option while generating patches
Kevin Willford [Thu, 10 Aug 2017 18:32:55 +0000 (14:32 -0400)] 
format-patch: have progress option while generating patches

When generating patches for the rebase command, if the user does
not realize the branch they are rebasing onto is thousands of
commits different, there is no progress indication after initial
rewinding message.

The progress meter as presented in this patch assumes the thousands of
patches to have a fine granularity as well as assuming to require all
the same amount of work/time for each, such that a steady progress bar
is achieved.

We do not want to estimate the time for each patch based e.g.
on their size or number of touched files (or parents) as that is too
expensive for just a progress meter.

This patch allows a progress option to be passed to format-patch
so that the user can be informed the progress of generating the
patch.  This option is then used by the rebase command when
calling format-patch.

Signed-off-by: Kevin Willford <kewillf@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotree-walk: convert fill_tree_descriptor() to object_id
René Scharfe [Sat, 12 Aug 2017 08:32:59 +0000 (10:32 +0200)] 
tree-walk: convert fill_tree_descriptor() to object_id

All callers of fill_tree_descriptor() have been converted to object_id
already, so convert that function as well.  As a nice side-effect we get
rid of NULL checks in tree-diff.c, as fill_tree_descriptor() already
does them for us.

Helped-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Reviewed-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agodiff: avoid redundantly clearing a flag
Jonathan Tan [Fri, 11 Aug 2017 22:49:14 +0000 (15:49 -0700)] 
diff: avoid redundantly clearing a flag

No code in diff.c sets DIFF_SYMBOL_MOVED_LINE except in
mark_color_as_moved(), so it is redundant to clear it for the current
line. Therefore, clear it only for previous lines.

This makes a refactoring in a subsequent patch easier.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agointerpret-trailers: fix documentation typo
Paolo Bonzini [Tue, 1 Aug 2017 09:03:33 +0000 (11:03 +0200)] 
interpret-trailers: fix documentation typo

Self-explanatory... trailer.ifexists is documented with the
right name, but after a while it switches to ifexist.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agointerpret-trailers: add options for actions
Paolo Bonzini [Tue, 1 Aug 2017 09:03:32 +0000 (11:03 +0200)] 
interpret-trailers: add options for actions

Allow using non-default values for trailers without having to set
them up in .gitconfig first.  For example, if you have the following
configuration

     trailer.signed-off-by.where = end

you may use "--where before" when a patch author forgets his
Signed-off-by and provides it in a separate email.  Likewise for
--if-exists and --if-missing

Reverting to the behavior specified by .gitconfig is done with
--no-where, --no-if-exists and --no-if-missing.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotrailers: introduce struct new_trailer_item
Paolo Bonzini [Tue, 1 Aug 2017 09:03:31 +0000 (11:03 +0200)] 
trailers: introduce struct new_trailer_item

This will provide a place to store the current state of the
--where, --if-exists and --if-missing options.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agohook: use correct logical variable
Kaartic Sivaraam [Mon, 14 Aug 2017 08:46:46 +0000 (14:16 +0530)] 
hook: use correct logical variable

Sign-off added should be that of the "committer", not that of the
"commit's author"; that is how the rest of Git adds sign-off using
sequencer.c::append_signoff().

Use the correct logical variable that identifies the committer.

Signed-off-by: Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agohttp: use a feature check to enable GSSAPI delegation control
Tom G. Christensen [Fri, 11 Aug 2017 16:37:34 +0000 (18:37 +0200)] 
http: use a feature check to enable GSSAPI delegation control

Turn the version check into a feature check to ensure this functionality
is also enabled with vendor supported curl versions where the feature
may have been backported.

Signed-off-by: Tom G. Christensen <tgc@jupiterrise.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agohttp: fix handling of missing CURLPROTO_*
Tom G. Christensen [Fri, 11 Aug 2017 16:37:33 +0000 (18:37 +0200)] 
http: fix handling of missing CURLPROTO_*

Commit aeae4db1 refactored the handling of the curl protocol
restriction support into a function but failed to add a version
check for older versions of curl that lack CURLPROTO_* support.

Add the missing check and at the same time convert it to a feature
check instead of a version based check.  This is done to ensure that
vendor supported curl versions that have had CURLPROTO_* support
backported are handled correctly.

Signed-off-by: Tom G. Christensen <tgc@jupiterrise.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agostash: clean untracked files before reset
Nicolas Morey-Chaisemartin [Fri, 11 Aug 2017 17:14:43 +0000 (19:14 +0200)] 
stash: clean untracked files before reset

If calling git stash -u on a repo that contains a file that is not
ignored any more due to a current modification of the gitignore file,
this file is stashed but not remove from the working tree.
This is due to git-stash first doing a reset --hard which clears the
.gitignore file modification and the call git clean, leaving the file
untouched.
This causes git stash pop to fail due to the file existing.

This patch simply switches the order between cleaning and resetting
and adds a test for this usecase.

Reported-by: Sam Partington <sam@whiteoctober.co.uk>
Signed-off-by: Nicolas Morey-Chaisemartin <nicolas@morey-chaisemartin.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosha1_file: remove read_packed_sha1()
Jonathan Tan [Fri, 11 Aug 2017 20:36:15 +0000 (13:36 -0700)] 
sha1_file: remove read_packed_sha1()

Use read_object() in its place instead. This avoids duplication of code.

This makes force_object_loose() slightly slower (because of a redundant
check of loose object storage), but only in the error case.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosha1_file: set whence in storage-specific info fn
Jonathan Tan [Fri, 11 Aug 2017 20:36:14 +0000 (13:36 -0700)] 
sha1_file: set whence in storage-specific info fn

Move the setting of oi->whence to sha1_loose_object_info() and
packed_object_info().

This allows sha1_object_info_extended() to not need to know about the
delta base cache. This will be useful during a future refactoring in
which packfile-related functions, including the handling of the delta
base cache, will be moved to a separate file.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoThe first batch of topics after the 2.14 cycle master
Junio C Hamano [Fri, 11 Aug 2017 20:34:31 +0000 (13:34 -0700)] 
The first batch of topics after the 2.14 cycle

Notably, let's declare that we aim to make "git add ''" illegal in
the cycle after this one.

The topic to do so, ex/deprecate-empty-pathspec-as-match-all, has
been cooking in 'next' too long, and will stay there during this
cycle, but not after.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge branch 'ma/pager-per-subcommand-action'
Junio C Hamano [Fri, 11 Aug 2017 20:27:07 +0000 (13:27 -0700)] 
Merge branch 'ma/pager-per-subcommand-action'

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.

* 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'
Junio C Hamano [Fri, 11 Aug 2017 20:27:07 +0000 (13:27 -0700)] 
Merge branch 'jk/rev-list-empty-input'

"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 'jt/t1450-fsck-corrupt-packfile'
Junio C Hamano [Fri, 11 Aug 2017 20:27:07 +0000 (13:27 -0700)] 
Merge branch 'jt/t1450-fsck-corrupt-packfile'

A test update.

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

6 years agoMerge branch 'js/git-gui-msgfmt-on-windows'
Junio C Hamano [Fri, 11 Aug 2017 20:27:06 +0000 (13:27 -0700)] 
Merge branch 'js/git-gui-msgfmt-on-windows'

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 agoMerge branch 'eb/contacts-reported-by'
Junio C Hamano [Fri, 11 Aug 2017 20:27:06 +0000 (13:27 -0700)] 
Merge branch 'eb/contacts-reported-by'

"git contacts" (in contrib/) now lists the address on the
"Reported-by:" trailer to its output, in addition to those on
S-o-b: and other trailers, to make it easier to notify (and thank)
the original bug reporter.

* eb/contacts-reported-by:
  git-contacts: also recognise "Reported-by:"

6 years agoMerge branch 'dl/credential-cache-socket-in-xdg-cache'
Junio C Hamano [Fri, 11 Aug 2017 20:27:06 +0000 (13:27 -0700)] 
Merge branch 'dl/credential-cache-socket-in-xdg-cache'

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 'rg/rerere-train-overwrite'
Junio C Hamano [Fri, 11 Aug 2017 20:27:05 +0000 (13:27 -0700)] 
Merge branch 'rg/rerere-train-overwrite'

The "rerere-train" script (in contrib/) learned the "--overwrite"
option to allow overwriting existing recorded resolutions.

* rg/rerere-train-overwrite:
  contrib/rerere-train: optionally overwrite existing resolutions

6 years agoMerge branch 'jb/t8008-cleanup'
Junio C Hamano [Fri, 11 Aug 2017 20:27:05 +0000 (13:27 -0700)] 
Merge branch 'jb/t8008-cleanup'

Code clean-up.

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

6 years agoMerge branch 'jt/subprocess-handshake'
Junio C Hamano [Fri, 11 Aug 2017 20:27:05 +0000 (13:27 -0700)] 
Merge branch 'jt/subprocess-handshake'

Code cleanup.

* jt/subprocess-handshake:
  sub-process: refactor handshake to common function
  Documentation: migrate sub-process docs to header

6 years agoMerge branch 'dc/fmt-merge-msg-microcleanup'
Junio C Hamano [Fri, 11 Aug 2017 20:27:05 +0000 (13:27 -0700)] 
Merge branch 'dc/fmt-merge-msg-microcleanup'

Code cleanup.

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

6 years agoMerge branch 'ah/doc-wserrorhighlight'
Junio C Hamano [Fri, 11 Aug 2017 20:27:04 +0000 (13:27 -0700)] 
Merge branch 'ah/doc-wserrorhighlight'

Doc update.

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

6 years agoMerge branch 'cc/ref-is-hidden-microcleanup'
Junio C Hamano [Fri, 11 Aug 2017 20:27:03 +0000 (13:27 -0700)] 
Merge branch 'cc/ref-is-hidden-microcleanup'

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'
Junio C Hamano [Fri, 11 Aug 2017 20:27:02 +0000 (13:27 -0700)] 
Merge branch 'js/run-process-parallel-api-fix'

API fix.

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

6 years agoMerge branch 'hb/gitweb-project-list'
Junio C Hamano [Fri, 11 Aug 2017 20:27:01 +0000 (13:27 -0700)] 
Merge branch 'hb/gitweb-project-list'

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

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

6 years agoMerge branch 'ks/commit-abort-on-empty-message-fix'
Junio C Hamano [Fri, 11 Aug 2017 20:27:01 +0000 (13:27 -0700)] 
Merge branch 'ks/commit-abort-on-empty-message-fix'

"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 'sb/hashmap-cleanup'
Junio C Hamano [Fri, 11 Aug 2017 20:27:01 +0000 (13:27 -0700)] 
Merge branch 'sb/hashmap-cleanup'

Many uses of comparision callback function the hashmap API uses
cast the callback function type when registering it to
hashmap_init(), which defeats the compile time type checking when
the callback interface changes (e.g. gaining more parameters).
The callback implementations have been updated to take "void *"
pointers and cast them to the type they expect instead.

* sb/hashmap-cleanup:
  t/helper/test-hashmap: use custom data instead of duplicate cmp functions
  name-hash.c: drop hashmap_cmp_fn cast
  submodule-config.c: drop hashmap_cmp_fn cast
  remote.c: drop hashmap_cmp_fn cast
  patch-ids.c: drop hashmap_cmp_fn cast
  convert/sub-process: drop cast to hashmap_cmp_fn
  config.c: drop hashmap_cmp_fn cast
  builtin/describe: drop hashmap_cmp_fn cast
  builtin/difftool.c: drop hashmap_cmp_fn cast
  attr.c: drop hashmap_cmp_fn cast

6 years agoMerge branch 'jk/reflog-walk'
Junio C Hamano [Fri, 11 Aug 2017 20:27:00 +0000 (13:27 -0700)] 
Merge branch 'jk/reflog-walk'

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 'ls/filter-process-delayed'
Junio C Hamano [Fri, 11 Aug 2017 20:27:00 +0000 (13:27 -0700)] 
Merge branch 'ls/filter-process-delayed'

The filter-process interface learned to allow a process with long
latency give a "delayed" response.

* ls/filter-process-delayed:
  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 'st/lib-gpg-kill-stray-agent'
Junio C Hamano [Fri, 11 Aug 2017 20:27:00 +0000 (13:27 -0700)] 
Merge branch 'st/lib-gpg-kill-stray-agent'

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 agoMerge branch 'rs/pack-objects-pbase-cleanup'
Junio C Hamano [Fri, 11 Aug 2017 20:27:00 +0000 (13:27 -0700)] 
Merge branch 'rs/pack-objects-pbase-cleanup'

Code clean-up.

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

6 years agoMerge branch 'jt/fsck-code-cleanup'
Junio C Hamano [Fri, 11 Aug 2017 20:26:59 +0000 (13:26 -0700)] 
Merge branch 'jt/fsck-code-cleanup'

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 'jc/http-sslkey-and-ssl-cert-are-paths'
Junio C Hamano [Fri, 11 Aug 2017 20:26:59 +0000 (13:26 -0700)] 
Merge branch 'jc/http-sslkey-and-ssl-cert-are-paths'

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/c99'
Junio C Hamano [Fri, 11 Aug 2017 20:26:58 +0000 (13:26 -0700)] 
Merge branch 'jk/c99'

Start using selected c99 constructs in small, stable and
essentialpart of the system to catch people who care about
older compilers that do not grok them.

* jk/c99:
  clean.c: use designated initializer
  strbuf: use designated initializers in STRBUF_INIT

6 years agoMerge branch 'jk/ref-filter-colors'
Junio C Hamano [Fri, 11 Aug 2017 20:26:58 +0000 (13:26 -0700)] 
Merge branch 'jk/ref-filter-colors'

"%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 'wd/rebase-conflict-guide'
Junio C Hamano [Fri, 11 Aug 2017 20:26:58 +0000 (13:26 -0700)] 
Merge branch 'wd/rebase-conflict-guide'

The advice message given when "git rebase" stops for conflicting
changes has been improved.

* wd/rebase-conflict-guide:
  rebase: make resolve message clearer for inexperienced users

6 years agoMerge branch 'rs/stat-data-unaligned-reads-fix'
Junio C Hamano [Fri, 11 Aug 2017 20:26:58 +0000 (13:26 -0700)] 
Merge branch 'rs/stat-data-unaligned-reads-fix'

Code clean-up.

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

6 years agoMerge branch 'rs/move-array'
Junio C Hamano [Fri, 11 Aug 2017 20:26:57 +0000 (13:26 -0700)] 
Merge branch 'rs/move-array'

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'
Junio C Hamano [Fri, 11 Aug 2017 20:26:57 +0000 (13:26 -0700)] 
Merge branch 'rs/bswap-ubsan-fix'

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 'ks/prepare-commit-msg-sample'
Junio C Hamano [Fri, 11 Aug 2017 20:26:56 +0000 (13:26 -0700)] 
Merge branch 'ks/prepare-commit-msg-sample'

Remove an example that is now obsolete from a sample hook,
and improve an old example in it that added a sign-off manually
to use the interpret-trailers command.

* ks/prepare-commit-msg-sample:
  hook: add a simple first example
  hook: add sign-off using "interpret-trailers"
  hook: name the positional variables
  hook: cleanup script

6 years agoMerge branch 'bw/object-id'
Junio C Hamano [Fri, 11 Aug 2017 20:26:56 +0000 (13:26 -0700)] 
Merge branch 'bw/object-id'

Conversion from uchar[20] to struct object_id continues.

* bw/object-id:
  receive-pack: don't access hash of NULL object_id pointer
  notes: don't access hash of NULL object_id pointer
  tree-diff: don't access hash of NULL object_id pointer

6 years agoMerge branch 'bc/object-id'
Junio C Hamano [Fri, 11 Aug 2017 20:26:55 +0000 (13:26 -0700)] 
Merge branch 'bc/object-id'

Conversion from uchar[20] to struct object_id continues.

* bc/object-id:
  sha1_name: convert uses of 40 to GIT_SHA1_HEXSZ
  sha1_name: convert GET_SHA1* flags to GET_OID*
  sha1_name: convert get_sha1* to get_oid*
  Convert remaining callers of get_sha1 to get_oid.
  builtin/unpack-file: convert to struct object_id
  bisect: convert bisect_checkout to struct object_id
  builtin/update_ref: convert to struct object_id
  sequencer: convert to struct object_id
  remote: convert struct push_cas to struct object_id
  submodule: convert submodule config lookup to use object_id
  builtin/merge-tree: convert remaining caller of get_sha1 to object_id
  builtin/fsck: convert remaining caller of get_sha1 to object_id

6 years agoMerge branch 'sb/object-id'
Junio C Hamano [Fri, 11 Aug 2017 20:26:55 +0000 (13:26 -0700)] 
Merge branch 'sb/object-id'

Conversion from uchar[20] to struct object_id continues.

* sb/object-id:
  tag: convert gpg_verify_tag to use struct object_id
  commit: convert lookup_commit_graft to struct object_id

6 years agosha1_file: release delta_stack on error in unpack_entry()
René Scharfe [Thu, 10 Aug 2017 09:42:21 +0000 (11:42 +0200)] 
sha1_file: release delta_stack on error in unpack_entry()

When unpack_entry() encounters a broken packed object, it returns early.
It adjusts the reference count of the pack window, but leaks the buffer
for a big delta stack in case the small automatic one was not enough.
Jump to the cleanup code at end instead, which takes care of that.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agofsck: free buffers on error in fsck_obj()
René Scharfe [Thu, 10 Aug 2017 09:42:10 +0000 (11:42 +0200)] 
fsck: free buffers on error in fsck_obj()

Move the code for releasing tree buffers and commit buffers in
fsck_obj() to the end of the function and make sure it's executed no
matter of an error is encountered or not.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agostrbuf: clear errno before calling getdelim(3)
René Scharfe [Thu, 10 Aug 2017 20:56:40 +0000 (22:56 +0200)] 
strbuf: clear errno before calling getdelim(3)

getdelim(3) returns -1 at the end of the file and if it encounters an
error, but sets errno only in the latter case.  Set errno to zero before
calling it to avoid misdiagnosing an out-of-memory condition due to a
left-over value from some other function call.

Reported-by: Yaroslav Halchenko <yoh@onerussian.com>
Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agowin32: plug memory leak on realloc() failure in syslog()
René Scharfe [Thu, 10 Aug 2017 10:23:45 +0000 (12:23 +0200)] 
win32: plug memory leak on realloc() failure in syslog()

If realloc() fails then the original buffer is still valid.  Free it
before exiting the function.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agomerge: use skip_prefix()
René Scharfe [Thu, 10 Aug 2017 16:47:55 +0000 (18:47 +0200)] 
merge: use skip_prefix()

Get rid of a magic string length constant by using skip_prefix() instead
of starts_with().

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotrailer: put process_trailers() options into a struct
Jeff King [Thu, 10 Aug 2017 18:03:58 +0000 (14:03 -0400)] 
trailer: put process_trailers() options into a struct

We already have two options and are about to add a few more.
To avoid having a huge number of boolean arguments, let's
convert to an options struct which can be passed in.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot1200: remove t1200-tutorial.sh
Stefan Beller [Wed, 9 Aug 2017 21:22:53 +0000 (14:22 -0700)] 
t1200: remove t1200-tutorial.sh

v1.2.0~121 (New tutorial, 2006-01-22) rewrote the tutorial such that the
original intent of 2ae6c70674 (Adapt tutorial to cygwin and add test case,
2005-10-13) to test the examples from the tutorial doesn't hold any more.

There are dedicated tests for the commands used, even "git whatchanged",
such that removing these tests doesn't seem like a reduction in test
coverage.

Signed-off-by: Stefan Beller <sbeller@google.com>
Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosha1_file: drop experimental GIT_USE_LOOKUP search
Jeff King [Wed, 9 Aug 2017 10:14:32 +0000 (06:14 -0400)] 
sha1_file: drop experimental GIT_USE_LOOKUP search

Long ago in 628522ec14 (sha1-lookup: more memory efficient
search in sorted list of SHA-1, 2007-12-29) we added
sha1_entry_pos(), a binary search that uses the uniform
distribution of sha1s to scale the selection of mid-points.
As this was a performance experiment, we tied it to the
GIT_USE_LOOKUP environment variable and never enabled it by
default.

This code was successful in reducing the number of steps in
each search. But the overhead of the scaling ends up making
it slower when the cache is warm. Here are best-of-five
timings for running rev-list on linux.git, which will have
to look up every object:

  $ time git rev-list --objects --all >/dev/null
  real 0m35.357s
  user 0m35.016s
  sys 0m0.340s

  $ time GIT_USE_LOOKUP=1 git rev-list --objects --all >/dev/null
  real 0m37.364s
  user 0m37.045s
  sys 0m0.316s

The USE_LOOKUP version might have more benefit on a cold
cache, as the time to fault in each page would dominate. But
that would be for a single lookup. In practice, most
operations tend to look up many objects, and the whole pack
.idx will end up warm.

It's possible that the code could be better optimized to
compete with a naive binary search for the warm-cache case,
and we could have the best of both worlds. But over the
years nobody has done so, and this is largely dead code that
is rarely run outside of the test suite. Let's drop it in
the name of simplicity.

This lets us remove sha1_entry_pos() entirely, as the .idx
lookup code was the only caller.  Note that sha1-lookup.c
still contains sha1_pos(), which differs from
sha1_entry_pos() in two ways:

  - it has a different interface; it uses a function pointer
    to access sha1 entries rather than a size/offset pair
    describing the table's memory layout

  - it only scales the initial selection of "mi", rather
    than each iteration of the search

We can't get rid of this function, as it's called from
several places. It may be that we could replace it with a
simple binary search, but that's out of scope for this patch
(and would need benchmarking).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agohashcmp: use memcmp instead of open-coded loop
Jeff King [Wed, 9 Aug 2017 10:16:45 +0000 (06:16 -0400)] 
hashcmp: use memcmp instead of open-coded loop

In 1a812f3a70 (hashcmp(): inline memcmp() by hand to
optimize, 2011-04-28), it was reported that an open-coded
loop outperformed memcmp() for comparing sha1s.

Discussion[1] a few years later in 2013 showed that this
depends on your libc's version of memcmp(). In particular,
glibc 2.13 optimized their memcmp around 2011. Here are
current timings with glibc 2.24 (best-of-five, on
linux.git):

  [before this patch, open-coded]
  $ time git rev-list --objects --all
  real 0m35.357s
  user 0m35.016s
  sys 0m0.340s

  [after this patch, memcmp]
  real 0m32.930s
  user 0m32.630s
  sys 0m0.300s

Now that we've had 6 years for that version of glibc to
make its way onto people's machines, it's worth revisiting
our benchmarks and switching to memcmp().

It may be that there are other non-glibc systems where
memcmp() isn't as well optimized. But since our single data
point in favor of open-coding was on a now-ancient glibc, we
should probably assume the system memcmp is good unless
proven otherwise. We may end up with a SLOW_MEMCMP Makefile
knob, but we can hold off on that until we actually find
such a system in practice.

[1] https://public-inbox.org/git/20130318073229.GA5551@sigill.intra.peff.net/

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoapply: remove prefix_length member from apply_state
René Scharfe [Wed, 9 Aug 2017 15:54:46 +0000 (17:54 +0200)] 
apply: remove prefix_length member from apply_state

Use a NULL-and-NUL check to see if we have a prefix and consistently use
C string functions on it instead of storing its length in a member of
struct apply_state.  This avoids strlen() calls and simplifies the code.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agobuiltin/add: add detail to a 'cannot chmod' error message
Ramsay Jones [Wed, 9 Aug 2017 00:51:23 +0000 (01:51 +0100)] 
builtin/add: add detail to a 'cannot chmod' error message

In addition to adding the missing newline, add the x-ecutable bit
'mode change' character to the error message. This message now has
the same form as similar messages output by 'update-index'.

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosha1_file: avoid comparison if no packed hash matches the first byte
René Scharfe [Tue, 8 Aug 2017 22:07:30 +0000 (00:07 +0200)] 
sha1_file: avoid comparison if no packed hash matches the first byte

find_pack_entry_one() uses the fan-out table of pack indexes to find out
which entries match the first byte of the searched hash and does a
binary search on this subset of the main index table.

If there are no matching entries then lo and hi will have the same
value.  The binary search still starts and compares the hash of the
following entry (which has a non-matching first byte, so won't cause any
trouble), or whatever comes after the sorted list of entries.

The probability of that stray comparison matching by mistake is low, but
let's not take any chances and check when entering the binary search
loop if we're actually done already.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot4062: use less than 256 repetitions in regex
René Scharfe [Wed, 9 Aug 2017 14:15:10 +0000 (16:15 +0200)] 
t4062: use less than 256 repetitions in regex

OpenBSD's regex library has a repetition limit (RE_DUP_MAX) of 255.
That's the minimum acceptable value according to POSIX.  In t4062 we use
4096 repetitions in the test "-G matches", though, causing it to fail.
Combine two repetition operators, both less than 256, to arrive at 4096
zeros instead of using a single one, to fix the test on OpenBSD.

Original-patch-by: David Coppa <dcoppa@openbsd.org>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot3700: fix broken test under !POSIXPERM
René Scharfe [Tue, 8 Aug 2017 19:21:41 +0000 (21:21 +0200)] 
t3700: fix broken test under !POSIXPERM

76e368c378 (t3700: fix broken test under !SANITY) explains that the test
'git add --chmod=[+-]x changes index with already added file' can fail
if xfoo3 is still present as a symlink from a previous test and deletes
it with rm(1).  That still leaves it present in the index, which causes
the test to fail if POSIXPERM is not defined.  Get rid of it by calling
"git reset --hard" as well, as 76e368c378 already mentioned in passing.

Helped-by: Adam Dinwoodie <adam@dinwoodie.org>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoam: fix signoff when other trailers are present
Phillip Wood [Tue, 8 Aug 2017 10:25:33 +0000 (11:25 +0100)] 
am: fix signoff when other trailers are present

If there was no 'Signed-off-by:' trailer but another trailer such as
'Reported-by:' then 'git am --signoff' would add a blank line between
the existing trailers and the added 'Signed-off-by:' line. e.g.

    Rebase accepts '--rerere-autoupdate' as an option but only honors
    it if '-m' is also given. Fix it for a non-interactive rebase by
    passing on the option to 'git am' and 'git cherry-pick'.

Reported-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Fix by using the code provided for this purpose in sequencer.c.
Change the tests so that they check the formatting of the
'Signed-off-by:' lines rather than just grepping for them.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agogit svn fetch: Create correct commit timestamp when using --localtime
Urs Thuermann [Sat, 5 Aug 2017 00:12:15 +0000 (02:12 +0200)] 
git svn fetch: Create correct commit timestamp when using --localtime

In parse_svn_date() prepend the correct UTC offset to the timestamp
returned.  This is the offset in effect at the commit time instead of
the offset in effect at calling time.

Signed-off-by: Urs Thuermann <urs@isnogud.escape.de>
Reviewed-by: Eric Wong <e@80x24.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoperl/Git.pm: typofix in a comment
Junio C Hamano [Mon, 7 Aug 2017 22:15:57 +0000 (15:15 -0700)] 
perl/Git.pm: typofix in a comment

No change of behaviour intended.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoparse_decoration_style: drop unused argument `var`
Martin Ågren [Mon, 7 Aug 2017 18:20:50 +0000 (20:20 +0200)] 
parse_decoration_style: drop unused argument `var`

The previous commit left it unused.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotreewide: deprecate git_config_maybe_bool, use git_parse_maybe_bool
Martin Ågren [Mon, 7 Aug 2017 18:20:49 +0000 (20:20 +0200)] 
treewide: deprecate git_config_maybe_bool, use git_parse_maybe_bool

The only difference between these is that the former takes an argument
`name` which it ignores completely. Still, the callers are quite careful
to provide reasonable values for it.

Once in-flight topics have landed, we should be able to remove
git_config_maybe_bool. In the meantime, document it as deprecated in the
technical documentation. While at it, document git_parse_maybe_bool.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoconfig: make git_{config,parse}_maybe_bool equivalent
Martin Ågren [Mon, 7 Aug 2017 18:20:48 +0000 (20:20 +0200)] 
config: make git_{config,parse}_maybe_bool equivalent

Both of these act on a string `value` which they parse as a boolean. The
"parse"-variant was introduced as a replacement for the "config"-variant
which for historical reasons takes an unused argument `name`. That it
was intended as a replacement is not obvious from commit 9a549d43
("config.c: rename git_config_maybe_bool_text and export it as
git_parse_maybe_bool", 2015-08-19), but that is what the background on
the mailing list suggests [1].

However, these two functions do not parse `value` in exactly the same
way. In particular, git_config_maybe_bool accepts integers (0 for false,
non-0 for true). This means there are two slightly different definitions
of "maybe_bool" in the code-base, and that every time a call to
git_config_maybe_bool is changed to use git_parse_maybe_bool, it risks
breaking someone's workflow.

Move the implementation of "config" into "parse" and make the latter a
trivial wrapper.

This also fixes the only user of git_parse_maybe_bool, `git push
--signed=..`.

[1] https://public-inbox.org/git/xmqq7fotd71o.fsf@gitster.dls.corp.google.com/

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoconfig: introduce git_parse_maybe_bool_text
Martin Ågren [Mon, 7 Aug 2017 18:20:47 +0000 (20:20 +0200)] 
config: introduce git_parse_maybe_bool_text

Commit 9a549d43 ("config.c: rename git_config_maybe_bool_text and export
it as git_parse_maybe_bool", 2015-08-19) intended git_parse_maybe_bool
to be a replacement for git_config_maybe_bool, which could then be
retired. That is not obvious from the commit message, but that is what
the background on the mailing list suggests [1].

However, git_{config,parse}_maybe_bool do not handle all input the same.
Before the rename, that was by design and there is a caller in config.c
which requires git_parse_maybe_bool to behave exactly as it does.

Prepare for the next patch by renaming git_parse_maybe_bool to ..._text
and reimplementing the first one as a simple call to the second one. Let
the existing users in config.c use ..._text, since it does what they
need.

[1] https://public-inbox.org/git/xmqq7fotd71o.fsf@gitster.dls.corp.google.com/

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot5334: document that git push --signed=1 does not work
Martin Ågren [Mon, 7 Aug 2017 18:20:46 +0000 (20:20 +0200)] 
t5334: document that git push --signed=1 does not work

When accepting booleans as command-line or config options throughout
Git, there are several documented synonyms for true and false.
However, one particular user is slightly broken: `git push --signed=..`
does not understand the integer synonyms for true and false.

This is hardly wanted. The --signed option has a different notion of
boolean than all other arguments and config options, including the
config option corresponding to it, push.gpgSign.

Add a test documenting the failure to handle --signed=1.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoDoc/git-{push,send-pack}: correct --sign= to --signed=
Martin Ågren [Mon, 7 Aug 2017 18:20:45 +0000 (20:20 +0200)] 
Doc/git-{push,send-pack}: correct --sign= to --signed=

Since we're about to touch the behavior of --signed=, do this as a
preparatory step.

The documentation mentions --sign=, and it works. But that's just
because it's an unambiguous abbreviation of --signed, which is how it is
actually implemented. This was added in commit 30261094 ("push: support
signing pushes iff the server supports it", 2015-08-19). Back when that
series was developed [1] [2], there were suggestions about both --sign=
and --signed=. The final implementation settled on --signed=, but some
of the documentation and commit messages ended up using --sign=.

The option is referred to as --signed= in Documentation/config.txt
(under push.gpgSign).

One could argue that we have promised --sign for two years now, so we
should implement it as an alias for --signed. (Then we might also
deprecate the latter, something which was considered already then.) That
would be a slightly more intrusive change.

This minor issue would only be a problem once we want to implement some
other option --signfoo, but the earlier we do this step, the better.

[1] v1-thread:
https://public-inbox.org/git/1439492451-11233-1-git-send-email-dborowitz@google.com/T/#u

[2] v2-thread:
https://public-inbox.org/git/1439998007-28719-1-git-send-email-dborowitz@google.com/T/#m6533a6c4707a30b0d81e86169ff8559460cbf6eb

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoscripts: use "git foo" not "git-foo"
Michael Forney [Sat, 5 Aug 2017 06:49:05 +0000 (23:49 -0700)] 
scripts: use "git foo" not "git-foo"

We want to make sure that people who copy & paste code would see
fewer instances of "git-foo".  The use of these dashed forms have
been discouraged since v1.6.0 days.

Signed-off-by: Michael Forney <mforney@mforney.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotest-path-utils: handle const parameter of basename and dirname
René Scharfe [Mon, 7 Aug 2017 13:57:31 +0000 (15:57 +0200)] 
test-path-utils: handle const parameter of basename and dirname

The parameter to basename(3) and dirname(3) traditionally had the type
"char *", but on OpenBSD it's been "const char *" for years.  That
causes (at least) Clang to throw an incompatible-pointer-types warning
for test-path-utils, where we try to pass around pointers to these
functions.

Avoid this warning (which is fatal in DEVELOPER mode) by ignoring the
promise of OpenBSD's implementations to keep input strings unmodified
and enclosing them in POSIX-compatible wrappers.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot0001: skip test with restrictive permissions if getpwd(3) respects them
René Scharfe [Mon, 7 Aug 2017 11:04:18 +0000 (13:04 +0200)] 
t0001: skip test with restrictive permissions if getpwd(3) respects them

The sub-test "init in long base path" in t0001 checks the ability to
handle long base paths with restrictive permissions (--x).  On OpenBSD
getcwd(3) fails in that case even for short paths.  Check the two
aspects separately by trying to use a long base path both with and
without execute-only permissions.  Only attempt the former if we know
that getcwd(3) doesn't care.

Original-patch-by: David Coppa <dcoppa@openbsd.org>
Reported-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotests: don't give unportable ">" to "test" built-in, use -gt
Ævar Arnfjörð Bjarmason [Sun, 6 Aug 2017 23:38:50 +0000 (23:38 +0000)] 
tests: don't give unportable ">" to "test" built-in, use -gt

Change an argument to test_line_count (which'll ultimately be turned
into a "test" expression) to use "-gt" instead of ">" for an
arithmetic test.

This broken on e.g. OpenBSD as of v2.13.0 with my commit
ac3f5a3468 ("ref-filter: add --no-contains option to
tag/branch/for-each-ref", 2017-03-24).

Downstream just worked around it by patching git and didn't tell us
about it, I discovered this when reading various Git packaging
implementations: https://github.com/openbsd/ports/commit/7e48bf88a20

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge tag 'v2.14.1'
Junio C Hamano [Fri, 4 Aug 2017 19:45:17 +0000 (12:45 -0700)] 
Merge tag 'v2.14.1'

6 years agoStart post 2.14 cycle
Junio C Hamano [Fri, 4 Aug 2017 19:44:55 +0000 (12:44 -0700)] 
Start post 2.14 cycle

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoGit 2.14.1 v2.14.1
Junio C Hamano [Fri, 4 Aug 2017 19:41:48 +0000 (12:41 -0700)] 
Git 2.14.1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge tag 'v2.13.5' into maint
Junio C Hamano [Fri, 4 Aug 2017 19:40:37 +0000 (12:40 -0700)] 
Merge tag 'v2.13.5' into maint

6 years agoGit 2.14 v2.14.0
Junio C Hamano [Fri, 4 Aug 2017 16:31:12 +0000 (09:31 -0700)] 
Git 2.14

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge branch 'ah/patch-id-doc'
Junio C Hamano [Fri, 4 Aug 2017 16:29:15 +0000 (09:29 -0700)] 
Merge branch 'ah/patch-id-doc'

Docfix.

* ah/patch-id-doc:
  doc: remove unsupported parameter from patch-id

6 years agoMerge branch 'as/diff-options-grammofix'
Junio C Hamano [Fri, 4 Aug 2017 16:29:14 +0000 (09:29 -0700)] 
Merge branch 'as/diff-options-grammofix'

A grammofix.

* as/diff-options-grammofix:
  diff-options doc: grammar fix

6 years agoclone: teach recursive clones to respect -q
Brandon Williams [Thu, 3 Aug 2017 22:25:44 +0000 (15:25 -0700)] 
clone: teach recursive clones to respect -q

Teach 'git clone --recurse-submodules' to respect the '-q' option by
passing down the quiet flag to the process which handles cloning of
submodules.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agogit.c: ignore pager.* when launching builtin as dashed external
Martin Ågren [Wed, 2 Aug 2017 19:40:55 +0000 (21:40 +0200)] 
git.c: ignore pager.* when launching builtin as dashed external

When running, e.g., `git -c alias.bar=foo bar`, we expand the alias and
execute `git-foo` as a dashed external. This is true even if git foo is
a builtin. That is on purpose, and is motivated in a comment which was
added in commit 441981bc ("git: simplify environment save/restore
logic", 2016-01-26).

Shortly before we launch a dashed external, and unless we have already
found out whether we should use a pager, we check `pager.foo`. This was
added in commit 92058e4d ("support pager.* for external commands",
2011-08-18). If the dashed external is a builtin, this does not match
that commit's intention and is arguably wrong, since it would be cleaner
if we let the "dashed external builtin" handle `pager.foo`.

This has not mattered in practice, but a recent patch taught `git-tag`
to ignore `pager.tag` under certain circumstances. But, when started
using an alias, it doesn't get the chance to do so, as outlined above.
That recent patch added a test to document this breakage.

Do not check `pager.foo` before launching a builtin as a dashed
external, i.e., if we recognize the name of the external as a builtin.
Change the test to use `test_expect_success`.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotag: change default of `pager.tag` to "on"
Martin Ågren [Wed, 2 Aug 2017 19:40:54 +0000 (21:40 +0200)] 
tag: change default of `pager.tag` to "on"

The previous patch taught `git tag` to only respect `pager.tag` in
list-mode. That patch left the default value of `pager.tag` at "off".

After that patch, it makes sense to let the default value be "on"
instead, since it will help with listing many tags, but will not hurt
users of `git tag -a` as it would have before. Make that change. Update
documentation and tests.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotag: respect `pager.tag` in list-mode only
Martin Ågren [Wed, 2 Aug 2017 19:40:53 +0000 (21:40 +0200)] 
tag: respect `pager.tag` in list-mode only

Using, e.g., `git -c pager.tag tag -a new-tag` results in errors such as
"Vim: Warning: Output is not to a terminal" and a garbled terminal.
Someone who makes use of both `git tag -a` and `git tag -l` will
probably not set `pager.tag`, so that `git tag -a` will actually work,
at the cost of not paging output of `git tag -l`.

Use the mechanisms introduced in two earlier patches to ignore
`pager.tag` in git.c and let the `git tag` builtin handle it on its own.
Only respect `pager.tag` when running in list-mode.

There is a window between where the pager is started before and after
this patch. This means that early errors can behave slightly different
before and after this patch. Since operation-parsing has to happen
inside this window, this can be seen with `git -c pager.tag="echo pager
is used" tag -l --unknown-option`. This change in paging-behavior should
be acceptable since it only affects erroneous usages.

Update the documentation and update tests.

If an alias is used to run `git tag -a`, then `pager.tag` will still be
respected. Document this known breakage. It will be fixed in a later
commit. Add a similar test for `-l`, which works.

Noticed-by: Anatoly Borodin <anatoly.borodin@gmail.com>
Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot7006: add tests for how git tag paginates
Martin Ågren [Wed, 2 Aug 2017 19:40:52 +0000 (21:40 +0200)] 
t7006: add tests for how git tag paginates

Using, e.g., `git -c pager.tag tag -a new-tag` results in errors such as
"Vim: Warning: Output is not to a terminal" and a garbled terminal.
Someone who makes use of both `git tag -a` and `git tag -l` will
probably not set `pager.tag`, so that `git tag -a` will actually work,
at the cost of not paging output of `git tag -l`.

Since we're about to change how `git tag` respects `pager.tag`, add tests
around this, including how the configuration is ignored if --no-pager or
--paginate are used.

Construct tests with a few different subcommands. First, use -l. Second,
use "no arguments" and --contains, since those imply -l. (There are
more arguments which imply -l, but using these two should be enough.)

Third, use -a as a representative for "not -l". Actually, the tests use
`git tag -am` so no editor is launched, but that is irrelevant, since we
just want to see whether the pager is used or not. Make one of the tests
demonstrate the broken behavior mentioned above, where `git tag -a`
respects `pager.tag`.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agogit.c: provide setup_auto_pager()
Martin Ågren [Wed, 2 Aug 2017 19:40:51 +0000 (21:40 +0200)] 
git.c: provide setup_auto_pager()

The previous patch introduced a way for builtins to declare that they
will take responsibility for handling the `pager.foo`-config item. (See
the commit message of that patch for why that could be useful.)

Provide setup_auto_pager(), which builtins can call in order to handle
`pager.<cmd>`, including possibly starting the pager. Make this function
don't do anything if a pager has already been started, as indicated by
use_pager or pager_in_use().

Whenever this function is called from a builtin, git.c will already have
called commit_pager_choice(). Since commit_pager_choice() treats the
special value -1 as "punt" or "not yet decided", it is not a problem
that we might end up calling commit_pager_choice() once in git.c and
once (or more) in the builtin. Make the new function use -1 in the same
way and document it as "punt".

Don't add any users of setup_auto_pager just yet, one will follow in
a later patch.

Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agogit.c: let builtins opt for handling `pager.foo` themselves
Martin Ågren [Wed, 2 Aug 2017 19:40:50 +0000 (21:40 +0200)] 
git.c: let builtins opt for handling `pager.foo` themselves

Before launching a builtin git foo and unless mechanisms with precedence
are in use, we check for and handle the `pager.foo` config. This is done
without considering exactly how git foo is being used, and indeed, git.c
cannot (and should not) know what the arguments to git foo are supposed
to achieve.

In practice this means that, e.g., `git -c pager.tag tag -a new-tag`
results in errors such as "Vim: Warning: Output is not to a terminal"
and a garbled terminal. Someone who makes use of both `git tag -a` and
`git tag -l` will probably not set `pager.tag`, so that `git tag -a`
will actually work, at the cost of not paging output of `git tag -l`.

To allow individual builtins to make more informed decisions about when
to respect `pager.foo`, introduce a flag DELAY_PAGER_CONFIG. If the flag
is set, do not check `pager.foo`.

Do not check for DELAY_PAGER_CONFIG in `execv_dashed_external()`. That
call site is arguably wrong, although in a way that is not yet visible,
and will be changed in a slightly different direction in a later patch.

Don't add any users of DELAY_PAGER_CONFIG just yet, one will follow in a
later patch.

Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agobuiltin.h: take over documentation from api-builtin.txt
Martin Ågren [Wed, 2 Aug 2017 19:40:49 +0000 (21:40 +0200)] 
builtin.h: take over documentation from api-builtin.txt

Delete Documentation/technical/api-builtin.txt and move its content
into builtin.h. Format it as a comment. Remove a '+' which was needed
when the information was formatted for AsciiDoc. Similarly, change
"::" to ":".

Document SUPPORT_SUPER_PREFIX, thereby bringing the documentation up to
date with the available flags.

While at it, correct '3 more things to do' to '4 more things to do'.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agorevision: do not fallback to default when rev_input_given is set
Jeff King [Wed, 2 Aug 2017 22:30:19 +0000 (18:30 -0400)] 
revision: do not fallback to default when rev_input_given is set

If revs->def is set (as it is in "git log") and there are no
pending objects after parsing the user's input, then we show
whatever is in "def". But if the user _did_ ask for some
input that just happened to be empty (e.g., "--glob" that
does not match anything), showing the default revision is
confusing. We should just show nothing, as that is what the
user's request yielded.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agorev-list: don't show usage when we see empty ref patterns
Jeff King [Wed, 2 Aug 2017 22:26:06 +0000 (18:26 -0400)] 
rev-list: don't show usage when we see empty ref patterns

If the user gives us no starting point for a traversal, we
want to complain with our normal usage message. But if they
tried to do so with "--all" or "--glob", but that happened
not to match any refs, the usage message isn't helpful. We
should just give them the empty output they asked for
instead.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agorevision: add rev_input_given flag
Jeff King [Wed, 2 Aug 2017 22:25:27 +0000 (18:25 -0400)] 
revision: add rev_input_given flag

Normally a caller that invokes setup_revisions() has to
check rev.pending to see if anything was actually queued for
the traversal. But they can't tell the difference between
two cases:

  1. The user gave us no tip from which to start a
     traversal.

  2. The user tried to give us tips via --glob, --all, etc,
     but their patterns ended up being empty.

Let's set a flag in the rev_info struct that callers can use
to tell the difference.  We can set this from the
init_all_refs_cb() function.  That's a little funny because
it's not exactly about initializing the "cb" struct itself.
But that function is the common setup place for doing
pattern traversals that is used by --glob, --all, etc.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot6018: flesh out empty input/output rev-list tests
Jeff King [Wed, 2 Aug 2017 22:24:51 +0000 (18:24 -0400)] 
t6018: flesh out empty input/output rev-list tests

In 751a2ac6e (rev-list --exclude: tests, 2013-11-01), we
added a few tests for handling "empty" inputs with rev-list
(i.e., where the user gave us some pattern but it turned out
not to queue any objects for traversal), all of which were
marked as failing.

In preparation for working on this area of the code, let's
give each test a more descriptive name. Let's also include
one more case which we should cover: feeding a --glob
pattern that doesn't match anything.

We can also drop the explanatory comment; we'll be
converting these to expect_success in the next few patches,
so the discussion isn't necessary.

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