]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
18 months agoMerge branch 'ds/bundle-uri-3'
Taylor Blau [Mon, 31 Oct 2022 01:04:43 +0000 (21:04 -0400)] 
Merge branch 'ds/bundle-uri-3'

Define the logical elements of a "bundle list", data structure to
store them in-core, format to transfer them, and code to parse
them.

* ds/bundle-uri-3:
  bundle-uri: suppress stderr from remote-https
  bundle-uri: quiet failed unbundlings
  bundle: add flags to verify_bundle()
  bundle-uri: fetch a list of bundles
  bundle: properly clear all revision flags
  bundle-uri: limit recursion depth for bundle lists
  bundle-uri: parse bundle list in config format
  bundle-uri: unit test "key=value" parsing
  bundle-uri: create "key=value" line parsing
  bundle-uri: create base key-value pair parsing
  bundle-uri: create bundle_list struct and helpers
  bundle-uri: use plain string in find_temp_filename()

18 months agoMerge branch 'rj/branch-do-not-exit-with-minus-one-status'
Taylor Blau [Mon, 31 Oct 2022 01:04:43 +0000 (21:04 -0400)] 
Merge branch 'rj/branch-do-not-exit-with-minus-one-status'

"git branch --edit-description" can exit with status -1 which is
not a good practice; it learned to use 1 as everybody else instead.

* rj/branch-do-not-exit-with-minus-one-status:
  branch: error code with --edit-description

18 months agoMerge branch 'rj/branch-copy-rename-error-codepath-cleanup'
Taylor Blau [Mon, 31 Oct 2022 01:04:43 +0000 (21:04 -0400)] 
Merge branch 'rj/branch-copy-rename-error-codepath-cleanup'

Code simplification.

* rj/branch-copy-rename-error-codepath-cleanup:
  branch: error copying or renaming a detached HEAD

18 months agoMerge branch 'tb/cap-patch-at-1gb'
Taylor Blau [Mon, 31 Oct 2022 01:04:43 +0000 (21:04 -0400)] 
Merge branch 'tb/cap-patch-at-1gb'

"git apply" limits its input to a bit less than 1 GiB.

* tb/cap-patch-at-1gb:
  apply: reject patches larger than ~1 GiB

18 months agoMerge branch 'jr/embargoed-releases-doc'
Taylor Blau [Mon, 31 Oct 2022 01:04:43 +0000 (21:04 -0400)] 
Merge branch 'jr/embargoed-releases-doc'

The role the security mailing list plays in an embargoed release
has been documented.

* jr/embargoed-releases-doc:
  embargoed releases: also describe the git-security list and the process

18 months agoMerge branch 'en/ort-dir-rename-and-symlink-fix'
Taylor Blau [Mon, 31 Oct 2022 01:04:43 +0000 (21:04 -0400)] 
Merge branch 'en/ort-dir-rename-and-symlink-fix'

Merging a branch with directory renames into a branch that changes
the directory to a symlink was mishandled by the ort merge
strategy, which has been corrected.

* en/ort-dir-rename-and-symlink-fix:
  merge-ort: fix bug with dir rename vs change dir to symlink

18 months agoMerge branch 'pb/subtree-split-and-merge-after-squashing-tag-fix'
Taylor Blau [Mon, 31 Oct 2022 01:04:43 +0000 (21:04 -0400)] 
Merge branch 'pb/subtree-split-and-merge-after-squashing-tag-fix'

A bugfix to "git subtree" in its split and merge features.

* pb/subtree-split-and-merge-after-squashing-tag-fix:
  subtree: fix split after annotated tag was squashed merged
  subtree: fix squash merging after annotated tag was squashed merged
  subtree: process 'git-subtree-split' trailer in separate function
  subtree: use named variables instead of "$@" in cmd_pull
  subtree: define a variable before its first use in 'find_latest_squash'
  subtree: prefix die messages with 'fatal'
  subtree: add 'die_incompatible_opt' function to reduce duplication
  subtree: use 'git rev-parse --verify [--quiet]' for better error messages
  test-lib-functions: mark 'test_commit' variables as 'local'

18 months agoMerge branch 'pw/rebase-reflog-fixes'
Taylor Blau [Mon, 31 Oct 2022 01:04:42 +0000 (21:04 -0400)] 
Merge branch 'pw/rebase-reflog-fixes'

Fix some bugs in the reflog messages when rebasing and changes the
reflog messages of "rebase --apply" to match "rebase --merge" with
the aim of making the reflog easier to parse.

* pw/rebase-reflog-fixes:
  rebase: cleanup action handling
  rebase --abort: improve reflog message
  rebase --apply: make reflog messages match rebase --merge
  rebase --apply: respect GIT_REFLOG_ACTION
  rebase --merge: fix reflog message after skipping
  rebase --merge: fix reflog when continuing
  t3406: rework rebase reflog tests
  rebase --apply: remove duplicated code

18 months agoMerge branch 'pw/rebase-keep-base-fixes'
Taylor Blau [Mon, 31 Oct 2022 01:04:42 +0000 (21:04 -0400)] 
Merge branch 'pw/rebase-keep-base-fixes'

"git rebase --keep-base" used to discard the commits that are
already cherry-picked to the upstream, even when "keep-base" meant
that the base, on top of which the history is being rebuilt, does
not yet include these cherry-picked commits.  The --keep-base
option now implies --reapply-cherry-picks and --no-fork-point
options.

* pw/rebase-keep-base-fixes:
  rebase --keep-base: imply --no-fork-point
  rebase --keep-base: imply --reapply-cherry-picks
  rebase: factor out branch_base calculation
  rebase: rename merge_base to branch_base
  rebase: store orig_head as a commit
  rebase: be stricter when reading state files containing oids
  t3416: set $EDITOR in subshell
  t3416: tighten two tests

18 months agoMerge branch 'jh/trace2-timers-and-counters'
Taylor Blau [Mon, 31 Oct 2022 01:04:42 +0000 (21:04 -0400)] 
Merge branch 'jh/trace2-timers-and-counters'

Two new facilities, "timer" and "counter", are introduced to the
trace2 API.

* jh/trace2-timers-and-counters:
  trace2: add global counter mechanism
  trace2: add stopwatch timers
  trace2: convert ctx.thread_name from strbuf to pointer
  trace2: improve thread-name documentation in the thread-context
  trace2: rename the thread_name argument to trace2_thread_start
  api-trace2.txt: elminate section describing the public trace2 API
  tr2tls: clarify TLS terminology
  trace2: use size_t alloc,nr_open_regions in tr2tls_thread_ctx

18 months agoMerge branch 'tb/shortlog-group'
Taylor Blau [Mon, 31 Oct 2022 01:04:42 +0000 (21:04 -0400)] 
Merge branch 'tb/shortlog-group'

"git shortlog" learned to group by the "format" string.

* tb/shortlog-group:
  shortlog: implement `--group=committer` in terms of `--group=<format>`
  shortlog: implement `--group=author` in terms of `--group=<format>`
  shortlog: extract `shortlog_finish_setup()`
  shortlog: support arbitrary commit format `--group`s
  shortlog: extract `--group` fragment for translation
  shortlog: make trailer insertion a noop when appropriate
  shortlog: accept `--date`-related options

18 months agoMerge branch 'rs/absorb-git-dir-simplify'
Taylor Blau [Mon, 31 Oct 2022 01:04:42 +0000 (21:04 -0400)] 
Merge branch 'rs/absorb-git-dir-simplify'

Code simplification by using strvec_pushf() instead of building an
argument in a separate strbuf.

