git
6 years agoMerge branch 'bc/hash-algo'
Junio C Hamano [Thu, 15 Feb 2018 22:55:47 +0000 (14:55 -0800)] 
Merge branch 'bc/hash-algo'

More abstraction of hash function from the codepath.

* bc/hash-algo:
  hash: update obsolete reference to SHA1_HEADER
  bulk-checkin: abstract SHA-1 usage
  csum-file: abstract uses of SHA-1
  csum-file: rename sha1file to hashfile
  read-cache: abstract away uses of SHA-1
  pack-write: switch various SHA-1 values to abstract forms
  pack-check: convert various uses of SHA-1 to abstract forms
  fast-import: switch various uses of SHA-1 to the_hash_algo
  sha1_file: switch uses of SHA-1 to the_hash_algo
  builtin/unpack-objects: switch uses of SHA-1 to the_hash_algo
  builtin/index-pack: improve hash function abstraction
  hash: create union for hash context allocation
  hash: move SHA-1 macros to hash.h

6 years agoMerge branch 'nd/ignore-glob-doc-update'
Junio C Hamano [Thu, 15 Feb 2018 22:55:46 +0000 (14:55 -0800)] 
Merge branch 'nd/ignore-glob-doc-update'

Doc update.

* nd/ignore-glob-doc-update:
  gitignore.txt: elaborate shell glob syntax

6 years agoMerge branch 'tg/reset-hard-show-head-with-pretty'
Junio C Hamano [Thu, 15 Feb 2018 22:55:45 +0000 (14:55 -0800)] 
Merge branch 'tg/reset-hard-show-head-with-pretty'

The way "git reset --hard" reports the commit the updated HEAD
points at is made consistent with the way how the commit title is
generated by the other parts of the system.  This matters when the
title is spread across physically multiple lines.

* tg/reset-hard-show-head-with-pretty:
  reset --hard: make use of the pretty machinery

6 years agoMerge branch 'rs/cocci-strbuf-addf-to-addstr'
Junio C Hamano [Thu, 15 Feb 2018 22:55:44 +0000 (14:55 -0800)] 
Merge branch 'rs/cocci-strbuf-addf-to-addstr'

* rs/cocci-strbuf-addf-to-addstr:
  cocci: simplify check for trivial format strings

6 years agoMerge branch 'nd/trace-index-ops'
Junio C Hamano [Thu, 15 Feb 2018 22:55:44 +0000 (14:55 -0800)] 
Merge branch 'nd/trace-index-ops'

* nd/trace-index-ops:
  trace: measure where the time is spent in the index-heavy operations

6 years agoMerge branch 'cc/perf-aggregate'
Junio C Hamano [Thu, 15 Feb 2018 22:55:44 +0000 (14:55 -0800)] 
Merge branch 'cc/perf-aggregate'

"make perf" enhancement.

* cc/perf-aggregate:
  perf/aggregate: sort JSON fields in output
  perf/aggregate: add --reponame option
  perf/aggregate: add --subsection option

6 years agoMerge branch 'ab/wildmatch-tests'
Junio C Hamano [Thu, 15 Feb 2018 22:55:44 +0000 (14:55 -0800)] 
Merge branch 'ab/wildmatch-tests'

More tests for wildmatch functions.

* ab/wildmatch-tests:
  wildmatch test: mark test as EXPENSIVE_ON_WINDOWS
  test-lib: add an EXPENSIVE_ON_WINDOWS prerequisite
  wildmatch test: create & test files on disk in addition to in-memory
  wildmatch test: perform all tests under all wildmatch() modes
  wildmatch test: use test_must_fail, not ! for test-wildmatch
  wildmatch test: remove dead fnmatch() test code
  wildmatch test: use a paranoia pattern from nul_match()
  wildmatch test: don't try to vertically align our output
  wildmatch test: use more standard shell style
  wildmatch test: indent with tabs, not spaces

6 years agoMerge branch 'po/object-id'
Junio C Hamano [Thu, 15 Feb 2018 22:55:43 +0000 (14:55 -0800)] 
Merge branch 'po/object-id'

Conversion from uchar[20] to struct object_id continues.

* po/object-id:
  sha1_file: rename hash_sha1_file_literally
  sha1_file: convert write_loose_object to object_id
  sha1_file: convert force_object_loose to object_id
  sha1_file: convert write_sha1_file to object_id
  notes: convert write_notes_tree to object_id
  notes: convert combine_notes_* to object_id
  commit: convert commit_tree* to object_id
  match-trees: convert splice_tree to object_id
  cache: clear whole hash buffer with oidclr
  sha1_file: convert hash_sha1_file to object_id
  dir: convert struct sha1_stat to use object_id
  sha1_file: convert pretend_sha1_file to object_id

6 years agoMerge branch 'sb/pull-rebase-submodule'
Junio C Hamano [Thu, 15 Feb 2018 22:55:43 +0000 (14:55 -0800)] 
Merge branch 'sb/pull-rebase-submodule'

"git pull --rebase" did not pass verbosity setting down when
recursing into a submodule.

* sb/pull-rebase-submodule:
  builtin/pull: respect verbosity settings in submodules

6 years agoMerge branch 'kg/packed-ref-cache-fix'
Junio C Hamano [Thu, 15 Feb 2018 22:55:42 +0000 (14:55 -0800)] 
Merge branch 'kg/packed-ref-cache-fix'

Avoid mmapping small files while using packed refs (especially ones
with zero size, which would cause later munmap() to fail).

* kg/packed-ref-cache-fix:
  packed_ref_cache: don't use mmap() for small files
  load_contents(): don't try to mmap an empty file
  packed_ref_iterator_begin(): make optimization more general
  find_reference_location(): make function safe for empty snapshots
  create_snapshot(): use `xmemdupz()` rather than a strbuf
  struct snapshot: store `start` rather than `header_len`

6 years agoMerge branch 'jt/fsck-code-cleanup'
Junio C Hamano [Thu, 15 Feb 2018 22:55:41 +0000 (14:55 -0800)] 
Merge branch 'jt/fsck-code-cleanup'

Plug recently introduced leaks in fsck.

* jt/fsck-code-cleanup:
  fsck: fix leak when traversing trees

6 years agoMerge branch 'en/merge-recursive-fixes'
Junio C Hamano [Thu, 15 Feb 2018 22:55:40 +0000 (14:55 -0800)] 
Merge branch 'en/merge-recursive-fixes'

* en/merge-recursive-fixes:
  merge-recursive: add explanation for src_entry and dst_entry
  merge-recursive: fix logic ordering issue
  Tighten and correct a few testcases for merging and cherry-picking

6 years agoMerge branch 'jc/worktree-add-short-help'
Junio C Hamano [Thu, 15 Feb 2018 22:55:40 +0000 (14:55 -0800)] 
Merge branch 'jc/worktree-add-short-help'

Error message fix.

* jc/worktree-add-short-help:
  worktree: say that "add" takes an arbitrary commit in short-help

6 years agoMerge branch 'ab/sha1dc-build'
Junio C Hamano [Thu, 15 Feb 2018 22:55:40 +0000 (14:55 -0800)] 
Merge branch 'ab/sha1dc-build'

