]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
2 years agotmp-objdir: new API for creating temporary writable databases
Neeraj Singh [Mon, 6 Dec 2021 22:05:04 +0000 (22:05 +0000)] 
tmp-objdir: new API for creating temporary writable databases

The tmp_objdir API provides the ability to create temporary object
directories, but was designed with the goal of having subprocesses
access these object stores, followed by the main process migrating
objects from it to the main object store or just deleting it.  The
subprocesses would view it as their primary datastore and write to it.

Here we add the tmp_objdir_replace_primary_odb function that replaces
the current process's writable "main" object directory with the
specified one. The previous main object directory is restored in either
tmp_objdir_migrate or tmp_objdir_destroy.

For the --remerge-diff usecase, add a new `will_destroy` flag in `struct
object_database` to mark ephemeral object databases that do not require
fsync durability.

Add 'git prune' support for removing temporary object databases, and
make sure that they have a name starting with tmp_ and containing an
operation-specific name.

Based-on-patch-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Neeraj Singh <neerajsi@microsoft.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoThe ninth batch
Junio C Hamano [Tue, 28 Sep 2021 19:35:08 +0000 (12:35 -0700)] 
The ninth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMerge branch 'en/typofixes'
Junio C Hamano [Tue, 28 Sep 2021 20:06:53 +0000 (13:06 -0700)] 
Merge branch 'en/typofixes'

Typofixes.

* en/typofixes:
  merge-ort: fix completely wrong comment
  trace2.h: fix trivial comment typo

2 years agoMerge branch 'cb/unicode-14'
Junio C Hamano [Tue, 28 Sep 2021 20:06:53 +0000 (13:06 -0700)] 
Merge branch 'cb/unicode-14'

The unicode character width table (used for output alignment) has
been updated.

* cb/unicode-14:
  unicode: update the width tables to Unicode 14

2 years agoMerge branch 'jk/reduce-malloc-in-v2-servers'
Junio C Hamano [Tue, 28 Sep 2021 20:06:53 +0000 (13:06 -0700)] 
Merge branch 'jk/reduce-malloc-in-v2-servers'

Code cleanup to limit memory consumption and tighten protocol
message parsing.

* jk/reduce-malloc-in-v2-servers:
  ls-refs: reject unknown arguments
  serve: reject commands used as capabilities
  serve: reject bogus v2 "command=ls-refs=foo"
  docs/protocol-v2: clarify some ls-refs ref-prefix details
  ls-refs: ignore very long ref-prefix counts
  serve: drop "keys" strvec
  serve: provide "receive" function for session-id capability
  serve: provide "receive" function for object-format capability
  serve: add "receive" method for v2 capabilities table
  serve: return capability "value" from get_capability()
  serve: rename is_command() to parse_command()

3 years agoThe eighth batch
Junio C Hamano [Thu, 23 Sep 2021 20:45:03 +0000 (13:45 -0700)] 
The eighth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'rs/use-xopen-in-index-pack'
Junio C Hamano [Thu, 23 Sep 2021 20:44:50 +0000 (13:44 -0700)] 
Merge branch 'rs/use-xopen-in-index-pack'

Code clean-up.

* rs/use-xopen-in-index-pack:
  index-pack: use xopen in init_thread

3 years agoMerge branch 'kz/revindex-comment-fix'
Junio C Hamano [Thu, 23 Sep 2021 20:44:49 +0000 (13:44 -0700)] 
Merge branch 'kz/revindex-comment-fix'

Header comment fix.

* kz/revindex-comment-fix:
  pack-revindex.h: correct the time complexity descriptions

3 years agoMerge branch 'cb/plug-leaks-in-alloca-emu-users'
Junio C Hamano [Thu, 23 Sep 2021 20:44:49 +0000 (13:44 -0700)] 
Merge branch 'cb/plug-leaks-in-alloca-emu-users'

Leakfix.

* cb/plug-leaks-in-alloca-emu-users:
  t0000: avoid masking git exit value through pipes
  tree-diff: fix leak when not HAVE_ALLOCA_H

3 years agoMerge branch 'jt/submodule-name-to-gitdir'
Junio C Hamano [Thu, 23 Sep 2021 20:44:49 +0000 (13:44 -0700)] 
Merge branch 'jt/submodule-name-to-gitdir'

Code refactoring.

* jt/submodule-name-to-gitdir:
  submodule: extract path to submodule gitdir func

3 years agoMerge branch 'ma/doc-git-version'
Junio C Hamano [Thu, 23 Sep 2021 20:44:49 +0000 (13:44 -0700)] 
Merge branch 'ma/doc-git-version'

Doc update.

* ma/doc-git-version:
  documentation: add documentation for 'git version'

3 years agoMerge branch 'ma/help-w-check-for-requested-page'
Junio C Hamano [Thu, 23 Sep 2021 20:44:48 +0000 (13:44 -0700)] 
Merge branch 'ma/help-w-check-for-requested-page'

The error in "git help no-such-git-command" is handled better.

* ma/help-w-check-for-requested-page:
  help: make sure local html page exists before calling external processes

3 years agoMerge branch 'cb/unix-sockets-with-windows'
Junio C Hamano [Thu, 23 Sep 2021 20:44:48 +0000 (13:44 -0700)] 
Merge branch 'cb/unix-sockets-with-windows'

Adjust credential-cache helper to Windows.

* cb/unix-sockets-with-windows:
  git-compat-util: include declaration for unix sockets in windows
  credential-cache: check for windows specific errors
  t0301: fixes for windows compatibility

3 years agoMerge branch 'ab/retire-option-argument'
Junio C Hamano [Thu, 23 Sep 2021 20:44:48 +0000 (13:44 -0700)] 
Merge branch 'ab/retire-option-argument'

An oddball OPTION_ARGUMENT feature has been removed from the
parse-options API.

* ab/retire-option-argument:
  parse-options API: remove OPTION_ARGUMENT feature
  difftool: use run_command() API in run_file_diff()
  difftool: prepare "diff" cmdline in cmd_difftool()
  difftool: prepare "struct child_process" in cmd_difftool()

3 years agoMerge branch 'mr/bisect-in-c-4'
Junio C Hamano [Thu, 23 Sep 2021 20:44:48 +0000 (13:44 -0700)] 
Merge branch 'mr/bisect-in-c-4'

Rewrite of "git bisect" in C continues.

* mr/bisect-in-c-4:
  bisect--helper: retire `--bisect-next-check` subcommand
  bisect--helper: reimplement `bisect_run` shell function in C
  bisect--helper: reimplement `bisect_visualize()` shell function in C
  run-command: make `exists_in_PATH()` non-static
  t6030-bisect-porcelain: add test for bisect visualize
  t6030-bisect-porcelain: add tests to control bisect run exit cases

3 years agoMerge branch 'ab/unused-script-helpers'
Junio C Hamano [Thu, 23 Sep 2021 20:44:47 +0000 (13:44 -0700)] 
Merge branch 'ab/unused-script-helpers'

Code clean-up.

* ab/unused-script-helpers:
  test-lib: remove unused $_x40 and $_z40 variables
  git-bisect: remove unused SHA-1 $x40 shell variable
  git-sh-setup: remove unused "pull with rebase" message
  git-submodule: remove unused is_zero_oid() function

