]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
2 years agoMerge branch 'gc/doc-first-contribution-reroll'
Junio C Hamano [Wed, 6 Oct 2021 20:40:12 +0000 (13:40 -0700)] 
Merge branch 'gc/doc-first-contribution-reroll'

Doc update.

* gc/doc-first-contribution-reroll:
  MyFirstContribution: Document --range-diff option when writing v2

2 years agoMerge branch 'pw/rebase-reread-todo-after-editing'
Junio C Hamano [Wed, 6 Oct 2021 20:40:12 +0000 (13:40 -0700)] 
Merge branch 'pw/rebase-reread-todo-after-editing'

The code to re-read the edited todo list in "git rebase -i" was
made more robust.

* pw/rebase-reread-todo-after-editing:
  rebase: fix todo-list rereading
  sequencer.c: factor out a function

2 years agoMerge branch 'ew/midx-doc-update'
Junio C Hamano [Wed, 6 Oct 2021 20:40:12 +0000 (13:40 -0700)] 
Merge branch 'ew/midx-doc-update'

Doc tweak.

* ew/midx-doc-update:
  doc/technical: update note about core.multiPackIndex

2 years agoMerge branch 'ab/repo-settings-cleanup'
Junio C Hamano [Wed, 6 Oct 2021 20:40:11 +0000 (13:40 -0700)] 
Merge branch 'ab/repo-settings-cleanup'

Code cleanup.

* ab/repo-settings-cleanup:
  repository.h: don't use a mix of int and bitfields
  repo-settings.c: simplify the setup
  read-cache & fetch-negotiator: check "enum" values in switch()
  environment.c: remove test-specific "ignore_untracked..." variable
  wrapper.c: add x{un,}setenv(), and use xsetenv() in environment.c

2 years agoMerge branch 'jk/grep-haystack-is-read-only'
Junio C Hamano [Wed, 6 Oct 2021 20:40:11 +0000 (13:40 -0700)] 
Merge branch 'jk/grep-haystack-is-read-only'

Code clean-up in the "grep" machinery.

* jk/grep-haystack-is-read-only:
  grep: store grep_source buffer as const
  grep: mark "haystack" buffers as const
  grep: stop modifying buffer in grep_source_1()
  grep: stop modifying buffer in show_line()
  grep: stop modifying buffer in strip_timestamp

2 years agoMerge branch 'tb/commit-graph-usage-fix'
Junio C Hamano [Wed, 6 Oct 2021 20:40:11 +0000 (13:40 -0700)] 
Merge branch 'tb/commit-graph-usage-fix'

Regression in "git commit-graph" command line parsing has been
corrected.

* tb/commit-graph-usage-fix:
  builtin/multi-pack-index.c: disable top-level --[no-]progress
  builtin/commit-graph.c: don't accept common --[no-]progress

2 years agoMerge branch 'pw/rebase-of-a-tag-fix'
Junio C Hamano [Wed, 6 Oct 2021 20:40:11 +0000 (13:40 -0700)] 
Merge branch 'pw/rebase-of-a-tag-fix'

"git rebase <upstream> <tag>" failed when aborted in the middle, as
it mistakenly tried to write the tag object instead of peeling it
to HEAD.

* pw/rebase-of-a-tag-fix:
  rebase: dereference tags
  rebase: use lookup_commit_reference_by_name()
  rebase: use our standard error return value
  t3407: rework rebase --quit tests
  t3407: strengthen rebase --abort tests
  t3407: use test_path_is_missing
  t3407: rename a variable
  t3407: use test_cmp_rev
  t3407: use test_commit
  t3407: run tests in $TEST_DIRECTORY

2 years agoMerge branch 'jt/add-submodule-odb-clean-up'
Junio C Hamano [Wed, 6 Oct 2021 20:40:10 +0000 (13:40 -0700)] 
Merge branch 'jt/add-submodule-odb-clean-up'

More code paths that use the hack to add submodule's object
database to the set of alternate object store have been cleaned up.

* jt/add-submodule-odb-clean-up:
  revision: remove "submodule" from opt struct
  repository: support unabsorbed in repo_submodule_init
  submodule: remove unnecessary unabsorbed fallback

2 years agoThe tenth batch
Junio C Hamano [Mon, 4 Oct 2021 04:49:43 +0000 (21:49 -0700)] 
The tenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMerge branch 'ah/connect-parse-feature-v0-fix'
Junio C Hamano [Mon, 4 Oct 2021 04:49:21 +0000 (21:49 -0700)] 
Merge branch 'ah/connect-parse-feature-v0-fix'

Protocol v0 clients can get stuck parsing a malformed feature line.

* ah/connect-parse-feature-v0-fix:
  connect: also update offset for features without values

2 years agoMerge branch 'ab/make-compdb-fix'
Junio C Hamano [Mon, 4 Oct 2021 04:49:21 +0000 (21:49 -0700)] 
Merge branch 'ab/make-compdb-fix'

Build update.

* ab/make-compdb-fix:
  Makefile: pass -Wno-pendantic under GENERATE_COMPILATION_DATABASE=yes

2 years agoMerge branch 'bs/difftool-msg-tweak'
Junio C Hamano [Mon, 4 Oct 2021 04:49:21 +0000 (21:49 -0700)] 
Merge branch 'bs/difftool-msg-tweak'

Message tweak.

* bs/difftool-msg-tweak:
  difftool: fix word spacing in the usage strings

2 years agoMerge branch 'rs/close-pack-leakfix'
Junio C Hamano [Mon, 4 Oct 2021 04:49:20 +0000 (21:49 -0700)] 
Merge branch 'rs/close-pack-leakfix'

Leakfix.

* rs/close-pack-leakfix:
  packfile: release bad_objects in close_pack()

2 years agoMerge branch 'ab/bundle-remove-verbose-option'
Junio C Hamano [Mon, 4 Oct 2021 04:49:20 +0000 (21:49 -0700)] 
Merge branch 'ab/bundle-remove-verbose-option'

Doc update.

