gitweb.git
Merge branch 'jk/system-path-cleanup'Junio C Hamano Tue, 19 Sep 2017 01:47:55 +0000 (10:47 +0900)

Merge branch 'jk/system-path-cleanup'

Code clean-up.

* jk/system-path-cleanup:
git_extract_argv0_path: do nothing without RUNTIME_PREFIX
system_path: move RUNTIME_PREFIX to a sub-function

Merge branch 'jh/hashmap-disable-counting'Junio C Hamano Tue, 19 Sep 2017 01:47:54 +0000 (10:47 +0900)

Merge branch 'jh/hashmap-disable-counting'

Our hashmap implementation in hashmap.[ch] is not thread-safe when
adding a new item needs to expand the hashtable by rehashing; add
an API to disable the automatic rehashing to work it around.

* jh/hashmap-disable-counting:
hashmap: add API to disable item counting when threaded

Merge branch 'bb/doc-eol-dirty'Junio C Hamano Tue, 19 Sep 2017 01:47:54 +0000 (10:47 +0900)

Merge branch 'bb/doc-eol-dirty'

Doc update.

* bb/doc-eol-dirty:
Documentation: mention that `eol` can change the dirty status of paths

Merge branch 'jt/packmigrate'Junio C Hamano Tue, 19 Sep 2017 01:47:53 +0000 (10:47 +0900)

Merge branch 'jt/packmigrate'

Remove unneeded file added by a topic already in 'master'.

* jt/packmigrate:
Remove inadvertently added outgoing/packfile.h

Merge branch 'jk/incore-lockfile-removal'Junio C Hamano Tue, 19 Sep 2017 01:47:53 +0000 (10:47 +0900)

Merge branch 'jk/incore-lockfile-removal'

The long-standing rule that an in-core lockfile instance, once it
is used, must not be freed, has been lifted and the lockfile and
tempfile APIs have been updated to reduce the chance of programming
errors.

* jk/incore-lockfile-removal:
stop leaking lock structs in some simple cases
ref_lock: stop leaking lock_files
lockfile: update lifetime requirements in documentation
tempfile: auto-allocate tempfiles on heap
tempfile: remove deactivated list entries
tempfile: use list.h for linked list
tempfile: release deactivated strbufs instead of resetting
tempfile: robustify cleanup handler
tempfile: factor out deactivation
tempfile: factor out activation
tempfile: replace die("BUG") with BUG()
tempfile: handle NULL tempfile pointers gracefully
tempfile: prefer is_tempfile_active to bare access
lockfile: do not rollback lock on failed close
tempfile: do not delete tempfile on failed close
always check return value of close_tempfile
verify_signed_buffer: prefer close_tempfile() to close()
setup_temporary_shallow: move tempfile struct into function
setup_temporary_shallow: avoid using inactive tempfile
write_index_as_tree: cleanup tempfile on error

Merge branch 'nd/prune-in-worktree'Junio C Hamano Tue, 19 Sep 2017 01:47:53 +0000 (10:47 +0900)

Merge branch 'nd/prune-in-worktree'

"git gc" and friends when multiple worktrees are used off of a
single repository did not consider the index and per-worktree refs
of other worktrees as the root for reachability traversal, making
objects that are in use only in other worktrees to be subject to
garbage collection.

* nd/prune-in-worktree:
refs.c: reindent get_submodule_ref_store()
refs.c: remove fallback-to-main-store code get_submodule_ref_store()
rev-list: expose and document --single-worktree
revision.c: --reflog add HEAD reflog from all worktrees
files-backend: make reflog iterator go through per-worktree reflog
revision.c: --all adds HEAD from all worktrees
refs: remove dead for_each_*_submodule()
refs.c: move for_each_remote_ref_submodule() to submodule.c
revision.c: use refs_for_each*() instead of for_each_*_submodule()
refs: add refs_head_ref()
refs: move submodule slash stripping code to get_submodule_ref_store
refs.c: refactor get_submodule_ref_store(), share common free block
revision.c: --indexed-objects add objects from all worktrees
revision.c: refactor add_index_objects_to_pending()
refs.c: use is_dir_sep() in resolve_gitlink_ref()
revision.h: new flag in struct rev_info wrt. worktree-related refs

Merge branch 'ma/split-symref-update-fix'Junio C Hamano Tue, 19 Sep 2017 01:47:53 +0000 (10:47 +0900)

Merge branch 'ma/split-symref-update-fix'

A leakfix.

* ma/split-symref-update-fix:
refs/files-backend: add `refname`, not "HEAD", to list
refs/files-backend: correct return value in lock_ref_for_update
refs/files-backend: fix memory leak in lock_ref_for_update
refs/files-backend: add longer-scoped copy of string to list

Merge branch 'mh/notes-cleanup'Junio C Hamano Tue, 19 Sep 2017 01:47:52 +0000 (10:47 +0900)

Merge branch 'mh/notes-cleanup'

Code clean-up.

* mh/notes-cleanup:
load_subtree(): check that `prefix_len` is in the expected range
load_subtree(): declare some variables to be `size_t`
hex_to_bytes(): simpler replacement for `get_oid_hex_segment()`
get_oid_hex_segment(): don't pad the rest of `oid`
load_subtree(): combine some common code
get_oid_hex_segment(): return 0 on success
load_subtree(): only consider blobs to be potential notes
load_subtree(): check earlier whether an internal node is a tree entry
load_subtree(): separate logic for internal vs. terminal entries
load_subtree(): fix incorrect comment
load_subtree(): reduce the scope of some local variables
load_subtree(): remove unnecessary conditional
notes: make GET_NIBBLE macro more robust

Merge branch 'mg/timestamp-t-fix'Junio C Hamano Tue, 19 Sep 2017 01:47:52 +0000 (10:47 +0900)

Merge branch 'mg/timestamp-t-fix'

A mismerge fix.

* mg/timestamp-t-fix:
name-rev: change ULONG_MAX to TIME_MAX

Merge branch 'ma/pkt-line-leakfix'Junio C Hamano Tue, 19 Sep 2017 01:47:52 +0000 (10:47 +0900)

Merge branch 'ma/pkt-line-leakfix'

A leakfix.