3 years agoMerge branch 'ab/http-drop-old-curl-plus'
Junio C Hamano [Thu, 23 Sep 2021 20:44:47 +0000 (13:44 -0700)] 
Merge branch 'ab/http-drop-old-curl-plus'

Conditional compilation around versions of libcURL has been
straightened out.

* ab/http-drop-old-curl-plus:
  http: don't hardcode the value of CURL_SOCKOPT_OK
  http: centralize the accounting of libcurl dependencies
  http: correct curl version check for CURLOPT_PINNEDPUBLICKEY
  http: correct version check for CURL_HTTP_VERSION_2
  http: drop support for curl < 7.18.0 (again)
  Makefile: drop support for curl < 7.9.8 (again)
  INSTALL: mention that we need libcurl 7.19.4 or newer to build
  INSTALL: reword and copy-edit the "libcurl" section
  INSTALL: don't mention the "curl" executable at all

3 years agoMerge branch 'po/git-config-doc-mentions-help-c'
Junio C Hamano [Thu, 23 Sep 2021 20:44:47 +0000 (13:44 -0700)] 
Merge branch 'po/git-config-doc-mentions-help-c'

Doc update.

* po/git-config-doc-mentions-help-c:
  doc: config, tell readers of `git help --config`

3 years agoMerge branch 'jk/http-server-protocol-versions'
Junio C Hamano [Thu, 23 Sep 2021 20:44:47 +0000 (13:44 -0700)] 
Merge branch 'jk/http-server-protocol-versions'

Taking advantage of the CGI interface, http-backend has been
updated to enable protocol v2 automatically when the other side
asks for it.

* jk/http-server-protocol-versions:
  docs/protocol-v2: point readers transport config discussion
  docs/git: discuss server-side config for GIT_PROTOCOL
  docs/http-backend: mention v2 protocol
  http-backend: handle HTTP_GIT_PROTOCOL CGI variable
  t5551: test v2-to-v0 http protocol fallback

3 years agoMerge branch 'ab/gc-remove-unused-call'
Junio C Hamano [Thu, 23 Sep 2021 20:44:46 +0000 (13:44 -0700)] 
Merge branch 'ab/gc-remove-unused-call'

Code clean-up.

* ab/gc-remove-unused-call:
  gc: remove unused launchctl_get_uid() call

3 years agoMerge branch 'ab/test-tool-run-command-cleanup'
Junio C Hamano [Thu, 23 Sep 2021 20:44:46 +0000 (13:44 -0700)] 
Merge branch 'ab/test-tool-run-command-cleanup'

Code clean-up.

* ab/test-tool-run-command-cleanup:
  test-tool run-command: fix flip-flop init pattern

3 years agoMerge branch 'en/tests-cleanup-leftover-untracked'
Junio C Hamano [Thu, 23 Sep 2021 20:44:46 +0000 (13:44 -0700)] 
Merge branch 'en/tests-cleanup-leftover-untracked'

Test clean-up.

* en/tests-cleanup-leftover-untracked:
  tests: remove leftover untracked files

3 years agoMerge branch 'jk/strvec-typefix'
Junio C Hamano [Thu, 23 Sep 2021 20:44:46 +0000 (13:44 -0700)] 
Merge branch 'jk/strvec-typefix'

Correct nr and alloc members of strvec struct to be of type size_t.

* jk/strvec-typefix:
  strvec: use size_t to store nr and alloc

3 years agoMerge branch 'rs/drop-core-compression-vars'
Junio C Hamano [Thu, 23 Sep 2021 20:44:46 +0000 (13:44 -0700)] 
Merge branch 'rs/drop-core-compression-vars'

Code clean-up.

* rs/drop-core-compression-vars:
  compression: drop write-only core_compression_* variables

3 years agoMerge branch 'rs/packfile-bad-object-list-in-oidset'
Junio C Hamano [Thu, 23 Sep 2021 20:44:45 +0000 (13:44 -0700)] 
Merge branch 'rs/packfile-bad-object-list-in-oidset'

Replace a handcrafted data structure used to keep track of bad
objects in the packfile API by an oidset.

* rs/packfile-bad-object-list-in-oidset:
  packfile: use oidset for bad objects
  packfile: convert has_packed_and_bad() to object_id
  packfile: convert mark_bad_packed_object() to object_id
  midx: inline nth_midxed_pack_entry()
  oidset: make oidset_size() an inline function

3 years agoMerge branch 'en/am-abort-fix'
Junio C Hamano [Thu, 23 Sep 2021 20:44:45 +0000 (13:44 -0700)] 
Merge branch 'en/am-abort-fix'

When "git am --abort" fails to abort correctly, it still exited
with exit status of 0, which has been corrected.

* en/am-abort-fix:
  am: fix incorrect exit status on am fail to abort
  t4151: add a few am --abort tests
  git-am.txt: clarify --abort behavior

3 years agoMerge branch 'ps/update-ref-batch-flush'
Junio C Hamano [Thu, 23 Sep 2021 20:44:45 +0000 (13:44 -0700)] 
Merge branch 'ps/update-ref-batch-flush'

"git update-ref --stdin" failed to flush its output as needed,
which potentially led the conversation to a deadlock.

* ps/update-ref-batch-flush:
  t1400: avoid SIGPIPE race condition on fifo
  update-ref: fix streaming of status updates

3 years agoThe seventh batch
Junio C Hamano [Mon, 20 Sep 2021 22:09:44 +0000 (15:09 -0700)] 
The seventh batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'jk/t5562-racefix'
Junio C Hamano [Mon, 20 Sep 2021 22:20:46 +0000 (15:20 -0700)] 
Merge branch 'jk/t5562-racefix'

Test update.

* jk/t5562-racefix:
  t5562: use alarm() to interrupt timed child-wait

3 years agoMerge branch 'rs/no-mode-to-open-when-appending'
Junio C Hamano [Mon, 20 Sep 2021 22:20:45 +0000 (15:20 -0700)] 
Merge branch 'rs/no-mode-to-open-when-appending'

The "mode" word is useless in a call to open(2) that does not
create a new file.  Such a call in the files backend of the ref
subsystem has been cleaned up.

* rs/no-mode-to-open-when-appending:
  refs/files-backend: remove unused open mode parameter

3 years agoMerge branch 'rs/setup-use-xopen-and-xdup'
Junio C Hamano [Mon, 20 Sep 2021 22:20:45 +0000 (15:20 -0700)] 
Merge branch 'rs/setup-use-xopen-and-xdup'

Code clean-up.

* rs/setup-use-xopen-and-xdup:
  setup: use xopen and xdup in sanitize_stdfds

3 years agoMerge branch 'js/run-command-close-packs'
Junio C Hamano [Mon, 20 Sep 2021 22:20:45 +0000 (15:20 -0700)] 
Merge branch 'js/run-command-close-packs'

The run-command API has been updated so that the callers can easily
ask the file descriptors open for packfiles to be closed immediately
before spawning commands that may trigger auto-gc.

* js/run-command-close-packs:
  Close object store closer to spawning child processes
  run_auto_maintenance(): implicitly close the object store
  run-command: offer to close the object store before running
  run-command: prettify the `RUN_COMMAND_*` flags
  pull: release packs before fetching
  commit-graph: when closing the graph, also release the slab

3 years agoMerge branch 'ds/mergies-with-sparse-index'
Junio C Hamano [Mon, 20 Sep 2021 22:20:44 +0000 (15:20 -0700)] 
Merge branch 'ds/mergies-with-sparse-index'