Push the submodule version of collision-detecting SHA-1 hash
implementation a bit harder on builders.

* ab/sha1dc-build:
  sha1dc_git.h: re-arrange an ifdef chain for a subsequent change
  Makefile: under "make dist", include the sha1collisiondetection submodule
  Makefile: don't error out under DC_SHA1_EXTERNAL if DC_SHA1_SUBMODULE=auto

6 years agoSecond batch for 2.17
Junio C Hamano [Wed, 14 Feb 2018 00:22:16 +0000 (16:22 -0800)] 
Second batch for 2.17

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge branch 'tz/doc-show-defaults-to-head'
Junio C Hamano [Tue, 13 Feb 2018 21:39:17 +0000 (13:39 -0800)] 
Merge branch 'tz/doc-show-defaults-to-head'

Doc update.

* tz/doc-show-defaults-to-head:
  doc: mention 'git show' defaults to HEAD

6 years agoMerge branch 'ew/svn-branch-segfault-fix'
Junio C Hamano [Tue, 13 Feb 2018 21:39:16 +0000 (13:39 -0800)] 
Merge branch 'ew/svn-branch-segfault-fix'

Workaround for segfault with more recent versions of SVN.

* ew/svn-branch-segfault-fix:
  git-svn: control destruction order to avoid segfault

6 years agoMerge branch 'sg/travis-linux32-sanity'
Junio C Hamano [Tue, 13 Feb 2018 21:39:16 +0000 (13:39 -0800)] 
Merge branch 'sg/travis-linux32-sanity'

Travis updates.

* sg/travis-linux32-sanity:
  travis-ci: don't fail if user already exists on 32 bit Linux build job
  travis-ci: don't run the test suite as root in the 32 bit Linux build
  travis-ci: don't repeat the path of the cache directory
  travis-ci: use 'set -e' in the 32 bit Linux build job
  travis-ci: use 'set -x' for the commands under 'su' in the 32 bit Linux build

6 years agoMerge branch 'nd/list-merge-strategy'
Junio C Hamano [Tue, 13 Feb 2018 21:39:15 +0000 (13:39 -0800)] 
Merge branch 'nd/list-merge-strategy'

Completion of "git merge -s<strategy>" (in contrib/) did not work
well in non-C locale.

* nd/list-merge-strategy:
  completion: fix completing merge strategies on non-C locales

6 years agoMerge branch 'jt/long-running-process-doc'
Junio C Hamano [Tue, 13 Feb 2018 21:39:15 +0000 (13:39 -0800)] 
Merge branch 'jt/long-running-process-doc'

Doc updates.

* jt/long-running-process-doc:
  Docs: split out long-running subprocess handshake

6 years agoMerge branch 'jk/daemon-fixes'
Junio C Hamano [Tue, 13 Feb 2018 21:39:15 +0000 (13:39 -0800)] 
Merge branch 'jk/daemon-fixes'

Assorted fixes to "git daemon".

* jk/daemon-fixes:
  daemon: fix length computation in newline stripping
  t/lib-git-daemon: add network-protocol helpers
  daemon: handle NULs in extended attribute string
  daemon: fix off-by-one in logging extended attributes
  t/lib-git-daemon: record daemon log
  t5570: use ls-remote instead of clone for interp tests

6 years agoMerge branch 'pw/sequencer-in-process-commit'
Junio C Hamano [Tue, 13 Feb 2018 21:39:15 +0000 (13:39 -0800)] 
Merge branch 'pw/sequencer-in-process-commit'

The sequencer infrastructure is shared across "git cherry-pick",
"git rebase -i", etc., and has always spawned "git commit" when it
needs to create a commit.  It has been taught to do so internally,
when able, by reusing the codepath "git commit" itself uses, which
gives performance boost for a few tens of percents in some sample
scenarios.

* pw/sequencer-in-process-commit:
  sequencer: run 'prepare-commit-msg' hook
  t7505: add tests for cherry-pick and rebase -i/-p
  t7505: style fixes
  sequencer: assign only free()able strings to gpg_sign
  sequencer: improve config handling
  t3512/t3513: remove KNOWN_FAILURE_CHERRY_PICK_SEES_EMPTY_COMMIT=1
  sequencer: try to commit without forking 'git commit'
  sequencer: load commit related config
  sequencer: simplify adding Signed-off-by: trailer
  commit: move print_commit_summary() to libgit
  commit: move post-rewrite code to libgit
  Add a function to update HEAD after creating a commit
  commit: move empty message checks to libgit
  t3404: check intermediate squash messages

6 years agoMerge branch 'nd/shared-index-fix'
Junio C Hamano [Tue, 13 Feb 2018 21:39:14 +0000 (13:39 -0800)] 
Merge branch 'nd/shared-index-fix'

Code clean-up.

* nd/shared-index-fix:
  read-cache: don't write index twice if we can't write shared index
  read-cache.c: move tempfile creation/cleanup out of write_shared_index
  read-cache.c: change type of "temp" in write_shared_index()

6 years agoMerge branch 'po/http-push-error-message'
Junio C Hamano [Tue, 13 Feb 2018 21:39:14 +0000 (13:39 -0800)] 
Merge branch 'po/http-push-error-message'

Debugging aid.

* po/http-push-error-message:
  http-push: improve error log

6 years agoMerge branch 'po/clang-format-functype-weight'
Junio C Hamano [Tue, 13 Feb 2018 21:39:14 +0000 (13:39 -0800)] 
Merge branch 'po/clang-format-functype-weight'

Prevent "clang-format" from breaking line after function return type.

* po/clang-format-functype-weight:
  clang-format: adjust penalty for return type line break

6 years agoMerge branch 'jc/mailinfo-cleanup-fix'
Junio C Hamano [Tue, 13 Feb 2018 21:39:14 +0000 (13:39 -0800)] 
Merge branch 'jc/mailinfo-cleanup-fix'

Corner case bugfix.

* jc/mailinfo-cleanup-fix:
  mailinfo: avoid segfault when can't open files

6 years agoMerge branch 'sg/cocci-move-array'
Junio C Hamano [Tue, 13 Feb 2018 21:39:13 +0000 (13:39 -0800)] 
Merge branch 'sg/cocci-move-array'

Code clean-up.

* sg/cocci-move-array:
  Use MOVE_ARRAY

6 years agoMerge branch 'tg/split-index-fixes'
Junio C Hamano [Tue, 13 Feb 2018 21:39:12 +0000 (13:39 -0800)] 
Merge branch 'tg/split-index-fixes'

The split-index mode had a few corner case bugs fixed.

* tg/split-index-fixes:
  travis: run tests with GIT_TEST_SPLIT_INDEX
  split-index: don't write cache tree with null oid entries
  read-cache: fix reading the shared index for other repos

6 years agoMerge branch 'rs/strbuf-cocci-workaround'
Junio C Hamano [Tue, 13 Feb 2018 21:39:12 +0000 (13:39 -0800)] 
Merge branch 'rs/strbuf-cocci-workaround'

