]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
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 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 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 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>
18 months agorepack: use tempfiles for signal cleanup
Jeff King [Sat, 22 Oct 2022 00:21:54 +0000 (20:21 -0400)] 
repack: use tempfiles for signal cleanup

When git-repack exits due to a signal, it tries to clean up by calling
its remove_temporary_files() function, which walks through the packs dir
looking for ".tmp-$$-pack-*" files to delete (where "$$" is the pid of
the current process).

The biggest problem here is that remove_temporary_files() is not safe to
call in a signal handler. It uses opendir(), which isn't on the POSIX
async-signal-safe list. The details will be platform-specific, but a
likely issue is that it needs to allocate memory; if we receive a signal
while inside malloc(), etc, we'll conflict on the allocator lock and
deadlock with ourselves.

We can fix this by just cleaning up the files directly, without walking
the directory. We already know the complete list of .tmp-* files that
were generated, because we recorded them via populate_pack_exts(). When
we find files there, we can use register_tempfile() to record the
filenames. If we receive a signal, then the tempfile API will clean them
up for us, and it's async-safe and pretty battle-tested.

Note that this is slightly racier than the existing scheme. We don't
record the filenames until pack-objects tells us the hash over stdout.
So during the period between it generating the file and reporting the
hash, we'd fail to clean up. However, that period is very small. During
most of the pack generation process pack-objects is using its own
internal tempfiles. It's only at the very end that it moves them into
the names git-repack expects, and then it immediately reports the name
to us. Given that cleanup like this is best effort (after all, we may
get SIGKILL), this level of race is acceptable.

When we register the tempfiles, we'll record them locally and use the
result to call rename_tempfile(), rather than renaming by hand.  This
isn't strictly necessary, as once we've renamed the files they're gone,
and the tempfile API's cleanup unlink() would simply become a pointless
noop. But managing the lifetimes of the tempfile objects is the cleanest
thing to do, and the tempfile pointers naturally fill the same role as
the old booleans.

This patch also fixes another small problem. We only hook signals, and
don't set up an atexit handler. So if we see an error that causes us to
die(), we'll leave the .tmp-* files in place. But since the tempfile API
handles this for us, this is now fixed for free. The new test covers
this by stimulating a failure of pack-objects when generating a cruft
pack. Before this patch, the .tmp-* file for the main pack would have
been left, but now we correctly clean it up.

Two small subtleties on the implementation:

  - in the renaming loop, we can stop re-constructing fname_old; we only
    use it when we have a tempfile to rename, so we can just ask the
    tempfile for its path (which, barring bugs, should be identical)

  - when renaming fails, our error message mentions fname_old. But since
    a failed rename_tempfile() invalidates the tempfile struct, we'll
    lose access to that string. Instead, let's mention the destination
    filename, which is what most other callers do.

Reported-by: Jan Pokorný <poki@fnusa.cz>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agorepack: expand error message for missing pack files
Jeff King [Sat, 22 Oct 2022 00:21:50 +0000 (20:21 -0400)] 
repack: expand error message for missing pack files

If pack-objects tells us it generated pack $hash, we expect to find
.tmp-$$-pack-$hash.pack, .idx, .rev, and so on. Some of these files are
optional, but others are not. For the required ones, we'll bail with an
error if any of them is missing.

The error message is just "missing required file", which is a bit vague.
We should be more clear that it is not the user's fault, but rather that
the sub-pgoram we called is not operating as expected. In practice,
nobody should ever see this message, as it would generally only be
caused by a bug in Git.

It probably doesn't make sense to convert this to a BUG(), though, as
there are other (unlikely) possibilities, such as somebody else racily
deleting the files, filesystem errors causing stat() to fail, and so on.

A nice side effect here is that we stop relying on fname_old in this
code path, which will let us deal with it only in the first part of the
conditional.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agorepack: populate extension bits incrementally
Jeff King [Sat, 22 Oct 2022 00:21:48 +0000 (20:21 -0400)] 
repack: populate extension bits incrementally

After generating the main pack and then any additional cruft packs, we
iterate over the "names" list (which contains hashes of packs generated
by pack-objects), and call populate_pack_exts() for each.

There's one small problem with this. In repack_promisor_objects(), we
may add entries to "names" and call populate_pack_exts() for them.
Calling it again is mostly just wasteful, as we'll stat() the filename
with each possible extension, get the same result, and just overwrite
our bits.

So we could drop the call there, and leave the final loop to populate
all of the bits. But instead, this patch does the reverse: drops the
final loop, and teaches the other two sites to populate the bits as they
add entries.

This makes the code easier to reason about, as you never have to worry
about when the util field is valid; it is always valid for each entry.

It also serves my ulterior purpose: recording the generated filenames as
soon as possible will make it easier for a future patch to use them for
cleaning up from a failed operation.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agorepack: convert "names" util bitfield to array
Jeff King [Sat, 22 Oct 2022 00:21:45 +0000 (20:21 -0400)] 
repack: convert "names" util bitfield to array