* rs/absorb-git-dir-simplify:
  submodule: use strvec_pushf() for --super-prefix

18 months agoMerge branch 'jk/repack-tempfile-cleanup'
Taylor Blau [Mon, 31 Oct 2022 01:04:42 +0000 (21:04 -0400)] 
Merge branch 'jk/repack-tempfile-cleanup'

The way "git repack" creared temporary files when it received a
signal was prone to deadlocking, which has been corrected.

* jk/repack-tempfile-cleanup:
  t7700: annotate cruft-pack failure with ok=sigpipe
  repack: drop remove_temporary_files()
  repack: use tempfiles for signal cleanup
  repack: expand error message for missing pack files
  repack: populate extension bits incrementally
  repack: convert "names" util bitfield to array

18 months agoMerge branch 'sg/stable-docdep'
Taylor Blau [Mon, 31 Oct 2022 01:04:42 +0000 (21:04 -0400)] 
Merge branch 'sg/stable-docdep'

Make sure generated dependency file is stably sorted to help
developers debugging their build issues.

* sg/stable-docdep:
  Documentation/build-docdep.perl: generate sorted output

18 months agoMerge branch 'sd/doc-smtp-encryption'
Taylor Blau [Mon, 31 Oct 2022 01:04:42 +0000 (21:04 -0400)] 
Merge branch 'sd/doc-smtp-encryption'

* sd/doc-smtp-encryption:
  docs: git-send-email: difference between ssl and tls smtp-encryption

18 months agoMerge branch 'jz/patch-id'
Taylor Blau [Mon, 31 Oct 2022 01:04:41 +0000 (21:04 -0400)] 
Merge branch 'jz/patch-id'

A new "--include-whitespace" option is added to "git patch-id", and
existing bugs in the internal patch-id logic that did not match
what "git patch-id" produces have been corrected.

* jz/patch-id:
  builtin: patch-id: remove unused diff-tree prefix
  builtin: patch-id: add --verbatim as a command mode
  patch-id: fix patch-id for mode changes
  builtin: patch-id: fix patch-id with binary diffs
  patch-id: use stable patch-id for rebases
  patch-id: fix stable patch id for binary / header-only

18 months agoThe eighth batch
Junio C Hamano [Fri, 28 Oct 2022 18:27:01 +0000 (11:27 -0700)] 
The eighth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoMerge branch 'tb/diffstat-with-utf8-strwidth'
Junio C Hamano [Fri, 28 Oct 2022 18:26:55 +0000 (11:26 -0700)] 
Merge branch 'tb/diffstat-with-utf8-strwidth'

"git diff --stat" etc. were invented back when everything was ASCII
and strlen() was a way to measure the display width of a string;
adjust them to compute the display width assuming UTF-8 pathnames.

* tb/diffstat-with-utf8-strwidth:
  diff: leave NEEDWORK notes in show_stats() function
  diff.c: use utf8_strwidth() to count display width

18 months agoMerge branch 'mm/git-pm-try-catch-syntax-fix'
Junio C Hamano [Fri, 28 Oct 2022 18:26:54 +0000 (11:26 -0700)] 
Merge branch 'mm/git-pm-try-catch-syntax-fix'

Fix a longstanding syntax error in Git.pm error codepath.

* mm/git-pm-try-catch-syntax-fix:
  Git.pm: trust rev-parse to find bare repositories
  Git.pm: add semicolon after catch statement

18 months agoMerge branch 'tb/remove-unused-pack-bitmap'
Junio C Hamano [Fri, 28 Oct 2022 18:26:54 +0000 (11:26 -0700)] 
Merge branch 'tb/remove-unused-pack-bitmap'

When creating a multi-pack bitmap, remove per-pack bitmap files
unconditionally as they will never be consulted.

* tb/remove-unused-pack-bitmap:
  builtin/repack.c: remove redundant pack-based bitmaps

18 months agoMerge branch 'ab/doc-synopsis-and-cmd-usage'
Junio C Hamano [Fri, 28 Oct 2022 18:26:54 +0000 (11:26 -0700)] 
Merge branch 'ab/doc-synopsis-and-cmd-usage'

The short-help text shown by "git cmd -h" and the synopsis text
shown at the beginning of "git help cmd" have been made more
consistent.

* ab/doc-synopsis-and-cmd-usage: (34 commits)
  tests: assert consistent whitespace in -h output
  tests: start asserting that *.txt SYNOPSIS matches -h output
  doc txt & -h consistency: make "worktree" consistent
  worktree: define subcommand -h in terms of command -h
  reflog doc: list real subcommands up-front
  doc txt & -h consistency: make "commit" consistent
  doc txt & -h consistency: make "diff-tree" consistent
  doc txt & -h consistency: use "[<label>...]" for "zero or more"
  doc txt & -h consistency: make "annotate" consistent
  doc txt & -h consistency: make "stash" consistent
  doc txt & -h consistency: add missing options
  doc txt & -h consistency: use "git foo" form, not "git-foo"
  doc txt & -h consistency: make "bundle" consistent
  doc txt & -h consistency: make "read-tree" consistent
  doc txt & -h consistency: make "rerere" consistent
  doc txt & -h consistency: add missing options and labels
  doc txt & -h consistency: make output order consistent
  doc txt & -h consistency: add or fix optional "--" syntax
  doc txt & -h consistency: fix mismatching labels
  doc SYNOPSIS & -h: use "-" to separate words in labels, not "_"
  ...

18 months agoThe seventh batch
Junio C Hamano [Thu, 27 Oct 2022 22:25:55 +0000 (15:25 -0700)] 
The seventh batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoSync with 'maint'
Junio C Hamano [Thu, 27 Oct 2022 22:25:24 +0000 (15:25 -0700)] 
Sync with 'maint'

18 months agoDownmerge a bit more for 2.38.2
Junio C Hamano [Thu, 27 Oct 2022 22:24:23 +0000 (15:24 -0700)] 
Downmerge a bit more for 2.38.2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoMerge branch 'rs/archive-dedup-printf' into maint-2.38
Junio C Hamano [Thu, 27 Oct 2022 22:24:14 +0000 (15:24 -0700)] 
Merge branch 'rs/archive-dedup-printf' into maint-2.38

Code simplification.

* rs/archive-dedup-printf:
  archive: deduplicate verbose printing

18 months agoMerge branch 'jh/struct-zero-init-with-older-clang' into maint-2.38
Junio C Hamano [Thu, 27 Oct 2022 22:24:13 +0000 (15:24 -0700)] 
Merge branch 'jh/struct-zero-init-with-older-clang' into maint-2.38

Work around older clang that warns against C99 zero initialization
syntax for struct.

* jh/struct-zero-init-with-older-clang:
  config.mak.dev: disable suggest braces error on old clang versions

18 months agoMerge branch 'rs/use-fspathncmp' into maint-2.38
Junio C Hamano [Thu, 27 Oct 2022 22:24:13 +0000 (15:24 -0700)] 
Merge branch 'rs/use-fspathncmp' into maint-2.38

Code clean-up.

* rs/use-fspathncmp:
  dir: use fspathncmp() in pl_hashmap_cmp()

18 months agoMerge branch 'rj/branch-edit-desc-unborn' into maint-2.38
Junio C Hamano [Thu, 27 Oct 2022 22:24:13 +0000 (15:24 -0700)] 
Merge branch 'rj/branch-edit-desc-unborn' into maint-2.38

"git branch --edit-description" on an unborh branch misleadingly
said that no such branch exists, which has been corrected.

* rj/branch-edit-desc-unborn:
  branch: description for non-existent branch errors