* ab/bundle-remove-verbose-option:
  bundle: remove ignored & undocumented "--verbose" flag

2 years agoMerge branch 'ab/auto-depend-with-pedantic'
Junio C Hamano [Mon, 4 Oct 2021 04:49:20 +0000 (21:49 -0700)] 
Merge branch 'ab/auto-depend-with-pedantic'

Improve build procedure for developers.

* ab/auto-depend-with-pedantic:
  Makefile: make COMPUTE_HEADER_DEPENDENCIES=auto work with DEVOPTS=pedantic

2 years agoMerge branch 'ab/make-clean-depend-dirs'
Junio C Hamano [Mon, 4 Oct 2021 04:49:19 +0000 (21:49 -0700)] 
Merge branch 'ab/make-clean-depend-dirs'

"make clean" has been updated to remove leftover .depend/
directories, even when it is not told to use them to compute header
dependencies.

* ab/make-clean-depend-dirs:
  Makefile: clean .depend dirs under COMPUTE_HEADER_DEPENDENCIES != yes

2 years agoMerge branch 'ds/perf-test-built-path-fix'
Junio C Hamano [Mon, 4 Oct 2021 04:49:19 +0000 (21:49 -0700)] 
Merge branch 'ds/perf-test-built-path-fix'

Perf test fix.

* ds/perf-test-built-path-fix:
  t/perf/run: fix bin-wrappers computation

2 years agoMerge branch 'jk/http-redact-fix'
Junio C Hamano [Mon, 4 Oct 2021 04:49:19 +0000 (21:49 -0700)] 
Merge branch 'jk/http-redact-fix'

Sensitive data in the HTTP trace were supposed to be redacted, but
we failed to do so in HTTP/2 requests.

* jk/http-redact-fix:
  http: match headers case-insensitively when redacting

2 years agoMerge branch 'bs/ls-files-opt-help-text-update'
Junio C Hamano [Mon, 4 Oct 2021 04:49:19 +0000 (21:49 -0700)] 
Merge branch 'bs/ls-files-opt-help-text-update'

Help text for "ls-files" options have been updated.

* bs/ls-files-opt-help-text-update:
  ls-files: use imperative mood for -X and -z option description

2 years agoMerge branch 'da/difftool-dir-diff-symlink-fix'
Junio C Hamano [Mon, 4 Oct 2021 04:49:18 +0000 (21:49 -0700)] 
Merge branch 'da/difftool-dir-diff-symlink-fix'

"git difftool --dir-diff" mishandled symbolic links.

* da/difftool-dir-diff-symlink-fix:
  difftool: fix symlink-file writing in dir-diff mode

2 years agoMerge branch 'hn/refs-errno-cleanup'
Junio C Hamano [Mon, 4 Oct 2021 04:49:18 +0000 (21:49 -0700)] 
Merge branch 'hn/refs-errno-cleanup'

Futz with the way 'errno' is relied on in the refs API to carry the
failure modes up the call chain.

* hn/refs-errno-cleanup:
  refs: make errno output explicit for read_raw_ref_fn
  refs/files-backend: stop setting errno from lock_ref_oid_basic
  refs: remove EINVAL errno output from specification of read_raw_ref_fn
  refs file backend: move raceproof_create_file() here

2 years agoMerge branch 'ab/refs-files-cleanup'
Junio C Hamano [Mon, 4 Oct 2021 04:49:18 +0000 (21:49 -0700)] 
Merge branch 'ab/refs-files-cleanup'

Continued work on top of the hn/refs-errno-cleanup topic.

* ab/refs-files-cleanup:
  refs/files: remove unused "errno != ENOTDIR" condition
  refs/files: remove unused "errno == EISDIR" code
  refs/files: remove unused "oid" in lock_ref_oid_basic()
  refs API: remove OID argument to reflog_expire()
  reflog expire: don't lock reflogs using previously seen OID
  refs/files: add a comment about refs_reflog_exists() call
  refs: make repo_dwim_log() accept a NULL oid
  refs/debug: re-indent argument list for "prepare"
  refs/files: remove unused "skip" in lock_raw_ref() too
  refs/files: remove unused "extras/skip" in lock_ref_oid_basic()
  refs: drop unused "flags" parameter to lock_ref_oid_basic()
  refs/files: remove unused REF_DELETING in lock_ref_oid_basic()
  refs/packet: add missing BUG() invocations to reflog callbacks

2 years agoMerge branch 'cb/cvsserver'
Junio C Hamano [Mon, 4 Oct 2021 04:49:17 +0000 (21:49 -0700)] 
Merge branch 'cb/cvsserver'

"git cvsserver" had a long-standing bug in its authentication code,
which has finally been corrected (it is unclear and is a separate
question if anybody is seriously using it, though).

* cb/cvsserver:
  Documentation: cleanup git-cvsserver
  git-cvsserver: protect against NULL in crypt(3)
  git-cvsserver: use crypt correctly to compare password hashes

2 years agoMerge branch 'jx/ci-l10n'
Junio C Hamano [Mon, 4 Oct 2021 04:49:17 +0000 (21:49 -0700)] 
Merge branch 'jx/ci-l10n'

CI help for l10n.

* jx/ci-l10n:
  ci: new github-action for git-l10n code review

2 years agoMerge branch 'jk/clone-unborn-head-in-bare'
Junio C Hamano [Mon, 4 Oct 2021 04:49:17 +0000 (21:49 -0700)] 
Merge branch 'jk/clone-unborn-head-in-bare'

"git clone" from a repository whose HEAD is unborn into a bare
repository didn't follow the branch name the other side used, which
is corrected.

* jk/clone-unborn-head-in-bare:
  clone: handle unborn branch in bare repos

2 years agoMerge branch 'en/stash-df-fix'
Junio C Hamano [Mon, 4 Oct 2021 04:49:16 +0000 (21:49 -0700)] 
Merge branch 'en/stash-df-fix'

"git stash", where the tentative change involves changing a
directory to a file (or vice versa), was confused, which has been
corrected.