Various mergy operations have been prepared to work efficiently
with the sparse index.

* ds/mergies-with-sparse-index:
  sparse-index: integrate with cherry-pick and rebase
  sequencer: ensure full index if not ORT strategy
  t1092: add cherry-pick, rebase tests
  merge-ort: expand only for out-of-cone conflicts
  merge: make sparse-aware with ORT
  diff: ignore sparse paths in diffstat

3 years agoMerge branch 'ds/sparse-index-ignored-files'
Junio C Hamano [Mon, 20 Sep 2021 22:20:44 +0000 (15:20 -0700)] 
Merge branch 'ds/sparse-index-ignored-files'

In cone mode, the sparse-index code path learned to remove ignored
files (like build artifacts) outside the sparse cone, allowing the
entire directory outside the sparse cone to be removed, which is
especially useful when the sparse patterns change.

* ds/sparse-index-ignored-files:
  sparse-checkout: clear tracked sparse dirs
  sparse-index: add SPARSE_INDEX_MEMORY_ONLY flag
  attr: be careful about sparse directories
  sparse-checkout: create helper methods
  sparse-index: use WRITE_TREE_MISSING_OK
  sparse-index: silently return when cache tree fails
  unpack-trees: fix nested sparse-dir search
  sparse-index: silently return when not using cone-mode patterns
  t7519: rewrite sparse index test

3 years agoMerge branch 'ar/submodule-run-update-procedure'
Junio C Hamano [Mon, 20 Sep 2021 22:20:44 +0000 (15:20 -0700)] 
Merge branch 'ar/submodule-run-update-procedure'

Reimplementation of parts of "git submodule" in C continues.

* ar/submodule-run-update-procedure:
  submodule--helper: run update procedures from C

3 years agoMerge branch 'ab/make-tags-cleanup'
Junio C Hamano [Mon, 20 Sep 2021 22:20:43 +0000 (15:20 -0700)] 
Merge branch 'ab/make-tags-cleanup'

Build clean-up for "make tags" and friends.

* ab/make-tags-cleanup:
  Makefile: normalize clobbering & xargs for tags targets
  Makefile: remove "cscope.out", not "cscope*" in cscope.out target
  Makefile: don't use "FORCE" for tags targets
  Makefile: add QUIET_GEN to "cscope" target
  Makefile: move ".PHONY: cscope" near its target

3 years agoMerge branch 'ab/serve-cleanup'
Junio C Hamano [Mon, 20 Sep 2021 22:20:43 +0000 (15:20 -0700)] 
Merge branch 'ab/serve-cleanup'

Code clean-up around "git serve".

* ab/serve-cleanup:
  upload-pack: document and rename --advertise-refs
  serve.[ch]: remove "serve_options", split up --advertise-refs code
  {upload,receive}-pack tests: add --advertise-refs tests
  serve.c: move version line to advertise_capabilities()
  serve: move transfer.advertiseSID check into session_id_advertise()
  serve.[ch]: don't pass "struct strvec *keys" to commands
  serve: use designated initializers
  transport: use designated initializers
  transport: rename "fetch" in transport_vtable to "fetch_refs"
  serve: mark has_capability() as static

3 years agoMerge branch 'ar/submodule-add-more'
Junio C Hamano [Mon, 20 Sep 2021 22:20:43 +0000 (15:20 -0700)] 
Merge branch 'ar/submodule-add-more'

More parts of "git submodule add" has been rewritten in C.

* ar/submodule-add-more:
  submodule--helper: rename compute_submodule_clone_url()
  submodule--helper: remove resolve-relative-url subcommand
  submodule--helper: remove add-config subcommand
  submodule--helper: remove add-clone subcommand
  submodule--helper: convert the bulk of cmd_add() to C
  dir: libify and export helper functions from clone.c
  submodule--helper: remove repeated code in sync_submodule()
  submodule--helper: refactor resolve_relative_url() helper
  submodule--helper: add options for compute_submodule_clone_url()

3 years agoMerge branch 'ar/submodule-add-config'
Junio C Hamano [Mon, 20 Sep 2021 22:20:42 +0000 (15:20 -0700)] 
Merge branch 'ar/submodule-add-config'

Large part of "git submodule add" gets rewritten in C.

* ar/submodule-add-config:
  submodule--helper: introduce add-config subcommand

3 years agoMerge branch 'ab/unbundle-progress'
Junio C Hamano [Mon, 20 Sep 2021 22:20:42 +0000 (15:20 -0700)] 
Merge branch 'ab/unbundle-progress'

Add progress display to "git bundle unbundle".

* ab/unbundle-progress:
  bundle: show progress on "unbundle"
  index-pack: add --progress-title option
  bundle API: change "flags" to be "extra_index_pack_args"
  bundle API: start writing API documentation

3 years agoMerge branch 'tb/pack-finalize-ordering'
Junio C Hamano [Mon, 20 Sep 2021 22:20:42 +0000 (15:20 -0700)] 
Merge branch 'tb/pack-finalize-ordering'

The order in which various files that make up a single (conceptual)
packfile has been reevaluated and straightened up.  This matters in
correctness, as an incomplete set of files must not be shown to a
running Git.

* tb/pack-finalize-ordering:
  pack-objects: rename .idx files into place after .bitmap files
  pack-write: split up finish_tmp_packfile() function
  builtin/index-pack.c: move `.idx` files into place last
  index-pack: refactor renaming in final()
  builtin/repack.c: move `.idx` files into place last
  pack-write.c: rename `.idx` files after `*.rev`
  pack-write: refactor renaming in finish_tmp_packfile()
  bulk-checkin.c: store checksum directly
  pack.h: line-wrap the definition of finish_tmp_packfile()

3 years agoMerge branch 'cb/pedantic-build-for-developers'
Junio C Hamano [Mon, 20 Sep 2021 22:20:41 +0000 (15:20 -0700)] 
Merge branch 'cb/pedantic-build-for-developers'

Update the build procedure to use the "-pedantic" build when
DEVELOPER makefile macro is in effect.

* cb/pedantic-build-for-developers:
  developer: enable pedantic by default
  win32: allow building with pedantic mode enabled
  gettext: remove optional non-standard parens in N_() definition

3 years agoMerge branch 'ab/progress-users-adjust-counters'
Junio C Hamano [Mon, 20 Sep 2021 22:20:41 +0000 (15:20 -0700)] 
Merge branch 'ab/progress-users-adjust-counters'

The code to show progress indicator in a few code paths did not
cover between 0-100%, which has been corrected.

* ab/progress-users-adjust-counters:
  entry: show finer-grained counter in "Filtering content" progress line
  commit-graph: fix bogus counter in "Scanning merged commits" progress line

3 years agoMerge branch 'dt/submodule-diff-fixes'
Junio C Hamano [Mon, 20 Sep 2021 22:20:41 +0000 (15:20 -0700)] 
Merge branch 'dt/submodule-diff-fixes'

"git diff --submodule=diff" showed failure from run_command() when
trying to run diff inside a submodule, when the user manually
removes the submodule directory.

* dt/submodule-diff-fixes:
  diff --submodule=diff: don't print failure message twice
  diff --submodule=diff: do not fail on ever-initialied deleted submodules
  t4060: remove unused variable

3 years agoMerge branch 'jv/pkt-line-batch'
Junio C Hamano [Mon, 20 Sep 2021 22:20:40 +0000 (15:20 -0700)] 
Merge branch 'jv/pkt-line-batch'