18 months agoMerge branch 'pw/remove-rebase-p-test' into maint-2.38
Junio C Hamano [Thu, 27 Oct 2022 22:24:13 +0000 (15:24 -0700)] 
Merge branch 'pw/remove-rebase-p-test' into maint-2.38

Remove outdated test.

* pw/remove-rebase-p-test:
  t3435: remove redundant test case

18 months agoMerge branch 'jc/use-of-uc-in-log-messages' into maint-2.38
Junio C Hamano [Thu, 27 Oct 2022 22:24:13 +0000 (15:24 -0700)] 
Merge branch 'jc/use-of-uc-in-log-messages' into maint-2.38

Clarify that "the sentence after <area>: prefix does not begin with
a capital letter" rule applies only to the commit title.

* jc/use-of-uc-in-log-messages:
  SubmittingPatches: use usual capitalization in the log message body

18 months agoMerge branch 'jc/tmp-objdir' into maint-2.38
Junio C Hamano [Thu, 27 Oct 2022 22:24:12 +0000 (15:24 -0700)] 
Merge branch 'jc/tmp-objdir' into maint-2.38

The code to clean temporary object directories (used for
quarantine) tried to remove them inside its signal handler, which
was a no-no.

* jc/tmp-objdir:
  tmp-objdir: skip clean up when handling a signal

18 months agoMerge branch 'dd/document-runtime-prefix-better' into maint-2.38
Junio C Hamano [Thu, 27 Oct 2022 22:24:12 +0000 (15:24 -0700)] 
Merge branch 'dd/document-runtime-prefix-better' into maint-2.38

Update comment in the Makefile about the RUNTIME_PREFIX config knob.

* dd/document-runtime-prefix-better:
  Makefile: clarify runtime relative gitexecdir

18 months agoMerge branch 'ab/unused-annotation' into maint-2.38
Junio C Hamano [Thu, 27 Oct 2022 22:24:12 +0000 (15:24 -0700)] 
Merge branch 'ab/unused-annotation' into maint-2.38

Compilation fix for ancient compilers.

* ab/unused-annotation:
  git-compat-util.h: GCC deprecated message arg only in GCC 4.5+

18 months agoMerge branch 'tb/midx-repack-ignore-cruft-packs' into maint-2.38
Junio C Hamano [Thu, 27 Oct 2022 22:24:11 +0000 (15:24 -0700)] 
Merge branch 'tb/midx-repack-ignore-cruft-packs' into maint-2.38

"git multi-pack-index repack/expire" used to repack unreachable
cruft into a new pack, which have been corrected.
cf. <63a1c3d4-eff3-af10-4263-058c88e74594@github.com>

* tb/midx-repack-ignore-cruft-packs:
  midx.c: avoid cruft packs with non-zero `repack --batch-size`
  midx.c: remove unnecessary loop condition
  midx.c: replace `xcalloc()` with `CALLOC_ARRAY()`
  midx.c: avoid cruft packs with `repack --batch-size=0`
  midx.c: prevent `expire` from removing the cruft pack
  Documentation/git-multi-pack-index.txt: clarify expire behavior
  Documentation/git-multi-pack-index.txt: fix typo

18 months agoMerge branch 'so/diff-merges-cleanup' into maint-2.38
Junio C Hamano [Thu, 27 Oct 2022 22:24:11 +0000 (15:24 -0700)] 
Merge branch 'so/diff-merges-cleanup' into maint-2.38

Code clean-up.

* so/diff-merges-cleanup:
  diff-merges: clarify log.diffMerges documentation
  diff-merges: cleanup set_diff_merges()
  diff-merges: cleanup func_by_opt()

18 months agoMerge branch 'rj/ref-filter-get-head-description-leakfix' into maint-2.38
Junio C Hamano [Thu, 27 Oct 2022 22:24:11 +0000 (15:24 -0700)] 
Merge branch 'rj/ref-filter-get-head-description-leakfix' into maint-2.38

Leakfix.

* rj/ref-filter-get-head-description-leakfix:
  ref-filter.c: fix a leak in get_head_description

18 months agoMerge branch 'jc/environ-docs' into maint-2.38
Junio C Hamano [Thu, 27 Oct 2022 22:24:09 +0000 (15:24 -0700)] 
Merge branch 'jc/environ-docs' into maint-2.38

Documentation on various Boolean GIT_* environment variables have
been clarified.

* jc/environ-docs:
  environ: GIT_INDEX_VERSION affects not just a new repository
  environ: simplify description of GIT_INDEX_FILE
  environ: GIT_FLUSH should be made a usual Boolean
  environ: explain Boolean environment variables
  environ: document GIT_SSL_NO_VERIFY

18 months agoMakefile: force -O0 when compiling with SANITIZE=leak
Jeff King [Tue, 18 Oct 2022 20:15:33 +0000 (16:15 -0400)] 
Makefile: force -O0 when compiling with SANITIZE=leak

Cherry pick commit d3775de0 (Makefile: force -O0 when compiling with
SANITIZE=leak, 2022-10-18), as otherwise the leak checker at GitHub
Actions CI seems to fail with a false positive.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoMerge branch 'js/cmake-updates'
Junio C Hamano [Thu, 27 Oct 2022 21:51:53 +0000 (14:51 -0700)] 
Merge branch 'js/cmake-updates'

Update to build procedure with VS using CMake/CTest.

* js/cmake-updates:
  cmake: increase time-out for a long-running test
  cmake: avoid editing t/test-lib.sh
  add -p: avoid ambiguous signed/unsigned comparison
  cmake: copy the merge tools for testing
  cmake: make it easier to diagnose regressions in CTest runs

18 months agoMerge branch 'nw/t1002-cleanup'
Junio C Hamano [Thu, 27 Oct 2022 21:51:53 +0000 (14:51 -0700)] 
Merge branch 'nw/t1002-cleanup'

Code clean-up in test.

* nw/t1002-cleanup:
  t1002: modernize outdated conditional

18 months agoMerge branch 'ab/run-hook-api-cleanup'
Junio C Hamano [Thu, 27 Oct 2022 21:51:53 +0000 (14:51 -0700)] 
Merge branch 'ab/run-hook-api-cleanup'

Move a global variable added as a hack during regression fixes to
its proper place in the API.

* ab/run-hook-api-cleanup:
  run-command.c: remove "max_processes", add "const" to signal() handler
  run-command.c: pass "opts" further down, and use "opts->processes"
  run-command.c: use "opts->processes", not "pp->max_processes"
  run-command.c: don't copy "data" to "struct parallel_processes"
  run-command.c: don't copy "ungroup" to "struct parallel_processes"
  run-command.c: don't copy *_fn to "struct parallel_processes"
  run-command.c: make "struct parallel_processes" const if possible
  run-command API: move *_tr2() users to "run_processes_parallel()"
  run-command API: have run_process_parallel() take an "opts" struct
  run-command.c: use designated init for pp_init(), add "const"
  run-command API: don't fall back on online_cpus()
  run-command API: make "n" parameter a "size_t"
  run-command tests: use "return", not "exit"
  run-command API: have "run_processes_parallel{,_tr2}()" return void
  run-command test helper: use "else if" pattern

18 months agoMerge branch 'tb/save-keep-pack-during-geometric-repack'
Junio C Hamano [Thu, 27 Oct 2022 21:51:53 +0000 (14:51 -0700)] 
Merge branch 'tb/save-keep-pack-during-geometric-repack'

When geometric repacking feature is in use together with the
--pack-kept-objects option, we lost packs marked with .keep files.

* tb/save-keep-pack-during-geometric-repack:
  repack: don't remove .keep packs with `--pack-kept-objects`

