]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
3 years agoTwelfth batch
Junio C Hamano [Mon, 11 Oct 2021 17:22:14 +0000 (10:22 -0700)] 
Twelfth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'tb/aggregate-ignore-leading-whitespaces'
Junio C Hamano [Mon, 11 Oct 2021 17:21:49 +0000 (10:21 -0700)] 
Merge branch 'tb/aggregate-ignore-leading-whitespaces'

Test portability update.

* tb/aggregate-ignore-leading-whitespaces:
  t/perf/aggregate.perl: tolerate leading spaces

3 years agoMerge branch 'rs/p3400-lose-tac'
Junio C Hamano [Mon, 11 Oct 2021 17:21:49 +0000 (10:21 -0700)] 
Merge branch 'rs/p3400-lose-tac'

Test portability update.

* rs/p3400-lose-tac:
  p3400: stop using tac(1)

3 years agoMerge branch 'mr/bisect-in-c-4'
Junio C Hamano [Mon, 11 Oct 2021 17:21:49 +0000 (10:21 -0700)] 
Merge branch 'mr/bisect-in-c-4'

Message fix.

* mr/bisect-in-c-4:
  bisect--helper: add space between colon and following sentence

3 years agoMerge branch 'da/difftool'
Junio C Hamano [Mon, 11 Oct 2021 17:21:48 +0000 (10:21 -0700)] 
Merge branch 'da/difftool'

Code clean-up in "git difftool".

* da/difftool:
  difftool: add a missing space to the run_dir_diff() comments
  difftool: remove an unnecessary call to strbuf_release()
  difftool: refactor dir-diff to write files using helper functions
  difftool: create a tmpdir path without repeated slashes

3 years agoMerge branch 'ab/designated-initializers'
Junio C Hamano [Mon, 11 Oct 2021 17:21:48 +0000 (10:21 -0700)] 
Merge branch 'ab/designated-initializers'

Code clean-up.

* ab/designated-initializers:
  cbtree.h: define cb_init() in terms of CBTREE_INIT
  *.h: move some *_INIT to designated initializers
  *.h _INIT macros: don't specify fields equal to 0
  *.[ch] *_INIT macros: use { 0 } for a "zero out" idiom
  submodule-config.h: remove unused SUBMODULE_INIT macro

3 years agoMerge branch 'ab/sanitize-leak-ci'
Junio C Hamano [Mon, 11 Oct 2021 17:21:47 +0000 (10:21 -0700)] 
Merge branch 'ab/sanitize-leak-ci'

CI learns to run the leak sanitizer builds.

* ab/sanitize-leak-ci:
  tests: add a test mode for SANITIZE=leak, run it in CI
  Makefile: add SANITIZE=leak flag to GIT-BUILD-OPTIONS

3 years agoMerge branch 'ab/retire-git-config-key-is-valid'
Junio C Hamano [Mon, 11 Oct 2021 17:21:47 +0000 (10:21 -0700)] 
Merge branch 'ab/retire-git-config-key-is-valid'

Code cleanup.

* ab/retire-git-config-key-is-valid:
  config.c: remove unused git_config_key_is_valid()

3 years agoMerge branch 'jk/ref-paranoia'
Junio C Hamano [Mon, 11 Oct 2021 17:21:47 +0000 (10:21 -0700)] 
Merge branch 'jk/ref-paranoia'

The ref iteration code used to optionally allow dangling refs to be
shown, which has been tightened up.

* jk/ref-paranoia:
  refs: drop "broken" flag from for_each_fullref_in()
  ref-filter: drop broken-ref code entirely
  ref-filter: stop setting FILTER_REFS_INCLUDE_BROKEN
  repack, prune: drop GIT_REF_PARANOIA settings
  refs: turn on GIT_REF_PARANOIA by default
  refs: omit dangling symrefs when using GIT_REF_PARANOIA
  refs: add DO_FOR_EACH_OMIT_DANGLING_SYMREFS flag
  refs-internal.h: reorganize DO_FOR_EACH_* flag documentation
  refs-internal.h: move DO_FOR_EACH_* flags next to each other
  t5312: be more assertive about command failure
  t5312: test non-destructive repack
  t5312: create bogus ref as necessary
  t5312: drop "verbose" helper
  t5600: provide detached HEAD for corruption failures
  t5516: don't use HEAD ref for invalid ref-deletion tests
  t7900: clean up some more broken refs

3 years agoMerge branch 'ab/http-pinned-public-key-mismatch'
Junio C Hamano [Mon, 11 Oct 2021 17:21:47 +0000 (10:21 -0700)] 
Merge branch 'ab/http-pinned-public-key-mismatch'

HTTPS error handling updates.

* ab/http-pinned-public-key-mismatch:
  http: check CURLE_SSL_PINNEDPUBKEYNOTMATCH when emitting errors

3 years agoMerge branch 'js/win-lazyload-buildfix'
Junio C Hamano [Mon, 11 Oct 2021 17:21:47 +0000 (10:21 -0700)] 
Merge branch 'js/win-lazyload-buildfix'

Compilation fix.

* js/win-lazyload-buildfix:
  Makefile: restrict -Wpedantic and -Wno-pedantic-ms-format better
  lazyload.h: use an even more generic function pointer than FARPROC
  lazyload.h: fix warnings about mismatching function pointer types

3 years agoMerge branch 'sg/test-split-index-fix'
Junio C Hamano [Mon, 11 Oct 2021 17:21:47 +0000 (10:21 -0700)] 
Merge branch 'sg/test-split-index-fix'

Test updates.

* sg/test-split-index-fix:
  read-cache: fix GIT_TEST_SPLIT_INDEX
  tests: disable GIT_TEST_SPLIT_INDEX for sparse index tests
  read-cache: look for shared index files next to the index, too
  t1600-index: disable GIT_TEST_SPLIT_INDEX
  t1600-index: don't run git commands upstream of a pipe
  t1600-index: remove unnecessary redirection