Reduce number of write(2) system calls while sending the
ref advertisement.

* jv/pkt-line-batch:
  upload-pack: use stdio in send_ref callbacks
  pkt-line: add stdio packet write functions

3 years agoMerge branch 'lh/systemd-timers'
Junio C Hamano [Mon, 20 Sep 2021 22:20:40 +0000 (15:20 -0700)] 
Merge branch 'lh/systemd-timers'

"git maintenance" scheduler learned to use systemd timers as a
possible backend.

* lh/systemd-timers:
  maintenance: add support for systemd timers on Linux
  maintenance: `git maintenance run` learned `--scheduler=<scheduler>`
  cache.h: Introduce a generic "xdg_config_home_for(…)" function

3 years agoMerge branch 'ab/tr2-leaks-and-fixes'
Junio C Hamano [Mon, 20 Sep 2021 22:20:40 +0000 (15:20 -0700)] 
Merge branch 'ab/tr2-leaks-and-fixes'

The tracing of process ancestry information has been enhanced.

* ab/tr2-leaks-and-fixes:
  tr2: log N parent process names on Linux
  tr2: do compiler enum check in trace2_collect_process_info()
  tr2: leave the parent list empty upon failure & don't leak memory
  tr2: stop leaking "thread_name" memory
  tr2: clarify TRACE2_PROCESS_INFO_EXIT comment under Linux
  tr2: remove NEEDSWORK comment for "non-procfs" implementations

3 years agoMerge branch 'jt/grep-wo-submodule-odb-as-alternate'
Junio C Hamano [Mon, 20 Sep 2021 22:20:39 +0000 (15:20 -0700)] 
Merge branch 'jt/grep-wo-submodule-odb-as-alternate'

The code to make "git grep" recurse into submodules has been
updated to migrate away from the "add submodule's object store as
an alternate object store" mechanism (which is suboptimal).

* jt/grep-wo-submodule-odb-as-alternate:
  t7814: show lack of alternate ODB-adding
  submodule-config: pass repo upon blob config read
  grep: add repository to OID grep sources
  grep: allocate subrepos on heap
  grep: read submodule entry with explicit repo
  grep: typesafe versions of grep_source_init
  grep: use submodule-ODB-as-alternate lazy-addition
  submodule: lazily add submodule ODBs as alternates

3 years agoMerge branch 'tb/multi-pack-bitmaps'
Junio C Hamano [Mon, 20 Sep 2021 22:20:39 +0000 (15:20 -0700)] 
Merge branch 'tb/multi-pack-bitmaps'

The reachability bitmap file used to be generated only for a single
pack, but now we've learned to generate bitmaps for history that
span across multiple packfiles.

* tb/multi-pack-bitmaps: (29 commits)
  pack-bitmap: drop bitmap_index argument from try_partial_reuse()
  pack-bitmap: drop repository argument from prepare_midx_bitmap_git()
  p5326: perf tests for MIDX bitmaps
  p5310: extract full and partial bitmap tests
  midx: respect 'GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP'
  t7700: update to work with MIDX bitmap test knob
  t5319: don't write MIDX bitmaps in t5319
  t5310: disable GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP
  t0410: disable GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP
  t5326: test multi-pack bitmap behavior
  t/helper/test-read-midx.c: add --checksum mode
  t5310: move some tests to lib-bitmap.sh
  pack-bitmap: write multi-pack bitmaps
  pack-bitmap: read multi-pack bitmaps
  pack-bitmap.c: avoid redundant calls to try_partial_reuse
  pack-bitmap.c: introduce 'bitmap_is_preferred_refname()'
  pack-bitmap.c: introduce 'nth_bitmap_object_oid()'
  pack-bitmap.c: introduce 'bitmap_num_objects()'
  midx: avoid opening multiple MIDXs when writing
  midx: close linked MIDXs, avoid leaking memory
  ...

3 years agoMerge branch 'ps/fetch-optim'
Junio C Hamano [Mon, 20 Sep 2021 22:20:39 +0000 (15:20 -0700)] 
Merge branch 'ps/fetch-optim'

Optimize code that handles large number of refs in the "git fetch"
code path.

* ps/fetch-optim:
  fetch: avoid second connectivity check if we already have all objects
  fetch: merge fetching and consuming refs
  fetch: refactor fetch refs to be more extendable
  fetch-pack: optimize loading of refs via commit graph
  connected: refactor iterator to return next object ID directly
  fetch: avoid unpacking headers in object existence check
  fetch: speed up lookup of want refs via commit-graph

3 years agomerge-ort: fix completely wrong comment
Elijah Newren [Sun, 19 Sep 2021 01:48:55 +0000 (01:48 +0000)] 
merge-ort: fix completely wrong comment

Not sure what happened, but the comment is describing code elsewhere in
the file.  Fix the comment to actually discuss the code that follows.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agotrace2.h: fix trivial comment typo
Elijah Newren [Sun, 19 Sep 2021 01:48:54 +0000 (01:48 +0000)] 
trace2.h: fix trivial comment typo

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agounicode: update the width tables to Unicode 14
Carlo Marcelo Arenas Belón [Fri, 17 Sep 2021 19:19:20 +0000 (12:19 -0700)] 
unicode: update the width tables to Unicode 14

Released[0] after a long beta period and including several additional
zero/double width characters.

[0] https://home.unicode.org/announcing-the-unicode-standard-version-14-0/

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot0000: avoid masking git exit value through pipes
Carlo Marcelo Arenas Belón [Thu, 16 Sep 2021 08:55:23 +0000 (01:55 -0700)] 
t0000: avoid masking git exit value through pipes

9af0b8dbe2 (t0000-basic: more commit-tree tests., 2006-04-26) adds
tests for commit-tree that mask the return exit from git as described
in a378fee5b07 (Documentation: add shell guidelines, 2018-10-05).

Fix the tests, to avoid pipes by using a temporary file instead.

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agotree-diff: fix leak when not HAVE_ALLOCA_H
Carlo Marcelo Arenas Belón [Thu, 16 Sep 2021 08:55:22 +0000 (01:55 -0700)] 
tree-diff: fix leak when not HAVE_ALLOCA_H

b8ba412bf7 (tree-diff: avoid alloca for large allocations, 2016-06-07)
adds a way to route some bigger allocations out of the stack and free
them through the addition of two conveniently named macros, but leaves
the calls to free the xalloca part, which could be also in the heap,
if the system doesn't HAVE_ALLOCA_H (ex: macOS and other BSD).

Add the missing free call, xalloca_free(), which is a noop if we
allocated memory in the stack frame, but a real free() if we
allocated in the heap instead, and while at it, change the expression
to match in both macros for ease of readability.

This avoids a leak reported by LSAN while running t0000 but that
wouldn't fail the test (which is fixed in the next patch):

  SUMMARY: LeakSanitizer: 1034 byte(s) leaked in 15 allocation(s).

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agopack-revindex.h: correct the time complexity descriptions
Kyle Zhao [Wed, 15 Sep 2021 09:09:23 +0000 (09:09 +0000)] 
pack-revindex.h: correct the time complexity descriptions

Time complexities for pack_pos_to_midx and midx_to_pack_pos are swapped,
correct it.