18 months agoMerge branch 'jk/unused-anno-more'
Junio C Hamano [Thu, 27 Oct 2022 21:51:52 +0000 (14:51 -0700)] 
Merge branch 'jk/unused-anno-more'

More UNUSED annotation to help using -Wunused option with the
compiler.

* jk/unused-anno-more:
  ll-merge: mark unused parameters in callbacks
  diffcore-pickaxe: mark unused parameters in pickaxe functions
  convert: mark unused parameter in null stream filter
  apply: mark unused parameters in noop error/warning routine
  apply: mark unused parameters in handlers
  date: mark unused parameters in handler functions
  string-list: mark unused callback parameters
  object-file: mark unused parameters in hash_unknown functions
  mark unused parameters in trivial compat functions
  update-index: drop unused argc from do_reupdate()
  submodule--helper: drop unused argc from module_list_compute()
  diffstat_consume(): assert non-zero length

18 months agoMerge branch 'tb/midx-bitmap-selection-fix'
Junio C Hamano [Thu, 27 Oct 2022 21:51:52 +0000 (14:51 -0700)] 
Merge branch 'tb/midx-bitmap-selection-fix'

A bugfix with tracing support in midx codepath

* tb/midx-bitmap-selection-fix:
  pack-bitmap-write.c: instrument number of reused bitmaps
  midx.c: instrument MIDX and bitmap generation with trace2 regions
  midx.c: consider annotated tags during bitmap selection
  midx.c: fix whitespace typo

18 months agobranch: error code with --edit-description
Rubén Justo [Tue, 25 Oct 2022 22:57:18 +0000 (00:57 +0200)] 
branch: error code with --edit-description

Since c2d17ba3db0d (branch --edit-description: protect against mistyped
branch name, 2012-02-05) we return -1 on error editing the branch
description.

Let's change to 1, which follows the established convention and it is
better for portability reasons.

Signed-off-by: Rubén Justo <rjusto@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agobranch: error copying or renaming a detached HEAD
Rubén Justo [Tue, 25 Oct 2022 23:01:29 +0000 (01:01 +0200)] 
branch: error copying or renaming a detached HEAD

In c847f53712 (Detached HEAD (experimental), 2007-01-01) an error
condition was introduced in rename_branch() to prevent renaming, later
also copying, a detached HEAD.

The condition used was checking for NULL in oldname, the source branch
to rename/copy.  That condition cannot be satisfied because if no source
branch is specified, HEAD is going to be used in the call.

The error issued instead is:

fatal: Invalid branch name: 'HEAD'

Let's remove the condition in copy_or_rename_branch() (the current
function name) and check for HEAD before calling it, dying with the
original intended error if we're in a detached HEAD.

Signed-off-by: Rubén Justo <rjusto@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoSync with 'maint'
Junio C Hamano [Wed, 26 Oct 2022 00:12:09 +0000 (17:12 -0700)] 
Sync with 'maint'

18 months agoThe sixth batch
Junio C Hamano [Tue, 25 Oct 2022 23:22:28 +0000 (16:22 -0700)] 
The sixth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoMerge branch 'jc/more-sanitizer-at-ci'
Junio C Hamano [Wed, 26 Oct 2022 00:11:44 +0000 (17:11 -0700)] 
Merge branch 'jc/more-sanitizer-at-ci'

Enable address and undefined sanitizer tasks at GitHub Actions CI.

* jc/more-sanitizer-at-ci:
  ci: add address and undefined sanitizer tasks

18 months agoMerge branch 'jc/ci-osx-with-sha1dc'
Junio C Hamano [Wed, 26 Oct 2022 00:11:44 +0000 (17:11 -0700)] 
Merge branch 'jc/ci-osx-with-sha1dc'

Give a bit more diversity to macOS CI by using sha1dc in one of the
jobs (the other one tests Apple Common Crypto).

* jc/ci-osx-with-sha1dc:
  ci: use DC_SHA1=YesPlease on osx-clang job for CI

18 months agoMerge branch 'gc/bare-repo-discovery'
Junio C Hamano [Wed, 26 Oct 2022 00:11:44 +0000 (17:11 -0700)] 
Merge branch 'gc/bare-repo-discovery'

Allow configuration files in "protected" scopes to include other
configuration files.

* gc/bare-repo-discovery:
  config: respect includes in protected config

18 months agoMerge branch 'rs/diff-caret-bang-with-parents'
Junio C Hamano [Wed, 26 Oct 2022 00:11:43 +0000 (17:11 -0700)] 
Merge branch 'rs/diff-caret-bang-with-parents'

"git diff rev^!" did not show combined diff to go to the rev from
its parents.

* rs/diff-caret-bang-with-parents:
  diff: support ^! for merges
  revisions.txt: unspecify order of resolved parts of ^!
  revision: use strtol_i() for exclude_parent

18 months agoDownmerge a handful of topics for 2.38.2
Junio C Hamano [Wed, 26 Oct 2022 00:11:13 +0000 (17:11 -0700)] 
Downmerge a handful of topics for 2.38.2

18 months agoMerge branch 'jk/cleanup-callback-parameters' into maint-2.38
Junio C Hamano [Wed, 26 Oct 2022 00:11:39 +0000 (17:11 -0700)] 
Merge branch 'jk/cleanup-callback-parameters' into maint-2.38

Code clean-up.

* jk/cleanup-callback-parameters:
  attr: drop DEBUG_ATTR code
  commit: avoid writing to global in option callback
  multi-pack-index: avoid writing to global in option callback
  test-submodule: inline resolve_relative_url() function

18 months agoMerge branch 'rs/gc-pack-refs-simplify' into maint-2.38
Junio C Hamano [Wed, 26 Oct 2022 00:11:39 +0000 (17:11 -0700)] 
Merge branch 'rs/gc-pack-refs-simplify' into maint-2.38

Code clean-up.

* rs/gc-pack-refs-simplify:
  gc: simplify maintenance_task_pack_refs()

18 months agoMerge branch 'nb/doc-mergetool-typofix' into maint-2.38
Junio C Hamano [Wed, 26 Oct 2022 00:11:38 +0000 (17:11 -0700)] 
Merge branch 'nb/doc-mergetool-typofix' into maint-2.38

Typofix.

* nb/doc-mergetool-typofix:
  mergetool.txt: typofix 'overwriten' -> 'overwritten'

18 months agoMerge branch 'jk/sequencer-missing-author-name-check' into maint-2.38
Junio C Hamano [Wed, 26 Oct 2022 00:11:38 +0000 (17:11 -0700)] 
Merge branch 'jk/sequencer-missing-author-name-check' into maint-2.38

Typofix in code.

* jk/sequencer-missing-author-name-check:
  sequencer: detect author name errors in read_author_script()

18 months agoMerge branch 'ds/bundle-uri-docfix' into maint-2.38
Junio C Hamano [Wed, 26 Oct 2022 00:11:37 +0000 (17:11 -0700)] 
Merge branch 'ds/bundle-uri-docfix' into maint-2.38

Doc formatting fix.

* ds/bundle-uri-docfix:
  bundle-uri: fix technical doc issues

18 months agoMerge branch 'ab/test-malloc-with-sanitize-leak' into maint-2.38
Junio C Hamano [Wed, 26 Oct 2022 00:11:37 +0000 (17:11 -0700)] 
Merge branch 'ab/test-malloc-with-sanitize-leak' into maint-2.38

Test fix.

* ab/test-malloc-with-sanitize-leak:
  test-lib: have SANITIZE=leak imply TEST_NO_MALLOC_CHECK