3 years agoMerge branch 'tb/midx-write-propagate-namehash'
Junio C Hamano [Mon, 11 Oct 2021 17:21:46 +0000 (10:21 -0700)] 
Merge branch 'tb/midx-write-propagate-namehash'

"git multi-pack-index write --bitmap" learns to propagate the
hashcache from original bitmap to resulting bitmap.

* tb/midx-write-propagate-namehash:
  t5326: test propagating hashcache values
  p5326: generate pack bitmaps before writing the MIDX bitmap
  p5326: don't set core.multiPackIndex unnecessarily
  p5326: create missing 'perf-tag' tag
  midx.c: respect 'pack.writeBitmapHashcache' when writing bitmaps
  pack-bitmap.c: propagate namehash values from existing bitmaps
  t/helper/test-bitmap.c: add 'dump-hashes' mode

3 years agoThe eleventh batch
Junio C Hamano [Wed, 6 Oct 2021 20:40:32 +0000 (13:40 -0700)] 
The eleventh batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'ab/retire-decl-of-missing-unused-funcs'
Junio C Hamano [Wed, 6 Oct 2021 20:40:14 +0000 (13:40 -0700)] 
Merge branch 'ab/retire-decl-of-missing-unused-funcs'

Remove external declaration of functions that no longer exist.

* ab/retire-decl-of-missing-unused-funcs:
  config.h: remove unused git_config_get_untracked_cache() declaration
  log-tree.h: remove unused function declarations
  grep.h: remove unused grep_threads_ok() declaration
  builtin.h: remove cmd_tar_tree() declaration

3 years agoMerge branch 'lh/systemd-timers'
Junio C Hamano [Wed, 6 Oct 2021 20:40:13 +0000 (13:40 -0700)] 
Merge branch 'lh/systemd-timers'

Testfix.

* lh/systemd-timers:
  maintenance: fix test t7900-maintenance.sh

3 years agoMerge branch 'ab/retire-string-list-init'
Junio C Hamano [Wed, 6 Oct 2021 20:40:13 +0000 (13:40 -0700)] 
Merge branch 'ab/retire-string-list-init'

Code cleanup.

* ab/retire-string-list-init:
  string-list.[ch]: remove string_list_init() compatibility function

3 years agoMerge branch 'ab/retire-refs-unused-funcs'
Junio C Hamano [Wed, 6 Oct 2021 20:40:13 +0000 (13:40 -0700)] 
Merge branch 'ab/retire-refs-unused-funcs'

Code cleanup.

* ab/retire-refs-unused-funcs:
  refs/ref-cache.[ch]: remove "incomplete" from create_dir_entry()
  refs/ref-cache.c: remove "mkdir" parameter from find_containing_dir()
  refs/ref-cache.[ch]: remove unused add_ref_entry()
  refs/ref-cache.[ch]: remove unused remove_entry_from_dir()
  refs.[ch]: remove unused ref_storage_backend_exists()

3 years agoMerge branch 'os/status-docfix'
Junio C Hamano [Wed, 6 Oct 2021 20:40:13 +0000 (13:40 -0700)] 
Merge branch 'os/status-docfix'

Docfix.

* os/status-docfix:
  doc: fix capitalization in "git status --porcelain=v2" description

3 years agoMerge branch 'ws/refer-to-forkpoint-config-in-rebase-doc'
Junio C Hamano [Wed, 6 Oct 2021 20:40:12 +0000 (13:40 -0700)] 
Merge branch 'ws/refer-to-forkpoint-config-in-rebase-doc'

Doc update.

* ws/refer-to-forkpoint-config-in-rebase-doc:
  Document `rebase.forkpoint` in rebase man page

3 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

3 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

3 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

3 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

3 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

3 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

3 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

3 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

3 years agot/perf/aggregate.perl: tolerate leading spaces
Taylor Blau [Sun, 3 Oct 2021 05:14:49 +0000 (01:14 -0400)] 
t/perf/aggregate.perl: tolerate leading spaces

When using `test_size` with `wc -c`, users on certain platforms can run
into issues when `wc` emits leading space characters in its output,
which confuses get_times.

Callers could switch to use test_file_size instead of `wc -c` (the
former never prints leading space characters, so will always work with
test_size regardless of platform), but this is an easy enough spot to
miss that we should teach get_times to be more tolerant of the input it
accepts.

Teach get_times to do just that by stripping any leading space
characters.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agop3400: stop using tac(1)
René Scharfe [Sat, 2 Oct 2021 17:44:14 +0000 (19:44 +0200)] 
p3400: stop using tac(1)

b3dfeebb92 (rebase: avoid computing unnecessary patch IDs, 2016-07-29)
added a perf test that calls tac(1) from GNU core utilities.  Support
systems without it by reversing the generated list using sort -nr
instead.  sort(1) with options -n and -r is already used in other tests.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 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>
3 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

3 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

3 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

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

3 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

3 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

3 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

3 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

3 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

3 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

3 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

3 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

3 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

3 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

3 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

3 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

3 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

3 years agobisect--helper: add space between colon and following sentence
Bagas Sanjaya [Fri, 1 Oct 2021 11:47:45 +0000 (18:47 +0700)] 
bisect--helper: add space between colon and following sentence

Add missing space between colon sentence (`bisect-run failed:`) and the
following sentence (`git bisect--helper --bisect-state`).

Fixes: d1bbbe45df (bisect--helper: reimplement `bisect_run` shell
function in C, 2021-09-13)
Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoconfig.h: remove unused git_config_get_untracked_cache() declaration
Ævar Arnfjörð Bjarmason [Fri, 1 Oct 2021 10:37:43 +0000 (12:37 +0200)] 
config.h: remove unused git_config_get_untracked_cache() declaration