* ma/pkt-line-leakfix:
pkt-line: re-'static'-ify buffer in packet_write_fmt_1()

Merge branch 'jk/config-lockfile-leak-fix'Junio C Hamano Tue, 19 Sep 2017 01:47:51 +0000 (10:47 +0900)

Merge branch 'jk/config-lockfile-leak-fix'

A leakfix.

* jk/config-lockfile-leak-fix:
config: use a static lock_file struct

Merge branch 'dw/diff-highlight-makefile-fix'Junio C Hamano Tue, 19 Sep 2017 01:47:50 +0000 (10:47 +0900)

Merge branch 'dw/diff-highlight-makefile-fix'

Build clean-up.

* dw/diff-highlight-makefile-fix:
diff-highlight: add clean target to Makefile

Merge branch 'ti/external-sha1dc'Junio C Hamano Tue, 19 Sep 2017 01:47:50 +0000 (10:47 +0900)

Merge branch 'ti/external-sha1dc'

Platforms that ship with a separate sha1 with collision detection
library can link to it instead of using the copy we ship as part of
our source tree.

* ti/external-sha1dc:
sha1dc: allow building with the external sha1dc library
sha1dc: build git plumbing code more explicitly

Sync with maintJunio C Hamano Sun, 10 Sep 2017 08:15:43 +0000 (17:15 +0900)

Sync with maint

* maint:
RelNotes: further fixes for 2.14.2 from the master front

The seventh batch post 2.14Junio C Hamano Sun, 10 Sep 2017 08:15:09 +0000 (17:15 +0900)

The seventh batch post 2.14

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

Merge branch 'rs/apply-epoch'Junio C Hamano Sun, 10 Sep 2017 08:08:25 +0000 (17:08 +0900)

Merge branch 'rs/apply-epoch'

Code simplification.

* rs/apply-epoch:
apply: remove epoch date from regex
apply: check date of potential epoch timestamps first

Merge branch 'jk/drop-sha1-entry-pos'Junio C Hamano Sun, 10 Sep 2017 08:08:25 +0000 (17:08 +0900)

Merge branch 'jk/drop-sha1-entry-pos'

Code clean-up.

* jk/drop-sha1-entry-pos:
sha1-lookup: remove sha1_entry_pos() from header file

Merge branch 'nd/worktree-kill-parse-ref'Junio C Hamano Sun, 10 Sep 2017 08:08:23 +0000 (17:08 +0900)

Merge branch 'nd/worktree-kill-parse-ref'

"git branch -M a b" while on a branch that is completely unrelated
to either branch a or branch b misbehaved when multiple worktree
was in use. This has been fixed.

* nd/worktree-kill-parse-ref:
branch: fix branch renaming not updating HEADs correctly

Merge branch 'mm/send-email-cc-cruft'Junio C Hamano Sun, 10 Sep 2017 08:08:22 +0000 (17:08 +0900)

Merge branch 'mm/send-email-cc-cruft'

In addition to "cc: <a@dd.re.ss> # cruft", "cc: a@dd.re.ss # cruft"
was taught to "git send-email" as a valid way to tell it that it
needs to also send a carbon copy to <a@dd.re.ss> in the trailer
section.

* mm/send-email-cc-cruft:
send-email: don't use Mail::Address, even if available
send-email: fix garbage removal after address

Merge branch 'ls/convert-filter-progress'Junio C Hamano Sun, 10 Sep 2017 08:08:22 +0000 (17:08 +0900)

Merge branch 'ls/convert-filter-progress'

The codepath to call external process filter for smudge/clean
operation learned to show the progress meter.

* ls/convert-filter-progress:
convert: display progress for filtered objects that have been delayed

Merge branch 'ma/up-to-date'Junio C Hamano Sun, 10 Sep 2017 08:08:22 +0000 (17:08 +0900)

Merge branch 'ma/up-to-date'

Message and doc updates.

* ma/up-to-date:
treewide: correct several "up-to-date" to "up to date"
Documentation/user-manual: update outdated example output

Merge branch 'ma/ts-cleanups'Junio C Hamano Sun, 10 Sep 2017 08:08:22 +0000 (17:08 +0900)

Merge branch 'ma/ts-cleanups'

Assorted bugfixes and clean-ups.

* ma/ts-cleanups:
ThreadSanitizer: add suppressions
strbuf_setlen: don't write to strbuf_slopbuf
pack-objects: take lock before accessing `remaining`
convert: always initialize attr_action in convert_attrs

RelNotes: further fixes for 2.14.2 from the master... Junio C Hamano Sun, 10 Sep 2017 08:06:09 +0000 (17:06 +0900)

RelNotes: further fixes for 2.14.2 from the master front

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

Merge branch 'jt/doc-pack-objects-fix' into maintJunio C Hamano Sun, 10 Sep 2017 08:03:10 +0000 (17:03 +0900)

Merge branch 'jt/doc-pack-objects-fix' into maint

Doc updates.

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

Merge branch 'jn/vcs-svn-cleanup' into maintJunio C Hamano Sun, 10 Sep 2017 08:03:09 +0000 (17:03 +0900)

Merge branch 'jn/vcs-svn-cleanup' into maint

Code clean-up.

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

Merge branch 'bc/vcs-svn-cleanup' into maintJunio C Hamano Sun, 10 Sep 2017 08:03:08 +0000 (17:03 +0900)

Merge branch 'bc/vcs-svn-cleanup' into maint

Code clean-up.

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

Merge branch 'jk/doc-the-this' into maintJunio C Hamano Sun, 10 Sep 2017 08:03:07 +0000 (17:03 +0900)

Merge branch 'jk/doc-the-this' into maint

Doc clean-up.

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

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

Merge branch 'rs/commit-h-single-parent-cleanup' into maint

Code clean-up.

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

Merge branch 'mg/format-ref-doc-fix' into maintJunio C Hamano Sun, 10 Sep 2017 08:03:06 +0000 (17:03 +0900)

Merge branch 'mg/format-ref-doc-fix' into maint

Doc fix.

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

Merge branch 'sb/submodule-parallel-update' into maintJunio C Hamano Sun, 10 Sep 2017 08:03:06 +0000 (17:03 +0900)