Signed-off-by: Kyle Zhao <kylezhao@tencent.com>
Reviewed-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoThe sixth batch
Junio C Hamano [Wed, 15 Sep 2021 20:15:09 +0000 (13:15 -0700)] 
The sixth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'jc/prefix-filename-allocates'
Junio C Hamano [Wed, 15 Sep 2021 20:15:28 +0000 (13:15 -0700)] 
Merge branch 'jc/prefix-filename-allocates'

Leakfix.

* jc/prefix-filename-allocates:
  hash-object: prefix_filename() returns allocated memory these days

3 years agoMerge branch 'rs/range-diff-avoid-segfault-with-I'
Junio C Hamano [Wed, 15 Sep 2021 20:15:27 +0000 (13:15 -0700)] 
Merge branch 'rs/range-diff-avoid-segfault-with-I'

"git range-diff -I... <range> <range>" segfaulted, which has been
corrected.

* rs/range-diff-avoid-segfault-with-I:
  range-diff: avoid segfault with -I

3 years agoMerge branch 'ab/reverse-midx-optim'
Junio C Hamano [Wed, 15 Sep 2021 20:15:27 +0000 (13:15 -0700)] 
Merge branch 'ab/reverse-midx-optim'

The code that optionally creates the *.rev reverse index file has
been optimized to avoid needless computation when it is not writing
the file out.

* ab/reverse-midx-optim:
  pack-write: skip *.rev work when not writing *.rev

3 years agoMerge branch 'bs/install-strip'
Junio C Hamano [Wed, 15 Sep 2021 20:15:26 +0000 (13:15 -0700)] 
Merge branch 'bs/install-strip'

"make INSTALL_STRIP=-s install" allows the installation step to use
"install -s" to strip the binaries as they get installed.

* bs/install-strip:
  make: add INSTALL_STRIP option variable

3 years agoMerge branch 'pb/test-use-user-env'
Junio C Hamano [Wed, 15 Sep 2021 20:15:26 +0000 (13:15 -0700)] 
Merge branch 'pb/test-use-user-env'

Teach "test_pause" and "debug" helpers to allow using the HOME and
TERM environment variables the user usually uses.

* pb/test-use-user-env:
  test-lib-functions: keep user's debugger config files and TERM in 'debug'
  test-lib-functions: optionally keep HOME, TERM and SHELL in 'test_pause'
  test-lib-functions: use 'TEST_SHELL_PATH' in 'test_pause'

3 years agoMerge branch 'jc/trivial-threeway-binary-merge'
Junio C Hamano [Wed, 15 Sep 2021 20:15:26 +0000 (13:15 -0700)] 
Merge branch 'jc/trivial-threeway-binary-merge'

The "git apply -3" code path learned not to bother the lower level
merge machinery when the three-way merge can be trivially resolved
without the content level merge.

* jc/trivial-threeway-binary-merge:
  apply: resolve trivial merge without hitting ll-merge with "--3way"

3 years agoMerge branch 'bs/doc-bugreport-outdir'
Junio C Hamano [Wed, 15 Sep 2021 20:15:25 +0000 (13:15 -0700)] 
Merge branch 'bs/doc-bugreport-outdir'

Docfix.

* bs/doc-bugreport-outdir:
  Documentation: fix default directory of git bugreport -o

3 years agoMerge branch 'ab/no-more-check-bindir'
Junio C Hamano [Wed, 15 Sep 2021 20:15:25 +0000 (13:15 -0700)] 
Merge branch 'ab/no-more-check-bindir'

Build simplification.

* ab/no-more-check-bindir:
  Makefile: remove the check_bindir script

3 years agoMerge branch 'ab/send-email-config-fix'
Junio C Hamano [Wed, 15 Sep 2021 20:15:24 +0000 (13:15 -0700)] 
Merge branch 'ab/send-email-config-fix'

Regression fix.

* ab/send-email-config-fix:
  send-email: fix a "first config key wins" regression in v2.33.0

3 years agoMerge branch 'so/diff-index-regression-fix'
Junio C Hamano [Wed, 15 Sep 2021 20:15:24 +0000 (13:15 -0700)] 
Merge branch 'so/diff-index-regression-fix'

Recent "diff -m" changes broke "gitk", which has been corrected.

* so/diff-index-regression-fix:
  diff-index: restore -c/--cc options handling

3 years agot1400: avoid SIGPIPE race condition on fifo
Jeff King [Wed, 15 Sep 2021 17:24:52 +0000 (13:24 -0400)] 
t1400: avoid SIGPIPE race condition on fifo

t1400.190 sometimes fails or even hangs because of the way it uses
fifos. Our goal is to interactively read and write lines from
update-ref, so we have two fifos, in and out. We open a descriptor
connected to "in" and redirect output to that, so that update-ref does
not see EOF as it would if we opened and closed it for each "echo" call.

But we don't do the same for the output. This leads to a race where our
"read response <out" has not yet opened the fifo, but update-ref tries
to write to it and gets SIGPIPE. This can result in the test failing, or
worse, hanging as we wait forever for somebody to write to the pipe.

This is the same proble we fixed in 4783e7ea83 (t0008: avoid SIGPIPE
race condition on fifo, 2013-07-12), and we can fix it the same way, by
opening a second long-running descriptor.

Before this patch, running:

  ./t1400-update-ref.sh --run=1,190 --stress

failed or hung within a few dozen iterations. After it, I ran it for
several hundred without problems.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agosubmodule: extract path to submodule gitdir func
Jonathan Tan [Wed, 15 Sep 2021 18:59:19 +0000 (11:59 -0700)] 
submodule: extract path to submodule gitdir func

We currently store each submodule gitdir in ".git/modules/<name>", but
this has problems with some submodule naming schemes, as described in a
comment in submodule_name_to_gitdir() in this patch.

Extract the determination of the location of a submodule's gitdir into
its own function submodule_name_to_gitdir(). For now, the problem
remains unsolved, but this puts us in a better position for finding a
solution.

This was motivated, at $DAYJOB, by a part of Android's repo hierarchy
[1]. In particular, there is a repo "build", and several repos of the
form "build/<name>".

This is based on earlier work by Brandon Williams [2].

[1] https://android.googlesource.com/platform/
[2] https://lore.kernel.org/git/20180808223323.79989-2-bmwill@google.com/

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agols-refs: reject unknown arguments
Jeff King [Wed, 15 Sep 2021 18:36:38 +0000 (14:36 -0400)] 
ls-refs: reject unknown arguments

The v2 ls-refs command may receive extra arguments from the client, one
per pkt-line. The spec is pretty clear that the arguments must come from
a specified set, but we silently ignore any unknown entries. For a
well-behaved client this doesn't matter, but it makes testing and
debugging more confusing. Let's tighten this up to match the spec.

In theory this liberal behavior _could_ be useful for extending the
protocol. But:

  - every other part of the protocol requires that the server first
    indicate that it supports the argument; this includes the fetch and
    object-info commands, plus the "unborn" capability added to ls-refs
    itself

  - it's not a very good extension mechanism anyway; without the server
    advertising support, clients would have no idea if the argument was
    silently ignored, or accepted and simply had no effect

So we're not really losing anything by tightening this.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoserve: reject commands used as capabilities
Jeff King [Wed, 15 Sep 2021 18:36:36 +0000 (14:36 -0400)] 
serve: reject commands used as capabilities