Update Coccinelle rules to catch and optimize strbuf_addf(&buf, "%s", str)

* rs/strbuf-cocci-workaround:
  cocci: use format keyword instead of a literal string

6 years agoMerge branch 'mr/packed-ref-store-fix'
Junio C Hamano [Tue, 13 Feb 2018 21:39:11 +0000 (13:39 -0800)] 
Merge branch 'mr/packed-ref-store-fix'

Crash fix for a corner case where an error codepath tried to unlock
what it did not acquire lock on.

* mr/packed-ref-store-fix:
  files_initial_transaction_commit(): only unlock if locked

6 years agoMerge branch 'jt/http-redact-cookies'
Junio C Hamano [Tue, 13 Feb 2018 21:39:11 +0000 (13:39 -0800)] 
Merge branch 'jt/http-redact-cookies'

The http tracing code, often used to debug connection issues,
learned to redact potentially sensitive information from its output
so that it can be more safely sharable.

* jt/http-redact-cookies:
  http: support omitting data from traces
  http: support cookie redaction when tracing

6 years agoMerge branch 'ds/use-get-be64'
Junio C Hamano [Tue, 13 Feb 2018 21:39:11 +0000 (13:39 -0800)] 
Merge branch 'ds/use-get-be64'

Code clean-up.

* ds/use-get-be64:
  packfile: use get_be64() for large offsets

6 years agoMerge branch 'cc/sha1-file-name'
Junio C Hamano [Tue, 13 Feb 2018 21:39:10 +0000 (13:39 -0800)] 
Merge branch 'cc/sha1-file-name'

Code clean-up.

* cc/sha1-file-name:
  sha1_file: improve sha1_file_name() perfs
  sha1_file: remove static strbuf from sha1_file_name()

6 years agoMerge branch 'nd/trace-with-env'
Junio C Hamano [Tue, 13 Feb 2018 21:39:10 +0000 (13:39 -0800)] 
Merge branch 'nd/trace-with-env'

The tracing machinery learned to report tweaking of environment
variables as well.

* nd/trace-with-env:
  run-command.c: print new cwd in trace_run_command()
  run-command.c: print env vars in trace_run_command()
  run-command.c: print program 'git' when tracing git_cmd mode
  run-command.c: introduce trace_run_command()
  trace.c: move strbuf_release() out of print_trace_line()
  trace: avoid unnecessary quoting
  sq_quote_argv: drop maxlen parameter

6 years agoMerge branch 'pc/submodule-helper'
Junio C Hamano [Tue, 13 Feb 2018 21:39:10 +0000 (13:39 -0800)] 
Merge branch 'pc/submodule-helper'

Rewrite two more "git submodule" subcommands in C.

* pc/submodule-helper:
  submodule: port submodule subcommand 'deinit' from shell to C
  submodule: port submodule subcommand 'sync' from shell to C

6 years agoMerge branch 'rb/hashmap-h-compilation-fix'
Junio C Hamano [Tue, 13 Feb 2018 21:39:10 +0000 (13:39 -0800)] 
Merge branch 'rb/hashmap-h-compilation-fix'

Code clean-up.

* rb/hashmap-h-compilation-fix:
  hashmap.h: remove unused variable

6 years agoMerge branch 'nd/diff-flush-before-warning'
Junio C Hamano [Tue, 13 Feb 2018 21:39:09 +0000 (13:39 -0800)] 
Merge branch 'nd/diff-flush-before-warning'

Avoid showing a warning message in the middle of a line of "git
diff" output.

* nd/diff-flush-before-warning:
  diff.c: flush stdout before printing rename warnings

6 years agoMerge branch 'tb/crlf-conv-flags'
Junio C Hamano [Tue, 13 Feb 2018 21:39:08 +0000 (13:39 -0800)] 
Merge branch 'tb/crlf-conv-flags'

Code clean-up.

* tb/crlf-conv-flags:
  convert_to_git(): safe_crlf/checksafe becomes int conv_flags

6 years agoMerge branch 'rs/describe-unique-abbrev'
Junio C Hamano [Tue, 13 Feb 2018 21:39:07 +0000 (13:39 -0800)] 
Merge branch 'rs/describe-unique-abbrev'

Code clean-up.

* rs/describe-unique-abbrev:
  describe: use strbuf_add_unique_abbrev() for adding short hashes

6 years agoMerge branch 'ks/submodule-doc-updates'
Junio C Hamano [Tue, 13 Feb 2018 21:39:07 +0000 (13:39 -0800)] 
Merge branch 'ks/submodule-doc-updates'

Doc updates.

* ks/submodule-doc-updates:
  Doc/git-submodule: improve readability and grammar of a sentence
  Doc/gitsubmodules: make some changes to improve readability and syntax

6 years agoMerge branch 'cl/t9001-cleanup'
Junio C Hamano [Tue, 13 Feb 2018 21:39:07 +0000 (13:39 -0800)] 
Merge branch 'cl/t9001-cleanup'

Test clean-up.

* cl/t9001-cleanup:
  t9001: use existing helper in send-email test

6 years agoMerge branch 'gs/retire-mru'
Junio C Hamano [Tue, 13 Feb 2018 21:39:06 +0000 (13:39 -0800)] 
Merge branch 'gs/retire-mru'

Retire mru API as it does not give enough abstraction over
underlying list API to be worth it.

* gs/retire-mru:
  mru: Replace mru.[ch] with list.h implementation

6 years agoMerge branch 'ot/mru-on-list'
Junio C Hamano [Tue, 13 Feb 2018 21:39:05 +0000 (13:39 -0800)] 
Merge branch 'ot/mru-on-list'

The first step to getting rid of mru API and using the
doubly-linked list API directly instead.

* ot/mru-on-list:
  mru: use double-linked list from list.h

6 years agoMerge branch 'jh/partial-clone'
Junio C Hamano [Tue, 13 Feb 2018 21:39:04 +0000 (13:39 -0800)] 
Merge branch 'jh/partial-clone'

The machinery to clone & fetch, which in turn involves packing and
unpacking objects, have been told how to omit certain objects using
the filtering mechanism introduced by the jh/object-filtering
topic, and also mark the resulting pack as a promisor pack to
tolerate missing objects, taking advantage of the mechanism
introduced by the jh/fsck-promisors topic.

* jh/partial-clone:
  t5616: test bulk prefetch after partial fetch
  fetch: inherit filter-spec from partial clone
  t5616: end-to-end tests for partial clone
  fetch-pack: restore save_commit_buffer after use
  unpack-trees: batch fetching of missing blobs
  clone: partial clone
  partial-clone: define partial clone settings in config
  fetch: support filters
  fetch: refactor calculation of remote list
  fetch-pack: test support excluding large blobs
  fetch-pack: add --no-filter
  fetch-pack, index-pack, transport: partial clone
  upload-pack: add object filtering for partial clone

6 years agoMerge branch 'jh/fsck-promisors'
Junio C Hamano [Tue, 13 Feb 2018 21:39:03 +0000 (13:39 -0800)] 
Merge branch 'jh/fsck-promisors'