* en/stash-df-fix:
  stash: restore untracked files AFTER restoring tracked files
  stash: avoid feeding directories to update-index
  t3903: document a pair of directory/file bugs

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()

2 years agoMakefile: pass -Wno-pendantic under GENERATE_COMPILATION_DATABASE=yes
Ævar Arnfjörð Bjarmason [Wed, 22 Sep 2021 22:08:02 +0000 (00:08 +0200)] 
Makefile: pass -Wno-pendantic under GENERATE_COMPILATION_DATABASE=yes

The same bug fixed in the "COMPUTE_HEADER_DEPENDENCIES=auto" mode in
the preceding commit was also present with
"GENERATE_COMPILATION_DATABASE=yes". Let's fix it so it works again
with "DEVOPTS=1".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoconnect: also update offset for features without values
Andrzej Hunt [Sun, 26 Sep 2021 15:58:33 +0000 (15:58 +0000)] 
connect: also update offset for features without values

parse_feature_value() takes an offset, and uses it to seek past the
point in features_list that we've already seen. However if the feature
being searched for does not specify a value, the offset is not
updated. Therefore if we call parse_feature_value() in a loop on a
value-less feature, we'll keep on parsing the same feature over and over
again. This usually isn't an issue: there's no point in using
next_server_feature_value() to search for repeated instances of the same
capability unless that capability typically specifies a value - but a
broken server could send a response that omits the value for a feature
even when we are expecting a value.

Therefore we add an offset update calculation for the no-value case,
which helps ensure that loops using next_server_feature_value() will
always terminate.

next_server_feature_value(), and the offset calculation, were first
added in 2.28 in 2c6a403d96 (connect: add function to parse multiple
v1 capability values, 2020-05-25).

Thanks to Peff for authoring the test.

Co-authored-by: Jeff King <peff@peff.net>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Andrzej Hunt <andrzej@ahunt.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agopackfile: release bad_objects in close_pack()
René Scharfe [Fri, 24 Sep 2021 06:10:10 +0000 (08:10 +0200)] 
packfile: release bad_objects in close_pack()

Unusable entries of a damaged pack file are recorded in the oidset
bad_objects.  Release it when we're done with the pack.

This doesn't affect intact packs because an empty oidset requires
no allocation.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorebase: fix todo-list rereading
Phillip Wood [Thu, 23 Sep 2021 15:26:21 +0000 (15:26 +0000)] 
rebase: fix todo-list rereading

54fd3243da ("rebase -i: reread the todo list if `exec` touched it",
2017-04-26) sought to reread the todo list after running an exec
command only if it had been changed. To accomplish this it checks the
stat data of the todo list after running an exec command to see if it
has changed. Unfortunately there are two problems, firstly the
implementation is buggy we actually reread the list after each exec
which is quadratic in the number of commit lookups and secondly the
design is predicated on using nanosecond time stamps which are not the
default.

The implementation bug stems from the fact that we write a new todo
list to disk before running each command but do not update the stat
data to reflect this[1].

The design problem is that it is possible for the user to edit the
todo list without changing its size or inode which means we have to
rely on the mtime to tell us if it has changed. Unfortunately unless
git is built with USE_NSEC it is possible for the original and edited
list to share the same mtime.

Ideally "git rebase --edit-todo" would set a flag that we would then
check in sequencer.c. Unfortunately this is approach will not work as
there are scripts in the wild that write to the todo list directly
without running "git rebase --edit-todo". Instead of relying on stat
data this patch simply reads the possibly edited todo list and
compares it to the original with memcmp(). This is much faster than
reparsing the todo list each time. This patch reduces the time to run

   git rebase -r -xtrue v2.32.0~100 v2.32.0

which runs 419 exec commands by 6.6%. For comparison fixing the
implementation bug in stat based approach reduces the time by a
further 1.4% and is indistinguishable from never rereading the todo
list.

[1] https://lore.kernel.org/git/20191125131833.GD23183@szeder.dev/

Reported-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agosequencer.c: factor out a function
Phillip Wood [Thu, 23 Sep 2021 15:26:20 +0000 (15:26 +0000)] 
sequencer.c: factor out a function

This code is heavily indented and obscures the high level logic within
the loop. Let's move it to its own function before modifying it in the
next commit. Note that there is a subtle change in behavior if the
todo list cannot be reread. Previously todo_list->current was
incremented before returning, now it returns immediately.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agodoc/technical: update note about core.multiPackIndex
Eric Wong [Fri, 24 Sep 2021 11:11:36 +0000 (11:11 +0000)] 
doc/technical: update note about core.multiPackIndex

MIDX files are used by default since commit 18e449f86b74
(midx: enable core.multiPackIndex by default, 2020-09-25)

Helped-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Eric Wong <e@80x24.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agobundle: remove ignored & undocumented "--verbose" flag
Ævar Arnfjörð Bjarmason [Thu, 23 Sep 2021 16:48:22 +0000 (18:48 +0200)] 
bundle: remove ignored & undocumented "--verbose" flag

In 73c3253d75e (bundle: framework for options before bundle file,
2019-11-10) the "git bundle" command was refactored to use
parse_options(). In that refactoring it started understanding the
"--verbose" flag before the subcommand, e.g.:

    git bundle --verbose verify --quiet

However, nothing ever did anything with this "verbose" variable, and
the change wasn't documented. It appears to have been something that
escaped the lab, and wasn't flagged by reviewers at the time. Let's
just remove it.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Reviewed-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 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>
2 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

2 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

2 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

2 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

2 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'

2 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

2 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

2 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()

2 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

2 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

2 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