This function was removed in ad0fb659993 (repo-settings: parse
core.untrackedCache, 2019-08-13), but not its corresponding *.h entry.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agolog-tree.h: remove unused function declarations
Ævar Arnfjörð Bjarmason [Fri, 1 Oct 2021 10:37:42 +0000 (12:37 +0200)] 
log-tree.h: remove unused function declarations

The init_log_tree_opt() and log_tree_opt_parse() functions were
removed in cd2bdc53094 (Common option parsing for "git log --diff" and
friends, 2006-04-14), but not their corresponding *.h declaration.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agogrep.h: remove unused grep_threads_ok() declaration
Ævar Arnfjörð Bjarmason [Fri, 1 Oct 2021 10:37:41 +0000 (12:37 +0200)] 
grep.h: remove unused grep_threads_ok() declaration

This function was removed in 0579f91dd74 (grep: enable threading with
-p and -W using lazy attribute lookup, 2011-12-12), but not its
corresponding *.h declaration.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agobuiltin.h: remove cmd_tar_tree() declaration
Ævar Arnfjörð Bjarmason [Fri, 1 Oct 2021 10:37:40 +0000 (12:37 +0200)] 
builtin.h: remove cmd_tar_tree() declaration

The cmd_tar_tree() function itself was removed in
925ceccf050 (tar-tree: remove deprecated command, 2013-11-10).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agodifftool: add a missing space to the run_dir_diff() comments
David Aguilar [Fri, 1 Oct 2021 01:37:56 +0000 (18:37 -0700)] 
difftool: add a missing space to the run_dir_diff() comments

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agodifftool: remove an unnecessary call to strbuf_release()
David Aguilar [Fri, 1 Oct 2021 01:37:55 +0000 (18:37 -0700)] 
difftool: remove an unnecessary call to strbuf_release()

The `buf` strbuf is reused again later in the same function, so there
is no benefit to calling strbuf_release(). The subsequent usage is
already using strbuf_reset() to reset the buffer, so releasing it
early is only going to lead to a wasteful reallocation.

Remove the early call to strbuf_release(). The same strbuf is already
cleaned up in the "finish:" section so nothing is leaked, either.

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agodifftool: refactor dir-diff to write files using helper functions
David Aguilar [Fri, 1 Oct 2021 01:37:54 +0000 (18:37 -0700)] 
difftool: refactor dir-diff to write files using helper functions

Add a helpers function to handle the unlinking and writing
of the dir-diff submodule and symlink stand-in files.

Use the helpers to implement the guts of the hashmap loops.
This eliminate duplicate code and safeguards the submodules
hashmap loop against the symlink-chasing behavior that 5bafb3576a
(difftool: fix symlink-file writing in dir-diff mode, 2021-09-22)
addressed.

The submodules loop should not strictly require the unlink() call that
this is introducing to them, but it does not necessarily hurt them
either beyond the cost of the extra unlink().

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agodifftool: create a tmpdir path without repeated slashes
David Aguilar [Fri, 1 Oct 2021 01:37:53 +0000 (18:37 -0700)] 
difftool: create a tmpdir path without repeated slashes

The paths generated by difftool are passed to user-facing diff tools.
Using paths with repeated slashes in them is a cosmetic blemish that
is exposed to users and can be avoided.

Use a strbuf to create the buffer used for the dir-diff tmpdir.
Strip trailing slashes from the value read from TMPDIR to avoid
repeated slashes in the generated paths.

Adjust the error handling to avoid leaking strbufs and to avoid
returning -1 to cmd_main().

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMakefile: restrict -Wpedantic and -Wno-pedantic-ms-format better
Carlo Marcelo Arenas Belón [Wed, 29 Sep 2021 03:19:40 +0000 (20:19 -0700)] 
Makefile: restrict -Wpedantic and -Wno-pedantic-ms-format better

6a8cbc41ba (developer: enable pedantic by default, 2021-09-03)
enables pedantic mode in as many compilers as possible to help gather
feedback on future tightening, so lets do so.

-Wpedantic is missing in some really old gcc 4 versions so lets restrict
it to gcc5 and clang4 (it does work in clang3 AFAIK, but it will be
unlikely that a developer will use such an old compiler anyway).

MinGW gcc is the only one which has -Wno-pedantic-ms-format, and while
that is available also in older compilers, the Windows SDK provides gcc10
so lets aim for that.

Note that in order to target the flag to only Windows, additional changes
were needed in config.mak.uname to propagate the OS detection which also
did some minor refactoring, but which is functionaly equivalent.

Helped-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agodoc: fix capitalization in "git status --porcelain=v2" description
Orgad Shaneh [Sun, 26 Sep 2021 03:48:02 +0000 (03:48 +0000)] 
doc: fix capitalization in "git status --porcelain=v2" description

The summary line had xy, while the description (and other sub-sections)
has XY.

Signed-off-by: Orgad Shaneh <orgads@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorefs/ref-cache.[ch]: remove "incomplete" from create_dir_entry()
Ævar Arnfjörð Bjarmason [Tue, 28 Sep 2021 13:02:24 +0000 (15:02 +0200)] 
refs/ref-cache.[ch]: remove "incomplete" from create_dir_entry()

Remove the now-unused "incomplete" parameter from create_dir_entry(),
all its callers specify it as "1", so let's drop the "incomplete=0"
case. The last caller to use it was search_for_subdir(), but that code
was removed in the preceding commit.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorefs/ref-cache.c: remove "mkdir" parameter from find_containing_dir()
Ævar Arnfjörð Bjarmason [Tue, 28 Sep 2021 13:02:23 +0000 (15:02 +0200)] 
refs/ref-cache.c: remove "mkdir" parameter from find_containing_dir()

Remove the "mkdir" parameter from the find_containing_dir() function,
the add_ref_entry() function removed in the preceding commit was its
last user.