18 months agoMerge branch 'rs/bisect-start-leakfix' into maint-2.38
Junio C Hamano [Wed, 26 Oct 2022 00:11:37 +0000 (17:11 -0700)] 
Merge branch 'rs/bisect-start-leakfix' into maint-2.38

Code clean-up that results in plugging a leak.

* rs/bisect-start-leakfix:
  bisect--helper: plug strvec leak

18 months agoMerge branch 'jc/branch-description-unset' into maint-2.38
Junio C Hamano [Wed, 26 Oct 2022 00:11:37 +0000 (17:11 -0700)] 
Merge branch 'jc/branch-description-unset' into maint-2.38

"GIT_EDITOR=: git branch --edit-description" resulted in failure,
which has been corrected.

* jc/branch-description-unset:
  branch: do not fail a no-op --edit-desc

18 months agoMerge branch 'pw/ssh-sign-report-errors' into maint-2.38
Junio C Hamano [Wed, 26 Oct 2022 00:11:35 +0000 (17:11 -0700)] 
Merge branch 'pw/ssh-sign-report-errors' into maint-2.38

The codepath to sign learned to report errors when it fails to read
from "ssh-keygen".

* pw/ssh-sign-report-errors:
  ssh signing: return an error when signature cannot be read

18 months agoMerge branch 'pw/mailinfo-b-fix' into maint-2.38
Junio C Hamano [Wed, 26 Oct 2022 00:11:35 +0000 (17:11 -0700)] 
Merge branch 'pw/mailinfo-b-fix' into maint-2.38

Fix a logic in "mailinfo -b" that miscomputed the length of a
substring, which lead to an out-of-bounds access.

* pw/mailinfo-b-fix:
  mailinfo -b: fix an out of bounds access

18 months agoMerge branch 'rs/test-httpd-in-C-locale' into maint-2.38
Junio C Hamano [Wed, 26 Oct 2022 00:11:35 +0000 (17:11 -0700)] 
Merge branch 'rs/test-httpd-in-C-locale' into maint-2.38

Force C locale while running tests around httpd to make sure we can
find expected error messages in the log.

* rs/test-httpd-in-C-locale:
  t/lib-httpd: pass LANG and LC_ALL to Apache

18 months agoMerge branch 'js/merge-ort-in-read-only-repo' into maint-2.38
Junio C Hamano [Wed, 26 Oct 2022 00:11:34 +0000 (17:11 -0700)] 
Merge branch 'js/merge-ort-in-read-only-repo' into maint-2.38

In read-only repositories, "git merge-tree" tried to come up with a
merge result tree object, which it failed (which is not wrong) and
led to a segfault (which is bad), which has been corrected.

* js/merge-ort-in-read-only-repo:
  merge-ort: return early when failing to write a blob
  merge-ort: fix segmentation fault in read-only repositories

18 months agoMerge branch 'ja/rebase-i-avoid-amending-self' into maint-2.38
Junio C Hamano [Wed, 26 Oct 2022 00:11:34 +0000 (17:11 -0700)] 
Merge branch 'ja/rebase-i-avoid-amending-self' into maint-2.38

"git rebase -i" can mistakenly attempt to apply a fixup to a commit
itself, which has been corrected.

* ja/rebase-i-avoid-amending-self:
  sequencer: avoid dropping fixup commit that targets self via commit-ish

18 months agoMerge branch 'jk/fsck-on-diet' into maint-2.38
Junio C Hamano [Wed, 26 Oct 2022 00:11:33 +0000 (17:11 -0700)] 
Merge branch 'jk/fsck-on-diet' into maint-2.38

"git fsck" failed to release contents of tree objects already used
from the memory, which has been fixed.

* jk/fsck-on-diet:
  parse_object_buffer(): respect save_commit_buffer
  fsck: turn off save_commit_buffer
  fsck: free tree buffers after walking unreachable objects

18 months agoMerge branch 'ah/fsmonitor-daemon-usage-non-l10n' into maint-2.38
Junio C Hamano [Wed, 26 Oct 2022 00:11:33 +0000 (17:11 -0700)] 
Merge branch 'ah/fsmonitor-daemon-usage-non-l10n' into maint-2.38

Fix messages incorrectly marked for translation.

* ah/fsmonitor-daemon-usage-non-l10n:
  fsmonitor--daemon: don't translate literal commands

18 months agoMerge branch 'jk/clone-allow-bare-and-o-together' into maint-2.38
Junio C Hamano [Wed, 26 Oct 2022 00:11:33 +0000 (17:11 -0700)] 
Merge branch 'jk/clone-allow-bare-and-o-together' into maint-2.38

"git clone" did not like to see the "--bare" and the "--origin"
options used together without a good reason.

* jk/clone-allow-bare-and-o-together:
  clone: allow "--bare" with "-o"

18 months agoMerge branch 'jk/remote-rename-without-fetch-refspec' into maint-2.38
Junio C Hamano [Wed, 26 Oct 2022 00:11:32 +0000 (17:11 -0700)] 
Merge branch 'jk/remote-rename-without-fetch-refspec' into maint-2.38

"git remote rename" failed to rename a remote without fetch
refspec, which has been corrected.

* jk/remote-rename-without-fetch-refspec:
  remote: handle rename of remote without fetch refspec

18 months agoMerge branch 'vd/fix-unaligned-read-index-v4' into maint-2.38
Junio C Hamano [Wed, 26 Oct 2022 00:11:32 +0000 (17:11 -0700)] 
Merge branch 'vd/fix-unaligned-read-index-v4' into maint-2.38

The codepath that reads from the index v4 had unaligned memory
accesses, which has been corrected.

* vd/fix-unaligned-read-index-v4:
  read-cache: avoid misaligned reads in index v4

18 months agoMerge branch 'ab/coding-guidelines-c99' into maint-2.38
Junio C Hamano [Wed, 26 Oct 2022 00:11:32 +0000 (17:11 -0700)] 
Merge branch 'ab/coding-guidelines-c99' into maint-2.38

Update CodingGuidelines to clarify what features to use and avoid
in C99.

* ab/coding-guidelines-c99:
  CodingGuidelines: recommend against unportable C99 struct syntax
  CodingGuidelines: mention C99 features we can't use
  CodingGuidelines: allow declaring variables in for loops
  CodingGuidelines: mention dynamic C99 initializer elements
  CodingGuidelines: update for C99

18 months agoapply: reject patches larger than ~1 GiB
Taylor Blau [Tue, 25 Oct 2022 18:24:31 +0000 (14:24 -0400)] 
apply: reject patches larger than ~1 GiB

The apply code is not prepared to handle extremely large files. It uses
"int" in some places, and "unsigned long" in others.

This combination leads to unfortunate problems when switching between
the two types. Using "int" prevents us from handling large files, since
large offsets will wrap around and spill into small negative values,
which can result in wrong behavior (like accessing the patch buffer with
a negative offset).

Converting from "unsigned long" to "int" also has truncation problems
even on LLP64 platforms where "long" is the same size as "int", since
the former is unsigned but the latter is not.

To avoid potential overflow and truncation issues in `git apply`, apply
similar treatment as in dcd1742e56 (xdiff: reject files larger than
~1GB, 2015-09-24), where the xdiff code was taught to reject large
files for similar reasons.

The maximum size was chosen somewhat arbitrarily, but picking a value
just shy of a gigabyte allows us to double it without overflowing 2^31-1
(after which point our value would wrap around to a negative number).
To give ourselves a bit of extra margin, the maximum patch size is a MiB
smaller than a full GiB, which gives us some slop in case we allocate
"(records + 1) * sizeof(int)" or similar.

