gitweb.git
push: add a config option push.gpgSign for default... Dave Borowitz Wed, 19 Aug 2015 15:26:47 +0000 (11:26 -0400)

push: add a config option push.gpgSign for default signed pushes

Signed-off-by: Dave Borowitz <dborowitz@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

push: support signing pushes iff the server supports itDave Borowitz Wed, 19 Aug 2015 15:26:46 +0000 (11:26 -0400)

push: support signing pushes iff the server supports it

Add a new flag --sign=true (or --sign=false), which means the same
thing as the original --signed (or --no-signed). Give it a third
value --sign=if-asked to tell push and send-pack to send a push
certificate if and only if the server advertised a push cert nonce.

If not, warn the user that their push may not be as secure as they
thought.

Signed-off-by: Dave Borowitz <dborowitz@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

builtin/send-pack.c: use parse_options APIDave Borowitz Wed, 19 Aug 2015 15:26:45 +0000 (11:26 -0400)

builtin/send-pack.c: use parse_options API

The old option parsing code in this plumbing command predates this
API, so option parsing was done more manually. Using the new API
brings send-pack more in line with push, and accepts new variants
like --no-* for negating options.

Signed-off-by: Dave Borowitz <dborowitz@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

config.c: rename git_config_maybe_bool_text and export... Dave Borowitz Wed, 19 Aug 2015 15:26:44 +0000 (11:26 -0400)

config.c: rename git_config_maybe_bool_text and export it as git_parse_maybe_bool

This helper function does not complain about the config variable
but just silently reports failure to the caller. It is useful for
callers that need to parse any string that could be boolean or other
string (e.g. tristate yes/no/auto).

Signed-off-by: Dave Borowitz <dborowitz@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

transport: remove git_transport_options.push_certDave Borowitz Wed, 19 Aug 2015 15:26:43 +0000 (11:26 -0400)

transport: remove git_transport_options.push_cert

This field was set in transport_set_option, but never read in the push
code. The push code basically ignores the smart_options field
entirely, and derives its options from the flags arguments to the
push* callbacks. Note that in git_transport_push there are already
several args set from flags that have no corresponding field in
git_transport_options; after this change, push_cert is just like
those.

Signed-off-by: Dave Borowitz <dborowitz@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

gitremote-helpers.txt: document pushcert optionDave Borowitz Wed, 19 Aug 2015 15:26:42 +0000 (11:26 -0400)

gitremote-helpers.txt: document pushcert option

Signed-off-by: Dave Borowitz <dborowitz@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Documentation/git-send-pack.txt: document --signedDave Borowitz Wed, 19 Aug 2015 15:26:41 +0000 (11:26 -0400)

Documentation/git-send-pack.txt: document --signed

Signed-off-by: Dave Borowitz <dborowitz@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Documentation/git-send-pack.txt: wrap long synopsis... Dave Borowitz Wed, 19 Aug 2015 15:26:40 +0000 (11:26 -0400)

Documentation/git-send-pack.txt: wrap long synopsis line

Signed-off-by: Dave Borowitz <dborowitz@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Documentation/git-push.txt: document when --signed... Dave Borowitz Wed, 19 Aug 2015 15:26:39 +0000 (11:26 -0400)

Documentation/git-push.txt: document when --signed may fail

Like --atomic, --signed will fail if the server does not advertise the
necessary capability. In addition, it requires gpg on the client side.

Signed-off-by: Dave Borowitz <dborowitz@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

submodule: allow erroneous values for the fetchRecurseS... Heiko Voigt Tue, 18 Aug 2015 00:22:00 +0000 (17:22 -0700)

submodule: allow erroneous values for the fetchRecurseSubmodules option

We should not die when reading the submodule config cache since the
user might not be able to get out of that situation when the
configuration is part of the history.

We should handle this condition later when the value is about to be
used.

Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

submodule: use new config API for worktree configurationsHeiko Voigt Tue, 18 Aug 2015 00:21:59 +0000 (17:21 -0700)

submodule: use new config API for worktree configurations

We remove the extracted functions and directly parse into and read out
of the cache. This allows us to have one unified way of accessing
submodule configuration values specific to single submodules. Regardless
whether we need to access a configuration from history or from the
worktree.

Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

submodule: extract functions for config set and lookupHeiko Voigt Tue, 18 Aug 2015 00:21:58 +0000 (17:21 -0700)

submodule: extract functions for config set and lookup

This is one step towards using the new configuration API. We just
extract these functions to make replacing the actual code easier.

Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

submodule: implement a config API for lookup of .gitmod... Heiko Voigt Tue, 18 Aug 2015 00:21:57 +0000 (17:21 -0700)

submodule: implement a config API for lookup of .gitmodules values

In a superproject some commands need to interact with submodules. They
need to query values from the .gitmodules file either from the worktree
of from certain revisions. At the moment this is quite hard since a
caller would need to read the .gitmodules file from the history and then
parse the values. We want to provide an API for this so we have one
place to get values from .gitmodules from any revision (including the
worktree).

The API is realized as a cache which allows us to lazily read
.gitmodules configurations by commit into a runtime cache which can then
be used to easily lookup values from it. Currently only the values for
path or name are stored but it can be extended for any value needed.

It is expected that .gitmodules files do not change often between
commits. Thats why we lookup the .gitmodules sha1 from a commit and then
either lookup an already parsed configuration or parse and cache an
unknown one for each sha1. The cache is lazily build on demand for each
requested commit.

This cache can be used for all purposes which need knowledge about
submodule configurations. Example use cases are:

* Recursive submodule checkout needs to lookup a submodule name from
its path when a submodule first appears. This needs be done before
this configuration exists in the worktree.

* The implementation of submodule support for 'git archive' needs to
lookup the submodule name to generate the archive when given a
revision that is not checked out.

* 'git fetch' when given the --recurse-submodules=on-demand option (or
configuration) needs to lookup submodule names by path from the
database rather than reading from the worktree. For new submodule it
needs to lookup the name from its path to allow cloning new
submodules into the .git folder so they can be checked out without
any network interaction when the user does a checkout of that
revision.

Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

am --skip/--abort: merge HEAD/ORIG_HEAD tree into indexPaul Tan Wed, 19 Aug 2015 08:22:22 +0000 (16:22 +0800)

am --skip/--abort: merge HEAD/ORIG_HEAD tree into index

After running "git am --abort", and then running "git reset --hard",
files that were not modified would still be re-checked out.

This is because clean_index() in builtin/am.c mistakenly called the
read_tree() function, which overwrites all entries in the index,
including the stat info.

"git am --skip" did not seem to have this issue because am_skip() called
am_run(), which called refresh_cache() to update the stat info. However,
there's still a performance penalty as the lack of stat info meant that
refresh_cache() would have to scan all files for changes.

Fix this by using unpack_trees() instead to merge the tree into the
index, so that the stat info from the index is kept.

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Paul Tan <pyokagan@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

untracked cache: fix entry invalidationNguyễn Thái Ngọc Duy Wed, 19 Aug 2015 13:01:26 +0000 (20:01 +0700)

untracked cache: fix entry invalidation

First, the current code in untracked_cache_invalidate_path() is wrong
because it can only handle paths "a" or "a/b", not "a/b/c" because
lookup_untracked() only looks for entries directly under the given
directory. In the last case, it will look for the entry "b/c" in
directory "a" instead. This means if you delete or add an entry in a
subdirectory, untracked cache may become out of date because it does not
invalidate properly. This is noticed by David Turner.