Since "mkdir" is always "0" we can also remove the parameter from
search_for_subdir(), which in turn means that we can delete most of
that function.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorefs/ref-cache.[ch]: remove unused add_ref_entry()
Ævar Arnfjörð Bjarmason [Tue, 28 Sep 2021 13:02:22 +0000 (15:02 +0200)] 
refs/ref-cache.[ch]: remove unused add_ref_entry()

This function has not been used since 9dd389f3d8d (packed_ref_store:
get rid of the `ref_cache` entirely, 2017-09-25).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorefs/ref-cache.[ch]: remove unused remove_entry_from_dir()
Ævar Arnfjörð Bjarmason [Tue, 28 Sep 2021 13:02:21 +0000 (15:02 +0200)] 
refs/ref-cache.[ch]: remove unused remove_entry_from_dir()

This function was missed in 9939b33d6a3 (packed-backend: rip out some
now-unused code, 2017-09-08), and has been orphaned since then. Let's
delete it.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorefs.[ch]: remove unused ref_storage_backend_exists()
Ævar Arnfjörð Bjarmason [Tue, 28 Sep 2021 13:02:20 +0000 (15:02 +0200)] 
refs.[ch]: remove unused ref_storage_backend_exists()

This function was added in 3dce444f178 (refs: add a backend method
structure, 2016-09-04), but has never been used by anything. The only
caller that might care uses find_ref_storage_backend() directly.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoconfig.c: remove unused git_config_key_is_valid()
Ævar Arnfjörð Bjarmason [Tue, 28 Sep 2021 12:56:03 +0000 (14:56 +0200)] 
config.c: remove unused git_config_key_is_valid()

The git_config_key_is_valid() function got left behind in a
refactoring in a9bcf6586d1 (alias: use the early config machinery to
expand aliases, 2017-06-14),

It previously had two users when it was added in 9e9de18f1ad (config:
silence warnings for command names with invalid keys, 2015-08-24), and
after 6a1e1bc0a15 (pager: use callbacks instead of configset,
2016-09-12) only one remained.

By removing it we can get rid of the "quiet" branches in this
function, as well as cases where "store_key" is NULL, for which there
are no other users.

Out of the 5 callers of git_config_parse_key() only one needs to pass
a non-NULL "size_t *baselen_", so we could remove the third parameter
from the public interface. I did not find that potential
simplification to be worthwhile.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agostring-list.[ch]: remove string_list_init() compatibility function
Ævar Arnfjörð Bjarmason [Tue, 28 Sep 2021 12:49:45 +0000 (14:49 +0200)] 
string-list.[ch]: remove string_list_init() compatibility function

Remove this function left over to accommodate in-flight changes, see
770fedaf9fb (string-list.[ch]: add a string_list_init_{nodup,dup}(),
2021-07-01) for the recent change to add
"string_list_init_{nodup,dup}()" initializers.

There was only one user of the API left in remote-curl.c. I don't know
why I didn't include this change to remote-curl.c in
bc40dfb10a0 (string-list.h users: change to use *_{nodup,dup}(),
2021-07-01), perhaps I just missed it.

In any case, let's change that one user to use the new API, as of
writing this there are no in-flight changes that use, so this seems
like a good time to drop this before we get any new users of this
compatibility API.

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

3 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

3 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 agomaintenance: fix test t7900-maintenance.sh
Lénaïc Huard [Mon, 27 Sep 2021 21:30:16 +0000 (23:30 +0200)] 
maintenance: fix test t7900-maintenance.sh

Commit b681b191 introduced the support of systemd timers for git
maintenance.
A test is leveraging the `systemd-analyze verify` utility to verify the
correctness of the systemd unit files generated by git.

But on some systems, although the `systemd-analyze` tool is installed
and supports the `verify` subcommand, it fails with some permission
errors.

So, instead of only checking if the `verify` subcommand exists, a more
reliable way of detecting whether `systemd-analyze verify` can be used
is to try to use it.

The SYSTEMD_ANALYZE prerequisite is now trying to run `systemd-analyze
verify` on a systemd unit file which is shipped by systemd itself.
We can reasonably think that, on systemd hosts, this file is present and
valid.

Signed-off-by: Lénaïc Huard <lenaic@lhuard.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocbtree.h: define cb_init() in terms of CBTREE_INIT
Ævar Arnfjörð Bjarmason [Mon, 27 Sep 2021 12:54:28 +0000 (14:54 +0200)] 
cbtree.h: define cb_init() in terms of CBTREE_INIT

Use the same pattern for cb_init() as the one established in the
recent refactoring of other such patterns in
5726a6b4012 (*.c *_init(): define in terms of corresponding *_INIT
macro, 2021-07-01).

It has been pointed out[1] that we could perhaps use this C99
replacement of using a compound literal for all of these:

    *t = (struct cb_tree){ 0 };

But let's just stick to the existing pattern established in
5726a6b4012 for now, we can leave another weather balloon for some
other time.

1. http://lore.kernel.org/git/ef724a3a-a4b8-65d3-c928-13a7d78f189a@gmail.com

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years ago*.h: move some *_INIT to designated initializers
Ævar Arnfjörð Bjarmason [Mon, 27 Sep 2021 12:54:27 +0000 (14:54 +0200)] 
*.h: move some *_INIT to designated initializers

Move various *_INIT macros to use designated initializers. This helps
readability. I've only picked those leftover macros that were not
touched by another in-flight series of mine which changed others, but
also how initialization was done.

In the case of SUBMODULE_ALTERNATE_SETUP_INIT I've left an explicit
initialization of "error_mode", even though
SUBMODULE_ALTERNATE_ERROR_IGNORE itself is defined as "0". Let's not
peek under the hood and assume that enum fields we know the value of
will stay at "0".

The change to "TESTSUITE_INIT" in "t/helper/test-run-command.c" was
part of an earlier on-list version[1] of c90be786da9 (test-tool
run-command: fix flip-flop init pattern, 2021-09-11).