Luckily, the security implications of these conversion issues are
relatively uninteresting, because a victim needs to be convinced to
apply a malicious patch.

Reported-by: 정재우 <thebound7@gmail.com>
Suggested-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoembargoed releases: also describe the git-security list and the process
Julia Ramer [Mon, 24 Oct 2022 22:07:19 +0000 (22:07 +0000)] 
embargoed releases: also describe the git-security list and the process

With the recent turnover on the git-security list, questions came up how
things are usually run. Rather than answering questions individually,
extend Git's existing documentation about security vulnerabilities to
describe the git-security mailing list, how things are run on that list,
and what to expect throughout the process from the time a security bug
is reported all the way to the time when a fix is released.

Helped-by: Junio C Hamano <gitster@pobox.com>
Helped-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Julia Ramer <gitprplr@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agobuiltin: patch-id: remove unused diff-tree prefix
Jerry Zhang [Mon, 24 Oct 2022 20:07:44 +0000 (20:07 +0000)] 
builtin: patch-id: remove unused diff-tree prefix

The last git version that had "diff-tree" in the header text
of "git diff-tree" output was v1.3.0 from 2006. The header text
was changed from "diff-tree" to "commit" in 91539833
("Log message printout cleanups").

Given how long ago this change was made, it is highly unlikely that
anyone is still feeding in outputs from that git version.

Remove the handling of the "diff-tree" prefix and document the
source of the other prefixes so that the overall functionality
is more clear.

Signed-off-by: Jerry Zhang <Jerry@skydio.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agobuiltin: patch-id: add --verbatim as a command mode
Jerry Zhang [Mon, 24 Oct 2022 20:07:43 +0000 (20:07 +0000)] 
builtin: patch-id: add --verbatim as a command mode

There are situations where the user might not want the default
setting where patch-id strips all whitespace. They might be working
in a language where white space is syntactically important, or they
might have CI testing that enforces strict whitespace linting. In
these cases, a whitespace change would result in the patch
fundamentally changing, and thus deserving of a different id.

Add a new mode that is exclusive of --stable and --unstable called
--verbatim. It also corresponds to the config
patchid.verbatim = true. In this mode, the stable algorithm is
used and whitespace is not stripped from the patch text.

Users of --unstable mainly care about compatibility with old git
versions, which unstripping the whitespace would break. Thus there
isn't a usecase for the combination of --verbatim and --unstable,
and we don't expose this so as to not add maintainence burden.

Signed-off-by: Jerry Zhang <jerry@skydio.com>
fixes https://github.com/Skydio/revup/issues/2
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agopatch-id: fix patch-id for mode changes
Jerry Zhang [Mon, 24 Oct 2022 20:07:42 +0000 (20:07 +0000)] 
patch-id: fix patch-id for mode changes

Currently patch-id as used in rebase and cherry-pick does not account
for file modes if the file is modified. One consequence of this is
that if you have a local patch that changes modes, but upstream
has applied an outdated version of the patch that doesn't include
that mode change, "git rebase" will drop your local version of the
patch along with your mode changes. It also means that internal
patch-id doesn't produce the same output as the builtin, which does
account for mode changes due to them being part of diff output.

Fix by adding mode to the patch-id if it has changed, in the same
format that would be produced by diff, so that it is compatible
with builtin patch-id.

Signed-off-by: Jerry Zhang <Jerry@skydio.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agobuiltin: patch-id: fix patch-id with binary diffs
Jerry Zhang [Mon, 24 Oct 2022 20:07:41 +0000 (20:07 +0000)] 
builtin: patch-id: fix patch-id with binary diffs

"git patch-id" currently doesn't produce correct output if the
incoming diff has any binary files. Add logic to get_one_patchid
to handle the different possible styles of binary diff. This
attempts to keep resulting patch-ids identical to what would be
produced by the counterpart logic in diff.c, that is it produces
the id by hashing the a and b oids in succession.

In general we handle binary diffs by first caching the object ids from
the "index" line and using those if we then find an indication
that the diff is binary.

The input could contain patches generated with "git diff --binary". This
currently breaks the parse logic and results in multiple patch-ids
output for a single commit. Here we have to skip the contents of the
patch itself since those do not go into the patch id. --binary
implies --full-index so the object ids are always available.

When the diff is generated with --full-index there is no patch content
to skip over.

When a diff is generated without --full-index or --binary, it will
contain abbreviated object ids. This will still result in a sufficiently
unique patch-id when hashed, but does not match internal patch id
output. We'll call this ok for now as we already need specialized
arguments to diff in order to match internal patch id (namely -U3).

Signed-off-by: Jerry Zhang <Jerry@skydio.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agopatch-id: use stable patch-id for rebases
Jerry Zhang [Mon, 24 Oct 2022 20:07:40 +0000 (20:07 +0000)] 
patch-id: use stable patch-id for rebases

Git doesn't persist patch-ids during the rebase process, so there is
no need to specifically invoke the unstable variant. Use the stable
logic for all internal patch-id calculations to minimize the number of
code paths and improve test coverage.

Signed-off-by: Jerry Zhang <jerry@skydio.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agopatch-id: fix stable patch id for binary / header-only
Jerry Zhang [Mon, 24 Oct 2022 20:07:39 +0000 (20:07 +0000)] 
patch-id: fix stable patch id for binary / header-only

Patch-ids for binary patches are found by hashing the object
ids of the before and after objects in succession. However in
the --stable case, there is a bug where hunks are not flushed
for binary and header-only patch ids, which would always result
in a patch-id of 0000. The --unstable case is currently correct.

Reorder the logic to branch into 3 cases for populating the
patch body: header-only which populates nothing, binary which
populates the object ids, and normal which populates the text
diff. All branches will end up flushing the hunk.

Don't populate the ---a/ and +++b/ lines for binary diffs, to correspond
to those lines not being present in the "git diff" text output.
This is necessary because we advertise that the patch-id calculated
internally and used in format-patch is the same that what the
builtin "git patch-id" would produce when piped from a diff.

Update the test to run on both binary and normal files.

Signed-off-by: Jerry Zhang <jerry@skydio.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoshortlog: implement `--group=committer` in terms of `--group=<format>`
Taylor Blau [Mon, 24 Oct 2022 18:55:47 +0000 (14:55 -0400)] 
shortlog: implement `--group=committer` in terms of `--group=<format>`

In the same spirit as the previous commit, reimplement
`--group=committer` as a special case of `--group=<format>`, too.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoshortlog: implement `--group=author` in terms of `--group=<format>`
Taylor Blau [Mon, 24 Oct 2022 18:55:44 +0000 (14:55 -0400)] 
shortlog: implement `--group=author` in terms of `--group=<format>`