The second problem is about invalidation inside a fully untracked/excluded
directory. In this case we may have to invalidate back to root. See the
comment block for detail.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

untracked-cache: fix subdirectory handlingDavid Turner Wed, 19 Aug 2015 13:01:25 +0000 (20:01 +0700)

untracked-cache: fix subdirectory handling

Previously, some calls lookup_untracked would pass a full path. But
lookup_untracked assumes that the portion of the path up to and
including to the untracked_cache_dir has been removed. So
lookup_untracked would be looking in the untracked_cache for 'foo' for
'foo/bar' (instead of just looking for 'bar'). This would cause
untracked cache corruption.

Instead, treat_directory learns to track the base length of the parent
directory, so that only the last path component is passed to
lookup_untracked.

Helped-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: David Turner <dturner@twopensource.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t7063: use --force-untracked-cache to speed up a bitNguyễn Thái Ngọc Duy Wed, 19 Aug 2015 13:01:24 +0000 (20:01 +0700)

t7063: use --force-untracked-cache to speed up a bit

When in the middle of t7063, we are sure untracked cache is supported,
so we can use --force-untracked-cache to skip the support detection
phase and save a few seconds. It's also good that --force-untracked-cache
is exercised in the test suite.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

notes: teach git-notes about notes.<name>.mergeStrategy... Jacob Keller Mon, 17 Aug 2015 21:33:34 +0000 (14:33 -0700)

notes: teach git-notes about notes.<name>.mergeStrategy option

Teach notes about a new "notes.<name>.mergeStrategy" option for
configuring the notes merge strategy when merging into
refs/notes/<name>. This option allows for the selection of merge
strategy for particular notes refs, rather than all notes ref merges, as
user may not want cat_sort_uniq for all refs, but only some. Note that
the <name> is the local reference we are merging into, not the remote
ref we merged from. The assumption is that users will mostly want to
configure separate local ref merge strategies rather than strategies
depending on which remote ref they merge from.

notes.<name>.mergeStrategy overrides the general behavior as it is more
specific.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

notes: add notes.mergeStrategy option to select default... Jacob Keller Mon, 17 Aug 2015 21:33:33 +0000 (14:33 -0700)

notes: add notes.mergeStrategy option to select default strategy

Teach git-notes about "notes.mergeStrategy" to select a general strategy
for all notes merges. This enables a user to always get expected merge
strategy such as "cat_sort_uniq" without having to pass the "-s" option
manually.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

notes: add tests for --commit/--abort/--strategy exclus... Jacob Keller Mon, 17 Aug 2015 21:33:32 +0000 (14:33 -0700)

notes: add tests for --commit/--abort/--strategy exclusivity

Add new tests to ensure that --commit, --abort, and --strategy are
mutually exclusive.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

notes: extract parse_notes_merge_strategy to notes... Jacob Keller Mon, 17 Aug 2015 21:33:31 +0000 (14:33 -0700)

notes: extract parse_notes_merge_strategy to notes-utils

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

notes: extract enum notes_merge_strategy to notes-utils.hJacob Keller Mon, 17 Aug 2015 21:33:30 +0000 (14:33 -0700)

notes: extract enum notes_merge_strategy to notes-utils.h

A future patch will extract parsing of the --strategy string into a
helper function in notes.c and will require the enumeration definition.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

notes: document cat_sort_uniq rewriteModeJacob Keller Mon, 17 Aug 2015 21:33:29 +0000 (14:33 -0700)

notes: document cat_sort_uniq rewriteMode

Teach documentation about the cat_sort_uniq rewriteMode that got added
at the same time as the equivalent merge strategy.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Third batch for 2.6Junio C Hamano Mon, 17 Aug 2015 22:09:25 +0000 (15:09 -0700)

Third batch for 2.6

Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'dt/untracked-sparse'Junio C Hamano Mon, 17 Aug 2015 22:07:52 +0000 (15:07 -0700)

Merge branch 'dt/untracked-sparse'

Allow untracked cache (experimental) to be used when sparse
checkout (experimental) is also in use.

* dt/untracked-sparse:
untracked-cache: support sparse checkout

Merge branch 'ta/docfix-index-format-tech'Junio C Hamano Mon, 17 Aug 2015 22:07:52 +0000 (15:07 -0700)

Merge branch 'ta/docfix-index-format-tech'

* ta/docfix-index-format-tech:
typofix for index-format.txt

Merge branch 'mh/get-remote-group-fix'Junio C Hamano Mon, 17 Aug 2015 22:07:51 +0000 (15:07 -0700)

Merge branch 'mh/get-remote-group-fix'

An off-by-one error made "git remote" to mishandle a remote with a
single letter nickname.

* mh/get-remote-group-fix:
get_remote_group(): use skip_prefix()
get_remote_group(): eliminate superfluous call to strcspn()
get_remote_group(): rename local variable "space" to "wordlen"
get_remote_group(): handle remotes with single-character names

Merge branch 'kd/pull-rebase-autostash'Junio C Hamano Mon, 17 Aug 2015 22:07:50 +0000 (15:07 -0700)

Merge branch 'kd/pull-rebase-autostash'

"git pull --rebase" has been taught to pay attention to
rebase.autostash configuration.

* kd/pull-rebase-autostash:
pull: allow dirty tree when rebase.autostash enabled

send-email: provide whitelist of SMTP AUTH mechanismsJan Viktorin Tue, 11 Aug 2015 23:39:44 +0000 (01:39 +0200)

send-email: provide whitelist of SMTP AUTH mechanisms

When sending an e-mail, the client and server must agree on an
authentication mechanism. Some servers (due to misconfiguration
or a bug) deny valid credentials for certain mechanisms. In this
patch, a new option --smtp-auth and configuration entry smtpAuth
are introduced. If smtp_auth is defined, it works as a whitelist
of allowed mechanisms for authentication selected from the ones
supported by the installed SASL perl library.

Signed-off-by: Jan Viktorin <viktorin@rehivetech.com>
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

po/README: Update directions for l10n contributorsPhilip Oakley Sun, 16 Aug 2015 07:56:56 +0000 (15:56 +0800)

po/README: Update directions for l10n contributors

Some Linux distributions (such as Ubuntu) have their own l10n workflows,
and their translations may be different. Add notes for this case for
l10n translators.

Signed-off-by: Philip Oakley <philipoakley@iee.org>
Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

http: add support for specifying the SSL versionElia Pinto Fri, 14 Aug 2015 19:37:43 +0000 (21:37 +0200)

http: add support for specifying the SSL version

Teach git about a new option, "http.sslVersion", which permits one
to specify the SSL version to use when negotiating SSL connections.
The setting can be overridden by the GIT_SSL_VERSION environment
variable.

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

config: close config file handle in case of errorSven Strickroth Fri, 14 Aug 2015 20:21:17 +0000 (22:21 +0200)

config: close config file handle in case of error

When updating an existing configuration file, we did not always
close the filehandle that is reading from the current configuration
file when we encountered an error (e.g. when unsetting a variable
that does not exist).

Signed-off-by: Sven Strickroth <email@cs-ware.de>
Signed-off-by: Sup Yut Sum <ch3cooli@gmail.com>
Reviewed-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

credential-cache--daemon: use tempfile moduleMichael Haggerty Mon, 10 Aug 2015 09:47:51 +0000 (11:47 +0200)

credential-cache--daemon: use tempfile module

Use the tempfile module to ensure that the socket file gets deleted on
program exit.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