Merge branch 'sb/submodule-parallel-update' into maint

Code clean-up.

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

Merge branch 'hv/t5526-andand-chain-fix' into maintJunio C Hamano Sun, 10 Sep 2017 08:03:05 +0000 (17:03 +0900)

Merge branch 'hv/t5526-andand-chain-fix' into maint

Test fix.

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

Merge branch 'sb/sha1-file-cleanup' into maintJunio C Hamano Sun, 10 Sep 2017 08:03:04 +0000 (17:03 +0900)

Merge branch 'sb/sha1-file-cleanup' into maint

Code clean-up.

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

Merge branch 'rs/t1002-do-not-use-sum' into maintJunio C Hamano Sun, 10 Sep 2017 08:03:04 +0000 (17:03 +0900)

Merge branch 'rs/t1002-do-not-use-sum' into maint

Test simplification.

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

Merge branch 'ah/doc-empty-string-is-false' into maintJunio C Hamano Sun, 10 Sep 2017 08:03:03 +0000 (17:03 +0900)

Merge branch 'ah/doc-empty-string-is-false' into maint

Doc update.

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

Merge branch 'rs/merge-microcleanup' into maintJunio C Hamano Sun, 10 Sep 2017 08:03:02 +0000 (17:03 +0900)

Merge branch 'rs/merge-microcleanup' into maint

Code clean-up.

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

Merge branch 'rs/find-pack-entry-bisection' into maintJunio C Hamano Sun, 10 Sep 2017 08:03:02 +0000 (17:03 +0900)

Merge branch 'rs/find-pack-entry-bisection' into maint

Code clean-up.

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

Merge branch 'rs/apply-lose-prefix-length' into maintJunio C Hamano Sun, 10 Sep 2017 08:03:01 +0000 (17:03 +0900)

Merge branch 'rs/apply-lose-prefix-length' into maint

Code clean-up.

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

Merge branch 'rj/add-chmod-error-message' into maintJunio C Hamano Sun, 10 Sep 2017 08:03:00 +0000 (17:03 +0900)

Merge branch 'rj/add-chmod-error-message' into maint

Message fix.

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

Merge branch 'jk/hashcmp-memcmp' into maintJunio C Hamano Sun, 10 Sep 2017 08:02:59 +0000 (17:02 +0900)

Merge branch 'jk/hashcmp-memcmp' into maint

Code clean-up.

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

Merge branch 'rs/t3700-clean-leftover' into maintJunio C Hamano Sun, 10 Sep 2017 08:02:58 +0000 (17:02 +0900)

Merge branch 'rs/t3700-clean-leftover' into maint

A test fix.

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

Merge branch 'jc/perl-git-comment-typofix' into maintJunio C Hamano Sun, 10 Sep 2017 08:02:57 +0000 (17:02 +0900)

Merge branch 'jc/perl-git-comment-typofix' into maint

A comment fix.

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

Merge branch 'mf/no-dashed-subcommands' into maintJunio C Hamano Sun, 10 Sep 2017 08:02:56 +0000 (17:02 +0900)

Merge branch 'mf/no-dashed-subcommands' into maint

Code clean-up.

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

Merge branch 'ab/ref-filter-no-contains' into maintJunio C Hamano Sun, 10 Sep 2017 08:02:56 +0000 (17:02 +0900)

Merge branch 'ab/ref-filter-no-contains' into maint

A test fix.

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

Merge branch 'rs/archive-excluded-directory' into maintJunio C Hamano Sun, 10 Sep 2017 08:02:55 +0000 (17:02 +0900)

Merge branch 'rs/archive-excluded-directory' into maint

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

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

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

Merge branch 'mg/killed-merge' into maintJunio C Hamano Sun, 10 Sep 2017 08:02:55 +0000 (17:02 +0900)

Merge branch 'mg/killed-merge' into maint

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

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

Merge branch 'tb/apply-with-crlf' into maintJunio C Hamano Sun, 10 Sep 2017 08:02:55 +0000 (17:02 +0900)

Merge branch 'tb/apply-with-crlf' into maint

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

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

Merge branch 'cc/subprocess-handshake-missing-capabilit... Junio C Hamano Sun, 10 Sep 2017 08:02:55 +0000 (17:02 +0900)

Merge branch 'cc/subprocess-handshake-missing-capabilities' into maint

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

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

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

Merge branch 'as/grep-quiet-no-match-exit-code-fix... Junio C Hamano Sun, 10 Sep 2017 08:02:55 +0000 (17:02 +0900)

Merge branch 'as/grep-quiet-no-match-exit-code-fix' into maint

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

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

Merge branch 'kd/stash-with-bash-4.4' into maintJunio C Hamano Sun, 10 Sep 2017 08:02:54 +0000 (17:02 +0900)

Merge branch 'kd/stash-with-bash-4.4' into maint

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

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

Merge branch 'rs/win32-syslog-leakfix' into maintJunio C Hamano Sun, 10 Sep 2017 08:02:54 +0000 (17:02 +0900)

Merge branch 'rs/win32-syslog-leakfix' into maint

Memory leak in an error codepath has been plugged.

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

Merge branch 'rs/unpack-entry-leakfix' into maintJunio C Hamano Sun, 10 Sep 2017 08:02:53 +0000 (17:02 +0900)

Merge branch 'rs/unpack-entry-leakfix' into maint

Memory leak in an error codepath has been plugged.

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

Merge branch 'rs/fsck-obj-leakfix' into maintJunio C Hamano Sun, 10 Sep 2017 08:02:52 +0000 (17:02 +0900)

Merge branch 'rs/fsck-obj-leakfix' into maint

Memory leak in an error codepath has been plugged.

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

Merge branch 'ur/svn-local-zone' into maintJunio C Hamano Sun, 10 Sep 2017 08:02:52 +0000 (17:02 +0900)

Merge branch 'ur/svn-local-zone' into maint

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

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

Merge branch 'pw/am-signoff' into maintJunio C Hamano Sun, 10 Sep 2017 08:02:51 +0000 (17:02 +0900)

Merge branch 'pw/am-signoff' into maint

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

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

Merge branch 'rs/in-obsd-basename-dirname-take-const... Junio C Hamano Sun, 10 Sep 2017 08:02:51 +0000 (17:02 +0900)