1. https://lore.kernel.org/git/patch-1.1-0aa4523ab6e-20210909T130849Z-avarab@gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years ago*.h _INIT macros: don't specify fields equal to 0
Ævar Arnfjörð Bjarmason [Mon, 27 Sep 2021 12:54:26 +0000 (14:54 +0200)] 
*.h _INIT macros: don't specify fields equal to 0

Change the initialization of "struct strbuf" changed in
cbc0f81d96f (strbuf: use designated initializers in STRBUF_INIT,
2017-07-10) to omit specifying "alloc" and "len", as we do with other
"alloc" and "len" (or "nr") in similar structs.

Let's likewise omit the explicit initialization of all fields in the
"struct ipc_client_connect_option" struct added in
59c7b88198a (simple-ipc: add win32 implementation, 2021-03-15).

Do the same for a few other initializers, e.g. STRVEC_INIT and
CACHE_DEF_INIT.

Finally, start incrementally changing the same pattern in
"t/helper/test-run-command.c". This change was part of an earlier
on-list version[1] of c90be786da9 (test-tool run-command: fix
flip-flop init pattern, 2021-09-11).

1. https://lore.kernel.org/git/patch-1.1-0aa4523ab6e-20210909T130849Z-avarab@gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years ago*.[ch] *_INIT macros: use { 0 } for a "zero out" idiom
Ævar Arnfjörð Bjarmason [Mon, 27 Sep 2021 12:54:25 +0000 (14:54 +0200)] 
*.[ch] *_INIT macros: use { 0 } for a "zero out" idiom

In C it isn't required to specify that all members of a struct are
zero'd out to 0, NULL or '\0', just providing a "{ 0 }" will
accomplish that.

Let's also change code that provided N zero'd fields to just
provide one, and change e.g. "{ NULL }" to "{ 0 }" for
consistency. I.e. even if the first member is a pointer let's use "0"
instead of "NULL". The point of using "0" consistently is to pick one,
and to not have the reader wonder why we're not using the same pattern
everywhere.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agosubmodule-config.h: remove unused SUBMODULE_INIT macro
Ævar Arnfjörð Bjarmason [Mon, 27 Sep 2021 12:54:24 +0000 (14:54 +0200)] 
submodule-config.h: remove unused SUBMODULE_INIT macro

This macro was added and used in c68f8375760 (implement fetching of
moved submodules, 2017-10-16) but its last user went away in
be76c212823 (fetch: ensure submodule objects fetched, 2018-12-06).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 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>
3 years agolazyload.h: use an even more generic function pointer than FARPROC
Carlo Marcelo Arenas Belón [Sun, 26 Sep 2021 10:05:12 +0000 (03:05 -0700)] 
lazyload.h: use an even more generic function pointer than FARPROC

gcc will helpfully raise a -Wcast-function-type warning when casting
between functions that might have incompatible return types
(ex: GetUserNameExW returns bool which is only half the size of the
return type from FARPROC which is long long), so create a new type that
could be used as a completely generic function pointer and cast through
it instead.

Additionaly remove the -Wno-incompatible-pointer-types temporary
flag added in 27e0c3c (win32: allow building with pedantic mode
enabled, 2021-09-03), as it will be no longer needed.

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorefs: drop "broken" flag from for_each_fullref_in()
Jeff King [Fri, 24 Sep 2021 18:48:48 +0000 (14:48 -0400)] 
refs: drop "broken" flag from for_each_fullref_in()

No callers pass in anything but "0" here. Likewise to our sibling
functions. Note that some of them ferry along the flag, but none of
their callers pass anything but "0" either.

Nor is anybody likely to change that. Callers which really want to see
all of the raw refs use for_each_rawref(). And anybody interested in
iterating a subset of the refs will likely be happy to use the
now-default behavior of showing broken refs, but omitting dangling
symlinks.

So we can get rid of this whole feature.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoref-filter: drop broken-ref code entirely
Jeff King [Fri, 24 Sep 2021 18:48:20 +0000 (14:48 -0400)] 
ref-filter: drop broken-ref code entirely

Now that none of our callers passes the INCLUDE_BROKEN flag, we can drop
it entirely, along with the code to plumb it through to the
for_each_fullref_in() functions.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoref-filter: stop setting FILTER_REFS_INCLUDE_BROKEN
Jeff King [Fri, 24 Sep 2021 18:48:05 +0000 (14:48 -0400)] 
ref-filter: stop setting FILTER_REFS_INCLUDE_BROKEN

Of the ref-filter callers, for-each-ref and git-branch both set the
INCLUDE_BROKEN flag (but git-tag does not, which is a weird
inconsistency).  But now that GIT_REF_PARANOIA is on by default, that
produces almost the same outcome for all three.

The one exception is that GIT_REF_PARANOIA will omit dangling symrefs.
That's a better behavior for these tools, as they would never include
such a symref in the main output anyway (they can't, as it doesn't point
to an object). Instead they issue a warning to stderr. But that warning
is somewhat useless; a dangling symref is a perfectly reasonable thing
to have in your repository, and is not a sign of corruption. It's much
friendlier to just quietly ignore it.

And in terms of robustness, the warning gains us little. It does not
impact the exit code of either tool. So while the warning _might_ clue
in a user that they have an unexpected broken symref, it would not help
any kind of scripted use.

This patch converts for-each-ref and git-branch to stop using the
INCLUDE_BROKEN flag. That gives them more reasonable behavior, and
harmonizes them with git-tag.