credential-cache--daemon: delete socket from main()Michael Haggerty Mon, 10 Aug 2015 09:47:50 +0000 (11:47 +0200)

credential-cache--daemon: delete socket from main()

main() is responsible for cleaning up the socket in the case of
errors, so it is reasonable to also make it responsible for cleaning
it up when there are no errors. This change also makes the next step
easier.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

gc: use tempfile module to handle gc.pid fileMichael Haggerty Mon, 10 Aug 2015 09:47:49 +0000 (11:47 +0200)

gc: use tempfile module to handle gc.pid file

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

lock_repo_for_gc(): compute the path to "gc.pid" only... Michael Haggerty Mon, 10 Aug 2015 09:47:48 +0000 (11:47 +0200)

lock_repo_for_gc(): compute the path to "gc.pid" only once

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

diff: use tempfile moduleMichael Haggerty Wed, 12 Aug 2015 17:12:01 +0000 (19:12 +0200)

diff: use tempfile module

Also add some code comments explaining how the fields in "struct
diff_tempfile" are used.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Second batch for 2.6Junio C Hamano Wed, 12 Aug 2015 21:16:31 +0000 (14:16 -0700)

Second batch for 2.6

Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'sb/remove-unused-var-from-builtin-add'Junio C Hamano Wed, 12 Aug 2015 21:09:58 +0000 (14:09 -0700)

Merge branch 'sb/remove-unused-var-from-builtin-add'

* sb/remove-unused-var-from-builtin-add:
add: remove dead code

Merge branch 'sb/parse-options-codeformat'Junio C Hamano Wed, 12 Aug 2015 21:09:57 +0000 (14:09 -0700)

Merge branch 'sb/parse-options-codeformat'

* sb/parse-options-codeformat:
parse-options: align curly braces for all options

Merge branch 'dt/unpack-trees-cache-tree-revalidate'Junio C Hamano Wed, 12 Aug 2015 21:09:57 +0000 (14:09 -0700)

Merge branch 'dt/unpack-trees-cache-tree-revalidate'

The code to perform multi-tree merges has been taught to repopulate
the cache-tree upon a successful merge into the index, so that
subsequent "diff-index --cached" (hence "status") and "write-tree"
(hence "commit") will go faster.

The same logic in "git checkout" may now be removed, but that is a
separate issue.

* dt/unpack-trees-cache-tree-revalidate:
unpack-trees: populate cache-tree on successful merge

Merge branch 'dt/reflog-tests'Junio C Hamano Wed, 12 Aug 2015 21:09:56 +0000 (14:09 -0700)

Merge branch 'dt/reflog-tests'

Tests that assume how reflogs are represented on the filesystem too
much have been corrected.

* dt/reflog-tests:
tests: remove some direct access to .git/logs
t/t7509: remove unnecessary manipulation of reflog

Merge branch 'es/worktree-add-cleanup'Junio C Hamano Wed, 12 Aug 2015 21:09:56 +0000 (14:09 -0700)

Merge branch 'es/worktree-add-cleanup'

The "new-worktree-mode" hack in "checkout" that was added in
nd/multiple-work-trees topic has been removed by updating the
implementation of new "worktree add".

* es/worktree-add-cleanup: (25 commits)
Documentation/git-worktree: fix duplicated 'from'
Documentation/config: mention "now" and "never" for 'expire' settings
Documentation/git-worktree: fix broken 'linkgit' invocation
checkout: drop intimate knowledge of newly created worktree
worktree: populate via "git reset --hard" rather than "git checkout"
worktree: avoid resolving HEAD unnecessarily
worktree: make setup of new HEAD distinct from worktree population
worktree: detect branch-name/detached and error conditions locally
worktree: add_worktree: construct worktree-population command locally
worktree: elucidate environment variables intended for child processes
worktree: make branch creation distinct from worktree population
worktree: add: suppress auto-vivication with --detach and no <branch>
worktree: make --detach mutually exclusive with -b/-B
worktree: introduce options container
worktree: simplify new branch (-b/-B) option checking
worktree: improve worktree setup message
branch: publish die_if_checked_out()
checkout: teach check_linked_checkout() about symbolic link HEAD
checkout: check_linked_checkout: simplify symref parsing
checkout: check_linked_checkout: improve "already checked out" aesthetic
...

Merge branch 'pt/am-builtin'Junio C Hamano Wed, 12 Aug 2015 21:09:55 +0000 (14:09 -0700)

Merge branch 'pt/am-builtin'

Rewrite "am" in "C".

* pt/am-builtin: (46 commits)
git-am: add am.threeWay config variable
builtin-am: remove redirection to git-am.sh
builtin-am: check for valid committer ident
builtin-am: implement legacy -b/--binary option
builtin-am: implement -i/--interactive
builtin-am: support and auto-detect mercurial patches
builtin-am: support and auto-detect StGit series files
builtin-am: support and auto-detect StGit patches
builtin-am: rerere support
builtin-am: invoke post-applypatch hook
builtin-am: invoke pre-applypatch hook
builtin-am: invoke applypatch-msg hook
builtin-am: support automatic notes copying
builtin-am: invoke post-rewrite hook
builtin-am: implement -S/--gpg-sign, commit.gpgsign
builtin-am: implement --committer-date-is-author-date
builtin-am: implement --ignore-date
builtin-am: pass git-apply's options to git-apply
builtin-am: implement --[no-]scissors
builtin-am: support --keep-cr, am.keepcr
...

Merge branch 'es/worktree-add'Junio C Hamano Wed, 12 Aug 2015 21:09:54 +0000 (14:09 -0700)

Merge branch 'es/worktree-add'

Remove remaining cruft from "git checkout --to", which
transitioned to "git worktree add".

* es/worktree-add:
config: rename "gc.pruneWorktreesExpire" to "gc.worktreePruneExpire"
Documentation/git-worktree: wordsmith worktree-related manpages
Documentation/config: fix stale "git prune --worktree" reference
Documentation/git-worktree: fix incorrect reference to file "locked"
Documentation/git-worktree: consistently use term "linked working tree"

Merge branch 'ad/bisect-cleanup'Junio C Hamano Wed, 12 Aug 2015 21:09:53 +0000 (14:09 -0700)

Merge branch 'ad/bisect-cleanup'

Code and documentation clean-up to "git bisect".

* ad/bisect-cleanup:
bisect: don't mix option parsing and non-trivial code
bisect: simplify the addition of new bisect terms
bisect: replace hardcoded "bad|good" by variables
Documentation/bisect: revise overall content
Documentation/bisect: move getting help section to the end
bisect: correction of typo

git_open_noatime: return with errno=0 on successClemens Buchacher Tue, 4 Aug 2015 08:24:29 +0000 (10:24 +0200)

git_open_noatime: return with errno=0 on success

In read_sha1_file_extended we die if read_object fails with a fatal
error. We detect a fatal error if errno is non-zero and is not
ENOENT. If the object could not be read because it does not exist,
this is not considered a fatal error and we want to return NULL.

Somewhere down the line, read_object calls git_open_noatime to open
a pack index file, for example. We first try open with O_NOATIME.
If O_NOATIME fails with EPERM, we retry without O_NOATIME. When the
second open succeeds, errno is however still set to EPERM from the
first attempt. When we finally determine that the object does not
exist, read_object returns NULL and read_sha1_file_extended dies
with a fatal error:

fatal: failed to read object <sha1>: Operation not permitted

Fix this by resetting errno to zero before we call open again.

Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Clemens Buchacher <clemens.buchacher@intel.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