In preparation for implementing narrow/partial clone, the machinery
for checking object connectivity used by gc and fsck has been
taught that a missing object is OK when it is referenced by a
packfile specially marked as coming from trusted repository that
promises to make them available on-demand and lazily.

* jh/fsck-promisors:
  gc: do not repack promisor packfiles
  rev-list: support termination at promisor objects
  sha1_file: support lazily fetching missing objects
  introduce fetch-object: fetch one promisor object
  index-pack: refactor writing of .keep files
  fsck: support promisor objects as CLI argument
  fsck: support referenced promisor objects
  fsck: support refs pointing to promisor objects
  fsck: introduce partialclone extension
  extension.partialclone: introduce partial clone extension

6 years agoMerge branch 'ab/simplify-perl-makefile'
Junio C Hamano [Tue, 13 Feb 2018 21:39:03 +0000 (13:39 -0800)] 
Merge branch 'ab/simplify-perl-makefile'

The build procedure for perl/ part has been greatly simplified by
weaning ourselves off of MakeMaker.

* ab/simplify-perl-makefile:
  perl: treat PERLLIB_EXTRA as an extra path again
  perl: avoid *.pmc and fix Error.pm further
  Makefile: replace perl/Makefile.PL with simple make rules

6 years agohash: update obsolete reference to SHA1_HEADER
brian m. carlson [Thu, 8 Feb 2018 02:48:58 +0000 (02:48 +0000)] 
hash: update obsolete reference to SHA1_HEADER

We moved away from SHA1_HEADER to a preprocessor if chain, but didn't
update the comment discussing the platform defines.  Update this comment
so it reflects the current state of our codebase.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agococci: simplify check for trivial format strings
René Scharfe [Thu, 1 Feb 2018 18:56:34 +0000 (19:56 +0100)] 
cocci: simplify check for trivial format strings

353d84c537 (coccicheck: make transformation for strbuf_addf(sb, "...")
more precise) added a check to avoid transforming calls with format
strings which contain percent signs, as that would change the result.
It uses embedded Python code for that.  Simplify this rule by using the
regular expression matching operator instead.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoreset --hard: make use of the pretty machinery
Thomas Gummerer [Thu, 1 Feb 2018 20:57:21 +0000 (20:57 +0000)] 
reset --hard: make use of the pretty machinery

reset --hard currently uses its own logic for printing the first line of
the commit message in its output.  Instead of just using the first line,
use the pretty machinery to create the output.

In addition to the easier to follow code, this makes the output more
consistent with other commands that print the title of the commit, such
as 'git commit --oneline' or 'git checkout', which both use
'pp_commit_easy()' with the CMIT_FMT_ONELINE modifier.

It is a slight change of the output if the second line of the commit
message is not a blank line, i.e. if the commit message is

    foo
    bar

previously we would print "HEAD is now at 000000 foo", while after
this change we print "HEAD is now at 000000 foo bar", same as 'git log
--oneline' shows "000000 foo bar".

So this does make the output more consistent with other commands, and
'reset' is a porcelain command, so nobody should be parsing the output
in scripts.

The current behaviour dates back to 0e5a7faa3a ("Make "git reset" a
builtin.", 2007-09-11), so I assume (without digging into the old
codebase too much) that the logic was implemented because there was
no convenience function such as 'pp_commit_easy' that would do this
already.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoperf/aggregate: sort JSON fields in output
Christian Couder [Thu, 1 Feb 2018 10:14:34 +0000 (11:14 +0100)] 
perf/aggregate: sort JSON fields in output

It is much easier to diff the output against a previous
one when the fields are sorted.

Helped-by: Philip Oakley <philipoakley@iee.org>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoperf/aggregate: add --reponame option
Christian Couder [Thu, 1 Feb 2018 10:14:33 +0000 (11:14 +0100)] 
perf/aggregate: add --reponame option

This makes it easier to use the aggregate script
on the command line when one wants to get the
"environment" fields set in the codespeed output.

Previously setting GIT_REPO_NAME was needed
for this purpose.

Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoperf/aggregate: add --subsection option
Christian Couder [Thu, 1 Feb 2018 10:14:32 +0000 (11:14 +0100)] 
perf/aggregate: add --subsection option

This makes it easier to use the aggregate script
on the command line, to get results from
subsections.

Previously setting GIT_PERF_SUBSECTION was needed
for this purpose.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agobulk-checkin: abstract SHA-1 usage
brian m. carlson [Thu, 1 Feb 2018 02:18:48 +0000 (02:18 +0000)] 
bulk-checkin: abstract SHA-1 usage

Convert uses of the direct SHA-1 functions to use the_hash_algo instead.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocsum-file: abstract uses of SHA-1
brian m. carlson [Thu, 1 Feb 2018 02:18:47 +0000 (02:18 +0000)] 
csum-file: abstract uses of SHA-1

Convert several direct uses of SHA-1 to use the_hash_algo instead.
Convert one use of the constant 20 as well.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocsum-file: rename sha1file to hashfile
brian m. carlson [Thu, 1 Feb 2018 02:18:46 +0000 (02:18 +0000)] 
csum-file: rename sha1file to hashfile

Rename struct sha1file to struct hashfile, along with all of its related
functions.

The transformation in this commit was made by global search-and-replace.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoread-cache: abstract away uses of SHA-1
brian m. carlson [Thu, 1 Feb 2018 02:18:45 +0000 (02:18 +0000)] 
read-cache: abstract away uses of SHA-1

Convert various uses of direct calls to SHA-1 and 20- and 40-based
constants to use the_hash_algo instead.  Don't yet convert the on-disk
data structures, which will be handled in a future commit.

Adjust some comments so as not to refer explicitly to SHA-1.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agopack-write: switch various SHA-1 values to abstract forms
brian m. carlson [Thu, 1 Feb 2018 02:18:44 +0000 (02:18 +0000)] 
pack-write: switch various SHA-1 values to abstract forms

Convert various uses of hardcoded 20- and 40-based numbers to use
the_hash_algo, along with direct calls to SHA-1.  Adjust the names of
variables to refer to "hash" instead of "sha1".

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agopack-check: convert various uses of SHA-1 to abstract forms
brian m. carlson [Thu, 1 Feb 2018 02:18:43 +0000 (02:18 +0000)] 
pack-check: convert various uses of SHA-1 to abstract forms

Convert various explicit calls to use SHA-1 functions and constants to
references to the_hash_algo.  Make several strings more generic with
respect to the hash algorithm used.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agofast-import: switch various uses of SHA-1 to the_hash_algo
brian m. carlson [Thu, 1 Feb 2018 02:18:42 +0000 (02:18 +0000)] 
fast-import: switch various uses of SHA-1 to the_hash_algo

Switch various uses of explicit calls to SHA-1 to use the_hash_algo.
Convert various uses of 20 and the GIT_SHA1 constants as well.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosha1_file: switch uses of SHA-1 to the_hash_algo
brian m. carlson [Thu, 1 Feb 2018 02:18:41 +0000 (02:18 +0000)] 
sha1_file: switch uses of SHA-1 to the_hash_algo