Merge branch 'rs/in-obsd-basename-dirname-take-const' into maint

Portability fix.

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

Merge branch 'rs/t4062-obsd' into maintJunio C Hamano Sun, 10 Sep 2017 08:02:51 +0000 (17:02 +0900)

Merge branch 'rs/t4062-obsd' into maint

Test portability fix.

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

Merge branch 'rs/obsd-getcwd-workaround' into maintJunio C Hamano Sun, 10 Sep 2017 08:02:50 +0000 (17:02 +0900)

Merge branch 'rs/obsd-getcwd-workaround' into maint

Test portability fix for BSDs.

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

Merge branch 'bw/clone-recursive-quiet' into maintJunio C Hamano Sun, 10 Sep 2017 08:02:49 +0000 (17:02 +0900)

Merge branch 'bw/clone-recursive-quiet' into maint

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

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

Merge branch 'pw/sequence-rerere-autoupdate' into maintJunio C Hamano Sun, 10 Sep 2017 08:02:49 +0000 (17:02 +0900)

Merge branch 'pw/sequence-rerere-autoupdate' into maint

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

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

Merge branch 'bw/push-options-recursively-to-submodules... Junio C Hamano Sun, 10 Sep 2017 08:02:49 +0000 (17:02 +0900)

Merge branch 'bw/push-options-recursively-to-submodules' into maint

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

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

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

Merge branch 'ma/pager-per-subcommand-action' into maint

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

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

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

Merge branch 'jk/rev-list-empty-input' into maintJunio C Hamano Sun, 10 Sep 2017 08:02:48 +0000 (17:02 +0900)

Merge branch 'jk/rev-list-empty-input' into maint

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

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

Merge branch 'st/lib-gpg-kill-stray-agent' into maintJunio C Hamano Sun, 10 Sep 2017 08:02:48 +0000 (17:02 +0900)

Merge branch 'st/lib-gpg-kill-stray-agent' into maint

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

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

refs/files-backend: add `refname`, not "HEAD", to listMartin Ågren Sat, 9 Sep 2017 06:57:18 +0000 (08:57 +0200)

refs/files-backend: add `refname`, not "HEAD", to list

An earlier patch rewrote `split_symref_update()` to add a copy of a
string to a string list instead of adding the original string. That was
so that the original string could be freed in a later patch, but it is
also conceptually cleaner, since now all calls to `string_list_insert()`
and `string_list_append()` add `update->refname`. --- Except a literal
"HEAD" is added in `split_head_update()`.

Restructure `split_head_update()` in the same way as the earlier patch
did for `split_symref_update()`. This does not correct any practical
problem, but makes things conceptually cleaner. The downside is a call
to `string_list_has_string()`, which should be relatively cheap.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

refs/files-backend: correct return value in lock_ref_fo... Martin Ågren Sat, 9 Sep 2017 06:57:17 +0000 (08:57 +0200)

refs/files-backend: correct return value in lock_ref_for_update

In one code path we return a literal -1 and not a symbolic constant. The
value -1 would be interpreted as TRANSACTION_NAME_CONFLICT, which is
wrong. Use TRANSACTION_GENERIC_ERROR instead (that is the only other
return value we have to choose from).

Noticed-by: Michael Haggerty <mhagger@alum.mit.edu>
Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

refs/files-backend: fix memory leak in lock_ref_for_updateMartin Ågren Sat, 9 Sep 2017 06:57:16 +0000 (08:57 +0200)

refs/files-backend: fix memory leak in lock_ref_for_update

After the previous patch, none of the functions we call hold on to
`referent.buf`, so we can safely release the string buffer before
returning.

Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

refs/files-backend: add longer-scoped copy of string... Martin Ågren Sat, 9 Sep 2017 06:57:15 +0000 (08:57 +0200)

refs/files-backend: add longer-scoped copy of string to list

split_symref_update() receives a string-pointer `referent` and adds it
to the list of `affected_refnames`. The list simply holds on to the
pointers it is given, it does not copy the strings and it does not ever
free them. The `referent` string in split_symref_update() belongs to a
string buffer in the caller. After we return, the string will be leaked.

In the next patch, we want to properly release the string buffer in the
caller, but we can't safely do so until we've made sure that
`affected_refnames` will not be holding on to a pointer to the string.
We could configure the list to handle its own resources, but it would
mean some alloc/free-churning. The list is already handling other
strings (through other code paths) which we do not need to worry about,
and we'd be memory-churning those strings too, completely unnecessary.

Observe that split_symref_update() creates a `new_update`-object through
ref_transaction_add_update(), after which `new_update->refname` is a
copy of `referent`. The difference is, this copy will be freed, and it
will be freed *after* `affected_refnames` has been cleared.

Rearrange the handling of `referent`, so that we don't add it directly
to `affected_refnames`. Instead, first just check whether `referent`
exists in the string list, and later add `new_update->refname`.

Helped-by: Michael Haggerty <mhagger@alum.mit.edu>
Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

load_subtree(): check that `prefix_len` is in the expec... Michael Haggerty Fri, 8 Sep 2017 16:10:10 +0000 (18:10 +0200)

load_subtree(): check that `prefix_len` is in the expected range

This value, which is stashed in the last byte of an object_id hash,
gets handed around a lot. So add a sanity check before using it in
`load_subtree()`.

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

hashmap: add API to disable item counting when threadedJeff Hostetler Wed, 6 Sep 2017 15:43:48 +0000 (15:43 +0000)

hashmap: add API to disable item counting when threaded

This is to address concerns raised by ThreadSanitizer on the mailing list
about threaded unprotected R/W access to map.size with my previous "disallow
rehash" change (0607e10009ee4e37cb49b4cec8d28a9dda1656a4).

See:
https://public-inbox.org/git/adb37b70139fd1e2bac18bfd22c8b96683ae18eb.1502780344.git.martin.agren@gmail.com/

Add API to hashmap to disable item counting and thus automatic rehashing.
Also include API to later re-enable them.

When item counting is disabled, the map.size field is invalid. So to
prevent accidents, the field has been renamed and an accessor function
hashmap_get_size() has been added. All direct references to this
field have been been updated. And the name of the field changed
to map.private_size to communicate this.