Our table of v2 "capabilities" contains everything we might tell the
client we support. But there are differences in how we expect the client
to respond. Some of the entries are true capabilities (i.e., we expect
the client to say "yes, I support this"), and some are ones we expect
them to send as commands (with "command=ls-refs" or similar).

When we receive a capability used as a command, we complain about that.
But when we receive a command used as a capability (e.g., just "ls-refs"
in a pkt-line by itself), we silently ignore it.

This isn't really hurting anything (clients shouldn't send it, and we'll
ignore it), but we can tighten up the protocol to match what we expect
to happen.

There are two new tests here. The first one checks a capability used as
a command, which already passes. The second tests a command as a
capability, which this patch fixes.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoserve: reject bogus v2 "command=ls-refs=foo"
Jeff King [Wed, 15 Sep 2021 18:36:33 +0000 (14:36 -0400)] 
serve: reject bogus v2 "command=ls-refs=foo"

When we see a line from the client like "command=ls-refs", we parse
everything after the equals sign as a capability, which we check against
our capabilities table. If we don't recognize the command (e.g.,
"command=foo"), we'll reject it.

But in parse_command(), we use the same get_capability() parser for
parsing non-command lines. So if we see "command=ls-refs=foo", we will
feed "ls-refs=foo" to get_capability(), which will say "OK, that's
ls-refs, with value 'foo'". But then we simply ignore the value
entirely.

The client is violating the spec here, which says:

      command = PKT-LINE("command=" key LF)
      key = 1*(ALPHA | DIGIT | "-_")

I.e., the key is not even allowed to have an equals sign in it. Whereas
a real non-command capability does allow a value:

      capability = PKT-LINE(key[=value] LF)

So by reusing the same get_capability() parser, we are mixing up the
"key" and "capability" tokens. However, since that parser tells us
whether it saw an "=", we can still use it; we just need to reject any
input that produces a non-NULL value field.

The current behavior isn't really hurting anything (the client should
never send such a request, and if it does, we just ignore the "value"
part). But since it does violate the spec, let's tighten it up to
prevent any surprising behavior.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agodocs/protocol-v2: clarify some ls-refs ref-prefix details
Jeff King [Wed, 15 Sep 2021 18:35:34 +0000 (14:35 -0400)] 
docs/protocol-v2: clarify some ls-refs ref-prefix details

We've never documented the fact that a client can provide multiple
ref-prefix capabilities. Let's describe the behavior.

We also never discussed the "best effort" nature of the prefixes. The
client side of git.git has always treated them this way, filtering the
result with local patterns. And indeed any client must do this, because
the prefix patterns are not sufficient to express the usual refspecs
(and so for "foo" we ask for "refs/heads/foo", "refs/tags/foo", and so
on).

So this may be considered a change in the spec with respect to client
expectations / requirements, but it's mostly codifying existing
behavior.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agols-refs: ignore very long ref-prefix counts
Jeff King [Wed, 15 Sep 2021 18:35:31 +0000 (14:35 -0400)] 
ls-refs: ignore very long ref-prefix counts

Because each "ref-prefix" capability from the client comes in its own
pkt-line, there's no limit to the number of them that a misbehaving
client may send. We read them all into a strvec, which means the client
can waste arbitrary amounts of our memory by just sending us "ref-prefix
foo" over and over.

One possible solution is to just drop the connection when the limit is
reached. If we set it high enough, then only misbehaving or malicious
clients would hit it. But "high enough" is vague, and it's unfriendly if
we guess wrong and a legitimate client hits this.

But we can do better. Since supporting the ref-prefix capability is
optional anyway, the client has to further cull the response based on
their own patterns. So we can simply ignore the patterns once we cross a
certain threshold. Note that we have to ignore _all_ patterns, not just
the ones past our limit (since otherwise we'd send too little data).

The limit here is fairly arbitrary, and probably much higher than anyone
would need in practice. It might be worth limiting it further, if only
because we check it linearly (so with "m" local refs and "n" patterns,
we do "m * n" string comparisons). But if we care about optimizing this,
an even better solution may be a more advanced data structure anyway.

I didn't bother making the limit configurable, since it's so high and
since Git should behave correctly in either case. It wouldn't be too
hard to do, but it makes both the code and documentation more complex.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoserve: drop "keys" strvec
Jeff King [Wed, 15 Sep 2021 18:35:29 +0000 (14:35 -0400)] 
serve: drop "keys" strvec

We collect the set of capabilities the client sends us in a strvec.
While this is usually small, there's no limit to the number of
capabilities the client can send us (e.g., they could just send us
"agent" pkt-lines over and over, and we'd keep adding them to the list).

Since all code has been converted away from using this list, let's get
rid of it. This avoids a potential attack where clients waste our
memory.

Note that we do have to replace it with a flag, because some of the
flush-packet logic checks whether we've seen any valid commands or keys.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoserve: provide "receive" function for session-id capability
Jeff King [Tue, 14 Sep 2021 23:51:30 +0000 (19:51 -0400)] 
serve: provide "receive" function for session-id capability

Rather than pulling the session-id string from the list of collected
capabilities, we can handle it as soon as we receive it. This gets us
closer to dropping the collected list entirely.

The behavior should be the same, with one exception. Previously if the
client sent us multiple session-id lines, we'd report only the first.
Now we'll pass each one along to trace2. This shouldn't matter in
practice, since clients shouldn't do that (and if they do, it's probably
sensible to log them all).

As this removes the last caller of the static has_capability(), we can
remove it, as well (and in fact we must to avoid -Wunused-function
complaining).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoserve: provide "receive" function for object-format capability
Jeff King [Tue, 14 Sep 2021 23:51:27 +0000 (19:51 -0400)] 
serve: provide "receive" function for object-format capability

We get any "object-format" specified by the client by searching for it
in the collected list of capabilities the client sent. We can instead
just handle it as soon as they send it. This is slightly more efficient,
and gets us one step closer to dropping that collected list.

Note that we do still have to do our final hash check after receiving
all capabilities (because they might not have sent an object-format line
at all, and we still have to check that the default matches our
repository algorithm). Since the check_algorithm() function would now be
down to a single if() statement, I've just inlined it in its only
caller.

There should be no change of behavior here, except for two
broken-protocol cases:

  - if the client sends multiple conflicting object-format capabilities
    (which they should not), we'll now choose the last one rather than
    the first. We could also detect and complain about the duplicates
    quite easily now, which we could not before, but I didn't do so
    here.

  - if the client sends a bogus "object-format" with no equals sign,
    we'll now say so, rather than "unknown object format: ''"

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoserve: add "receive" method for v2 capabilities table
Jeff King [Tue, 14 Sep 2021 15:31:07 +0000 (11:31 -0400)] 
serve: add "receive" method for v2 capabilities table

We have a capabilities table that tells us what we should tell the
client we are capable of, and what to do when a client gives us a
particular command (e.g., "command=ls-refs"). But it doesn't tell us
what to do when the client sends us back a capability (e.g.,
"object-format=sha256"). We just collect them all in a strvec and hope
somebody can use them later.

Instead, let's provide a function pointer in the table to act on these.
This will eventually help us avoid collecting the strings, which will be
more efficient and less prone to mischief.

Using the new method is optional, which helps in two ways:

  - we can move existing capabilities over to this new system gradually
    in individual commits

  - some capabilities we don't actually do anything with anyway. For
    example, the client is free to say "agent=git/1.2.3" to us, but we
    do not act on the information in any way.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoserve: return capability "value" from get_capability()
Jeff King [Tue, 14 Sep 2021 15:30:50 +0000 (11:30 -0400)] 
serve: return capability "value" from get_capability()

When the client sends v2 capabilities, they may be simple, like:

  foo

or have a value like:

  foo=bar

(all of the current capabilities actually expect a value, but the
protocol allows for boolean ones).

We use get_capability() to make sure the client's pktline matches a
capability. In doing so, we parse enough to see the "=" and the value
(if any), but we immediately forget it. Nobody cares for now, because they end
up parsing the values out later using has_capability(). But in
preparation for changing that, let's pass back a pointer so the callers
know what we found.

Note that unlike has_capability(), we'll return NULL for a "simple"
capability. Distinguishing these will be useful for some future patches.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoserve: rename is_command() to parse_command()
Jeff King [Tue, 14 Sep 2021 15:30:20 +0000 (11:30 -0400)] 
serve: rename is_command() to parse_command()

The is_command() function not only tells us whether the pktline is a
valid command string, but it also parses out the command (and complains
if we see a duplicate). Let's rename it to make those extra functions
a bit more obvious.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'ab/serve-cleanup' into jk/reduce-malloc-in-v2-servers
Junio C Hamano [Tue, 14 Sep 2021 17:56:05 +0000 (10:56 -0700)] 
Merge branch 'ab/serve-cleanup' into jk/reduce-malloc-in-v2-servers

* ab/serve-cleanup:
  upload-pack: document and rename --advertise-refs
  serve.[ch]: remove "serve_options", split up --advertise-refs code
  {upload,receive}-pack tests: add --advertise-refs tests
  serve.c: move version line to advertise_capabilities()
  serve: move transfer.advertiseSID check into session_id_advertise()
  serve.[ch]: don't pass "struct strvec *keys" to commands
  serve: use designated initializers
  transport: use designated initializers
  transport: rename "fetch" in transport_vtable to "fetch_refs"
  serve: mark has_capability() as static

3 years agodocumentation: add documentation for 'git version'
Matthias Aßhauer [Tue, 14 Sep 2021 13:27:18 +0000 (13:27 +0000)] 
documentation: add documentation for 'git version'

While 'git version' is probably the least complex git command,
it is a non-experimental user-facing builtin command. As such
it should have a help page.

Both `git help` and `git version` can be called as options
(`--help`/`--version`) that internally get converted to the
corresponding command. Add a small paragraph to
Documentation/git.txt describing how these two options
interact with each other and link to this help page for the
sub-options that `--version` can take. Well, currently there
is only one sub-option, but that could potentially increase
in future versions of Git.

Signed-off-by: Matthias Aßhauer <mha1993@live.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agohelp: make sure local html page exists before calling external processes
Matthias Aßhauer [Tue, 14 Sep 2021 13:27:17 +0000 (13:27 +0000)] 
help: make sure local html page exists before calling external processes

We check that git.html exists, regardless of the page the user wants to open.
Checking whether the requested page exists instead gives us a smoother user
experience in two use cases:

1) The requested page doesn't exist