Instead of handling SHORTLOG_GROUP_AUTHOR separately, reimplement it as
a special case of the new `--group=<format>` mode, where the author mode
is a shorthand for `--group='%aN <%aE>'.

Note that we still need to keep the SHORTLOG_GROUP_AUTHOR enum since it
has a different meaning in `read_from_stdin()`, where it is still used
for a different purpose.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoshortlog: extract `shortlog_finish_setup()`
Taylor Blau [Mon, 24 Oct 2022 18:55:41 +0000 (14:55 -0400)] 
shortlog: extract `shortlog_finish_setup()`

Extract a function which finishes setting up the shortlog struct for
use. The caller in `make_cover_letter()` does not care about trailer
sorting, so it isn't strictly necessary to add a call there in this
patch.

But the next patch will add additional functionality to the new
`shortlog_finish_setup()` function, which the caller in
`make_cover_letter()` will care about.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoshortlog: support arbitrary commit format `--group`s
Taylor Blau [Mon, 24 Oct 2022 18:55:39 +0000 (14:55 -0400)] 
shortlog: support arbitrary commit format `--group`s

In addition to generating a shortlog based on committer, author, or the
identity in one or more specified trailers, it can be useful to generate
a shortlog based on an arbitrary commit format.

This can be used, for example, to generate a distribution of commit
activity over time, like so:

    $ git shortlog --group='%cd' --date='format:%Y-%m' -s v2.37.0..
       117  2022-06
       274  2022-07
       324  2022-08
       263  2022-09
         7  2022-10

Arbitrary commit formats can be used. In fact, `git shortlog`'s default
behavior (to count by commit authors) can be emulated as follows:

    $ git shortlog --group='%aN <%aE>' ...

and future patches will make the default behavior (as well as
`--committer`, and `--group=trailer:<trailer>`) special cases of the
more flexible `--group` option.

Note also that the SHORTLOG_GROUP_FORMAT enum value is used only to
designate that `--group:<format>` is in use when in stdin mode to
declare that the combination is invalid.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoshortlog: extract `--group` fragment for translation
Taylor Blau [Mon, 24 Oct 2022 18:55:36 +0000 (14:55 -0400)] 
shortlog: extract `--group` fragment for translation

The subsequent commit will add another unhandled case in
`read_from_stdin()` which will want to use the same message as with
`--group=trailer`.

Extract the "--group=trailer" part from this message so the same
translation key can be used for both cases.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoshortlog: make trailer insertion a noop when appropriate
Taylor Blau [Mon, 24 Oct 2022 18:55:33 +0000 (14:55 -0400)] 
shortlog: make trailer insertion a noop when appropriate

When there are no trailers to insert, it is natural that
insert_records_from_trailers() should return without having done any
work.

But instead we guard this call unnecessarily by first checking whether
`log->groups` has the `SHORTLOG_GROUP_TRAILER` bit set.

Prepare to match a similar pattern in the future where a function which
inserts records of a certain type does no work when no specifiers
matching that type are given.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoshortlog: accept `--date`-related options
Jeff King [Mon, 24 Oct 2022 18:55:30 +0000 (14:55 -0400)] 
shortlog: accept `--date`-related options

Prepare for a future patch which will introduce arbitrary pretty formats
via the `--group` argument.

To allow additional customizability (for example, to support something
like `git shortlog -s --group='%aD' --date='format:%Y-%m' ...` (which
groups commits by the datestring 'YYYY-mm' according to author date), we
must store off the `--date` parsed from calling `parse_revision_opt()`.

Note that this also affects custom output `--format` strings in `git
shortlog`. Though this is a behavior change, this is arguably fixing a
long-standing bug (ie., that `--format` strings are not affected by
`--date` specifiers as they should be).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agotrace2: add global counter mechanism
Jeff Hostetler [Mon, 24 Oct 2022 13:41:07 +0000 (13:41 +0000)] 
trace2: add global counter mechanism

Add global counters mechanism to Trace2.

The Trace2 counters mechanism adds the ability to create a set of
global counter variables and an API to increment them efficiently.
Counters can optionally report per-thread usage in addition to the sum
across all threads.

Counter events are emitted to the Trace2 logs when a thread exits and
at process exit.

Counters are an alternative to `data` and `data_json` events.

Counters are useful when you want to measure something across the life
of the process, when you don't want per-measurement events for
performance reasons, when the data does not fit conveniently within a
region, or when your control flow does not easily let you write the
final total.  For example, you might use this to report the number of
calls to unzip() or the number of de-delta steps during a checkout.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agotrace2: add stopwatch timers
Jeff Hostetler [Mon, 24 Oct 2022 13:41:06 +0000 (13:41 +0000)] 
trace2: add stopwatch timers

Add stopwatch timer mechanism to Trace2.

Timers are an alternative to Trace2 Regions.  Regions are useful for
measuring the time spent in various computation phases, such as the
time to read the index, time to scan for unstaged files, time to scan
for untracked files, and etc.

However, regions are not appropriate in all places.  For example,
during a checkout, it would be very inefficient to use regions to
measure the total time spent inflating objects from the ODB from
across the entire lifetime of the process; a per-unzip() region would
flood the output and significantly slow the command; and some form of
post-processing would be requried to compute the time spent in unzip().

Timers can be used to measure a series of timer intervals and emit
a single summary event (at thread and/or process exit).

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agotrace2: convert ctx.thread_name from strbuf to pointer
Jeff Hostetler [Mon, 24 Oct 2022 13:41:05 +0000 (13:41 +0000)] 
trace2: convert ctx.thread_name from strbuf to pointer

Convert the `tr2tls_thread_ctx.thread_name` field from a `strbuf`
to a "const char*" pointer.

The `thread_name` field is a constant string that is constructed when
the context is created.  Using a (non-const) `strbuf` structure for it
caused some confusion in the past because it implied that someone
could rename a thread after it was created.  That usage was not
intended.  Change it to a const pointer to make the intent more clear.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agotrace2: improve thread-name documentation in the thread-context
Jeff Hostetler [Mon, 24 Oct 2022 13:41:04 +0000 (13:41 +0000)] 
trace2: improve thread-name documentation in the thread-context

Improve the documentation of the tr2tls_thread_ctx.thread_name field
and its relation to the tr2tls_thread_ctx.thread_id field.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agotrace2: rename the thread_name argument to trace2_thread_start
Jeff Hostetler [Mon, 24 Oct 2022 13:41:03 +0000 (13:41 +0000)] 
trace2: rename the thread_name argument to trace2_thread_start

Rename the `thread_name` argument in `tr2tls_create_self()` and
`trace2_thread_start()` to be `thread_base_name` to make it clearer
that the passed argument is a component used in the construction of
the actual `struct tr2tls_thread_ctx.thread_name` variable.

The base name will be used along with the thread id to create a
unique thread name.

This commit does not change how the `thread_name` field is
allocated or stored within the `tr2tls_thread_ctx` structure.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoapi-trace2.txt: elminate section describing the public trace2 API
Jeff Hostetler [Mon, 24 Oct 2022 13:41:02 +0000 (13:41 +0000)] 
api-trace2.txt: elminate section describing the public trace2 API

Eliminate the mostly obsolete `Public API` sub-section from the
`Trace2 API` section in the documentation.  Strengthen the referral
to `trace2.h`.

Most of the technical information in this sub-section was moved to
`trace2.h` in 6c51cb525d (trace2: move doc to trace2.h, 2019-11-17) to
be adjacent to the function prototypes.  The remaining text wasn't
that useful by itself.

Furthermore, the text would need a bit of overhaul to add routines
that do not immediately generate a message, such as stopwatch timers.
So it seemed simpler to just get rid of it.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agotr2tls: clarify TLS terminology
Jeff Hostetler [Mon, 24 Oct 2022 13:41:01 +0000 (13:41 +0000)] 
tr2tls: clarify TLS terminology

Reduce or eliminate use of the term "TLS" in the Trace2 code.

The term "TLS" has two popular meanings: "thread-local storage" and
"transport layer security".  In the Trace2 source, the term is associated
with the former.  There was concern on the mailing list about it refering
to the latter.

Update the source and documentation to eliminate the use of the "TLS" term
or replace it with the phrase "thread-local storage" to reduce ambiguity.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agotrace2: use size_t alloc,nr_open_regions in tr2tls_thread_ctx
Jeff Hostetler [Mon, 24 Oct 2022 13:41:00 +0000 (13:41 +0000)] 
trace2: use size_t alloc,nr_open_regions in tr2tls_thread_ctx

Use "size_t" rather than "int" for the "alloc" and "nr_open_regions"
fields in the "tr2tls_thread_ctx".  These are used by ALLOC_GROW().

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agosubmodule: use strvec_pushf() for --super-prefix
René Scharfe [Sun, 23 Oct 2022 06:47:35 +0000 (08:47 +0200)] 
submodule: use strvec_pushf() for --super-prefix

absorb_git_dir_into_superproject() uses a strbuf and strvec_pushl() to
build and add the --super-prefix option and its argument.  Use a single
strvec_pushf() call to add the stuck form instead, which reduces the
code size and avoids a strbuf allocation and release.  The same is
already done in submodule_reset_index() and submodule_move_head().

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agot7700: annotate cruft-pack failure with ok=sigpipe
Jeff King [Sun, 23 Oct 2022 17:00:45 +0000 (13:00 -0400)] 
t7700: annotate cruft-pack failure with ok=sigpipe

One of our tests intentionally causes the cruft-pack generation phase of
repack to fail, in order to stimulate an exit from repack at the desired
moment. It does so by feeding a bogus option argument to pack-objects.
This is a simple and reliable way to get pack-objects to fail, but it
has one downside: pack-objects will die before reading its stdin, which
means the caller repack may racily get SIGPIPE writing to it.

For the purposes of this test, that's OK. We are checking whether repack
cleans up already-created .tmp files, and it will do so whether it exits
or dies by signal (because the tempfile API hooks both).

But we have to tell test_must_fail that either outcome is OK, or it
complains about the signal. Arguably this is a workaround (compared to
fixing repack), as repack dying to SIGPIPE means that it loses the
opportunity to give a more detailed message. But we don't actually write
such a message anyway; we rely on pack-objects to have written something
useful to stderr, and it does. In either case (signal or exit), that is
the main thing the user will see.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoGit.pm: trust rev-parse to find bare repositories
Jeff King [Sat, 22 Oct 2022 22:08:59 +0000 (18:08 -0400)] 
Git.pm: trust rev-parse to find bare repositories

When initializing a repository object, we run "git rev-parse --git-dir"
to let the C version of Git find the correct directory. But curiously,
if this fails we don't automatically say "not a git repository".
Instead, we do our own pure-perl check to see if we're in a bare
repository.

This makes little sense, as rev-parse will report both bare and non-bare
directories. This logic comes from d5c7721d58 (Git.pm: Add support for
subdirectories inside of working copies, 2006-06-24), but I don't see
any reason given why we can't just rely on rev-parse. Worse, because we
treat any non-error response from rev-parse as a non-bare repository,
we'll erroneously set the object's WorkingCopy, even in a bare
repository.

But it gets worse. Since 8959555cee (setup_git_directory(): add an owner
check for the top-level directory, 2022-03-02), it's actively wrong (and
dangerous). The perl code doesn't implement the same ownership checks.
And worse, after "finding" the bare repository, it sets GIT_DIR in the
environment, which tells any subsequent Git commands that we've
confirmed the directory is OK, and to trust us. I.e., it re-opens the
vulnerability plugged by 8959555cee when using Git.pm's repository
discovery code.

We can fix this by just relying on rev-parse to tell us when we're not
in a repository, which fixes the vulnerability. Furthermore, we'll ask
its --is-bare-repository function to tell us if we're bare or not, and
rely on that.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agomerge-ort: fix bug with dir rename vs change dir to symlink
Elijah Newren [Sat, 22 Oct 2022 19:04:10 +0000 (19:04 +0000)] 
merge-ort: fix bug with dir rename vs change dir to symlink

When changing a directory to a symlink on one side of history, and
renaming the parent of that directory to a different directory name
on the other side, e.g. with this kind of setup:

    Base commit: Has a file named dir/subdir/file
    Side1:       Rename dir/ -> renamed-dir/
    Side2:       delete dir/subdir/file, add dir/subdir as symlink

Then merge-ort was running into an assertion failure:

    git: merge-ort.c:2622: apply_directory_rename_modifications: Assertion `ci->dirmask == 0' failed