Switch various uses of explicit calls to SHA-1 into references to
the_hash_algo for better abstraction.  Convert some calls to use struct
object_id.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agobuiltin/unpack-objects: switch uses of SHA-1 to the_hash_algo
brian m. carlson [Thu, 1 Feb 2018 02:18:40 +0000 (02:18 +0000)] 
builtin/unpack-objects: switch uses of SHA-1 to the_hash_algo

Switch various uses of explicit calls to SHA-1 into references to
the_hash_algo to better abstract away the various uses of it.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agobuiltin/index-pack: improve hash function abstraction
brian m. carlson [Thu, 1 Feb 2018 02:18:39 +0000 (02:18 +0000)] 
builtin/index-pack: improve hash function abstraction

Convert several uses of unsigned char [20] to struct object_id and
convert various hard-coded constants and uses of SHA-1 functions to use
the_hash_algo.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agohash: create union for hash context allocation
brian m. carlson [Thu, 1 Feb 2018 02:18:38 +0000 (02:18 +0000)] 
hash: create union for hash context allocation

In various parts of our code, we want to allocate a structure
representing the internal state of a hash algorithm.  The original
implementation of the hash algorithm abstraction assumed we would do
that using heap allocations, and added a context size element to struct
git_hash_algo.  However, most of the existing code uses stack
allocations and conversion would needlessly complicate various parts of
the code.  Add a union for the purpose of allocating hash contexts on
the stack and a typedef for ease of use.  Use this union for defining
the init, update, and final functions to avoid casts.  Remove the ctxsz
element for struct git_hash_algo, which is no longer very useful.

This does mean that stack allocations will grow slightly as additional
hash functions are added, but this should not be a significant problem,
since we don't allocate many hash contexts.  The improved usability and
benefits from avoiding dynamic allocation outweigh this small downside.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agohash: move SHA-1 macros to hash.h
brian m. carlson [Thu, 1 Feb 2018 02:18:37 +0000 (02:18 +0000)] 
hash: move SHA-1 macros to hash.h

Most of the other code dealing with SHA-1 and other hashes is located in
hash.h, which is in turn loaded by cache.h.  Move the SHA-1 macros to
hash.h as well, so we can use them in additional hash-related items in
the future.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotrace: measure where the time is spent in the index-heavy operations
Nguyễn Thái Ngọc Duy [Sat, 27 Jan 2018 12:27:56 +0000 (19:27 +0700)] 
trace: measure where the time is spent in the index-heavy operations

All the known heavy code blocks are measured (except object database
access). This should help identify if an optimization is effective or
not. An unoptimized git-status would give something like below:

    0.001791141 s: read cache ...
    0.004011363 s: preload index
    0.000516161 s: refresh index
    0.003139257 s: git command: ... 'status' '--porcelain=2'
    0.006788129 s: diff-files
    0.002090267 s: diff-index
    0.001885735 s: initialize name hash
    0.032013138 s: read directory
    0.051781209 s: git command: './git' 'status'

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agogitignore.txt: elaborate shell glob syntax
Duy Nguyen [Thu, 1 Feb 2018 09:59:15 +0000 (16:59 +0700)] 
gitignore.txt: elaborate shell glob syntax

`fnmatch(3)` is a great mention if the intended audience is
programmers. For normal users it's probably better to spell out what
a shell glob is.

This paragraph is updated to roughly tell (or remind) what the main
wildcards are supposed to do. All the details are still hidden away
behind the `fnmatch(3)` wall because bringing the whole specification
here may be too much.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agowildmatch test: mark test as EXPENSIVE_ON_WINDOWS
Ævar Arnfjörð Bjarmason [Tue, 30 Jan 2018 21:21:24 +0000 (21:21 +0000)] 
wildmatch test: mark test as EXPENSIVE_ON_WINDOWS

Mark the newly added test which creates test files on-disk as
EXPENSIVE_ON_WINDOWS. According to [1] it takes almost ten minutes to
run this test file on Windows after this recent change, but just a few
seconds on Linux as noted in my [2].

This could be done faster by exiting earlier, however by using this
pattern we'll emit "skip" lines for each skipped test, making it clear
we're not running a lot of them in the TAP output, at the cost of some
overhead.