Here is the relevant output from ThreadSanitizer showing the problem:

WARNING: ThreadSanitizer: data race (pid=10554)
Read of size 4 at 0x00000082d488 by thread T2 (mutexes: write M16):
#0 hashmap_add hashmap.c:209
#1 hash_dir_entry_with_parent_and_prefix name-hash.c:302
#2 handle_range_dir name-hash.c:347
#3 handle_range_1 name-hash.c:415
#4 lazy_dir_thread_proc name-hash.c:471
#5 <null> <null>

Previous write of size 4 at 0x00000082d488 by thread T1 (mutexes: write M31):
#0 hashmap_add hashmap.c:209
#1 hash_dir_entry_with_parent_and_prefix name-hash.c:302
#2 handle_range_dir name-hash.c:347
#3 handle_range_1 name-hash.c:415
#4 handle_range_dir name-hash.c:380
#5 handle_range_1 name-hash.c:415
#6 lazy_dir_thread_proc name-hash.c:471
#7 <null> <null>

Martin gives instructions for running TSan on test t3008 in this post:
https://public-inbox.org/git/CAN0heSoJDL9pWELD6ciLTmWf-a=oyxe4EXXOmCKvsG5MSuzxsA@mail.gmail.com/

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git_extract_argv0_path: do nothing without RUNTIME_PREFIXJeff King Wed, 6 Sep 2017 12:32:10 +0000 (08:32 -0400)

git_extract_argv0_path: do nothing without RUNTIME_PREFIX

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

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

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

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

system_path: move RUNTIME_PREFIX to a sub-functionJeff King Wed, 6 Sep 2017 12:30:28 +0000 (08:30 -0400)

system_path: move RUNTIME_PREFIX to a sub-function

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

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

Documentation: mention that `eol` can change the dirty... Ben Boeckel Thu, 31 Aug 2017 13:19:36 +0000 (09:19 -0400)

Documentation: mention that `eol` can change the dirty status of paths

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

Signed-off-by: Ben Boeckel <mathstuf@gmail.com>
Reviewed-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

stop leaking lock structs in some simple casesJeff King Tue, 5 Sep 2017 12:15:21 +0000 (08:15 -0400)

stop leaking lock structs in some simple cases

Now that it's safe to declare a "struct lock_file" on the
stack, we can do so (and avoid an intentional leak). These
leaks were found by running t0000 and t0001 under valgrind
(though certainly other similar leaks exist and just don't
happen to be exercised by those tests).

Initializing the lock_file's inner tempfile with NULL is not
strictly necessary in these cases, but it's a good practice
to model. It means that if we were to call a function like
rollback_lock_file() on a lock that was never taken in the
first place, it becomes a quiet noop (rather than undefined
behavior).

Likewise, it's always safe to rollback_lock_file() on a file
that has already been committed or deleted, since that
operation is a noop on an inactive lockfile (and that's why
the case in config.c can drop the "if (lock)" check as we
move away from using a pointer).

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

ref_lock: stop leaking lock_filesJeff King Tue, 5 Sep 2017 12:15:15 +0000 (08:15 -0400)

ref_lock: stop leaking lock_files

Since the tempfile code recently relaxed the rule that
tempfile structs (and thus locks) need to hang around
forever, we no longer have to leak our lock_file structs.

In fact, we don't even need to heap-allocate them anymore,
since their lifetime can just match that of the surrounding
ref_lock (and if we forget to delete a lock, the effect is
the same as before: it will eventually go away at program
exit).

Note that there is a check in unlock_ref() to only rollback
a lock file if it has been allocated. We don't need that
check anymore; we zero the ref_lock (and thus the
lock_file), so at worst we pass a NULL pointer to
delete_tempfile(), which considers that a noop.

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

lockfile: update lifetime requirements in documentationJeff King Tue, 5 Sep 2017 12:15:12 +0000 (08:15 -0400)

lockfile: update lifetime requirements in documentation

Now that the tempfile system we rely on has loosened the
lifetime requirements for storage, we can adjust our
documentation to match.

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

tempfile: auto-allocate tempfiles on heapJeff King Tue, 5 Sep 2017 12:15:08 +0000 (08:15 -0400)

tempfile: auto-allocate tempfiles on heap

The previous commit taught the tempfile code to give up
ownership over tempfiles that have been renamed or deleted.
That makes it possible to use a stack variable like this:

struct tempfile t;

create_tempfile(&t, ...);
...
if (!err)
rename_tempfile(&t, ...);
else
delete_tempfile(&t);

But doing it this way has a high potential for creating
memory errors. The tempfile we pass to create_tempfile()
ends up on a global linked list, and it's not safe for it to
go out of scope until we've called one of those two
deactivation functions.

Imagine that we add an early return from the function that
forgets to call delete_tempfile(). With a static or heap
tempfile variable, the worst case is that the tempfile hangs
around until the program exits (and some functions like
setup_shallow_temporary rely on this intentionally, creating
a tempfile and then leaving it for later cleanup).

But with a stack variable as above, this is a serious memory
error: the variable goes out of scope and may be filled with
garbage by the time the tempfile code looks at it. Let's
see if we can make it harder to get this wrong.

Since many callers need to allocate arbitrary numbers of
tempfiles, we can't rely on static storage as a general
solution. So we need to turn to the heap. We could just ask
all callers to pass us a heap variable, but that puts the
burden on them to call free() at the right time.

Instead, let's have the tempfile code handle the heap
allocation _and_ the deallocation (when the tempfile is
deactivated and removed from the list).

This changes the return value of all of the creation
functions. For the cleanup functions (delete and rename),
we'll add one extra bit of safety: instead of taking a
tempfile pointer, we'll take a pointer-to-pointer and set it
to NULL after freeing the object. This makes it safe to
double-call functions like delete_tempfile(), as the second
call treats the NULL input as a noop. Several callsites
follow this pattern.

The resulting patch does have a fair bit of noise, as each
caller needs to be converted to handle:

1. Storing a pointer instead of the struct itself.

2. Passing the pointer instead of taking the struct
address.

3. Handling a "struct tempfile *" return instead of a file
descriptor.