When calling a git command and there is an error, most users reasonably expect
git to produce an error message on the standard error stream, but in this case
we pass the filepath to git web--browse which passes it on to a browser (or a
helper program like xdg-open or start that should in turn open a browser)
without any error and many GUI based browsers or helpers won't output such a
message onto the standard error stream.

Especially the helper programs tend to show the corresponding error message in
a message box and wait for user input before exiting. This leaves users in
interactive console sessions without an error message in their console,
without a console prompt and without the help page they expected.

2) git.html is missing for some reason, but the user asked for some other page

We currently refuse to show any local html help page when we can't find
git.html. Even if the requested help page exists. If we check for the requested
page instead, we can show the user all available pages and only error out on
those that don't exist.

Signed-off-by: Matthias Aßhauer <mha1993@live.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agogit-compat-util: include declaration for unix sockets in windows
Carlo Marcelo Arenas Belón [Tue, 14 Sep 2021 07:26:00 +0000 (00:26 -0700)] 
git-compat-util: include declaration for unix sockets in windows

Available since Windows 10 release 1803 and Windows Server 2019.

NO_UNIX_SOCKETS is still the default for Windows builds, as they need
to keep backward compatibility with releases up to Windows 7, but allow
including the header otherwise.

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocredential-cache: check for windows specific errors
Carlo Marcelo Arenas Belón [Tue, 14 Sep 2021 07:25:59 +0000 (00:25 -0700)] 
credential-cache: check for windows specific errors

Connect and reset errors aren't what will be expected by POSIX but
are instead compatible with the ones used by WinSock.

To avoid any possibility of confusion with other systems, checks
for disconnection and availability had been abstracted into helper
functions that are platform specific.

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot0301: fixes for windows compatibility
Carlo Marcelo Arenas Belón [Tue, 14 Sep 2021 07:25:58 +0000 (00:25 -0700)] 
t0301: fixes for windows compatibility

In preparation for a future patch that will allow building with
Unix Sockets in Windows, workaround a couple of issues from the
Mingw-W64 compatibility layer.

test -S is not able to detect that a file is a socket, so use
test -e instead (through a library function).

`mkdir -m` can't represent a valid ACL directly and fails with
permission problems, so instead call mkdir followed by chmod, which
has been enhanced to do so.

The last invocation of mkdir would likely need the same treatment
but SYMLINK is unlikely to be enabled on Windows so it has been
punted for now.

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agodoc: config, tell readers of `git help --config`
Philip Oakley [Mon, 13 Sep 2021 21:23:05 +0000 (22:23 +0100)] 
doc: config, tell readers of `git help --config`

The `git help` command gained the ability to list config variables in
3ac68a93fd (help: add --config to list all available config, 2018-05-26)
but failed to tell readers of the config documenation itself.

Provide that cross reference.

Signed-off-by: Philip Oakley <philipoakley@iee.email>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agobisect--helper: retire `--bisect-next-check` subcommand
Miriam Rubio [Mon, 13 Sep 2021 17:39:04 +0000 (19:39 +0200)] 
bisect--helper: retire `--bisect-next-check` subcommand

After reimplementation of `git bisect run` in C,
`--bisect-next-check` subcommand is not needed anymore.

Let's remove it from options list and code.

Mentored by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Miriam Rubio <mirucam@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agobisect--helper: reimplement `bisect_run` shell function in C
Tanushree Tumane [Mon, 13 Sep 2021 17:39:03 +0000 (19:39 +0200)] 
bisect--helper: reimplement `bisect_run` shell function in C

Reimplement the `bisect_run()` shell function
in C and also add `--bisect-run` subcommand to
`git bisect--helper` to call it from git-bisect.sh.

Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Tanushree Tumane <tanushreetumane@gmail.com>
Signed-off-by: Miriam Rubio <mirucam@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agobisect--helper: reimplement `bisect_visualize()` shell function in C
Pranit Bauva [Mon, 13 Sep 2021 17:39:02 +0000 (19:39 +0200)] 
bisect--helper: reimplement `bisect_visualize()` shell function in C

Reimplement the `bisect_visualize()` shell function
in C and also add `--bisect-visualize` subcommand to
`git bisect--helper` to call it from git-bisect.sh.

Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Mentored-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Tanushree Tumane <tanushreetumane@gmail.com>
Signed-off-by: Miriam Rubio <mirucam@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorun-command: make `exists_in_PATH()` non-static
Pranit Bauva [Mon, 13 Sep 2021 17:39:01 +0000 (19:39 +0200)] 
run-command: make `exists_in_PATH()` non-static