am: let --signoff override --no-signoffPaul Tan Tue, 4 Aug 2015 14:08:51 +0000 (22:08 +0800)

am: let --signoff override --no-signoff

After resolving a conflicting patch, a user may wish to sign off the
patch to declare that the patch has been modified. As such, the user
will expect that running "git am --signoff --continue" will append the
signoff to the commit message.

However, the --signoff option is only taken into account during the
mail-parsing stage. If the --signoff option is set, then the signoff
will be appended to the commit message. Since the mail-parsing stage
comes before the patch application stage, the --signoff option, if
provided on the command-line when resuming, will have no effect at all.

We cannot move the append_signoff() call to the patch application stage
as the applypatch-msg hook and interactive mode, which run before patch
application, may expect the signoff to be there.

Fix this by taking note if the user explictly set the --signoff option
on the command-line, and append the signoff to the commit message when
resuming if so.

Signed-off-by: Paul Tan <pyokagan@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

am: let command-line options override saved optionsPaul Tan Tue, 4 Aug 2015 14:08:50 +0000 (22:08 +0800)

am: let command-line options override saved options

When resuming, git-am mistakenly ignores command-line options.

For instance, when a patch fails to apply with "git am patch",
subsequently running "git am --3way" would not cause git-am to fall
back on attempting a threeway merge. This occurs because by default
the --3way option is saved as "false", and the saved am options are
loaded after the command-line options are parsed, thus overwriting
the command-line options when resuming.

Fix this by moving the am_load() function call before parse_options(),
so that command-line options will override the saved am options.

The purpose of supporting this use case is to enable users to "wiggle"
that one conflicting patch. As such, it is expected that the
command-line options do not affect subsequent applied patches. Implement
this by calling am_load() once we apply the conflicting patch
successfully.

Noticed-by: Junio C Hamano <gitster@pobox.com>
Helped-by: Junio C Hamano <gitster@pobox.com>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Paul Tan <pyokagan@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

test_terminal: redirect child process' stdin to a ptyPaul Tan Tue, 4 Aug 2015 14:08:49 +0000 (22:08 +0800)

test_terminal: redirect child process' stdin to a pty

When resuming, git-am detects if we are trying to feed it patches or not
by checking if stdin is a TTY.

However, the test library redirects stdin to /dev/null. This makes it
difficult, for instance, to test the behavior of "git am -3" when
resuming, as git-am will think we are trying to feed it patches and
error out.

Support this use case by extending test-terminal.perl to create a
pseudo-tty for the child process' standard input as well.

Note that due to the way the code is structured, the child's stdin
pseudo-tty will be closed when we finish reading from our stdin. This
means that in the common case, where our stdin is attached to /dev/null,
the child's stdin pseudo-tty will be closed immediately. Some operations
like isatty(), which git-am uses, require the file descriptor to be
open, and hence if the success of the command depends on such functions,
test_terminal's stdin should be redirected to a source with large amount
of data to ensure that the child's stdin is not closed, e.g.

test_terminal git am --3way </dev/zero

Cc: Jonathan Nieder <jrnieder@gmail.com>
Cc: Jeff King <peff@peff.net>
Signed-off-by: Paul Tan <pyokagan@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

pseudoref: check return values from read_ref()David Turner Wed, 15 Jul 2015 22:05:28 +0000 (18:05 -0400)

pseudoref: check return values from read_ref()

These codepaths attempt to compare the "expected" current value with
the actual current value, but did not check if we successfully read
the current value before comparison.

Signed-off-by: David Turner <dturner@twopensource.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t2019: skip test requiring '*' in a file name non WindowsJohannes Sixt Tue, 11 Aug 2015 20:38:46 +0000 (22:38 +0200)

t2019: skip test requiring '*' in a file name non Windows

A test case introduced by ae454f61 (Add tests for wildcard "path vs ref"
disambiguation) allocates a file named '*.c'. This does not work on
Windows, because the OS forbids file names containing wildcard
characters. The test case fails where the shell attempts to allocate the
file. Skip the test on Windows.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t7300-clean: require POSIXPERM for chmod 0 testJohannes Sixt Tue, 11 Aug 2015 20:29:48 +0000 (22:29 +0200)

t7300-clean: require POSIXPERM for chmod 0 test

A test case introduced by 91479b9c (t7300: add tests to document
behavior of clean and nested git) uses 'chmod 0' to verify that a
subdirectory that has an unreadable .git file is not removed. This can
work only when the system pays attention to the permissions set with
'chmod'. Therefore, set the POSIXPERM prerequisite on the test case.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

vreportf: avoid intermediate bufferJeff King Tue, 11 Aug 2015 18:13:59 +0000 (14:13 -0400)

vreportf: avoid intermediate buffer

When we call "die(fmt, args...)", we end up in vreportf with
two pieces of information:

1. The prefix "fatal: "

2. The original fmt and va_list of args.

We format item (2) into a temporary buffer, and then fprintf
the prefix and the temporary buffer, along with a newline.
This has the unfortunate side effect of truncating any error
messages that are longer than 4096 bytes.

Instead, let's use separate calls for the prefix and
newline, letting us hand the item (2) directly to vfprintf.
This is essentially undoing d048a96 (print
warning/error/fatal messages in one shot, 2007-11-09), which
tried to have the whole output end up in a single `write`
call.

But we can address this instead by explicitly requesting
line-buffering for the output handle, and by making sure
that the buffer is empty before we start (so that outputting
the prefix does not cause a flush due to hitting the buffer
limit).

We may still break the output into two writes if the content
is larger than our buffer, but there's not much we can do
there; depending on the stdio implementation, that might
have happened even with a single fprintf call.

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

vreportf: report to arbitrary filehandlesJeff King Tue, 11 Aug 2015 18:06:15 +0000 (14:06 -0400)

vreportf: report to arbitrary filehandles

The vreportf function always goes to stderr, but run-command
wants child errors to go to the parent's original stderr. To
solve this, commit a5487dd duplicates the stderr fd and
installs die and error handlers to direct the output
appropriately (which later turned into the vwritef
function). This has two downsides, though:

- we make multiple calls to write(), which contradicts the
"write at once" logic from d048a96 (print
warning/error/fatal messages in one shot, 2007-11-09).

- the custom handlers basically duplicate the normal
handlers. They're only a few lines of code, but we
should not have to repeat the magic "exit(128)", for
example.

We can solve the first by using fdopen() on the duplicated
descriptor. We can't pass this to vreportf, but we could
introduce a new vreportf_to to handle it.

However, to fix the second problem, we instead introduce a
new "set_error_handle" function, which lets the normal
vreportf calls output to a handle besides stderr. Thus we
can get rid of our custom handlers entirely, and just ask
the regular handlers to output to our new descriptor.

And as vwritef has no more callers, it can just go away.

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

notes: handle multiple worktreesDavid Turner Mon, 10 Aug 2015 17:52:45 +0000 (13:52 -0400)

notes: handle multiple worktrees

Before creating NOTES_MERGE_REF, check NOTES_MERGE_REF using
find_shared_symref and die if we find one. This prevents simultaneous
merges to the same notes branch from different worktrees.

Signed-off-by: David Turner <dturner@twopensource.com>
Reviewed-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

worktrees: add find_shared_symrefDavid Turner Mon, 10 Aug 2015 17:52:44 +0000 (13:52 -0400)

worktrees: add find_shared_symref