We could play games to make this less noisy. For example, by
defining the tempfile like this:

struct tempfile {
struct heap_allocated_part_of_tempfile {
int fd;
...etc
} *actual_data;
}

Callers would continue to have a "struct tempfile", and it
would be "active" only when the inner pointer was non-NULL.
But that just makes things more awkward in the long run.
There aren't that many callers, so we can simply bite
the bullet and adjust all of them. And the compiler makes it
easy for us to find them all.

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

tempfile: remove deactivated list entriesJeff King Tue, 5 Sep 2017 12:15:04 +0000 (08:15 -0400)

tempfile: remove deactivated list entries

Once a "struct tempfile" is added to the global cleanup
list, it is never removed. This means that its storage must
remain valid for the lifetime of the program. For single-use
tempfiles and locks, this isn't a big deal: we just declare
the struct static. But for library code which may take
multiple simultaneous locks (like the ref code), they're
forced to allocate a struct on the heap and leak it.

This is mostly OK in practice. The size of the leak is
bounded by the number of refs, and most programs exit after
operating on a fixed number of refs (and allocate
simultaneous memory proportional to the number of ref
updates in the first place). But:

1. It isn't hard to imagine a real leak: a program which
runs for a long time taking a series of ref update
instructions and fulfilling them one by one. I don't
think we have such a program now, but it's certainly
plausible.

2. The leaked entries appear as false positives to
tools like valgrind.

Let's relax this rule by keeping only "active" tempfiles on
the list. We can do this easily by moving the list-add
operation from prepare_tempfile_object to activate_tempfile,
and adding a deletion in deactivate_tempfile.

Existing callers do not need to be updated immediately.
They'll continue to leak any tempfile objects they may have
allocated, but that's no different than the status quo. We
can clean them up individually.

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

tempfile: use list.h for linked listJeff King Tue, 5 Sep 2017 12:15:00 +0000 (08:15 -0400)

tempfile: use list.h for linked list

The tempfile API keeps to-be-cleaned tempfiles in a
singly-linked list and never removes items from the list. A
future patch would like to start removing items, but removal
from a singly linked list is O(n), as we have to walk the
list to find the predecessor element. This means that a
process which takes "n" simultaneous lockfiles (for example,
an atomic transaction on "n" refs) may end up quadratic in
"n".

Before we start allowing items to be removed, it would be
nice to have a way to cover this case in linear time.

The simplest solution is to make an assumption about the
order in which tempfiles are added and removed from the
list. If both operations iterate over the tempfiles in the
same order, then by putting new items at the end of the list
our removal search will always find its items at the
beginning of the list. And indeed, that would work for the
case of refs. But it creates a hidden dependency between
unrelated parts of the code. If anybody changes the ref code
(or if we add a new caller that opens multiple simultaneous
tempfiles) they may unknowingly introduce a performance
regression.

Another solution is to use a better data structure. A
doubly-linked list works fine, and we already have an
implementation in list.h. But there's one snag: the elements
of "struct tempfile" are all marked as "volatile", since a
signal handler may interrupt us and iterate over the list at
any moment (even if we were in the middle of adding a new
entry).

We can declare a "volatile struct list_head", but we can't
actually use it with the normal list functions. The compiler
complains about passing a pointer-to-volatile via a regular
pointer argument. And rightfully so, as the sub-function
would potentially need different code to deal with the
volatile case.

That leaves us with a few options:

1. Drop the "volatile" modifier for the list items.

This is probably a bad idea. I checked the assembly
output from "gcc -O2", and the "volatile" really does
impact the order in which it updates memory.

2. Use macros instead of inline functions. The irony here
is that list.h is entirely implemented as trivial
inline functions. So we basically are already
generating custom code for each call. But sadly there's no
way in C to declare the inline function to take a more
generic type.

We could do so by switching the inline functions to
macros, but it does make the end result harder to read.
And it doesn't fully solve the problem (for instance,
the declaration of list_head needs to change so that
its "prev" and "next" pointers point to other volatile
structs).

3. Don't use list.h, and just make our own ad-hoc
doubly-linked list. It's not that much code to
implement the basics that we need here. But if we're
going to do so, why not add the few extra lines
required to model it after the actual list.h interface?
We can even reuse a few of the macro helpers.

So this patch takes option 3, but actually implements a
parallel "volatile list" interface in list.h, where it could
potentially be reused by other code. This implements just
enough for tempfile.c's use, though we could easily port
other functions later if need be.

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

tempfile: release deactivated strbufs instead of resettingJeff King Tue, 5 Sep 2017 12:14:56 +0000 (08:14 -0400)

tempfile: release deactivated strbufs instead of resetting

When a tempfile is deactivated, we reset its strbuf to the
empty string, which means we hold onto the memory for later
reuse.

Since we'd like to move to a system where tempfile structs
can actually be freed, deactivating one should drop all
resources it is currently using. And thus "release" rather
than "reset" is the appropriate function to call.

In theory the reset may have saved a malloc() when a
tempfile (or a lockfile) is reused multiple times. But in
practice this happened rarely. Most of our tempfiles are
single-use, since in cases where we might actually use many
(like ref locking) we xcalloc() a fresh one for each ref. In
fact, we leak those locks (to appease the rule that tempfile
storage can never be freed). Which means that using reset is
actively hurting us: instead of leaking just the tempfile
struct, we're leaking the extra heap chunk for the filename,
too.

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

tempfile: robustify cleanup handlerJeff King Tue, 5 Sep 2017 12:14:53 +0000 (08:14 -0400)

tempfile: robustify cleanup handler

We may call remove_tempfiles() from an atexit handler, or
from a signal handler. In the latter case we must take care
to avoid functions which may deadlock if the process is in
an unknown state, including looking at any stdio handles
(which may be in the middle of doing I/O and locked) or
calling malloc() or free().

The current implementation calls delete_tempfile(). We unset
the tempfile's stdio handle (if any) to avoid deadlocking
there. But delete_tempfile() still calls unlink_or_warn(),
which can deadlock writing to stderr if the unlink fails.

Since delete_tempfile() isn't very long, let's just
open-code our own simple conservative version of the same
thing. Notably:

1. The "skip_fclose" flag is now called "in_signal_handler",
because it should inform more decisions than just the
fclose handling.

2. We can replace close_tempfile() with just close(fd).
That skips the fclose() question altogether. This is
fine for the atexit() case, too; there's no point
flushing data to a file which we're about to delete
anyway.

3. We can choose between unlink/unlink_or_warn based on
whether it's safe to use stderr.

4. We can replace the deactivate_tempfile() call with a
simple setting of the active flag. There's no need to
do any further cleanup since we know the program is
exiting. And even though the current deactivation code
is safe in a signal handler, this frees us up in future
patches to make non-signal deactivation more
complicated (e.g., by freeing resources).

5. There's no need to remove items from the tempfile_list.
The "active" flag is the ultimate answer to whether an
entry has been handled or not. Manipulating the list
just introduces more chance of recursive signals
stomping on each other, and the whole list will go away
when the program exits anyway. Less is more.

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

tempfile: factor out deactivationJeff King Tue, 5 Sep 2017 12:14:50 +0000 (08:14 -0400)

tempfile: factor out deactivation

When we deactivate a tempfile, we also have to clean up the
"filename" strbuf. Let's pull this out into its own function
to keep the logic in one place (which will become more
important when a future patch makes it more complicated).

Note that we can use the same function when deactivating an
object that _isn't_ actually active yet (like when we hit an
error creating a tempfile). These callsites don't currently
reset the "active" flag to 0, but it's OK to do so (it's
just a noop for these cases).

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

tempfile: factor out activationJeff King Tue, 5 Sep 2017 12:14:47 +0000 (08:14 -0400)

tempfile: factor out activation

There are a few steps required to "activate" a tempfile
struct. Let's pull these out into a function. That saves a
few repeated lines now, but more importantly will make it
easier to change the activation scheme later.

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

tempfile: replace die("BUG") with BUG()Jeff King Tue, 5 Sep 2017 12:14:43 +0000 (08:14 -0400)

tempfile: replace die("BUG") with BUG()

Compared to die(), using BUG() triggers abort(). That may
give us an actual coredump, which should make it easier to
get a stack trace. And since the programming error for these
assertions is not in the functions themselves but in their
callers, such a stack trace is needed to actually find the
source of the bug.

In addition, abort() raises SIGABRT, which is more likely to
be caught by our test suite.

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

tempfile: handle NULL tempfile pointers gracefullyJeff King Tue, 5 Sep 2017 12:14:40 +0000 (08:14 -0400)

tempfile: handle NULL tempfile pointers gracefully

The tempfile functions all take pointers to tempfile
objects, but do not check whether the argument is NULL.
This isn't a big deal in practice, since the lifetime of any
tempfile object is defined to last for the whole program. So
even if we try to call delete_tempfile() on an
already-deleted tempfile, our "active" check will tell us
that it's a noop.

In preparation for transitioning to a new system that
loosens the "tempfile objects can never be freed" rule,
let's tighten up our active checks:

1. A NULL pointer is now defined as "inactive" (so it will
BUG for most functions, but works as a silent noop for
things like delete_tempfile).

2. Functions should always do the "active" check before
looking at any of the struct fields.

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

tempfile: prefer is_tempfile_active to bare accessJeff King Tue, 5 Sep 2017 12:14:36 +0000 (08:14 -0400)

tempfile: prefer is_tempfile_active to bare access

The tempfile code keeps an "active" flag, and we have a
number of assertions to make sure that the objects are being
used in the right order. Most of these directly check
"active" rather than using the is_tempfile_active()
accessor.

Let's prefer using the accessor, in preparation for it
growing more complicated logic (like checking for NULL).

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

lockfile: do not rollback lock on failed closeJeff King Tue, 5 Sep 2017 12:14:33 +0000 (08:14 -0400)

lockfile: do not rollback lock on failed close

Since the lockfile code is based on the tempfile code, it
has some of the same problems, including that close_lock_file()
erases the tempfile's filename buf, making it hard for the
caller to write a good error message.

In practice this comes up less for lockfiles than for
straight tempfiles, since we usually just report the
refname. But there is at least one buggy case in
write_ref_to_lockfile(). Besides, given the coupling between
the lockfile and tempfile modules, it's less confusing if
their close() functions have the same semantics.

Just as the previous commit did for close_tempfile(), let's
teach close_lock_file() and its wrapper close_ref() not to
rollback on error. And just as before, we'll give them new
"gently" names to catch any new callers that are added.

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

tempfile: do not delete tempfile on failed closeJeff King Tue, 5 Sep 2017 12:14:30 +0000 (08:14 -0400)

tempfile: do not delete tempfile on failed close

When close_tempfile() fails, we delete the tempfile and
reset the fields of the tempfile struct. This makes it
easier for callers to return without cleaning up, but it
also makes this common pattern:

if (close_tempfile(tempfile))
return error_errno("error closing %s", tempfile->filename.buf);

wrong, because the "filename" field has been reset after the
failed close. And it's not easy to fix, as in many cases we
don't have another copy of the filename (e.g., if it was
created via one of the mks_tempfile functions, and we just
have the original template string).

Let's drop the feature that a failed close automatically
deletes the file. This puts the burden on the caller to do
the deletion themselves, but this isn't that big a deal.
Callers which do:

if (write(...) || close_tempfile(...)) {
delete_tempfile(...);
return -1;
}

already had to call delete when the write() failed, and so
aren't affected. Likewise, any caller which just calls die()
in the error path is OK; we'll delete the tempfile during
the atexit handler.