Remove the `static` keyword from `exists_in_PATH()` function
and declare the function in `run-command.h` file.
The function will be used in bisect_visualize() in a later
commit.

Mentored by: Christian Couder <chriscool@tuxfamily.org>
Mentored by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Tanushree Tumane <tanushreetumane@gmail.com>
Signed-off-by: Miriam Rubio <mirucam@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot6030-bisect-porcelain: add test for bisect visualize
Miriam Rubio [Mon, 13 Sep 2021 17:39:00 +0000 (19:39 +0200)] 
t6030-bisect-porcelain: add test for bisect visualize

Add a test to control breakages in bisect visualize command.

Signed-off-by: Miriam Rubio <mirucam@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot6030-bisect-porcelain: add tests to control bisect run exit cases
Miriam Rubio [Mon, 13 Sep 2021 17:38:59 +0000 (19:38 +0200)] 
t6030-bisect-porcelain: add tests to control bisect run exit cases

There is a gap on bisect run test coverage related with error exits.
Add two tests to control these error cases.

Signed-off-by: Miriam Rubio <mirucam@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agohttp: don't hardcode the value of CURL_SOCKOPT_OK
Ævar Arnfjörð Bjarmason [Mon, 13 Sep 2021 14:51:29 +0000 (16:51 +0200)] 
http: don't hardcode the value of CURL_SOCKOPT_OK

Use the new git-curl-compat.h header to define CURL_SOCKOPT_OK to its
known value if we're on an older curl version that doesn't have it. It
was hardcoded in http.c in a15d069a198 (http: enable keepalive on TCP
sockets, 2013-10-12).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agohttp: centralize the accounting of libcurl dependencies
Ævar Arnfjörð Bjarmason [Mon, 13 Sep 2021 14:51:28 +0000 (16:51 +0200)] 
http: centralize the accounting of libcurl dependencies

As discussed in 644de29e220 (http: drop support for curl < 7.19.4,
2021-07-30) checking against LIBCURL_VERSION_NUM isn't as reliable as
checking specific symbols present in curl, as some distros have been
known to backport features.

However, while some of the curl_easy_setopt() arguments we rely on are
macros, others are enum, and we can't assume that those that are
macros won't change into enums in the future.

So we're still going to have to check LIBCURL_VERSION_NUM, but by
doing that in one central place and using a macro definition of our
own, anyone who's backporting features can define it themselves, and
thus have access to more modern curl features that they backported,
even if they didn't bump the LIBCURL_VERSION_NUM.

More importantly, as shown in a preceding commit doing these version
checks makes for hard to read and possibly buggy code, as shown by the
bug fixed there where we were conflating base 10 for base 16 when
comparing the version.

By doing them all in one place we'll hopefully reduce the chances of
such future mistakes, furthermore it now becomes easier to see at a
glance what the oldest supported version is, which makes it easier to
reason about any future deprecation similar to the recent
e48a623dea0 (Merge branch 'ab/http-drop-old-curl', 2021-08-24).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agohttp: correct curl version check for CURLOPT_PINNEDPUBLICKEY
Ævar Arnfjörð Bjarmason [Mon, 13 Sep 2021 14:51:27 +0000 (16:51 +0200)] 
http: correct curl version check for CURLOPT_PINNEDPUBLICKEY

In aeff8a61216 (http: implement public key pinning, 2016-02-15) a
dependency and warning() was added if curl older than 7.44.0 was used,
but the relevant code depended on CURLOPT_PINNEDPUBLICKEY, introduced
in 7.39.0.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agohttp: correct version check for CURL_HTTP_VERSION_2
Ævar Arnfjörð Bjarmason [Mon, 13 Sep 2021 14:51:26 +0000 (16:51 +0200)] 
http: correct version check for CURL_HTTP_VERSION_2

In d73019feb44 (http: add support selecting http version, 2018-11-08)
a dependency was added on CURL_HTTP_VERSION_2, but this feature was
introduced in curl version 7.43.0, not 7.47.0, as the incorrect
version check led us to believe.

As looking through the history of that commit on the mailing list will
reveal[1], the reason for this is that an earlier version of it
depended on CURL_HTTP_VERSION_2TLS, which was introduced in libcurl
7.47.0.

But the version that made it in in d73019feb44 had dropped the
dependency on CURL_HTTP_VERSION_2TLS, but the corresponding version
check was not corrected.

The newest symbol we depend on is CURL_HTTP_VERSION_2. It was added in
7.33.0, but the CURL_HTTP_VERSION_2 alias we used was added in
7.47.0. So we could support an even older version here, but let's just
correct the checked version.

1. https://lore.kernel.org/git/pull.69.git.gitgitgadget@gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agohttp: drop support for curl < 7.18.0 (again)
Ævar Arnfjörð Bjarmason [Mon, 13 Sep 2021 14:51:25 +0000 (16:51 +0200)] 
http: drop support for curl < 7.18.0 (again)

In 644de29e220 (http: drop support for curl < 7.19.4, 2021-07-30) we
dropped support for curl < 7.19.4, so we can drop support for this
non-obvious dependency on curl < 7.18.0.

It's non-obvious because in curl's hex version notation 0x071800 is
version 7.24.0, *not* 7.18.0, so at a glance this patch looks
incorrect.

But it's correct, because the existing version check being removed
here is wrong. The check guards use of the following curl defines:

    CURLPROXY_SOCKS4                7.10
    CURLPROXY_SOCKS4A               7.18.0
    CURLPROXY_SOCKS5                7.10
    CURLPROXY_SOCKS5_HOSTNAME       7.18.0

I.e. the oldest version that has these is in fact 7.18.0, not
7.24.0. That we were checking 7.24.0 is just an mistake in
6d7afe07f29 (remote-http(s): support SOCKS proxies, 2015-10-26),
i.e. its author confusing base 10 and base 16.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMakefile: drop support for curl < 7.9.8 (again)
Ævar Arnfjörð Bjarmason [Mon, 13 Sep 2021 14:51:24 +0000 (16:51 +0200)] 
Makefile: drop support for curl < 7.9.8 (again)

In 1119a15b5c8 (http: drop support for curl < 7.11.1, 2021-07-30)
support for curl versions older than 7.11.1 was removed, and we
currently require at least version 7.19.4, see 644de29e220 (http: drop
support for curl < 7.19.4, 2021-07-30).

In those changes this Makefile-specific check added in
0890098780f (Decide whether to build http-push in the Makefile,
2005-11-18) was missed, now that we're never going to use such an
ancient curl version we don't need to check that we have at least
7.9.8 here. I have no idea what in http-push.c broke on versions older
than that.

This does not impact "NO_CURL" setups, as this is in the "else" branch
after that check.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoINSTALL: mention that we need libcurl 7.19.4 or newer to build
Ævar Arnfjörð Bjarmason [Mon, 13 Sep 2021 14:51:23 +0000 (16:51 +0200)] 
INSTALL: mention that we need libcurl 7.19.4 or newer to build

Without NO_CURL=Y we require at least version "7.19.4" of libcurl, see
644de29e220 (http: drop support for curl < 7.19.4, 2021-07-30). Let's
document this in the "INSTALL" document.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>