Add a new function, find_shared_symref, which contains the heart of
die_if_checked_out, but works for any symref, not just HEAD. Refactor
die_if_checked_out to use the same infrastructure as
find_shared_symref.

Soon, we will use find_shared_symref to protect notes merges in
worktrees.

Signed-off-by: David Turner <dturner@twopensource.com>
Reviewed-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

memoize common git-path "constant" filesJeff King Mon, 10 Aug 2015 09:38:57 +0000 (05:38 -0400)

memoize common git-path "constant" files

One of the most common uses of git_path() is to pass a
constant, like git_path("MERGE_MSG"). This has two
drawbacks:

1. The return value is a static buffer, and the lifetime
is dependent on other calls to git_path, etc.

2. There's no compile-time checking of the pathname. This
is OK for a one-off (after all, we have to spell it
correctly at least once), but many of these constant
strings appear throughout the code.

This patch introduces a series of functions to "memoize"
these strings, which are essentially globals for the
lifetime of the program. We compute the value once, take
ownership of the buffer, and return the cached value for
subsequent calls. cache.h provides a helper macro for
defining these functions as one-liners, and defines a few
common ones for global use.

Using a macro is a little bit gross, but it does nicely
document the purpose of the functions. If we need to touch
them all later (e.g., because we learned how to change the
git_dir variable at runtime, and need to invalidate all of
the stored values), it will be much easier to have the
complete list.

Note that the shared-global functions have separate, manual
declarations. We could do something clever with the macros
(e.g., expand it to a declaration in some places, and a
declaration _and_ a definition in path.c). But there aren't
that many, and it's probably better to stay away from
too-magical macros.

Likewise, if we abandon the C preprocessor in favor of
generating these with a script, we could get much fancier.
E.g., normalizing "FOO/BAR-BAZ" into "git_path_foo_bar_baz".
But the small amount of saved typing is probably not worth
the resulting confusion to readers who want to grep for the
function's definition.

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

get_repo_path: refactor path-allocationJeff King Mon, 10 Aug 2015 09:37:55 +0000 (05:37 -0400)

get_repo_path: refactor path-allocation

The get_repo_path function calls mkpath() and then does some
non-trivial operations on it, like calling
is_git_directory() and read_gitfile(). These are actually
OK (they do not use more pathname static buffers
themselves), but it takes a fair bit of work to verify.

Let's use our own strbuf to store the path, and we can
simply reuse it for each iteration of the loop (we can even
avoid rewriting the beginning part, since we are trying a
series of suffixes).

To make the strbuf cleanup easier, we split out a thin
wrapper. As a bonus, this wrapper can factor out the
canonicalization that happens in all of the early-return
code paths.

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

find_hook: keep our own static bufferJeff King Mon, 10 Aug 2015 09:37:45 +0000 (05:37 -0400)

find_hook: keep our own static buffer

The find_hook function returns the results of git_path,
which is a static buffer shared by other path-related calls.
Returning such a buffer is slightly dangerous, because it
can be overwritten by seemingly unrelated functions.

Let's at least keep our _own_ static buffer, so you can
only get in trouble by calling find_hook in quick
succession, which is less likely to happen and more obvious
to notice.

While we're at it, let's add some documentation of the
function's limitations.

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

refs.c: remove_empty_directories can take a strbufJeff King Mon, 10 Aug 2015 09:37:27 +0000 (05:37 -0400)

refs.c: remove_empty_directories can take a strbuf

The first thing we do in this function is copy the input
into a strbuf. Of the 4 callers, 3 of them already have a
strbuf we could use. Let's just take the strbuf, and convert
the remaining caller to use a strbuf, rather than a raw
git_path. This is safer, anyway, as remove_dir_recursively
is a non-trivial function that might use the pathname
buffers itself (this is _probably_ OK, as the likely culprit
would be calling resolve_gitlink_ref, but we do not pass the
proper flags to ask it to avoid blowing away gitlinks).

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

refs.c: avoid git_path assignment in lock_ref_sha1_basicJeff King Mon, 10 Aug 2015 09:37:12 +0000 (05:37 -0400)

refs.c: avoid git_path assignment in lock_ref_sha1_basic

Assigning the result of git_path is a bad pattern, because
it's not immediately obvious how long you expect the content
to stay valid (and it may be overwritten by subsequent
calls). Let's use a function-local strbuf here instead,
which we know is safe (we just have to remember to free it
in all code paths).

As a bonus, we get rid of a confusing variable-reuse
("ref_file" is used for two distinct purposes).

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

refs.c: avoid repeated git_path calls in rename_tmp_logJeff King Mon, 10 Aug 2015 09:36:53 +0000 (05:36 -0400)

refs.c: avoid repeated git_path calls in rename_tmp_log

Because it's not safe to store the static-buffer results of
git_path for a long time, we end up formatting the same
filename over and over. We can fix this by using a
function-local strbuf to store the formatted pathname and
avoid repeating ourselves.

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

refs.c: simplify strbufs in reflog setup and writingJeff King Mon, 10 Aug 2015 12:26:38 +0000 (08:26 -0400)

refs.c: simplify strbufs in reflog setup and writing

Commit 1a83c24 (git_snpath(): retire and replace with
strbuf_git_path(), 2014-11-30) taught log_ref_setup and
log_ref_write_1 to take a strbuf parameter, rather than a
bare string. It then makes an alias to the strbuf's "buf"
field under the original name.

This made the original diff much shorter, but the resulting
code is more complicated that it needs to be. Since we've
aliased the pointer, we drop our reference to the strbuf to
ensure we don't accidentally change it. But if we simply
drop our alias and use "logfile.buf" directly, we do not
have to worry about this aliasing. It's a larger diff, but
the resulting code is simpler.

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

path.c: drop git_path_submoduleJeff King Mon, 10 Aug 2015 09:36:27 +0000 (05:36 -0400)

path.c: drop git_path_submodule

There are no callers of the slightly-dangerous static-buffer
git_path_submodule left. Let's drop it.

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

refs.c: remove extra git_path calls from read_loose_refsJeff King Mon, 10 Aug 2015 09:36:19 +0000 (05:36 -0400)

refs.c: remove extra git_path calls from read_loose_refs

In iterating over the loose refs in "refs/foo/", we keep a
running strbuf with "refs/foo/one", "refs/foo/two", etc. But
we also need to access these files in the filesystem, as
".git/refs/foo/one", etc. For this latter purpose, we make a
series of independent calls to git_path(). These are safe
(we only use the result to call stat()), but assigning the
result of git_path is a suspicious pattern that we'd rather
avoid.

This patch keeps a running buffer with ".git/refs/foo/", and
we can just append/reset each directory element as we loop.
This matches how we handle the refnames. It should also be
more efficient, as we do not keep formatting the same
".git/refs/foo" prefix (which can be arbitrarily deep).

Technically we are dropping a call to strbuf_cleanup() on
each generated filename, but that's OK; it wasn't doing
anything, as we are putting in single-level names we read
from the filesystem (so it could not possibly be cleaning up
cruft like "./" in this instance).

A clever reader may also note that the running refname
buffer ("refs/foo/") is actually a subset of the filesystem
path buffer (".git/refs/foo/"). We could get by with one
buffer, indexing the length of $GIT_DIR when we want the
refname. However, having tried this, the resulting code
actually ends up a little more confusing, and the efficiency
improvement is tiny (and almost certainly dwarfed by the
system calls we are making).

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

remote.c: drop extraneous local variable from migrate_fileJeff King Mon, 10 Aug 2015 09:35:49 +0000 (05:35 -0400)