merge-recursive did not have as obvious an issue handling this case,
likely because we never fixed it to handle the case from commit
902c521a35 ("t6423: more involved directory rename test", 2020-10-15)
where we need to be careful about nested renames when a directory rename
occurs (dir/ -> renamed-dir/ implies dir/subdir/ ->
renamed-dir/subdir/).  However, merge-recursive does have multiple
problems with this testcase:

  * Incorrect stages for the file: merge-recursive omits the stage in
    the index corresponding to the base stage, making `git status`
    report "added by us" for renamed-dir/subdir/file instead of the
    expected "deleted by them".

  * Poor directory/file conflict handling: For the renamed-dir/subdir
    symlink, instead of reporting a file/directory conflict as
    expected, it reports "Error: Refusing to lose untracked file at
    renamed-dir/subdir".  This is a lie because there is no untracked
    file at that location.  It then does the normal suboptimal
    merge-recursive thing of having the symlink be tracked in the index
    at a location where it can't be written due to D/F conflicts
    (namely, renamed-dir/subdir), but writes it to the working tree at
    a different location as a new untracked file (namely,
    renamed-dir/subdir~B^0)

Technically, these problems don't prevent the user from resolving the
merge if they can figure out to ignore the confusion, but because both
pieces of output are quite confusing I don't want to modify the test
to claim the recursive also passes it even if it doesn't have the bug
that ort did.

So, fix the bug in ort by splitting the conflict_info for "dir/subdir"
into two, one for the directory part, one for the file (i.e. symlink)
part, since the symlink is being renamed by directory rename detection.
The directory part is needed for proper nesting, since there are still
conflict_info fields for files underneath it (though those are marked
as is_null, they are still present until the entries are processed,
and the entry processing wants every non-toplevel entry to have a
parent directory).

Reported-by: Stefano Rivera <stefano@rivera.za.net>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agorepack: drop remove_temporary_files()
Jeff King [Sat, 22 Oct 2022 00:21:58 +0000 (20:21 -0400)] 
repack: drop remove_temporary_files()

After we've successfully finished the repack, we call
remove_temporary_files(), which looks for and removes any files matching
".tmp-$$-pack-*", where $$ is the pid of the current process. But this
is pointless. If we make it this far in the process, we've already
renamed these tempfiles into place, and there is nothing left to delete.

Nor is there a point in trying to call it to clean up when we _aren't_
successful. It's not safe for using in a signal handler, and the
previous commit already handed that job over to the tempfile API.

It might seem like it would be useful to clean up stray .tmp files left
by other invocations of git-repack. But it won't clean those files; it
only matches ones with its pid, and leaves the rest. Fortunately, those
are cleaned up naturally by successive calls to git-repack; we'll
consider .tmp-*.pack the same as normal packfiles, so "repack -ad", etc,
will roll up their contents and eventually delete them.

The one case that could matter is if pack-objects generates an extension
we don't know about, like ".tmp-pack-$$-$hash.some-new-ext". The current
code will quietly delete such a file, while after this patch we'd leave
it in place. In practice this doesn't happen, and would be indicative of
a bug. Leaving the file as cruft is arguably a better behavior, as it
means somebody is more likely to eventually notice and fix the bug.  If
we really wanted to be paranoid, we could scan for and warn about such
files, but that seems like overkill.

There's nothing to test with regard to the removal of this function. It
was doing nothing, so the behavior should be the same.  However, we can
verify (and protect) our assumption that "repack -ad" will eventually
remove stray files by adding a test for that.

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