We keep a string_list "names" containing the hashes of packs generated
on our behalf by pack-objects. The util field of each item is treated as
a bitfield that tells us which extensions (.pack, .idx, .rev, etc) are
present for each name.

Let's switch this to allocating a real array. That will give us room in
a future patch to store more data than just a single bit per extension.
And it makes the code a little easier to read, as we avoid casting back
and forth between uintptr_t and a void pointer.

Since the only thing we're storing is an array, we could just allocate
it directly. But instead I've put it into a named struct here. That
further increases readability around the casts, and in particular helps
differentiate us from other string_lists in the same file which use
their util field differently. E.g., the existing_*_packs lists still do
bit-twiddling, but their bits have different meaning than the ones in
"names". This makes it hard to grep around the code to see how the util
fields are used; now you can look for "generated_pack_data".

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agodiff: leave NEEDWORK notes in show_stats() function
Junio C Hamano [Fri, 21 Oct 2022 21:53:25 +0000 (14:53 -0700)] 
diff: leave NEEDWORK notes in show_stats() function

The previous step made an attempt to correctly compute display
columns allocated and padded different parts of diffstat output.
There are at least two known codepaths in the function that still
mixes up display widths and byte length that need to be fixed.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoDocumentation/build-docdep.perl: generate sorted output
SZEDER Gábor [Fri, 21 Oct 2022 10:29:50 +0000 (12:29 +0200)] 
Documentation/build-docdep.perl: generate sorted output

To make sure that our manpages are rebuilt when any of the included
source files change and only the affected manpages are rebuilt,
'build-docdep.perl' scans our documentation source files for include
directives, and outputs 'make' dependencies to be included by
'Documentation/Makefile'.  This script relies on Perl's hash data
structures, and generates its output while iterating over them, and
since hashes in Perl are very much unordered, the output varies
greatly from run to run, both the order of targets and the order of
dependencies of each target.

This lack of ordering doesn't matter for 'make', because it cares
neither about the order of targets in a Makefile nor about the order
of a target's dependencies.  However, it does matter to developers
looking into build issues potentially involving these generated
dependencies, as it's rather hard to tell whether there are any
relevant (i.e. not order-only) changes among the dependencies compared
to the previous run.

So let's make 'build-docdep.perl's output stable and ordered by
sorting the keys of the hashes before iterating over them.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoThe fifth batch
Junio C Hamano [Fri, 21 Oct 2022 18:37:36 +0000 (11:37 -0700)] 
The fifth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoMerge branch 'rj/branch-edit-description-with-nth-checkout'
Junio C Hamano [Fri, 21 Oct 2022 18:37:29 +0000 (11:37 -0700)] 
Merge branch 'rj/branch-edit-description-with-nth-checkout'

"git branch --edit-description @{-1}" is now a way to edit branch
description of the branch you were on before switching to the
current branch.

* rj/branch-edit-description-with-nth-checkout:
  branch: support for shortcuts like @{-1}, completed

18 months agoMerge branch 'ds/cmd-main-reorder'
Junio C Hamano [Fri, 21 Oct 2022 18:37:28 +0000 (11:37 -0700)] 
Merge branch 'ds/cmd-main-reorder'

Code clean-up.

* ds/cmd-main-reorder:
  git.c: improve code readability in cmd_main()

18 months agoMerge branch 'ab/grep-simplify-extended-expression'
Junio C Hamano [Fri, 21 Oct 2022 18:37:28 +0000 (11:37 -0700)] 
Merge branch 'ab/grep-simplify-extended-expression'

Giving "--invert-grep" and "--all-match" without "--grep" to the
"git log" command resulted in an attempt to access grep pattern
expression structure that has not been allocated, which has been
corrected.

* ab/grep-simplify-extended-expression:
  grep.c: remove "extended" in favor of "pattern_expression", fix segfault

18 months agoMerge branch 'jc/symbolic-ref-no-recurse'
Junio C Hamano [Fri, 21 Oct 2022 18:37:28 +0000 (11:37 -0700)] 
Merge branch 'jc/symbolic-ref-no-recurse'

After checking out a "branch" that is a symbolic-ref that points at
another branch, "git symbolic-ref HEAD" reports the underlying
branch, not the symbolic-ref the user gave checkout as argument.
The command learned the "--no-recurse" option to stop after
dereferencing a symbolic-ref only once.

* jc/symbolic-ref-no-recurse:
  symbolic-ref: teach "--[no-]recurse" option

18 months agoMerge branch 'jk/use-o0-in-leak-sanitizer'
Junio C Hamano [Fri, 21 Oct 2022 18:37:27 +0000 (11:37 -0700)] 
Merge branch 'jk/use-o0-in-leak-sanitizer'

Avoid false-positive from LSan whose assumption may be broken with
higher optimization levels.

* jk/use-o0-in-leak-sanitizer:
  Makefile: force -O0 when compiling with SANITIZE=leak