remote.c: drop extraneous local variable from migrate_file

It's an anti-pattern to assign the result of git_path to a
variable, since other calls may reuse our buffer. In this
case, we feed the result to unlink_or_warn immediately
afterwards, so it's OK. However, it's nice to avoid
assignment entirely, which makes it more obvious that
there's no bug.

We can just pass the result directly to unlink_or_warn,
which is a known-simple function. As a bonus, the code flow
is a little more obvious, as we eliminate an extra
conditional (a reader does not have to wonder any more
"under which circumstances is 'path' set?").

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

prefer mkpathdup to mkpath in assignmentsJeff King Mon, 10 Aug 2015 09:35:38 +0000 (05:35 -0400)

prefer mkpathdup to mkpath in assignments

As with the previous commit to git_path, assigning the
result of mkpath is suspicious, since it is not clear
whether we will still depend on the value after it may have
been overwritten by subsequent calls. This patch converts
low-hanging fruit to use mkpathdup instead of mkpath (with
the downside that we must remember to free the result).

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

prefer git_pathdup to git_path in some possibly-dangero... Jeff King Mon, 10 Aug 2015 09:35:31 +0000 (05:35 -0400)

prefer git_pathdup to git_path in some possibly-dangerous cases

Because git_path uses a static buffer that is shared with
calls to git_path, mkpath, etc, it can be dangerous to
assign the result to a variable or pass it to a non-trivial
function. The value may change unexpectedly due to other
calls.

None of the cases changed here has a known bug, but they're
worth converting away from git_path because:

1. It's easy to use git_pathdup in these cases.

2. They use constructs (like assignment) that make it
hard to tell whether they're safe or not.

The extra malloc overhead should be trivial, as an
allocation should be an order of magnitude cheaper than a
system call (which we are clearly about to make, since we
are constructing a filename). The real cost is that we must
remember to free the result.

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

add_to_alternates_file: don't add duplicate entriesJeff King Mon, 10 Aug 2015 09:34:46 +0000 (05:34 -0400)

add_to_alternates_file: don't add duplicate entries

The add_to_alternates_file function blindly uses
hold_lock_file_for_append to copy the existing contents, and
then adds the new line to it. This has two minor problems:

1. We might add duplicate entries, which are ugly and
inefficient.

2. We do not check that the file ends with a newline, in
which case we would bogusly append to the final line.
This is quite unlikely in practice, though, as we call
this function only from git-clone, so presumably we are
the only writers of the file (and we always add a
newline).

Instead of using hold_lock_file_for_append, let's copy the
file line by line, which ensures all records are properly
terminated. If we see an extra line, we can simply abort the
update (there is no point in even copying the rest, as we
know that it would be identical to the original).

As a bonus, we also get rid of some calls to the
static-buffer mkpath and git_path functions.

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

t5700: modernize styleJeff King Mon, 10 Aug 2015 09:32:30 +0000 (05:32 -0400)

t5700: modernize style

The early part of this test is rather old, and does not
follow our usual style guidelines. In particular:

- the tests liberally chdir, and expect out-of-test "cd"
commands to return them to a sane state

- test commands aren't indented at all

- there are a lot of minor formatting nits, like the
opening quote of the test block on the wrong line,
spaces after ">", etc

This patch fixes the style issues, and uses a few helper
functions, along with subshells and "git -C", to avoid
changing the cwd of the main script.

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

cache.h: complete set of git_path_submodule helpersJeff King Mon, 10 Aug 2015 09:32:22 +0000 (05:32 -0400)

cache.h: complete set of git_path_submodule helpers