We have to change one test to adapt to the situation. t1430 tries to
trigger all of the REF_ISBROKEN behaviors from the underlying ref code.
It uses for-each-ref to do so (because there isn't any other mechanism).
That will no longer issue a warning about the symref which points to an
invalid name, as it's considered dangling (and we can instead be sure
that it's _not_ mentioned on stderr). Note that we do still complain
about the illegally named "broken..symref"; its problem is not that it's
dangling, but the name of the symref itself is illegal.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorepack, prune: drop GIT_REF_PARANOIA settings
Jeff King [Fri, 24 Sep 2021 18:46:37 +0000 (14:46 -0400)] 
repack, prune: drop GIT_REF_PARANOIA settings

Now that GIT_REF_PARANOIA is the default, we don't need to selectively
enable it for destructive operations. In fact, it's harmful to do so,
because it overrides any GIT_REF_PARANOIA=0 setting that the user may
have provided (because they're trying to work around some corruption).

With these uses gone, we can further clean up the ref_paranoia global,
and make it a static variable inside the refs code.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorefs: turn on GIT_REF_PARANOIA by default
Jeff King [Fri, 24 Sep 2021 18:46:13 +0000 (14:46 -0400)] 
refs: turn on GIT_REF_PARANOIA by default

The original point of the GIT_REF_PARANOIA flag was to include broken
refs in iterations, so that possibly-destructive operations would not
silently ignore them (and would generally instead try to operate on the
oids and fail when the objects could not be accessed).

We already turned this on by default for some dangerous operations, like
"repack -ad" (where missing a reachability tip would mean dropping the
associated history). But it was not on for general use, even though it
could easily result in the spreading of corruption (e.g., imagine
cloning a repository which simply omits some of its refs because
their objects are missing; the result quietly succeeds even though you
did not clone everything!).

This patch turns on GIT_REF_PARANOIA by default. So a clone as mentioned
above would actually fail (upload-pack tells us about the broken ref,
and when we ask for the objects, pack-objects fails to deliver them).
This may be inconvenient when working with a corrupted repository, but:

  - we are better off to err on the side of complaining about
    corruption, and then provide mechanisms for explicitly loosening
    safety.

  - this is only one type of corruption anyway. If we are missing any
    other objects in the history that _aren't_ ref tips, then we'd
    behave similarly (happily show the ref, but then barf when we
    started traversing).

We retain the GIT_REF_PARANOIA variable, but simply default it to "1"
instead of "0". That gives the user an escape hatch for loosening this
when working with a corrupt repository. It won't work across a remote
connection to upload-pack (because we can't necessarily set environment
variables on the remote), but there the client has other options (e.g.,
choosing which refs to fetch).

As a bonus, this also makes ref iteration faster in general (because we
don't have to call has_object_file() for each ref), though probably not
noticeably so in the general case. In a repo with a million refs, it
shaved a few hundred milliseconds off of upload-pack's advertisement;
that's noticeable, but most repos are not nearly that large.

The possible downside here is that any operation which iterates refs but
doesn't ever open their objects may now quietly claim to have X when the
object is corrupted (e.g., "git rev-list new-branch --not --all" will
treat a broken ref as uninteresting). But again, that's not really any
different than corruption below the ref level. We might have
refs/heads/old-branch as non-corrupt, but we are not actively checking
that we have the entire reachable history. Or the pointed-to object
could even be corrupted on-disk (but our "do we have it" check would
still succeed). In that sense, this is merely bringing ref-corruption in
line with general object corruption.

One alternative implementation would be to actually check for broken
refs, and then _immediately die_ if we see any. That would cause the
"rev-list --not --all" case above to abort immediately. But in many ways
that's the worst of all worlds:

  - it still spends time looking up the objects an extra time

  - it still doesn't catch corruption below the ref level

  - it's even more inconvenient; with the current implementation of
    GIT_REF_PARANOIA for something like upload-pack, we can make
    the advertisement and let the client choose a non-broken piece of
    history. If we bail as soon as we see a broken ref, they cannot even
    see the advertisement.

The test changes here show some of the fallout. A non-destructive "git
repack -adk" now fails by default (but we can override it). Deleting a
broken ref now actually tells the hooks the correct "before" state,
rather than a confusing null oid.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorefs: omit dangling symrefs when using GIT_REF_PARANOIA
Jeff King [Fri, 24 Sep 2021 18:42:38 +0000 (14:42 -0400)] 
refs: omit dangling symrefs when using GIT_REF_PARANOIA

Dangling symrefs aren't actually a corruption problem. It's perfectly
fine for refs/remotes/origin/HEAD to point to an unborn branch. And in
particular, if you are trying to establish reachability, a symref that
points nowhere doesn't matter either way. Any ref it could point to will
be examined during the rest of the traversal.

It's possible that a symref pointing nowhere _could_ be a sign that the
ref it was meant to point to was deleted accidentally (e.g., via
corruption). But there is no particular reason to think that is true for
any given case, and in the meantime, GIT_REF_PARANOIA kicking in
automatically for some operations means they'll fail unnecessarily.

So let's loosen it just a bit. The new test in t5312 shows off an
example that is safe, but currently fails (and no longer does after this
patch).

Note that we don't do anything if the caller explicitly asked for
DO_FOR_EACH_INCLUDE_BROKEN. In that case they may be looking for
dangling symrefs themselves, and setting GIT_REF_PARANOIA should not
_loosen_ things from what the caller asked for.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorefs: add DO_FOR_EACH_OMIT_DANGLING_SYMREFS flag
Jeff King [Fri, 24 Sep 2021 18:41:32 +0000 (14:41 -0400)] 
refs: add DO_FOR_EACH_OMIT_DANGLING_SYMREFS flag

When the DO_FOR_EACH_INCLUDE_BROKEN flag is used, we include both actual
corrupt refs (illegal names, missing objects), but also symrefs that
point to nothing. This latter is not really a corruption, but just
something that may happen normally. For example, the symref at
refs/remotes/origin/HEAD may point to a tracking branch which is later
deleted. (The local HEAD may also be unborn, of course, but we do not
access it through ref iteration).

Most callers of for_each_ref() etc, do not care. They don't pass
INCLUDE_BROKEN, so don't see it at all. But for those which do pass it,
this somewhat-normal state causes extra warnings (e.g., from
for-each-ref) or even aborts operations (destructive repacks with
GIT_REF_PARANOIA set).

This patch just introduces the flag and the mechanism; there are no
callers yet (and hence no tests). Two things to note on the
implementation:

  - we actually skip any symref that does not resolve to a ref. This
    includes ones which point to an invalidly-named ref. You could argue
    this is a more serious breakage than simple dangling. But the
    overall effect is the same (we could not follow the symref), as well
    as the impact on things like REF_PARANOIA (either way, a symref we
    can't follow won't impact reachability, because we'll see the ref
    itself during iteration). The underlying resolution function doesn't
    distinguish these two cases (they both get REF_ISBROKEN).

  - we change the iterator in refs/files-backend.c where we check
    INCLUDE_BROKEN. There's a matching spot in refs/packed-backend.c,
    but we don't know need to do anything there. The packed backend does
    not support symrefs at all.

The resulting set of flags might be a bit easier to follow if we broke
this down into "INCLUDE_CORRUPT_REFS" and "INCLUDE_DANGLING_SYMREFS".
But there are a few reasons not do so:

  - adding a new OMIT_DANGLING_SYMREFS flag lets us leave existing
    callers intact, without changing their behavior (and some of them
    really do want to see the dangling symrefs; e.g., t5505 has a test
    which expects us to report when a symref becomes dangling)

  - they're not actually independent. You cannot say "include dangling
    symrefs" without also including refs whose objects are not
    reachable, because dangling symrefs by definition do not have an
    object. We could tweak the implementation to distinguish this, but
    in practice nobody wants to ask for that. Adding the OMIT flag keeps
    the implementation simple and makes sure we don't regress the
    current behavior.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorefs-internal.h: reorganize DO_FOR_EACH_* flag documentation
Jeff King [Fri, 24 Sep 2021 18:39:44 +0000 (14:39 -0400)] 
refs-internal.h: reorganize DO_FOR_EACH_* flag documentation

The documentation for the DO_FOR_EACH_* flags is sprinkled over the
refs-internal.h file. We define the two flags in one spot, and then
describe them in more detail far away from there, in the definitions of
refs_ref_iterator_begin() and ref_iterator_advance_fn().

Let's try to organize this a bit better:

  - convert the #defines to an enum. This makes it clear that they are
    related, and that the enum shows the complete set of flags.

  - combine all descriptions for each flag in a single spot, next to the
    flag's definition

  - use the enum rather than a bare int for functions which take the
    flags. This helps readers realize which flags can be used.

  - clarify the mention of flags for ref_iterator_advance_fn(). It does
    not take flags itself, but is meant to depend on ones set up
    earlier.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorefs-internal.h: move DO_FOR_EACH_* flags next to each other
Jeff King [Fri, 24 Sep 2021 18:37:58 +0000 (14:37 -0400)] 
refs-internal.h: move DO_FOR_EACH_* flags next to each other

There are currently two DO_FOR_EACH_* flags, which must not have their
bits overlap. Yet they're defined hundreds of lines apart. Let's move
them next to each other to make it clear that they are related and are a
complete set (which matters if you are adding a new flag and would like
to know what the next available bit is).

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot5312: be more assertive about command failure
Jeff King [Fri, 24 Sep 2021 18:37:11 +0000 (14:37 -0400)] 
t5312: be more assertive about command failure

When repacking or pruning in a corrupted repository, our tests in t5312
argue that it is OK to complete the operation or bail, as long as we
don't actually delete the objects pointed to by the corruption.

This isn't a wrong line of reasoning, but the tests are a bit permissive
by using test_might_fail. The fact is that we _do_ bail currently, and
if we ever stopped doing so, that would be worthy of a human
investigating. So let's switch these to test_must_fail.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot5312: test non-destructive repack
Jeff King [Fri, 24 Sep 2021 18:36:42 +0000 (14:36 -0400)] 
t5312: test non-destructive repack

In t5312, we create a state with a broken ref, and then make sure that
destructive repacks don't silently ignore the breakage (where a
destructive repack is one that might drop objects). But we don't check
the behavior of non-destructive repacks at all (i.e., ones where we'd
keep unreachable objects).

So let's add a test to confirm the current behavior, which is that
they are allowed (i.e., ignoring the breakage and considering any
objects it points to as unreachable). This may change in the future, but
we'd like for the test suite to alert us to that fact.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot5312: create bogus ref as necessary
Jeff King [Fri, 24 Sep 2021 18:36:18 +0000 (14:36 -0400)] 
t5312: create bogus ref as necessary

Some tests in t5312 create an illegally-named ref, and then see how
various operations handle it. But between those operations, we also do
some more setup (e.g., repacking), and we are subtly depending on how
those setup steps react to the illegal ref.

To future-proof us against those behaviors changing, let's instead
create and clean up our bogus ref on demand in the tests that need it.

This has two small extra advantages:

 - the tests are more stand-alone; we do not need an extra test to clean
   up the ref before moving on to other parts of the script

 - the creation and cleanup is together in one helper function. Because
   these depend on touching the refs in the filesystem directly, they
   may need to be tweaked for a world with alternate backends (they have
   not been noticed so far in the reftable work because with a non-file
   backend the tests don't fail; they simply become uninteresting noops
   because the broken ref isn't read at all).

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot5312: drop "verbose" helper
Jeff King [Fri, 24 Sep 2021 18:35:29 +0000 (14:35 -0400)] 
t5312: drop "verbose" helper

t5312 has several uses of the "verbose" helper, as described in
8ad1652418 (t5304: use helper to report failure of "test foo = bar",
2014-10-10). Back then the "-x" trace option for tests was new, and was
not as pleasant to use (e.g., some tests failed under "-x", we did not
support BASH_XTRACEFD, etc).

These days it is clear that "-x" is the preferred way to get extra
output, and we don't need to mark up individual tests. Let's get rid of
the uses of "verbose" here, as one step toward eradicating it totally.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot5600: provide detached HEAD for corruption failures
Jeff King [Fri, 24 Sep 2021 18:34:04 +0000 (14:34 -0400)] 
t5600: provide detached HEAD for corruption failures

When checking how git-clone behaves when it fails, we stimulate some
failures by trying to do a clone from a local repository whose objects
have been removed. Because these clones use local optimizations, there's
a subtle dependency in how the corruption is handled on the sending
side.

If upload-pack does not show us the broken refs (which it does not
currently), then we see only HEAD (which is itself broken), and clone
that as a detached HEAD. When we try to write the ref, we notice that we
never got the object and bail.

But if upload-pack _does_ show us the broken refs (which it may in a
future patch), then we'll realize that HEAD is a symref and just write
that. You'd think we'd fail when writing out the refs themselves, but we
don't; we do a bulk write and skip the connectivity check because of our
--local optimizations. For the non-bare case, we do notice the problem
when we try to checkout. But for a bare repository, we unexpectedly
complete the clone successfully!

At first glance this may seem like a bug. But the whole point of those
local optimizations is to give up some safety for speed. If you want to
be careful, you should be using "--no-local", which would notice that
the pack did not transfer sufficient objects. We could do that in these
tests, but part of the point is for them to fail at specific moments
(and indeed, we have a later test that checks for transport failure).

However, we can make this less subtle and future-proof it against
changes on the upload-pack side by just having an explicit detached
HEAD in the corrupted repo. Now we'll fail as expected during the ref
write if any ref _or_ HEAD is corrupt, whether we're --bare or not.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot5516: don't use HEAD ref for invalid ref-deletion tests
Jeff King [Fri, 24 Sep 2021 18:33:00 +0000 (14:33 -0400)] 
t5516: don't use HEAD ref for invalid ref-deletion tests

A few tests in t5516 want to assert that we can delete a corrupted ref
whose pointed-to object is missing. They do so by using the "main"
branch, which is also pointed to by HEAD.

This does work, but only because of a subtle assumption about the
implementation. We do not block the deletion because of the invalid ref,
but we _also_ do not notice that the deleted branch is pointed to by
HEAD. And so the safety rule of "do not allow HEAD to be deleted in a
non-bare repository" does not kick in, and the test passes.

Let's instead use a non-HEAD branch. That still tests what we care about
here (deleting a corrupt ref), but without implicitly depending on our
failure to notice that we're deleting HEAD. That will future proof the
test against that behavior changing.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot7900: clean up some more broken refs
Jeff King [Fri, 24 Sep 2021 18:32:17 +0000 (14:32 -0400)] 
t7900: clean up some more broken refs

The "incremental-repack task" test replaces the object directory with a
known state. As a result, some of our refs point to objects that are not
included in that state.

Commit 3cf5f221be (t7900: clean up some broken refs, 2021-01-19) cleaned
up some of those (that were causing warnings to stderr from the
maintenance process). But there are a few more that were missed. These
aren't hurting anything for now, but it's certainly an unexpected state
to leave the test repository in, and it will become a problem if repack
ever gets more picky about broken refs.

Let's clean up those additional refs (which are all in refs/remotes,
with nothing there that isn't broken), and add an extra "for-each-ref"
call to assert that we've got everything.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agohttp: check CURLE_SSL_PINNEDPUBKEYNOTMATCH when emitting errors
Ævar Arnfjörð Bjarmason [Fri, 24 Sep 2021 10:08:20 +0000 (12:08 +0200)] 
http: check CURLE_SSL_PINNEDPUBKEYNOTMATCH when emitting errors

Change the error shown when a http.pinnedPubKey doesn't match to point
the http.pinnedPubKey variable added in aeff8a61216 (http: implement
public key pinning, 2016-02-15), e.g.:

    git -c http.pinnedPubKey=sha256/someNonMatchingKey ls-remote https://github.com/git/git.git
    fatal: unable to access 'https://github.com/git/git.git/' with http.pinnedPubkey configuration: SSL: public key does not match pinned public key!

Before this we'd emit the exact same thing without the " with
http.pinnedPubkey configuration". The advantage of doing this is that
we're going to get a translated message (everything after the ":" is
hardcoded in English in libcurl), and we've got a reference to the
git-specific configuration variable that's causing the error.

Unfortunately we can't test this easily, as there are no tests that
require https:// in the test suite, and t/lib-httpd.sh doesn't know
how to set up such tests. See [1] for the start of a discussion about
what it would take to have divergent "t/lib-httpd/apache.conf" test
setups. #leftoverbits

1. https://lore.kernel.org/git/YUonS1uoZlZEt+Yd@coredump.intra.peff.net/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 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>
3 years agolazyload.h: fix warnings about mismatching function pointer types
Johannes Sixt [Sun, 26 Sep 2021 10:05:11 +0000 (03:05 -0700)] 
lazyload.h: fix warnings about mismatching function pointer types

Here, GCC warns about every use of the INIT_PROC_ADDR macro, for example:

In file included from compat/mingw.c:8:
compat/mingw.c: In function 'mingw_strftime':
compat/win32/lazyload.h:38:12: warning: assignment to
   'size_t (*)(char *, size_t,  const char *, const struct tm *)'
   {aka 'long long unsigned int (*)(char *, long long unsigned int,
      const char *, const struct tm *)'} from incompatible pointer type
   'FARPROC' {aka 'long long int (*)()'} [-Wincompatible-pointer-types]
   38 |  (function = get_proc_addr(&proc_addr_##function))
      |            ^
compat/mingw.c:1014:6: note: in expansion of macro 'INIT_PROC_ADDR'
 1014 |  if (INIT_PROC_ADDR(strftime))
      |      ^~~~~~~~~~~~~~

(message wrapped for convenience). Insert a cast to keep the compiler
happy. A cast is fine in these cases because they are generic function
pointer values that have been looked up in a DLL.

Helped-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 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>
3 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>
3 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>