1. nycvar.QRO.7.76.6.1801061337020.1337@wbunaarf-fpuvaqryva.tvgsbejvaqbjf.bet
   (https://public-inbox.org/git/nycvar.QRO.7.76.6.1801061337020.1337@wbunaarf-fpuvaqryva.tvgsbejvaqbjf.bet/)

2. 87mv1raz9p.fsf@evledraar.gmail.com
   (https://public-inbox.org/git/87mv1raz9p.fsf@evledraar.gmail.com/)

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotest-lib: add an EXPENSIVE_ON_WINDOWS prerequisite
Ævar Arnfjörð Bjarmason [Tue, 30 Jan 2018 21:21:23 +0000 (21:21 +0000)] 
test-lib: add an EXPENSIVE_ON_WINDOWS prerequisite

Add an EXPENSIVE_ON_WINDOWS prerequisite to mark those tests which are
very expensive to run on Windows, but cheap elsewhere.

Certain tests that heavily stress the filesystem or run a lot of shell
commands are disproportionately expensive on Windows, this
prerequisite will later be used by a tests that runs in 4-8 seconds on
a modern Linux system, but takes almost 10 minutes on Windows.

There's no reason to skip such tests by default on other platforms,
but Windows users shouldn't need to wait around while they finish.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agowildmatch test: create & test files on disk in addition to in-memory
Ævar Arnfjörð Bjarmason [Tue, 30 Jan 2018 21:21:22 +0000 (21:21 +0000)] 
wildmatch test: create & test files on disk in addition to in-memory

There has never been any full roundtrip testing of what git-ls-files
and other commands that use wildmatch() actually do, rather we've been
satisfied with just testing the underlying C function.

Due to git-ls-files and friends having their own codepaths before they
call wildmatch() there's sometimes differences in the behavior between
the two. Even when we test for those (as with [1]), there was no one
place where you can review how these two modes differ.

Now there is. We now attempt to create a file called $haystack and
match $needle against it for each pair of $needle and $haystack that
we were passing to test-wildmatch.

If we can't create the file we skip the test. This ensures that we can
run this on all platforms and not maintain some infinitely growing
whitelist of e.g. platforms that don't support certain characters in
filenames.

A notable exception to this is Windows, where due to the reasons
explained in [2] the shellscript emulation layer might fake the
creation of a file such as "*", and "test -e" for it will succeed
since it just got created with some character that maps to "*", but
git ls-files won't be fooled by this.

Thus we need to skip creating certain filenames entirely on Windows,
the list here might be overly aggressive. I don't have access to a
Windows system to test this.

As a result of doing these tests we can now see the cases where these
two ways of testing wildmatch differ:

 * Creating a file called 'a[]b' and running ls-files 'a[]b' will show
   that file, but wildmatch("a[]b", "a[]b") will not match

 * wildmatch() won't match a file called \ against \, but ls-files
   will.

 * `git --glob-pathspecs ls-files 'foo**'` will match a file
   'foo/bba/arr', but wildmatch won't, however pathmatch will.

   This seems like a bug to me, the two are otherwise equivalent as
   these tests show.

This also reveals the case discussed in [1], since 2.16.0 '' is now an
error as far as ls-files is concerned, but wildmatch() itself happily
accepts it.

1. 9e4e8a64c2 ("pathspec: die on empty strings as pathspec",
   2017-06-06)

2. nycvar.QRO.7.76.6.1801052133380.1337@wbunaarf-fpuvaqryva.tvgsbejvaqbjf.bet
   (https://public-inbox.org/git/?q=nycvar.QRO.7.76.6.1801052133380.1337%40wbunaarf-fpuvaqryva.tvgsbejvaqbjf.bet)

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agowildmatch test: perform all tests under all wildmatch() modes
Ævar Arnfjörð Bjarmason [Tue, 30 Jan 2018 21:21:21 +0000 (21:21 +0000)] 
wildmatch test: perform all tests under all wildmatch() modes

Rewrite the wildmatch() test suite so that each test now tests all
combinations of the wildmatch() WM_CASEFOLD and WM_PATHNAME flags.

Before this change some test inputs were not tested on
e.g. WM_PATHNAME. Now the function is stress tested on all possible
inputs, and for each input we declare what the result should be if the
mode is case-insensitive, or pathname matching, or case-sensitive or
not matching pathnames.

Also before this change, nothing was testing case-insensitive
non-pathname matching, so I've added that to test-wildmatch.c and made
use of it.

This yields a rather scary patch, but there are no functional changes
here, just more test coverage. Some now-redundant tests were deleted
as a result of this change, since they were now duplicating an earlier
test.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agowildmatch test: use test_must_fail, not ! for test-wildmatch
Ævar Arnfjörð Bjarmason [Tue, 30 Jan 2018 21:21:20 +0000 (21:21 +0000)] 
wildmatch test: use test_must_fail, not ! for test-wildmatch

Use of ! should be reserved for non-git programs that are assumed not
to fail, see README. With this change only
t/t0110-urlmatch-normalization.sh is still using this anti-pattern.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agowildmatch test: remove dead fnmatch() test code
Ævar Arnfjörð Bjarmason [Tue, 30 Jan 2018 21:21:19 +0000 (21:21 +0000)] 
wildmatch test: remove dead fnmatch() test code

Remove the unused fnmatch() test parameter from the wildmatch
test. The code that used to test this was removed in 70a8fc999d ("stop
using fnmatch (either native or compat)", 2014-02-15).

As a --word-diff shows the only change to the body of the tests is the
removal of the second out of four parameters passed to match().

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agowildmatch test: use a paranoia pattern from nul_match()
Ævar Arnfjörð Bjarmason [Tue, 30 Jan 2018 21:21:18 +0000 (21:21 +0000)] 
wildmatch test: use a paranoia pattern from nul_match()

Use a pattern from the nul_match() function in t7008-grep-binary.sh to
make sure that we don't just fall through to the "else" if there's an
unknown parameter.

This is something I added in commit 77f6f4406f ("grep: add a test
helper function for less verbose -f \0 tests", 2017-05-20) to grep
tests, which were modeled on these wildmatch tests, and I'm now
porting back to the original wildmatch tests.

I am not using the "say '...'; exit 1" pattern from t0000-basic.sh
because if I fail I want to run the rest of the tests (unless under
-i), and doing this makes sure we do that and don't exit right away
without fully reporting our errors.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agowildmatch test: don't try to vertically align our output
Ævar Arnfjörð Bjarmason [Tue, 30 Jan 2018 21:21:17 +0000 (21:21 +0000)] 
wildmatch test: don't try to vertically align our output

Don't try to vertically align the test output, which is futile anyway
under the TAP output where we're going to be emitting a number for
each test without aligning the test count.

This makes subsequent changes of mine where I'm not going to be
aligning this output as I add new tests easier.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agowildmatch test: use more standard shell style
Ævar Arnfjörð Bjarmason [Tue, 30 Jan 2018 21:21:16 +0000 (21:21 +0000)] 
wildmatch test: use more standard shell style

Change the wildmatch test to use more standard shell style, usually we
use "if test" not "if [".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agowildmatch test: indent with tabs, not spaces
Ævar Arnfjörð Bjarmason [Tue, 30 Jan 2018 21:21:15 +0000 (21:21 +0000)] 
wildmatch test: indent with tabs, not spaces

Replace the 4-width mixed space & tab indentation in this file with
indentation with tabs as we do in most of the rest of our tests.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotravis-ci: don't fail if user already exists on 32 bit Linux build job
SZEDER Gábor [Mon, 29 Jan 2018 17:17:13 +0000 (18:17 +0100)] 
travis-ci: don't fail if user already exists on 32 bit Linux build job

The 32 bit Linux build job runs in a Docker container, which lends
itself to running and debugging locally, too.  Especially during
debugging one usually doesn't want to start with a fresh container
every time, to save time spent on installing a bunch of dependencies.
However, that doesn't work quite smootly, because the script running
in the container always creates a new user, which then must be removed
every time before subsequent executions, or the build script fails.

Make this process more convenient and don't try to create that user if
it already exists and has the right user ID in the container, so
developers don't have to bother with running a 'userdel' each time
before they run the build script.

The build job on Travis CI always starts with a fresh Docker
container, so this change doesn't make a difference there.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotravis-ci: don't run the test suite as root in the 32 bit Linux build
SZEDER Gábor [Mon, 29 Jan 2018 17:17:12 +0000 (18:17 +0100)] 
travis-ci: don't run the test suite as root in the 32 bit Linux build

Travis CI runs the 32 bit Linux build job in a Docker container, where
all commands are executed as root by default.  Therefore, ever since
we added this build job in 88dedd5e7 (Travis: also test on 32-bit
Linux, 2017-03-05), we have a bit of code to create a user in the
container matching the ID of the host user and then to run the test
suite as this user.  Matching the host user ID is important, because
otherwise the host user would have no access to any files written by
processes running in the container, notably the logs of failed tests
couldn't be included in the build job's trace log.

Alas, this piece of code never worked, because it sets the variable
holding the user name ($CI_USER) in a subshell, meaning it doesn't
have any effect by the time we get to the point to actually use the
variable to switch users with 'su'.  So all this time we were running
the test suite as root.

Reorganize that piece of code in 'ci/run-linux32-build.sh' a bit to
avoid that problematic subshell and to ensure that we switch to the
right user.  Furthermore, make the script's optional host user ID
option mandatory, so running the build accidentally as root will
become harder when debugging locally.  If someone really wants to run
the test suite as root, whatever the reasons might be, it'll still be
possible to do so by explicitly passing '0' as host user ID.

Finally, one last catch: since commit 7e72cfcee (travis-ci: save prove
state for the 32 bit Linux build, 2017-12-27) the 'prove' test harness
has been writing its state to the Travis CI cache directory from
within the Docker container while running as root.  After this patch
'prove' will run as a regular user, so in future build jobs it won't
be able overwrite a previously written, still root-owned state file,
resulting in build job failures.  To resolve this we should manually
delete caches containing such root-owned files, but that would be a
hassle.  Instead, work this around by changing the owner of the whole
contents of the cache directory to the host user ID.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotravis-ci: don't repeat the path of the cache directory
SZEDER Gábor [Mon, 29 Jan 2018 17:17:11 +0000 (18:17 +0100)] 
travis-ci: don't repeat the path of the cache directory

Some of our 'ci/*' scripts repeat the name or full path of the Travis
CI cache directory, and the following patches will add new places
using that path.

Use a variable to refer to the path of the cache directory instead, so
it's hard-coded only in a single place.

Pay extra attention to the 32 bit Linux build: it runs in a Docker
container, so pass the path of the cache directory from the host to
the container in an environment variable.  Note that an environment
variable passed this way is exported inside the container, therefore
its value is directly available in the 'su' snippet even though that
snippet is single quoted.  Furthermore, use the variable in the
container only if it's been assigned a non-empty value, to prevent
errors when someone is running or debugging the Docker build locally,
because in that case the variable won't be set as there won't be any
Travis CI cache.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotravis-ci: use 'set -e' in the 32 bit Linux build job
SZEDER Gábor [Mon, 29 Jan 2018 17:17:10 +0000 (18:17 +0100)] 
travis-ci: use 'set -e' in the 32 bit Linux build job

The script 'ci/run-linux32-build.sh' running inside the Docker
container of the 32 bit Linux build job uses an && chain to break the
build if one of the commands fails.  This is problematic for two
reasons:

  - The && chain is broken, because there is this in the middle:

    test -z $HOST_UID || (CI_USER="ci" && useradd -u $HOST_UID $CI_USER) &&

    Luckily it is broken in a way that it didn't lead to false
    successes.  If installing dependencies fails, then the rest of the
    first && chain is skipped and execution resumes  after the ||
    operator.  At that point $HOST_UID is still unset, causing
    'useradd' to error out with "invalid user ID 'ci'", which in turn
    causes the second && chain to abort the script and thus break the
    build.

  - All other 'ci/*' scripts use 'set -e' to break the build if one of
    the commands fails.  This inconsistency among these scripts is
    asking for trouble: I forgot about the && chain more than once
    while working on this patch series.

Enable 'set -e' for the whole script and for the commands executed
under 'su' as well.

While touching every line in the 'su' command block anyway, change
their indentation to use a tab instead of spaces.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotravis-ci: use 'set -x' for the commands under 'su' in the 32 bit Linux build
SZEDER Gábor [Mon, 29 Jan 2018 17:17:09 +0000 (18:17 +0100)] 
travis-ci: use 'set -x' for the commands under 'su' in the 32 bit Linux build

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agogit-svn: control destruction order to avoid segfault
Eric Wong [Mon, 29 Jan 2018 23:11:07 +0000 (23:11 +0000)] 
git-svn: control destruction order to avoid segfault

It seems necessary to control destruction ordering to avoid a
segfault with SVN 1.9.5 when using "git svn branch".  I've also
reported the problem against libsvn-perl to Debian [Bug #888791],
but releasing the SVN::Client instance can be beneficial anyways to
save memory.

ref: https://bugs.debian.org/888791
Tested-by: Todd Zullinger <tmz@pobox.com>
Reported-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Eric Wong <e@80x24.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agodoc: mention 'git show' defaults to HEAD
Todd Zullinger [Sun, 28 Jan 2018 19:16:07 +0000 (14:16 -0500)] 
doc: mention 'git show' defaults to HEAD

When 'git show' is called without any object it defaults to HEAD.  This
has been true since d4ed9793fd ("Simplify common default options setup
for built-in log family.", 2006-04-16).

The SYNOPSIS suggests that the object argument is required.  Clarify
that it is not required and note the default.

Signed-off-by: Todd Zullinger <tmz@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosha1_file: rename hash_sha1_file_literally
Patryk Obara [Sun, 28 Jan 2018 00:13:22 +0000 (01:13 +0100)] 
sha1_file: rename hash_sha1_file_literally

This function was already converted to use struct object_id earlier.

Signed-off-by: Patryk Obara <patryk.obara@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosha1_file: convert write_loose_object to object_id
Patryk Obara [Sun, 28 Jan 2018 00:13:21 +0000 (01:13 +0100)] 
sha1_file: convert write_loose_object to object_id

Convert the definition and declaration of static write_loose_object
function to struct object_id.

Signed-off-by: Patryk Obara <patryk.obara@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosha1_file: convert force_object_loose to object_id
Patryk Obara [Sun, 28 Jan 2018 00:13:20 +0000 (01:13 +0100)] 
sha1_file: convert force_object_loose to object_id

Convert the definition and declaration of force_object_loose to
struct object_id and adjust usage of this function.

Signed-off-by: Patryk Obara <patryk.obara@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosha1_file: convert write_sha1_file to object_id
Patryk Obara [Sun, 28 Jan 2018 00:13:19 +0000 (01:13 +0100)] 
sha1_file: convert write_sha1_file to object_id

Convert the definition and declaration of write_sha1_file to
struct object_id and adjust usage of this function.

This commit also converts static function write_sha1_file_prepare, as it
is closely related.

Rename these functions to write_object_file and
write_object_file_prepare respectively.

Replace sha1_to_hex, hashcpy and hashclr with their oid equivalents
wherever possible.

Signed-off-by: Patryk Obara <patryk.obara@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agonotes: convert write_notes_tree to object_id
Patryk Obara [Sun, 28 Jan 2018 00:13:18 +0000 (01:13 +0100)] 
notes: convert write_notes_tree to object_id

Convert the definition and declaration of write_notes_tree to
struct object_id and adjust usage of this function.

Additionally, improve style of small part of this function, as old
formatting made it hard to understand at glance what this part of
code is doing.

Signed-off-by: Patryk Obara <patryk.obara@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agonotes: convert combine_notes_* to object_id
Patryk Obara [Sun, 28 Jan 2018 00:13:17 +0000 (01:13 +0100)] 
notes: convert combine_notes_* to object_id

Convert the definition and declarations of combine_notes_* functions
to struct object_id and adjust usage of these functions.

Signed-off-by: Patryk Obara <patryk.obara@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocommit: convert commit_tree* to object_id
Patryk Obara [Sun, 28 Jan 2018 00:13:16 +0000 (01:13 +0100)] 
commit: convert commit_tree* to object_id

Convert the definitions and declarations of commit_tree and
commit_tree_extended to use struct object_id and adjust all usages of
these functions.

Signed-off-by: Patryk Obara <patryk.obara@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agomatch-trees: convert splice_tree to object_id
Patryk Obara [Sun, 28 Jan 2018 00:13:15 +0000 (01:13 +0100)] 
match-trees: convert splice_tree to object_id

Convert the definition of static recursive splice_tree function to use
struct object_id and adjust single caller.

Signed-off-by: Patryk Obara <patryk.obara@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocache: clear whole hash buffer with oidclr
Patryk Obara [Sun, 28 Jan 2018 00:13:14 +0000 (01:13 +0100)] 
cache: clear whole hash buffer with oidclr

As long as GIT_SHA1_RAWSZ is equal to GIT_MAX_RAWSZ there's no problem,
but when new hashing algorithm will be in place this memset will clear
only 20-byte prefix of hash buffer.

Alternatively, hashclr implementation could be adjusted, but this
function is almost removed from codebase already.  Separate
implementation of oidclr prevents potential buffer overrun in case
someone incorrectly used hashclr on object_id in future.

Signed-off-by: Patryk Obara <patryk.obara@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosha1_file: convert hash_sha1_file to object_id
Patryk Obara [Sun, 28 Jan 2018 00:13:13 +0000 (01:13 +0100)] 
sha1_file: convert hash_sha1_file to object_id

Convert the declaration and definition of hash_sha1_file to use
struct object_id and adjust all function calls.

Rename this function to hash_object_file.

Signed-off-by: Patryk Obara <patryk.obara@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agodir: convert struct sha1_stat to use object_id
Patryk Obara [Sun, 28 Jan 2018 00:13:12 +0000 (01:13 +0100)] 
dir: convert struct sha1_stat to use object_id

Convert the declaration of struct sha1_stat. Adjust all usages of this
struct and replace hash{clr,cmp,cpy} with oid{clr,cmp,cpy} wherever
possible.  Rename it to struct oid_stat.

Rename static function load_sha1_stat to load_oid_stat.

Remove macro EMPTY_BLOB_SHA1_BIN, as it's no longer used.

Signed-off-by: Patryk Obara <patryk.obara@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosha1_file: convert pretend_sha1_file to object_id
Patryk Obara [Sun, 28 Jan 2018 00:13:11 +0000 (01:13 +0100)] 
sha1_file: convert pretend_sha1_file to object_id

Convert the declaration and definition of pretend_sha1_file to use
struct object_id and adjust all usages of this function.  Rename it to
pretend_object_file.

Signed-off-by: Patryk Obara <patryk.obara@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocompletion: fix completing merge strategies on non-C locales
Duy Nguyen [Fri, 26 Jan 2018 01:31:42 +0000 (08:31 +0700)] 
completion: fix completing merge strategies on non-C locales

The anchor string "Available strategies are:" is translatable so
__git_list_merge_strategies may fail to collect available strategies
from 'git merge' on non-C locales. Force C locale on this command.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agodaemon: fix length computation in newline stripping
Jeff King [Thu, 25 Jan 2018 00:58:54 +0000 (19:58 -0500)] 
daemon: fix length computation in newline stripping

When git-daemon gets a pktline request, we strip off any
trailing newline, replacing it with a NUL. Clients prior to
5ad312bede (in git v1.4.0) would send:

  git-upload-pack repo.git\n

and we need to strip it off to understand their request.
After 5ad312bede, we send the host attribute but no newline,
like:

  git-upload-pack repo.git\0host=example.com\0

Both of these are parsed correctly by git-daemon. But if
some client were to combine the two:

  git-upload-pack repo.git\n\0host=example.com\0

we don't parse it correctly. The problem is that we use the
"len" variable to record the position of the NUL separator,
but then decrement it when we strip the newline. So we start
with:

  git-upload-pack repo.git\n\0host=example.com\0
                             ^-- len

and end up with:

  git-upload-pack repo.git\0\0host=example.com\0
                           ^-- len

This is arguably correct, since "len" tells us the length of
the initial string, but we don't actually use it for that.
What we do use it for is finding the offset of the extended
attributes; they used to be at len+1, but are now at len+2.

We can solve that by just leaving "len" where it is. We
don't have to care about the length of the shortened string,
since we just treat it like a C string.

No version of Git ever produced such a string, but it seems
like the daemon code meant to handle this case (and it seems
like a reasonable thing for somebody to do in a 3rd-party
implementation).

Reported-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot/lib-git-daemon: add network-protocol helpers
Jeff King [Thu, 25 Jan 2018 00:58:19 +0000 (19:58 -0500)] 
t/lib-git-daemon: add network-protocol helpers

All of our git-protocol tests rely on invoking the client
and having it make a request of a server. That gives a nice
real-world test of how the two behave together, but it
doesn't leave any room for testing how a server might react
to _other_ clients.

Let's add a few test helper functions which can be used to
manually conduct a git-protocol conversation with a remote
git-daemon:

  1. To connect to a remote git-daemon, we need something
     like "netcat". But not everybody will have netcat. And
     even if they do, the behavior with respect to
     half-duplex shutdowns is not portable (openbsd netcat
     has "-N", with others you must rely on "-q 1", which is
     racy).

     Here we provide a "fake_nc" that is capable of doing
     a client-side netcat, with sane half-duplex semantics.
     It relies on perl's IO::Socket::INET. That's been in
     the base distribution since 5.6.0, so it's probably
     available everywhere. But just to be on the safe side,
     we'll add a prereq.

  2. To help tests speak and read pktline, this patch adds
     packetize() and depacketize() functions.

I've put fake_nc() into lib-git-daemon.sh, since that's
really the only server where we'd need to use a network
socket.  Whereas the pktline helpers may be of more general
use, so I've added them to test-lib-functions.sh. Programs
like upload-pack speak pktline, but can talk directly over
stdio without a network socket.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agodaemon: handle NULs in extended attribute string
Jeff King [Thu, 25 Jan 2018 00:56:20 +0000 (19:56 -0500)] 
daemon: handle NULs in extended attribute string

If we receive a request with extended attributes after the
NUL, we try to write those attributes to the log. We do so
with a "%s" format specifier, which will only show
characters up to the first NUL.

That's enough for printing a "host=" specifier. But since
dfe422d04d (daemon: recognize hidden request arguments,
2017-10-16) we may have another NUL, followed by protocol
parameters, and those are not logged at all.

Let's cut out the attempt to show the whole string, and
instead log when we parse individual attributes. We could
leave the "extended attributes (%d bytes) exist" part of the
log, which in theory could alert us to attributes that fail
to parse. But anything we don't parse as a "host=" parameter
gets blindly added to the "protocol" attribute, so we'd see
it in that part of the log.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agodaemon: fix off-by-one in logging extended attributes
Jeff King [Thu, 25 Jan 2018 00:56:07 +0000 (19:56 -0500)] 
daemon: fix off-by-one in logging extended attributes

If receive a request like:

  git-upload-pack /foo.git\0host=localhost

we mark the offset of the NUL byte as "len", and then log
the bytes after the NUL with a "%.*s" placeholder, using
"pktlen - len" as the length, and "line + len + 1" as the
start of the string.

This is off-by-one, since the start of the string skips past
the separating NUL byte, but the adjusted length includes
it. Fortunately this doesn't actually read past the end of
the buffer, since "%.*s" will stop when it hits a NUL. And
regardless of what is in the buffer, packet_read() will
always add an extra NUL terminator for safety.

As an aside, the git.git client sends an extra NUL after a
"host" field, too, so we'd generally hit that one first, not
the one added by packet_read(). You can see this in the test
output which reports 15 bytes, even though the string has
only 14 bytes of visible data. But the point is that even a
client sending unusual data could not get us to read past
the end of the buffer, so this is purely a cosmetic fix.

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