The git_path function has "git_pathdup" and
"strbuf_git_path" variants, but git_submodule_path only
comes in the dangerous, static-buffer variant. That makes
refactoring callers to use the safer functions hard (since
they don't exist).

Since we're already using a strbuf behind the scenes, it's
easy to expose all three of these interfaces with thin
wrappers.

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

cache.h: clarify documentation for git_path, et alJeff King Mon, 10 Aug 2015 09:32:07 +0000 (05:32 -0400)

cache.h: clarify documentation for git_path, et al

The comment above these functions actually describes
sha1_file_name, and comes from the very first revision of
git. Commit 723c31f (Add "git_path()" and "head_ref()"
helper functions., 2005-07-05) added git_path, pushing the
comment away from the function it describes; later commits
added more functions in this block.

Let's fix the comment to describe these related functions in
more detail. Let's also make sure to point out their safer
alternatives (and move those alternatives below, which makes
more sense when reading the file).

Note that we do not need to move the existing comment to
sha1_file_name. Commit d40d535 (sha1_file.c: document a
bunch of functions defined in the file, 2014-02-21) already
added a much more descriptive comment to it.

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

setup_temporary_shallow(): use tempfile moduleMichael Haggerty Mon, 10 Aug 2015 09:47:46 +0000 (11:47 +0200)

setup_temporary_shallow(): use tempfile module

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

write_shared_index(): use tempfile moduleMichael Haggerty Mon, 10 Aug 2015 09:47:45 +0000 (11:47 +0200)

write_shared_index(): use tempfile module

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

register_tempfile(): new function to handle an existing... Michael Haggerty Mon, 10 Aug 2015 09:47:44 +0000 (11:47 +0200)

register_tempfile(): new function to handle an existing temporary file

Allow an existing file to be registered with the tempfile-handling
infrastructure; in particular, arrange for it to be deleted on program
exit. This can be used if the temporary file has to be created in a
more complicated way than just open(). For example:

* If the file itself needs to be created via the lockfile API
* If it is not a regular file (e.g., a socket)

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

tempfile: add several functions for creating temporary... Michael Haggerty Mon, 10 Aug 2015 09:47:43 +0000 (11:47 +0200)

tempfile: add several functions for creating temporary files

Add several functions for creating temporary files with
automatically-generated names, analogous to mkstemps(), but also
arranging for the files to be deleted on program exit.

The functions are named according to a pattern depending how they
operate. They will be used to replace many places in the code where
temporary files are created and cleaned up ad-hoc.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

prepare_tempfile_object(): new function, extracted... Michael Haggerty Mon, 10 Aug 2015 09:47:42 +0000 (11:47 +0200)

prepare_tempfile_object(): new function, extracted from create_tempfile()

This makes the next step easier.

The old code used to use "path" to set the initial length of
tempfile->filename. This was not helpful because path was usually
relative whereas the value stored to filename will be absolute. So
just initialize the length to 0.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

tempfile: a new module for handling temporary filesMichael Haggerty Mon, 10 Aug 2015 09:47:41 +0000 (11:47 +0200)

tempfile: a new module for handling temporary files

A lot of work went into defining the state diagram for lockfiles and
ensuring correct, race-resistant cleanup in all circumstances.

Most of that infrastructure can be applied directly to *any* temporary
file. So extract a new "tempfile" module from the "lockfile" module.
Reimplement lockfile on top of tempfile.

Subsequent commits will add more users of the new module.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

commit_lock_file(): use get_locked_file_path()Michael Haggerty Mon, 10 Aug 2015 09:47:40 +0000 (11:47 +0200)

commit_lock_file(): use get_locked_file_path()

First beef up the sanity checking in get_locked_file_path() to match
that in commit_lock_file(). Then rewrite commit_lock_file() to use
get_locked_file_path() for its pathname computation.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

lockfile: add accessor get_lock_file_path()Michael Haggerty Mon, 10 Aug 2015 09:47:39 +0000 (11:47 +0200)

lockfile: add accessor get_lock_file_path()

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

lockfile: add accessors get_lock_file_fd() and get_lock... Michael Haggerty Mon, 10 Aug 2015 09:47:38 +0000 (11:47 +0200)

lockfile: add accessors get_lock_file_fd() and get_lock_file_fp()

We are about to move those members, so change client code to read them
through accessor functions.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

create_bundle(): duplicate file descriptor to avoid... Michael Haggerty Mon, 10 Aug 2015 09:47:37 +0000 (11:47 +0200)

create_bundle(): duplicate file descriptor to avoid closing it twice

write_pack_data() passes bundle_fd to start_command() to be used as
the stdout of pack-objects. But start_command() closes its stdout if
it is > 1. This is a problem if bundle_fd is the fd of a lock_file,
because commit_lock_file() will also try to close the fd.

So the old code suppressed commit_lock_file()'s usual behavior of
closing the file descriptor by setting the lock_file object's fd field
to -1.

But this is not really kosher. Code here shouldn't be mutating fields
within the lock_file object.

Instead, duplicate the file descriptor before passing it to
write_pack_data(). Then that function can close its copy without
closing the copy held in the lock_file object.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

lockfile: move documentation to lockfile.h and lockfile.cMichael Haggerty Mon, 10 Aug 2015 09:47:36 +0000 (11:47 +0200)

lockfile: move documentation to lockfile.h and lockfile.c

Rearrange/rewrite it somewhat to fit its new environment.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

strbuf_read(): skip unnecessary strbuf_grow() at eofJim Hill Sun, 31 May 2015 18:16:45 +0000 (11:16 -0700)

strbuf_read(): skip unnecessary strbuf_grow() at eof

The loop in strbuf_read() uses xread() repeatedly while extending
the strbuf until the call returns zero. If the buffer is
sufficiently large to begin with, this results in xread()
returning the remainder of the file to the end (returning
non-zero), the loop extending the strbuf, and then making another
call to xread() to have it return zero.

By using read_in_full(), we can tell when the read reached the end
of file: when it returns less than was requested, it's eof. This
way we can avoid an extra iteration that allocates an extra 8kB
that is never used.

Signed-off-by: Jim Hill <gjthill@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

sha1_file.c: rename move_temp_to_file() to finalize_obj... Junio C Hamano Fri, 7 Aug 2015 21:40:24 +0000 (14:40 -0700)

sha1_file.c: rename move_temp_to_file() to finalize_object_file()

Since 5a688fe4 ("core.sharedrepository = 0mode" should set, not
loosen, 2009-03-25), we kept reminding ourselves:

NEEDSWORK: this should be renamed to finalize_temp_file() as
"moving" is only a part of what it does, when no patch between
master to pu changes the call sites of this function.

without doing anything about it. Let's do so.

The purpose of this function was not to move but to finalize. The
detail of the primarily implementation of finalizing was to link the
temporary file to its final name and then to unlink, which wasn't
even "moving". The alternative implementation did "move" by calling
rename(2), which is a fun tangent.

Signed-off-by: Junio C Hamano <gitster@pobox.com>

clone: abort if no dir name could be guessedPatrick Steinhardt Mon, 10 Aug 2015 15:48:25 +0000 (17:48 +0200)

clone: abort if no dir name could be guessed

Due to various components of the URI being stripped off it may
happen that we fail to guess a directory name. We currently error
out with a message that it is impossible to create the working
tree '' in such cases. Instead, error out early with a sensible
error message hinting that a directory name should be specified
manually on the command line.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

clone: do not use port number as dir namePatrick Steinhardt Mon, 10 Aug 2015 15:48:24 +0000 (17:48 +0200)

clone: do not use port number as dir name

If the URI contains a port number and the URI's path component is
empty we fail to guess a sensible directory name. E.g. cloning a
repository 'ssh://example.com:2222/' we guess a directory name
'2222' where we would want the hostname only, e.g. 'example.com'.

We need to take care to not drop trailing port-like numbers in
certain cases. E.g. when cloning a repository 'foo/bar:2222.git'
we want to guess the directory name '2222' instead of 'bar'.
Thus, we have to first check the stripped URI for path separators
and only strip port numbers if there are path separators present.
This heuristic breaks when cloning a repository 'bar:2222.git',
though.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

clone: do not include authentication data in guessed dirPatrick Steinhardt Mon, 10 Aug 2015 15:48:23 +0000 (17:48 +0200)

clone: do not include authentication data in guessed dir

If the URI contains authentication data and the URI's path
component is empty, we fail to guess a sensible directory name.
E.g. cloning a repository 'ssh://user:password@example.com/' we
guess a directory name 'password@example.com' where we would want
the hostname only, e.g. 'example.com'.

The naive way of just adding '@' as a path separator would break
cloning repositories like 'foo/bar@baz.git' (which would
currently become 'bar@baz' but would then become 'baz' only).
Instead fix this by first dropping the scheme and then greedily
scanning for an '@' sign until we find the first path separator.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

clone: use computed length in guess_dir_nameJeff King Mon, 10 Aug 2015 15:48:22 +0000 (17:48 +0200)

clone: use computed length in guess_dir_name

Commit 7e837c6 (clone: simplify string handling in
guess_dir_name(), 2015-07-09) changed clone to use
strip_suffix instead of hand-rolled pointer manipulation.
However, strip_suffix will strip from the end of a
NUL-terminated string, and we may have already stripped some
characters (like directory separators, or "/.git"). This
leads to commands like:

git clone host:foo.git/

failing to strip the ".git".

We must instead convert our pointer arithmetic into a
computed length and feed that to strip_suffix_mem, which will
then reduce the length further for us.

It would be nicer if we could drop the pointer manipulation
entirely, and just continually strip using strip_suffix. But
that doesn't quite work for two reasons:

1. The early suffixes we're stripping are not constant; we
need to look for is_dir_sep, which could be one of
several characters.

2. Mid-way through the stripping we compute the pointer
"start", which shows us the beginning of the pathname.
Which really give us two lengths to work with: the
offset from the start of the string, and from the start
of the path. By using pointers for the early part, we
can just compute the length from "start" when we need
it.

Signed-off-by: Jeff King <peff@peff.net>
Acked-by: Sebastian Schuberth <sschuberth@gmail.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

clone: add tests for output directoryJeff King Mon, 10 Aug 2015 15:48:21 +0000 (17:48 +0200)

clone: add tests for output directory

When we run "git clone $url", clone guesses from the $url
what to name the local output directory. We don't have any
test coverage of this, so let's add some basic tests.

This reveals a few problems:

- cloning "foo.git/" does not properly remove the ".git";
this is a recent regression from 7e837c6 (clone:
simplify string handling in guess_dir_name(), 2015-07-09)

- likewise, cloning foo/.git does not seem to handle the
bare case (we should end up in foo.git, but we try to
use foo/.git on the local end), which also comes from
7e837c6.

- cloning the root is not very smart about URL parsing,
and usernames and port numbers may end up in the
directory name

All of these tests are marked as failures.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

completion: list variable names reliably with 'git... SZEDER Gábor Mon, 10 Aug 2015 09:46:07 +0000 (11:46 +0200)

completion: list variable names reliably with 'git config --name-only'

Recenty I created a multi-line branch description with '.' and '='
characters on one of the lines, and noticed that fragments of that line
show up when completing set variable names for 'git config', e.g.:

$ git config --get branch.b.description
Branch description to fool the completion script with a
second line containing dot . and equals = characters.
$ git config --unset <TAB>
...
second line containing dot . and equals
...

The completion script runs 'git config --list' and processes its output
to strip the values and keep only the variable names. It does so by
looking for lines containing '.' and '=' and outputting everything
before the '=', which was fooled by my multi-line branch description.

A similar issue exists with aliases and pretty format aliases with
multi-line values, but in that case 'git config --get-regexp' is run and
lines in its output are simply stripped after the first space, so
subsequent lines don't even have to contain '.' and '=' to fool the
completion script.

Use the new '--name-only' option added in the previous commit to list
config variable names reliably in both cases, without error-prone post
processing.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

config: add '--name-only' option to list only variable... SZEDER Gábor Mon, 10 Aug 2015 09:46:06 +0000 (11:46 +0200)

config: add '--name-only' option to list only variable names

'git config' can only show values or name-value pairs, so if a shell
script needs the names of set config variables it has to run 'git config
--list' or '--get-regexp' and parse the output to separate config
variable names from their values. However, such a parsing can't cope
with multi-line values. Though 'git config' can produce null-terminated
output for newline-safe parsing, that's of no use in such a case, becase
shells can't cope with null characters.

Even our own bash completion script suffers from these issues.

Help the completion script, and shell scripts in general, by introducing
the '--name-only' option to modify the output of '--list' and
'--get-regexp' to list only the names of config variables, so they don't
have to perform error-prone post processing to separate variable names
from their values anymore.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

test-lib: disable trace when test is not verboseJeff King Thu, 6 Aug 2015 05:33:57 +0000 (01:33 -0400)

test-lib: disable trace when test is not verbose

The "-x" test-script option turns on the shell's "-x"
tracing, which can help show why a particular test is
failing. Unfortunately, this can create false negatives in
some tests if they invoke a shell function with its stderr
redirected. t5512.10 is such a test, as it does:

test_must_fail git ls-remote refs*master >actual 2>&1 &&
test_cmp exp actual

The "actual" file gets the "-x" trace for the test_must_fail
function, which prevents it from matching the expected
output.

There's no way to avoid this without managing the
trace flag inside each sub-function, which isn't really a
workable solution. But unless you specifically care about
t5512.10, we can work around it by enabling tracing only for
the specific tests we want.

You can already do:

./t5512-ls-remote.sh -x --verbose-only=16

to see the trace only for a specific test. But that doesn't
_disable_ the tracing in the other tests; it just sends it
to /dev/null. However, there's no point in generating a
trace that the user won't see, so we can simply disable
tracing whenever it doesn't have a matching verbose flag.

The normal case of just "./t5512-ls-remote.sh -x" stays the
same, as "-x" already implies "--verbose" (and
"--verbose-only" overrides "--verbose", which is why this
works at all). And for our test, we need only check
$verbose, as maybe_setup_verbose will have already
set that flag based on the $verbose_only list).

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