2 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`

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 years agodifftool: fix symlink-file writing in dir-diff mode
David Aguilar [Thu, 23 Sep 2021 04:12:50 +0000 (21:12 -0700)] 
difftool: fix symlink-file writing in dir-diff mode

The difftool dir-diff mode handles symlinks by replacing them with their
readlink(2) values. This allows diff tools to see changes to symlinks
as if they were regular text diffs with the old and new path values.
This is analogous to what "git diff" displays when symlinks change.

The temporary diff directories that are created initially contain
symlinks because they get checked-out using a temporary index that
retains the original symlinks as checked-in to the repository.

A bug was introduced when difftool was rewritten in C that made
difftool write the readlink(2) contents into the pointed-to file rather
than the symlink itself. The write was going through the symlink and
writing to its target rather than writing to the symlink path itself.

Replace symlinks with raw text files by unlinking the symlink path
before writing the readlink(2) content into them.

When 18ec800512 (difftool: handle modified symlinks in dir-diff mode,
2017-03-15) added handling for modified symlinks this bug got recorded
in the test suite. The tests included the pointed-to symlink target
paths. These paths were being reported because difftool was erroneously
writing to them, but they should have never been reported nor written.

Correct the modified-symlinks test cases by removing the target files
from the expected output.

Add a test to ensure that symlinks are written with the readlink(2)
values and that the target files contain their original content.

Reported-by: Alan Blotz <work@blotz.org>
Helped-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMakefile: make COMPUTE_HEADER_DEPENDENCIES=auto work with DEVOPTS=pedantic
Ævar Arnfjörð Bjarmason [Wed, 22 Sep 2021 22:08:01 +0000 (00:08 +0200)] 
Makefile: make COMPUTE_HEADER_DEPENDENCIES=auto work with DEVOPTS=pedantic

The "COMPUTE_HEADER_DEPENDENCIES" feature added in [1] was extended to
use auto-detection in [2], that "auto" detection has always piped
STDERR to /dev/null, so any failures on compilers that didn't support
these GCC flags would silently fall back to
"COMPUTE_HEADER_DEPENDENCIES=no".

Later when -Wpedantic support was added to DEVOPTS in [3] we started
passing -Wpedantic in combination with -Werror to the compiler
here. Note (to the pedantic): [3] actually passed "-pedantic", but it
and "-Wpedantic" are synonyms.

Turning on -Wpedantic in [3] broke the auto-detection, since this
relies on compiling an empty program. GCC would loudly complain on
STDERR:

    /dev/null:1: error: ISO C forbids an empty translation unit
    [-Werror=pedantic]
    cc1: note: unrecognized command-line option
    ‘-Wno-pedantic-ms-format’ may have been intended to silence
    earlier diagnostics
    cc1: all warnings being treated as errors

But as that ended up in the "$(dep_check)" variable due to the "2>&1"
in [2] we didn't see it.

Then when [4] made DEVOPTS=pedantic the default specifying
"DEVELOPER=1" would effectively set "COMPUTE_HEADER_DEPENDENCIES=no".

To fix these issues let's unconditionally pass -Wno-pedantic after
$(ALL_CFLAGS), we might get a -Wpedantic via config.mak.dev after, or
the builder might specify it via CFLAGS. In either case this will undo
current and future problems with -Wpedantic.

I think it would make sense to simply remove the "2>&1", it would mean
that anyone using a non-GCC-like compiler would get warnings under
COMPUTE_HEADER_DEPENDENCIES=auto, e.g on AIX's xlc would emit:

    /opt/IBM/xlc/13.1.3/bin/.orig/xlc: 1501-208 (S) command option D is missing a subargument
    Non-zero 40 exit with COMPUTE_HEADER_DEPENDENCIES=auto, set it to "yes" or "no" to quiet auto-detect

And on Solaris with SunCC:

    cc: Warning: Option -x passed to ld, if ld is invoked, ignored otherwise
    cc: refused to overwrite input file by output file: /dev/null
    cc: Warning: Option -x passed to ld, if ld is invoked, ignored otherwise
    cc: refused to overwrite input file by output file: /dev/null
    Non-zero 1 exit with COMPUTE_HEADER_DEPENDENCIES=auto, set it to "yes" or "no" to quiet auto-detect

Both could be quieted by setting COMPUTE_HEADER_DEPENDENCIES=no
explicitly, as suggested, but let's see if this'll fix it without
emitting too much noise at those that aren't using "gcc" or "clang".

1. f2fabbf76e4 (Teach Makefile to check header dependencies,
   2010-01-26)
2. 111ee18c31f (Makefile: Use computed header dependencies if the
   compiler supports it, 2011-08-18)
3. 729b3925ed9 (Makefile: add a DEVOPTS flag to get pedantic
   compilation, 2018-07-24)
4. 6a8cbc41bac (developer: enable pedantic by default, 2021-09-03)

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agohttp: match headers case-insensitively when redacting
Jeff King [Wed, 22 Sep 2021 22:11:53 +0000 (18:11 -0400)] 
http: match headers case-insensitively when redacting

When HTTP/2 is in use, we fail to correctly redact "Authorization" (and
other) headers in our GIT_TRACE_CURL output.

We get the headers in our CURLOPT_DEBUGFUNCTION callback, curl_trace().
It passes them along to curl_dump_header(), which in turn checks
redact_sensitive_header(). We see the headers as a text buffer like:

  Host: ...
  Authorization: Basic ...

After breaking it into lines, we match each header using skip_prefix().
This is case-sensitive, even though HTTP headers are case-insensitive.
This has worked reliably in the past because these headers are generated
by curl itself, which is predictable in what it sends.

But when HTTP/2 is in use, instead we get a lower-case "authorization:"
header, and we fail to match it. The fix is simple: we should match with
skip_iprefix().

Testing is more complicated, though. We do have a test for the redacting
feature, but we don't hit the problem case because our test Apache setup
does not understand HTTP/2. You can reproduce the issue by applying this
on top of the test change in this patch:

diff --git a/t/lib-httpd/apache.conf b/t/lib-httpd/apache.conf
index afa91e38b0..19267c7107 100644
--- a/t/lib-httpd/apache.conf
+++ b/t/lib-httpd/apache.conf
@@ -29,6 +29,9 @@ ErrorLog error.log
  LoadModule setenvif_module modules/mod_setenvif.so
 </IfModule>

+LoadModule http2_module modules/mod_http2.so
+Protocols h2c
+
 <IfVersion < 2.4>
 LockFile accept.lock
 </IfVersion>
@@ -64,8 +67,8 @@ LockFile accept.lock
 <IfModule !mod_access_compat.c>
  LoadModule access_compat_module modules/mod_access_compat.so
 </IfModule>
-<IfModule !mod_mpm_prefork.c>
- LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
+<IfModule !mod_mpm_event.c>
+ LoadModule mpm_event_module modules/mod_mpm_event.so
 </IfModule>
 <IfModule !mod_unixd.c>
  LoadModule unixd_module modules/mod_unixd.so
diff --git a/t/t5551-http-fetch-smart.sh b/t/t5551-http-fetch-smart.sh
index 1c2a444ae7..ff74f0ae8a 100755
--- a/t/t5551-http-fetch-smart.sh
+++ b/t/t5551-http-fetch-smart.sh
@@ -24,6 +24,10 @@ test_expect_success 'create http-accessible bare repository' '
  git push public main:main
 '

+test_expect_success 'prefer http/2' '
+ git config --global http.version HTTP/2
+'
+
 setup_askpass_helper

 test_expect_success 'clone http repository' '

but this has a few issues:

  - it's not necessarily portable. The http2 apache module might not be
    available on all systems. Further, the http2 module isn't compatible
    with the prefork mpm, so we have to switch to something else. But we
    don't necessarily know what's available. It would be nice if we
    could have conditional config, but IfModule only tells us if a
    module is already loaded, not whether it is available at all.

    This might be a non-issue. The http tests are already optional, and
    modern-enough systems may just have both of these. But...

  - if we do this, then we'd no longer be testing HTTP/1.1 at all. I'm
    not sure how much that matters since it's all handled by curl under
    the hood, but I'd worry that some detail leaks through. We'd
    probably want two scripts running similar tests, one with HTTP/2 and
    one with HTTP/1.1.

  - speaking of which, a later test fails with the patch above! The
    problem is that it is making sure we used a chunked
    transfer-encoding by looking for that header in the trace. But
    HTTP/2 doesn't support that, as it has its own streaming mechanisms
    (the overall operation works fine; we just don't see the header in
    the trace).

Furthermore, even with the changes above, this test still does not
detect the current failure, because we see _both_ HTTP/1.1 and HTTP/2
requests, which confuse it. Quoting only the interesting bits from the
resulting trace file, we first see:

  => Send header: GET /auth/smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1
  => Send header: Connection: Upgrade, HTTP2-Settings
  => Send header: Upgrade: h2c
  => Send header: HTTP2-Settings: AAMAAABkAAQCAAAAAAIAAAAA

  <= Recv header: HTTP/1.1 401 Unauthorized
  <= Recv header: Date: Wed, 22 Sep 2021 20:03:32 GMT
  <= Recv header: Server: Apache/2.4.49 (Debian)
  <= Recv header: WWW-Authenticate: Basic realm="git-auth"

So the client asks for HTTP/2, but Apache does not do the upgrade for
the 401 response. Then the client repeats with credentials:

  => Send header: GET /auth/smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1
  => Send header: Authorization: Basic <redacted>
  => Send header: Connection: Upgrade, HTTP2-Settings
  => Send header: Upgrade: h2c
  => Send header: HTTP2-Settings: AAMAAABkAAQCAAAAAAIAAAAA

  <= Recv header: HTTP/1.1 101 Switching Protocols
  <= Recv header: Upgrade: h2c
  <= Recv header: Connection: Upgrade
  <= Recv header: HTTP/2 200
  <= Recv header: content-type: application/x-git-upload-pack-advertisement

So the client does properly redact there, because we're speaking
HTTP/1.1, and the server indicates it can do the upgrade. And then the
client will make further requests using HTTP/2:

  => Send header: POST /auth/smart/repo.git/git-upload-pack HTTP/2
  => Send header: authorization: Basic dXNlckBob3N0OnBhc3NAaG9zdA==
  => Send header: content-type: application/x-git-upload-pack-request

And there we can see that the credential is _not_ redacted. This part of
the test is what gets confused:

# Ensure that there is no "Basic" followed by a base64 string, but that
# the auth details are redacted
! grep "Authorization: Basic [0-9a-zA-Z+/]" trace &&
grep "Authorization: Basic <redacted>" trace

The first grep does not match the un-redacted HTTP/2 header, because
it insists on an uppercase "A". And the second one does find the
HTTP/1.1 header. So as far as the test is concerned, everything is OK,
but it failed to notice the un-redacted lines.

We can make this test (and the other related ones) more robust by adding
"-i" to grep case-insensitively. This isn't really doing anything for
now, since we're not actually speaking HTTP/2, but it future-proofs the
tests for a day when we do (either we add explicit HTTP/2 test support,
or it's eventually enabled by default by our Apache+curl test setup).
And it doesn't hurt in the meantime for the tests to be more careful.

The change to use "grep -i", coupled with the changes to use HTTP/2
shown above, causes the test to fail with the current code, and pass
after this patch is applied.

And finally, there's one other way to demonstrate the issue (and how I
actually found it originally). Looking at GIT_TRACE_CURL output against
github.com, you'll see the unredacted output, even if you didn't set
http.version. That's because setting it is only necessary for curl to
send the extra headers in its HTTP/1.1 request that say "Hey, I speak
HTTP/2; upgrade if you do, too". But for a production site speaking
https, the server advertises via ALPN, a TLS extension, that it supports
HTTP/2, and the client can immediately start using it.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agodifftool: fix word spacing in the usage strings
Bagas Sanjaya [Tue, 21 Sep 2021 11:17:13 +0000 (18:17 +0700)] 
difftool: fix word spacing in the usage strings

Remove spaces in `non - zero` and add a space between the diff
format/mode and option parentheses in difftool's usage strings.

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMyFirstContribution: Document --range-diff option when writing v2
Glen Choo [Wed, 22 Sep 2021 20:22:18 +0000 (13:22 -0700)] 
MyFirstContribution: Document --range-diff option when writing v2

In the "Sending v2" section, readers are directed to create v2 patches
without using --range-diff. However, it is customary to include a
range-diff against the v1 patches as a reviewer aid.

Update the "Sending v2" section to suggest a simple workflow that uses
the --range-diff option. Also include some explanation for -v2 and
--range-diff to help the reader understand the importance.

Signed-off-by: Glen Choo <chooglen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMakefile: clean .depend dirs under COMPUTE_HEADER_DEPENDENCIES != yes
Ævar Arnfjörð Bjarmason [Wed, 22 Sep 2021 20:17:06 +0000 (22:17 +0200)] 
Makefile: clean .depend dirs under COMPUTE_HEADER_DEPENDENCIES != yes

Fix a logic error in dfea575017d (Makefile: lazily compute header
dependencies, 2010-01-26) where we'd make whether we cleaned the
.depend dirs contingent on the currently configured
COMPUTE_HEADER_DEPENDENCIES value. Before this running e.g.:

    make COMPUTE_HEADER_DEPENDENCIES=yes grep.o
    make COMPUTE_HEADER_DEPENDENCIES=no clean

Would leave behind the .depend directory, now it'll be removed.

Normally we'd need to use another variable, but in this case there's
no other uses of $(dep_dirs), as opposed to $(dep_args) which is used
as an argument to $(CC). So just deleting this line makes everything
work correctly.

See http://lore.kernel.org/git/xmqqmto48ufz.fsf@gitster.g for a report
about this issue.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agot/perf/run: fix bin-wrappers computation
Derrick Stolee [Tue, 21 Sep 2021 15:46:12 +0000 (15:46 +0000)] 
t/perf/run: fix bin-wrappers computation

The GIT_TEST_INSTALLED was moved from perf-lib.sh to run in df0f5021
(perf-lib.sh: remove GIT_TEST_INSTALLED from perf-lib.sh, 2019-05-07)
and that included a change to how it inspected the existence of a
bin-wrappers directory. However, that included a typo that made the
match of bin-wrappers never work. Specifically, the assignment was

mydir_abs_wrappers="$mydir_abs_wrappers/bin-wrappers"

which uses the same variable before it is initialized. By changing it to

mydir_abs_wrappers="$mydir_abs/bin-wrappers"

We can correctly use the bin-wrappers directory.

This is critical to successfully computing performance of commands that
execute subcommands. The bin-wrappers ensure that the --exec-path is set
correctly.

Reported-by: Victoria Dye <vdye@github.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorepository.h: don't use a mix of int and bitfields
Ævar Arnfjörð Bjarmason [Tue, 21 Sep 2021 13:13:03 +0000 (15:13 +0200)] 
repository.h: don't use a mix of int and bitfields

Change the bitfield added in 58300f47432 (sparse-index: add
index.sparse config option, 2021-03-30) and 3964fc2aae7 (sparse-index:
add guard to ensure full index, 2021-03-30) to just use an "int"
boolean instead.

It might be smart to optimize the space here in the future, but by
consistently using an "int" we can take its address and pass it to
repo_cfg_bool(), and therefore don't need to handle "sparse_index" as
a special-case when reading the "index.sparse" setting.

There's no corresponding config for "command_requires_full_index", but
let's change it too for consistency and to prevent future bugs
creeping in due to one of these being "unsigned".

Using "int" consistently also prevents subtle bugs or undesired
control flow creeping in here. Before the preceding commit the
initialization of "command_requires_full_index" in
prepare_repo_settings() did nothing, i.e. this:

    r->settings.command_requires_full_index = 1

Was redundant to the earlier memset() to -1. Likewise for
"sparse_index" added in 58300f47432 (sparse-index: add index.sparse
config option, 2021-03-30) the code and comment added there was
misleading, we weren't initializing it to off, but re-initializing it
from "1" to "0", and then finally checking the config, and perhaps
setting it to "1" again. I.e. we could have applied this patch before
the preceding commit:

+ assert(r->settings.command_requires_full_index == 1);
  r->settings.command_requires_full_index = 1;

  /*
   * Initialize this as off.
   */
+ assert(r->settings.sparse_index == 1);
  r->settings.sparse_index = 0;
  if (!repo_config_get_bool(r, "index.sparse", &value) && value)
  r->settings.sparse_index = 1;

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorepo-settings.c: simplify the setup
Ævar Arnfjörð Bjarmason [Tue, 21 Sep 2021 13:13:02 +0000 (15:13 +0200)] 
repo-settings.c: simplify the setup

Simplify the setup code in repo-settings.c in various ways, making the
code shorter, easier to read, and requiring fewer hacks to do the same
thing as it did before:

Since 7211b9e7534 (repo-settings: consolidate some config settings,
2019-08-13) we have memset() the whole "settings" structure to -1 in
prepare_repo_settings(), and subsequently relied on the -1 value.

Most of the fields did not need to be initialized to -1, and because
we were doing that we had the enum labels "UNTRACKED_CACHE_UNSET" and
"FETCH_NEGOTIATION_UNSET" purely to reflect the resulting state
created this memset() in prepare_repo_settings(). No other code used
or relied on them, more on that below.

For the rest most of the subsequent "are we -1, then read xyz" can
simply be removed by re-arranging what we read first. E.g. when
setting the "index.version" setting we should have first read
"feature.experimental", so that it (and "feature.manyfiles") can
provide a default for our "index.version".

Instead the code setting it, added when "feature.manyFiles"[1] was
created, was using the UPDATE_DEFAULT_BOOL() macro added in an earlier
commit[2]. That macro is now gone, since it was only needed for this
pattern of reading things in the wrong order.

This also fixes an (admittedly obscure) logic error where we'd
conflate an explicit "-1" value in the config with our own earlier
memset() -1.

We can also remove the UPDATE_DEFAULT_BOOL() wrapper added in
[3]. Using it is redundant to simply using the return value from
repo_config_get_bool(), which is non-zero if the provided key exists
in the config.

Details on edge cases relating to the memset() to -1, continued from
"more on that below" above:

 * UNTRACKED_CACHE_KEEP:

   In [4] the "unset" and "keep" handling for core.untrackedCache was
   consolidated. But it while we understand the "keep" value, we don't
   handle it differently than the case of any other unknown value.

   So let's retain UNTRACKED_CACHE_KEEP and remove the
   UNTRACKED_CACHE_UNSET setting (which was always implicitly
   UNTRACKED_CACHE_KEEP before). We don't need to inform any code
   after prepare_repo_settings() that the setting was "unset", as far
   as anyone else is concerned it's core.untrackedCache=keep. if
   "core.untrackedcache" isn't present in the config.

 * FETCH_NEGOTIATION_UNSET & FETCH_NEGOTIATION_NONE:

   Since these two two enum fields added in [5] don't rely on the
   memzero() setting them to "-1" anymore we don't have to provide
   them with explicit values.

1. c6cc4c5afd2 (repo-settings: create feature.manyFiles setting,
   2019-08-13)
2. 31b1de6a09b (commit-graph: turn on commit-graph by default,
   2019-08-13)
3. 31b1de6a09b (commit-graph: turn on commit-graph by default,
   2019-08-13)
4. ad0fb659993 (repo-settings: parse core.untrackedCache,
   2019-08-13)
5. aaf633c2ad1 (repo-settings: create feature.experimental setting,
   2019-08-13)

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoread-cache & fetch-negotiator: check "enum" values in switch()
Ævar Arnfjörð Bjarmason [Tue, 21 Sep 2021 13:13:01 +0000 (15:13 +0200)] 
read-cache & fetch-negotiator: check "enum" values in switch()

Change tweak_untracked_cache() in "read-cache.c" to use a switch() to
have the compiler assert that we checked all possible values in the
"enum untracked_cache_setting" type, and likewise remove the "default"
case in fetch_negotiator_init() in favor of checking for
"FETCH_NEGOTIATION_UNSET" and "FETCH_NEGOTIATION_NONE".

As will be discussed in a subsequent we'll only ever have either of
these set to FETCH_NEGOTIATION_NONE, FETCH_NEGOTIATION_UNSET and
UNTRACKED_CACHE_UNSET within the prepare_repo_settings() function
itself. In preparation for fixing that code let's add a BUG() here to
mark this as unreachable code.

See ad0fb659993 (repo-settings: parse core.untrackedCache, 2019-08-13)
for when the "unset" and "keep" handling for core.untrackedCache was
consolidated, and aaf633c2ad1 (repo-settings: create
feature.experimental setting, 2019-08-13) for the addition of the
"default" pattern in "fetch-negotiator.c".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoenvironment.c: remove test-specific "ignore_untracked..." variable
Ævar Arnfjörð Bjarmason [Tue, 21 Sep 2021 13:13:00 +0000 (15:13 +0200)] 
environment.c: remove test-specific "ignore_untracked..." variable

Instead of the global ignore_untracked_cache_config variable added in
dae6c322fa1 (test-dump-untracked-cache: don't modify the untracked
cache, 2016-01-27) we can make use of the new facility to set config
via environment variables added in d8d77153eaf (config: allow
specifying config entries via envvar pairs, 2021-01-12).

It's arguably a bit hacky to use setenv() and getenv() to pass
messages between the same program, but since the test helpers are not
the main intended audience of repo-settings.c I think it's better than
hardcoding the test-only special-case in prepare_repo_settings().

This uses the xsetenv() wrapper added in the preceding commit, if we
don't set these in the environment we'll fail in
t7063-status-untracked-cache.sh, but let's fail earlier anyway if that
were to happen.

This breaks any parent process that's potentially using the
GIT_CONFIG_* and GIT_CONFIG_PARAMETERS mechanism to pass one-shot
config setting down to a git subprocess, but in this case we don't
care about the general case of such potential parents. This process
neither spawns other "git" processes, nor is it interested in other
configuration. We might want to pick up other test modes here, but
those will be passed via GIT_TEST_* environment variables.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agowrapper.c: add x{un,}setenv(), and use xsetenv() in environment.c
Ævar Arnfjörð Bjarmason [Tue, 21 Sep 2021 13:12:59 +0000 (15:12 +0200)] 
wrapper.c: add x{un,}setenv(), and use xsetenv() in environment.c

Add fatal wrappers for setenv() and unsetenv(). In d7ac12b25d3 (Add
set_git_dir() function, 2007-08-01) we started checking its return
value, and since 48988c4d0c3 (set_git_dir: die when setenv() fails,
2018-03-30) we've had set_git_dir_1() die if we couldn't set it.

Let's provide a wrapper for both, this will be useful in many other
places, a subsequent patch will make another use of xsetenv().

The checking of the return value here is over-eager according to
setenv(3) and POSIX. It's documented as returning just -1 or 0, so
perhaps we should be checking -1 explicitly.

Let's just instead die on any non-zero, if our C library is so broken
as to return something else than -1 on error (and perhaps not set
errno?) the worst we'll do is die with a nonsensical errno value, but
we'll want to die in either case.

Let's make these return "void" instead of "int". As far as I can tell
there's no other x*() wrappers that needed to make the decision of
deviating from the signature in the C library, but since their return
value is only used to indicate errors (so we'd die here), we can catch
unreachable code such as

    if (xsetenv(...) < 0)
        [...];

I think it would be OK skip the NULL check of the "name" here for the
calls to die_errno(). Almost all of our setenv() callers are taking a
constant string hardcoded in the source as the first argument, and for
the rest we can probably assume they've done the NULL check
themselves. Even if they didn't, modern C libraries are forgiving
about it (e.g. glibc formatting it as "(null)"), on those that aren't,
well, we were about to die anyway. But let's include the check anyway
for good measure.

1. https://pubs.opengroup.org/onlinepubs/009604499/functions/setenv.html

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agols-files: use imperative mood for -X and -z option description
Bagas Sanjaya [Tue, 21 Sep 2021 11:13:05 +0000 (18:13 +0700)] 
ls-files: use imperative mood for -X and -z option description

Usage description for -X and -z options use descriptive instead of
imperative mood. Edit it for consistency with other options.

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorebase: dereference tags
Phillip Wood [Tue, 21 Sep 2021 10:24:07 +0000 (10:24 +0000)] 
rebase: dereference tags

A rebase started with 'git rebase <A> <B>' is conceptually to first
checkout <B> and run 'git rebase <A>' starting from that state.  'git
rebase --abort' in the middle of such a rebase should take us back to
the state we checked out <B>.

This used to work, even when <B> is a tag that points at a commit,
until Git 2.20.0 when the command was reimplemented in C.  The command
now complains that the tag object itself cannot be checked out, which
may be technically correct but is not what the user asked to do.

Fix this old regression by using lookup_commit_reference_by_name()
when parsing <B>. The scripted version did not need to peel the tag
because the commands it passed the tag to (e.g 'git reset') peeled the
tag themselves.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorebase: use lookup_commit_reference_by_name()
Phillip Wood [Tue, 21 Sep 2021 10:24:06 +0000 (10:24 +0000)] 
rebase: use lookup_commit_reference_by_name()

peel_committish() appears to have been copied from the scripted rebase
but it duplicates the functionality of
lookup_commit_reference_by_name() so lets use that instead.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorebase: use our standard error return value
Phillip Wood [Tue, 21 Sep 2021 10:24:05 +0000 (10:24 +0000)] 
rebase: use our standard error return value

Git uses −1 to signal an error. The builtin rebase converts these to
+1 all over the place using !! (presumably because the in the scripted
version an error was signalled by +1). This is confusing and clutters
the code, we only need to convert the value when the function returns.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agogrep: store grep_source buffer as const
Jeff King [Tue, 21 Sep 2021 03:51:28 +0000 (23:51 -0400)] 
grep: store grep_source buffer as const

Our grep_buffer() function takes a non-const buffer, which is confusing:
we don't take ownership of nor write to the buffer.

This mostly comes from the fact that the underlying grep_source struct
in which we store the buffer uses non-const pointer. The memory pointed
to by the struct is sometimes owned by us (for FILE or OID sources), and
sometimes not (for BUF sources).

Let's store it as const, which lets us err on the side of caution (i.e.,
the compiler will warn us if any of our code writes to or tries to free
it).

As a result, we must annotate the one place where we do free it by
casting away the constness. But that's a small price to pay for the
extra safety and clarity elsewhere (and indeed, it already had a comment
explaining why GREP_SOURCE_BUF _didn't_ free it).

And then we can mark grep_buffer() as taking a const buffer.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agogrep: mark "haystack" buffers as const
Jeff King [Tue, 21 Sep 2021 03:49:49 +0000 (23:49 -0400)] 
grep: mark "haystack" buffers as const

When we're grepping in a buffer, we don't need to modify it. So we can
take "const char *" buffers, rather than "char *". This can avoid some
awkward casts in our callers, and make our expectations more clear (we
will not take ownership of the memory, nor will we ever write to it).

These spots don't all necessarily have to be converted at the same time,
but some of them are dependent on others, because we pass
pointers-to-pointers in a few cases. And none of this should change any
behavior, since we're just adding "const" qualifiers (and likewise, the
compiler will let us know if we missed any spots). So it's relatively
low-risk to just do this all at once.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agogrep: stop modifying buffer in grep_source_1()
Jeff King [Tue, 21 Sep 2021 03:48:44 +0000 (23:48 -0400)] 
grep: stop modifying buffer in grep_source_1()

We find the end of each matching line of a buffer, and then temporarily
write a NUL to turn it into a regular C string. But we don't need to do
so, because the only thing we do in the interim is pass the line and its
length (via an "eol" pointer) to match_line(). And that function should
only look at the bytes we passed it, whether it has a terminating NUL or
not.

We can drop this temporary write in order to simplify the code and make
it easier to use const buffers in more of grep.c.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agogrep: stop modifying buffer in show_line()
Jeff King [Tue, 21 Sep 2021 03:48:09 +0000 (23:48 -0400)] 
grep: stop modifying buffer in show_line()

When showing lines via grep (or looking for funcnames), we call
show_line() on a multi-line buffer. It finds the end of line and marks
it with a NUL. However, we don't need to do so, as the resulting line is
only used along with its "eol" marker:

 - we pass both to next_match(), which takes care to look at only the
   bytes we specified

 - we pass the line to output_color() without its matching eol marker.
   However, we do use the "match" struct we got from next_match() to
   tell it how many bytes to look at (which can never exceed the string
   we passed it).

So we can stop setting and restoring this NUL marker. That makes the
code simpler, and will allow us to take a const buffer in a future
patch.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agogrep: stop modifying buffer in strip_timestamp
Jeff King [Tue, 21 Sep 2021 03:46:56 +0000 (23:46 -0400)] 
grep: stop modifying buffer in strip_timestamp

When grepping for headers in commit objects, we receive individual
lines (e.g., "author Name <email> 1234 -0000"), and then strip off the
timestamp to do our match. We do so by writing a NUL byte over the
whitespace separator, and then remembering to restore it later.

We had to do it this way when this was added back in a4d7d2c6db (log
--author/--committer: really match only with name part, 2008-09-04),
because we fed the result directly to regexec(), which expects a
NUL-terminated string. But since b7d36ffca0 (regex: use regexec_buf(),
2016-09-21), we have a function which can match part of a buffer.

So instead of modifying the string, we can instead just move the "eol"
pointer, and the rest of the code will do the right thing. This will let
further patches mark more buffers as "const".

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agobuiltin/multi-pack-index.c: disable top-level --[no-]progress
Taylor Blau [Mon, 20 Sep 2021 21:39:19 +0000 (17:39 -0400)] 
builtin/multi-pack-index.c: disable top-level --[no-]progress

In a similar spirit as the previous patch, let sub-commands which
support showing or hiding a progress meter handle parsing the
`--progress` or `--no-progress` option, but do not expose it as an
option to the top-level `multi-pack-index` builtin.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 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>
2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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()

2 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

2 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

2 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()

2 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

2 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

2 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

2 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

2 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