Because this patch changes the semantics of close_tempfile()
without changing its signature, all callers need to be
manually checked and converted to the new scheme. This patch
covers all in-tree callers, but there may be others for
not-yet-merged topics. To catch these, we rename the
function to close_tempfile_gently(), which will attract
compile-time attention to new callers. (Technically the
original could be considered "gentle" already in that it
didn't die() on errors, but this one is even more so).

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

always check return value of close_tempfileJeff King Tue, 5 Sep 2017 12:14:26 +0000 (08:14 -0400)

always check return value of close_tempfile

If close_tempfile() encounters an error, then it deletes the
tempfile and resets the "struct tempfile". But many code
paths ignore the return value and continue to use the
tempfile. Instead, we should generally treat this the same
as a write() error.

Note that in the postimage of some of these cases our error
message will be bogus after a failed close because we look
at tempfile->filename (either directly or via get_tempfile_path).
But after the failed close resets the tempfile object, this
is guaranteed to be the empty string. That will be addressed
in a future patch (because there are many more cases of the
same problem than just these instances).

Note also in the hunk in gpg-interface.c that it's fine to
call delete_tempfile() in the error path, even if
close_tempfile() failed and already deleted the file. The
tempfile code is smart enough to know the second deletion is
a noop.

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

verify_signed_buffer: prefer close_tempfile() to close()Jeff King Tue, 5 Sep 2017 12:14:23 +0000 (08:14 -0400)

verify_signed_buffer: prefer close_tempfile() to close()

We do a manual close() on the descriptor provided to us by
mks_tempfile. But this runs contrary to the advice in
tempfile.h, which notes that you should always use
close_tempfile(). Otherwise the descriptor may be reused
without the tempfile object knowing it, and the later call
to delete_tempfile() could close a random descriptor.

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

setup_temporary_shallow: move tempfile struct into... Jeff King Tue, 5 Sep 2017 12:14:19 +0000 (08:14 -0400)

setup_temporary_shallow: move tempfile struct into function

The setup_temporary_shallow() function creates a temporary
file, but we never access the tempfile struct outside of the
function. This is OK, since it means we'll just clean up the
tempfile on exit. But we can simplify the code a bit by
moving the global tempfile struct to the only function in
which it's used.

Note that it must remain "static" due to tempfile.c's
requirement that tempfile storage never goes away until
program exit.

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

setup_temporary_shallow: avoid using inactive tempfileJeff King Tue, 5 Sep 2017 12:14:16 +0000 (08:14 -0400)

setup_temporary_shallow: avoid using inactive tempfile

When there are no shallow entries to write, we skip creating
the tempfile entirely and try to return the empty string.

But we do so by calling get_tempfile_path() on the inactive
tempfile object. This will trigger an assertion that kills
the program. The bug was introduced by 6e122b449b
(setup_temporary_shallow(): use tempfile module,
2015-08-10). But nobody seems to have noticed since then
because we do not end up calling this function at all when
there are no shallow items. In other words, this code path
is completely unexercised.

Since the tempfile object is a static global, it _is_
possible that we call the function twice, writing out
shallow info the first time and then "reusing" our tempfile
object the second time. But:

1. It seems unlikely that this was the intent, as hitting
this code path would imply somebody clearing the
shallow_info list between calls.

And if somebody _did_ call the function multiple times
without clearing the shallow_info list, we'd hit a
different BUG for trying to reuse an already-active
tempfile.

2. I verified by code inspection that the function is only
called once per program. And also replacing this code
with a BUG() and running the test suite demonstrates
that it is not triggered there.

So we could probably just replace this with an assertion and
confirm that it's never called. However, the original intent
does seem to be that you _could_ call it when the
shallow_info is empty. And that's easy enough to do; since
the return value doesn't need to point to a writable buffer,
we can just return a string literal.

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

write_index_as_tree: cleanup tempfile on errorJeff King Tue, 5 Sep 2017 12:14:07 +0000 (08:14 -0400)

write_index_as_tree: cleanup tempfile on error

If we failed to write our new index file, we rollback our
lockfile to remove the temporary index. But if we fail
before we even get to the write step (because reading the
old index failed), we leave the lockfile in place, which
makes no sense.

In practice this hasn't been a big deal because failing at
write_index_as_tree() typically results in the whole program
exiting (and thus the tempfile handler kicking in and
cleaning up the files). But this function should
consistently take responsibility for the resources it
allocates.

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

The sixth batch post 2.14Junio C Hamano Wed, 6 Sep 2017 04:15:24 +0000 (13:15 +0900)

The sixth batch post 2.14

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

Merge branch 'rs/archive-excluded-directory'Junio C Hamano Wed, 6 Sep 2017 04:11:25 +0000 (13:11 +0900)

Merge branch 'rs/archive-excluded-directory'

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

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

Merge branch 'po/read-graft-line'Junio C Hamano Wed, 6 Sep 2017 04:11:25 +0000 (13:11 +0900)

Merge branch 'po/read-graft-line'

Conversion from uchar[20] to struct object_id continues; this is to
ensure that we do not assume sizeof(struct object_id) is the same
as the length of SHA-1 hash (or length of longest hash we support).

* po/read-graft-line:
commit: rewrite read_graft_line
commit: allocate array using object_id size
commit: replace the raw buffer with strbuf in read_graft_line
sha1_file: fix definition of null_sha1

Merge branch 'ks/branch-set-upstream'Junio C Hamano Wed, 6 Sep 2017 04:11:24 +0000 (13:11 +0900)

Merge branch 'ks/branch-set-upstream'

"branch --set-upstream" that has been deprecated in Git 1.8 has
finally been retired.

* ks/branch-set-upstream:
branch: quote branch/ref names to improve readability
builtin/branch: stop supporting the "--set-upstream" option
t3200: cleanup cruft of a test

pkt-line: re-'static'-ify buffer in packet_write_fmt_1()Martin Ågren Sun, 27 Aug 2017 07:37:32 +0000 (09:37 +0200)

pkt-line: re-'static'-ify buffer in packet_write_fmt_1()

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

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

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

config: use a static lock_file structJeff King Tue, 29 Aug 2017 18:58:50 +0000 (14:58 -0400)

config: use a static lock_file struct

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

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

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

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

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

Remove inadvertently added outgoing/packfile.hJonathan Tan Tue, 29 Aug 2017 01:12:41 +0000 (18:12 -0700)

Remove inadvertently added outgoing/packfile.h

This empty file was inadvertently introduced in commit 4f39cd8 ("pack:
move pack name-related functions", 2017-08-23). Remove this file.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

diff-highlight: add clean target to MakefileDaniel Watkins Tue, 29 Aug 2017 11:23:11 +0000 (12:23 +0100)

diff-highlight: add clean target to Makefile

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

Signed-off-by: Daniel Watkins <daniel@daniel-watkins.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>