test-lib: turn off "-x" tracing during chain-lint checkJeff King Thu, 6 Aug 2015 05:31:47 +0000 (01:31 -0400)

test-lib: turn off "-x" tracing during chain-lint check

Now that GIT_TEST_CHAIN_LINT is on by default, running:

./t0000-basic.sh -x --verbose-only=1

starts with:

expecting success:
find .git/objects -type f -print >should-be-empty &&
test_line_count = 0 should-be-empty

+ exit 117
error: last command exited with $?=117
+ find .git/objects -type f -print
+ test_line_count = 0 should-be-empty
+ test 3 != 3
+ wc -l
+ test 0 = 0
ok 1 - .git/objects should be empty after git init in an empty repo

This is confusing, as the "exit 117" line and the error line
(which is printed in red, no less!) are not part of the test
at all, but are rather in the separate chain-lint test_eval.
Let's unset the "trace" variable when eval-ing the chain
lint check, which avoids this.

Note that we cannot just do a one-shot variable like:

trace= test_eval ...

as the behavior of one-shot variables for function calls
is not portable.

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

refs: support negative transfer.hideRefsJeff King Tue, 28 Jul 2015 20:23:26 +0000 (16:23 -0400)

refs: support negative transfer.hideRefs

If you hide a hierarchy of refs using the transfer.hideRefs
config, there is no way to later override that config to
"unhide" it. This patch implements a "negative" hide which
causes matches to immediately be marked as unhidden, even if
another match would hide it. We take care to apply the
matches in reverse-order from how they are fed to us by the
config machinery, as that lets our usual "last one wins"
config precedence work (and entries in .git/config, for
example, will override /etc/gitconfig).

So you can now do:

$ git config --system transfer.hideRefs refs/secret
$ git config transfer.hideRefs '!refs/secret/not-so-secret'

to hide refs/secret in all repos, except for one public bit
in one specific repo. Or you can even do:

$ git clone \
-u "git -c transfer.hiderefs="!refs/foo" upload-pack" \
remote:repo.git

to clone remote:repo.git, overriding any hiding it has
configured.

There are two alternatives that were considered and
rejected:

1. A generic config mechanism for removing an item from a
list. E.g.: (e.g., "[transfer] hideRefs -= refs/foo").

This is nice because it could apply to other
multi-valued config, as well. But it is not nearly as
flexible. There is no way to say:

[transfer]
hideRefs = refs/secret
hideRefs = refs/secret/not-so-secret

Having explicit negative specifications means we can
override previous entries, even if they are not the
same literal string.

2. Adding another variable to override some parts of
hideRefs (e.g., "exposeRefs").

This solves the problem from alternative (1), but it
cannot easily obey the normal config precedence,
because it would use two separate lists. For example:

[transfer]
hideRefs = refs/secret
exposeRefs = refs/secret/not-so-secret
hideRefs = refs/secret/not-so-secret/no-really-its-secret

With two lists, we have to apply the "expose" rules
first, and only then apply the "hide" rules. But that
does not match what the above config intends.

Of course we could internally parse that to a single
list, respecting the ordering, which saves us having to
invent the new "!" syntax. But using a single name
communicates to the user that the ordering _is_
important. And "!" is well-known for negation, and
should not appear at the beginning of a ref (it is
actually valid in a ref-name, but all entries here
should be fully-qualified, starting with "refs/").

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

completion: offer '--edit-todo' during interactive... Thomas Braun Wed, 5 Aug 2015 13:40:00 +0000 (15:40 +0200)

completion: offer '--edit-todo' during interactive rebase

Helped-by: John Keeping <john@keeping.me.uk>
Helped-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Thomas Braun <thomas.braun@virtuell-zuhause.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

tests: fix cleanup after tests in t1509-root-worktreePatrick Steinhardt Wed, 5 Aug 2015 09:43:51 +0000 (11:43 +0200)

tests: fix cleanup after tests in t1509-root-worktree

During cleanup we do a simple 'rm /*' to remove leftover files
from previous tests. As 'rm' errors out when there is anything it
cannot delete and there are directories present at '/' it will
throw an error, causing the '&&' chain to fail.

Fix this by explicitly removing the files.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

tests: fix broken && chains in t1509-root-worktreePatrick Steinhardt Wed, 5 Aug 2015 09:43:50 +0000 (11:43 +0200)

tests: fix broken && chains in t1509-root-worktree

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Documentation/git-worktree: fix duplicated 'from'Patrick Steinhardt Tue, 4 Aug 2015 12:27:57 +0000 (14:27 +0200)

Documentation/git-worktree: fix duplicated 'from'

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Acked-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>