{"thread":{"id":"59352","subject":"[ANNOUNCE] Git v2.40.0-rc2","startedAt":"2023-03-07T19:56:10Z","lastAt":"2023-03-10T09:33:00Z","messageCount":5,"participants":["Junio C Hamano","Philippe Blain","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"473151","messageId":"xmqqy1o8wdgi.fsf@gitster.g","threadId":"59352","inReplyTo":null,"subject":"[ANNOUNCE] Git v2.40.0-rc2","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-03-07T19:47:41Z","receivedAt":"2023-03-07T19:56:10Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"A release candidate Git v2.40.0-rc2 is now available for testing at\nthe usual places.  It is comprised of 461 non-merge commits since\nv2.39.0, contributed by 78 people, 30 of which are new faces [*].\n\nRelative to 2.40-rc1, there is one fix to make \"git range-diff\n--abbrev=<number>\" option work on platforms whose char is unsigned.\n\nThe tarballs are found at:\n\n    https://www.kernel.org/pub/software/scm/git/testing/\n\nThe following public repositories all have a copy of the\n'v2.40.0-rc2' tag and the 'master' branch that the tag points at:\n\n  url = https://git.kernel.org/pub/scm/git/git\n  url = https://kernel.googlesource.com/pub/scm/git/git\n  url = git://repo.or.cz/alt-git.git\n  url = https://github.com/gitster/git\n\nNew contributors whose contributions weren't in v2.39.0 are as follows.\nWelcome to the Git development community!\n\n  Adam Szkoda, Alison Winters, Ashutosh Pandey, Carl Baldwin,\n  Daniël Haazen, Drew Noakes, Eric Sesterhenn, Gwyneth Morgan,\n  Harshil-Jani, Hubert Jasudowicz, idriss fekir, Kostya Farber,\n  Marco Nenciarini, Markus Vervier, Matheus Tavares Bernardino,\n  Mathias Krause, Pat LaVarre, Peter Grayson, Rudy Rigot, Seija,\n  Seija Kijin, Simon Gerber, Thierry Reding, toon@iotcl.com, Wes\n  Lord, Yukai Chou, Yutaro Ohno, yvvdwf, Zhang Yi, and 孟子易.\n\nReturning contributors who helped this release are as follows.\nThanks for your continued support.\n\n  Ævar Arnfjörð Bjarmason, Andrei Rybak, Calvin Wan, Carlo\n  Marcelo Arenas Belón, Christian Couder, Chris. Webster,\n  Derrick Stolee, Đoàn Trần Công Danh, Elijah Newren,\n  Emily Shaffer, Eric Sunshine, Eric Wong, Erik Cervin Edin, Glen\n  Choo, Jeff Hostetler, Jeff King, Jiang Xin, Joern Schneeweisz,\n  Johannes Schindelin, Johannes Sixt, John Cai, Jonathan Tan,\n  Junio C Hamano, Karthik Nayak, Kevin Willford, Kyle Meyer, Kyle\n  Zhao, Lars Kellogg-Stedman, Martin Ågren, Matthias Aßhauer,\n  M Hickford, Patrick Steinhardt, Philip Oakley, Philippe Blain,\n  Phillip Wood, Randall S. Becker, René Scharfe, Rubén Justo,\n  Sean Allred, Siddharth Asthana, Sven Strickroth, SZEDER Gábor,\n  Taylor Blau, Teng Long, Torsten Bögershausen, William Sprent,\n  Yoichi Nakayama, and ZheNing Hu.\n\n[*] We are counting not just the authorship contribution but issue\n    reporting, mentoring, helping and reviewing that are recorded in\n    the commit trailers.\n\n----------------------------------------------------------------\n\nGit v2.40 Release Notes (draft)\n===============================\n\nUI, Workflows & Features\n\n * \"merge-tree\" learns a new `--merge-base` option.\n\n * \"git jump\" (in contrib/) learned to present the \"quickfix list\" to\n   its standard output (instead of letting it consumed by the editor\n   it invokes), and learned to also drive emacs/emacsclient.\n\n * \"git var UNKNOWN_VARIABLE\" and \"git var VARIABLE\" with the variable\n   given an empty value used to behave identically.  Now the latter\n   just gives an empty output, while the former still gives an error\n   message.\n\n * Introduce a case insensitive mode to the Bash completion helpers.\n\n * The advice message given by \"git status\" when it takes long time to\n   enumerate untracked paths has been updated.\n\n * Just like \"git var GIT_EDITOR\" abstracts the complex logic to\n   choose which editor gets used behind it, \"git var\" now give support\n   to GIT_SEQUENCE_EDITOR.\n\n * \"git format-patch\" learned to honor format.mboxrd even when sending\n   patches to the standard output stream,\n\n * 'cat-file' gains mailmap support for its '--batch-check' and '-s'\n   options.\n\n * Conditionally skip the pre-applypatch and applypatch-msg hooks when\n   applying patches with 'git am'.\n\n * Introduce an optional configuration to allow the trailing hash that\n   protects the index file from bit flipping.\n\n * \"git check-attr\" learned to take an optional tree-ish to read the\n   .gitattributes file from.\n\n * \"scalar\" learned to give progress bar.\n\n * \"grep -P\" learned to use Unicode Character Property to grok\n   character classes when processing \\b and \\w etc.\n\n * \"git rebase\" often ignored incompatible options instead of\n   complaining, which has been corrected.\n\n * \"scalar\" warns but continues when its periodic maintenance\n   feature cannot be enabled.\n\n * The bundle-URI subsystem adds support for creation-token heuristics\n   to help incremental fetches.\n\n * Userdiff regexp update for Java language.\n\n * \"git fetch --jobs=0\" used to hit a BUG(), which has been corrected\n   to use the available CPUs.\n\n * An invalid label or ref in the \"rebase -i\" todo file used to\n   trigger an runtime error. SUch an error is now diagnosed while the\n   todo file is parsed.\n\n * The \"diff\" drivers specified by the \"diff\" attribute attached to\n   paths can now specify which algorithm (e.g. histogram) to use.\n\n * \"git range-diff\" learned --abbrev=<num> option.\n\n * \"git archive HEAD^{tree}\" records the paths with the current\n   timestamp in the archive, making it harder to obtain a stable\n   output.  The command learned the --mtime option to specify an\n   arbitrary timestamp (e.g. --mtime=\"@0 +0000\" for the epoch).\n\n * The credential subsystem learned that a password may have an\n   explicit expiration.\n\n * The format.attach configuration variable lacked a way to override a\n   value defined in a lower-priority configuration file (e.g. the\n   system one) by redefining it in a higher-priority configuration\n   file.  Now, setting format.attach to an empty string means show the\n   patch inline in the e-mail message, without using MIME attachment.\n\n   This is a backward incompatible change.\n\n\nPerformance, Internal Implementation, Development Support etc.\n\n * `git bisect` becomes a builtin.\n\n * The pack-bitmap machinery is taught to log the paths of redundant\n   bitmap(s) to trace2 instead of stderr.\n\n * Use the SHA1DC implementation on macOS, just like other platforms,\n   by default.\n\n * Even in a repository with promisor remote, it is useless to\n   attempt to lazily attempt fetching an object that is expected to be\n   commit, because no \"filter\" mode omits commit objects.  Take\n   advantage of this assumption to fail fast on errors.\n\n * Stop using \"git --super-prefix\" and narrow the scope of its use to\n   the submodule--helper.\n\n * Stop running win+VS build by default.\n\n * CI updates.  We probably want a clean-up to move the long shell\n   script embedded in yaml file into a separate file, but that can\n   come later.\n\n * Use `git diff --no-index` as a test_cmp on Windows.\n\n   We'd probably need to revisit \"do we really want to, and have to,\n   lose CRLF vs LF?\" later, at which time we may be able to further\n   clean this up by replacing \"git diff --no-index\" with \"diff -u\".\n\n * Avoid unnecessary builds in CI, with settings configured in\n   ci-config.\n\n * Plug leaks in sequencer subsystem and its users.\n\n * In-tree .gitattributes update to match the way we recommend our\n   users to mark a file as text.\n   (merge 1f34e0cd3d po/attributes-text later to maint).\n\n * Finally retire the scripted \"git add -p/-i\" implementation and have\n   everybody use the one reimplemented in C.\n\n\nFixes since v2.39\n-----------------\n\n * Various leak fixes.\n\n * Fix a bug where `pack-objects` would not respect multiple `--filter`\n   arguments when invoked directly.\n   (merge d4f7036887 rs/multi-filter-args later to maint).\n\n * Make fsmonitor more robust to avoid the flakiness seen in t7527.\n   (merge 6692d45477 jh/t7527-unflake-by-forcing-cookie later to maint).\n\n * Stop using deprecated macOS API in fsmonitor.\n   (merge b0226007f0 jh/fsmonitor-darwin-modernize later to maint).\n\n * Redefining system functions for a few functions did not follow our\n   usual \"implement git_foo() and #define foo(args) git_foo(args)\"\n   pattern, which has broken build for some folks.\n\n * The way the diff machinery prepares the options array for the\n   parse_options API has been refactored to avoid resource leaks.\n   (merge 189e97bc4b rs/diff-parseopts later to maint).\n\n * Correct pthread API usage.\n   (merge 786e67611d sx/pthread-error-check-fix later to maint).\n\n * The code to auto-correct a misspelt subcommand unnecessarily called\n   into git_default_config() from the early config codepath, which was\n   a no-no.  This has bee corrected.\n   (merge 0918d08887 sg/help-autocorrect-config-fix later to maint).\n\n * \"git http-fetch\" (which is rarely used) forgot to identify itself\n   in the trace2 output.\n   (merge 7abb43cbc8 jt/http-fetch-trace2-report-name later to maint).\n\n * The output from \"git diff --stat\" on an unmerged path lost the\n   terminating LF in Git 2.39, which has been corrected.\n   (merge 209d9cb011 pg/diff-stat-unmerged-regression-fix later to maint).\n\n * \"git pull -v --recurse-submodules\" attempted to pass \"-v\" down to\n   underlying \"git submodule update\", which did not understand the\n   request and barfed, which has been corrected.\n   (merge 6f65f84766 ss/pull-v-recurse-fix later to maint).\n\n * When given a pattern that matches an empty string at the end of a\n   line, the code to parse the \"git diff\" line-ranges fell into an\n   infinite loop, which has been corrected.\n\n * Fix the sequence to fsync $GIT_DIR/packed-refs file that forgot to\n   flush its output to the disk..\n\n * Fix to a small regression in 2.38 days.\n\n * \"git diff --relative\" did not mix well with \"git diff --ext-diff\",\n   which has been corrected.\n\n * The logic to see if we are using the \"cone\" mode by checking the\n   sparsity patterns has been tightened to avoid mistaking a pattern\n   that names a single file as specifying a cone.\n\n * Deal with a few deprecation warning from cURL library.\n\n * Doc update for environment variables set when hooks are invoked.\n\n * Document ORIG_HEAD a bit more.\n\n * \"git ls-tree --format='%(path) %(path)' $tree $path\" showed the\n   path three times, which has been corrected.\n\n * Remove \"git env--helper\" and demote it to a test-tool subcommand.\n   (merge 4a1baacd46 ab/test-env-helper later to maint).\n\n * Newer regex library macOS stopped enabling GNU-like enhanced BRE,\n   where '\\(A\\|B\\)' works as alternation, unless explicitly asked with\n   the REG_ENHANCED flag.  \"git grep\" now can be compiled to do so, to\n   retain the old behaviour.\n\n * Pthread emulation on Win32 leaked thread handle when a thread is\n   joined.\n   (merge 238a9dfe86 sk/win32-close-handle-upon-pthread-join later to maint).\n\n * \"git send-email -v 3\" used to be expanded to \"git send-email\n   --validate 3\" when the user meant to pass them down to\n   \"format-patch\", which has been corrected.\n   (merge 8774aa56ad km/send-email-with-v-reroll-count later to maint).\n\n * Document that \"branch -f <branch>\" disables only the safety to\n   avoid recreating an existing branch.\n\n * \"git fetch <group>\", when \"<group>\" of remotes lists the same\n   remote twice, unnecessarily failed when parallel fetching was\n   enabled, which has been corrected.\n   (merge 06a668cb90 cw/fetch-remote-group-with-duplication later to maint).\n\n * Clarify how \"checkout -b/-B\" and \"git branch [-f]\" are similar but\n   different in the documentation.\n\n * \"git hash-object\" now checks that the resulting object is well\n   formed with the same code as \"git fsck\".\n   (merge 8e4309038f jk/hash-object-fsck later to maint).\n\n * Improve the error message given when private key is not loaded in\n   the ssh agent in the codepath to sign with an ssh key.\n   (merge dce7b31126 as/ssh-signing-improve-key-missing-error later to maint).\n\n * Adjust \"git request-pull\" to strip embedded signature from signed\n   tags to notice non-PGP signatures.\n   (merge a9cad02538 gm/request-pull-with-non-pgp-signed-tags later to maint).\n\n * Remove support for MSys, which now lags way behind MSys2.\n   (merge 2987407f3c hj/remove-msys-support later to maint).\n\n * Fix use of CreateThread() API call made early in the windows\n   start-up code.\n   (merge 592bcab61b sk/winansi-createthread-fix later to maint).\n\n * \"git pack-objects\" learned to release delta-island bitmap data when\n   it is done using it, saving peak heap memory usage.\n   (merge 647982bb71 ew/free-island-marks later to maint).\n\n * In an environment where dynamically generated code is prohibited to\n   run (e.g. SELinux), failure to JIT pcre patterns is expected.  Fall\n   back to interpreted execution in such a case.\n   (merge 50b6ad55b0 cb/grep-fallback-failing-jit later to maint).\n\n * \"git name-rev\" heuristics update.\n   (merge b2182a8730 en/name-rev-make-taggerdate-much-less-important later to maint).\n\n * Remove more remaining uses of macros that relies on the_index\n   singleton instance without explicitly spelling it out.\n\n * Remove unnecessary explicit sizing of strbuf.\n   (merge 93ea118bed rs/cache-tree-strbuf-growth-fix later to maint).\n\n * Doc update.\n   (merge d9ec3b0dc0 jk/doc-ls-remote-matching later to maint).\n\n * Error messages given upon a signature verification failure used to\n   discard the errors from underlying gpg program, which has been\n   corrected.\n   (merge ad6b320756 js/gpg-errors later to maint).\n\n * Update --date=default documentation.\n   (merge 9deef088ae rd/doc-default-date-format later to maint).\n\n * A test helper had a single write(2) of 256kB, which was too big for\n   some platforms (e.g. NonStop), which has been corrected by using\n   xwrite() wrapper appropriately.\n   (merge 58eab6ff13 jc/genzeros-avoid-raw-write later to maint).\n\n * sscanf(3) used in \"git symbolic-ref --short\" implementation found\n   to be not working reliably on macOS in UTF-8 locales.  Rewrite the\n   code to avoid sscanf() altogether to work it around.\n   (merge 613bef56b8 jk/shorten-unambiguous-ref-wo-sscanf later to maint).\n\n * Various fix-ups on HTTP tests.\n   (merge 8f2146dbf1 jk/http-test-fixes later to maint).\n\n * Fixes to code that parses the todo file used in \"rebase -i\".\n   (merge 666b6e1135 pw/rebase-i-parse-fix later to maint).\n\n * Test library clean-up.\n   (merge c600a91c94 ar/test-lib-remove-stale-comment later to maint).\n\n * Other code cleanup, docfix, build fix, etc.\n   (merge 4eb1ccecd4 dh/mingw-ownership-check-typofix later to maint).\n   (merge f95526419b ar/typofix-gitattributes-doc later to maint).\n   (merge 27875aeec9 km/doc-branch-start-point later to maint).\n   (merge 35c194dc57 es/t1509-root-fixes later to maint).\n   (merge 7b341645e3 pw/ci-print-failure-name-fix later to maint).\n   (merge bcb71d45bf jx/t1301-updates later to maint).\n   (merge ebdc46c242 jc/doc-diff-patch.txt later to maint).\n   (merge a87a20cbb4 ar/test-cleanup later to maint).\n   (merge f5156f1885 ar/bisect-doc-update later to maint).\n   (merge fca2d86c97 jk/interop-error later to maint).\n   (merge cf4936ed74 tl/ls-tree-code-clean-up later to maint).\n   (merge dcb47e52b0 en/t6426-todo-cleanup later to maint).\n   (merge 5b8db44bdd jc/format-patch-v-unleak later to maint).\n   (merge 590b636737 jk/hash-object-literally-fd-leak later to maint).\n   (merge 5458ba0a4d tb/t0003-invoke-dd-more-portably later to maint).\n   (merge 70661d288b ar/markup-em-dash later to maint).\n   (merge e750951e74 en/ls-files-doc-update later to maint).\n   (merge 4f542975d1 mh/doc-credential-cache-only-in-core later to maint).\n   (merge 3a2ebaebc7 gc/index-format-doc later to maint).\n   (merge b08edf709d jk/httpd-test-updates later to maint).\n   (merge d85e9448dd wl/new-command-doc later to maint).\n   (merge d912a603ed kf/t5000-modernise later to maint).\n   (merge e65b868d07 rs/size-t-fixes later to maint).\n   (merge 3eb1e1ca9a ab/config-h-remove-unused later to maint).\n   (merge d390e08076 cw/doc-pushurl-vs-url later to maint).\n   (merge 567342fc77 rs/ctype-test later to maint).\n   (merge d35d8f2e7a ap/t2015-style-update later to maint).\n\n----------------------------------------------------------------\n\nChanges since v2.39.0 are as follows:\n\nAdam Szkoda (1):\n      ssh signing: better error message when key not in agent\n\nAlison Winters (2):\n      completion: add optional ignore-case when matching refs\n      completion: add case-insensitive match of pseudorefs\n\nAndrei Rybak (12):\n      gitattributes.txt: fix typo in \"comma separated\"\n      *: fix typos which duplicate a word\n      git-bisect-lk2009: update java code conventions link\n      git-bisect-lk2009: update nist report link\n      t6003: uncomment test '--max-age=c3, --topo-order'\n      t6422: drop commented out code\n      t7527: use test_when_finished in 'case insensitive+preserving'\n      Documentation: render dash correctly\n      userdiff: support Java type parameters\n      userdiff: support Java record types\n      userdiff: support Java sealed classes\n      test-lib: drop comment about test_description\n\nAshutosh Pandey (1):\n      t2015-checkout-unborn.sh: changes the style for cd\n\nCalvin Wan (2):\n      fetch: fix duplicate remote parallel fetch bug\n      Documentation: clarify multiple pushurls vs urls\n\nCarlo Marcelo Arenas Belón (2):\n      test-lib: add prerequisite for 64-bit platforms\n      grep: correctly identify utf-8 characters with \\{b,w} in -P\n\nChris. Webster (3):\n      ci (check-whitespace): suggest fixes for errors\n      ci (check-whitespace): add links to job output\n      ci (check-whitespace): move to actions/checkout@v3\n\nDaniël Haazen (1):\n      mingw: fix typo in an error message from ownership check\n\nDerrick Stolee (25):\n      transport: rename got_remote_heads\n      bundle-uri: serve bundle.* keys from config\n      strbuf: introduce strbuf_strip_file_from_path()\n      bundle-uri: allow relative URLs in bundle lists\n      bundle-uri: download bundles from an advertised list\n      clone: unbundle the advertised bundles\n      hashfile: allow skipping the hash function\n      read-cache: add index.skipHash config option\n      test-lib-functions: add helper for trailing hash\n      features: feature.manyFiles implies fast index writes\n      t1600: fix racy index.skipHash test\n      t: allow 'scalar' in test_must_fail\n      t921*: test scalar behavior starting maintenance\n      scalar: only warn when background maintenance fails\n      bundle: test unbundling with incomplete history\n      bundle: verify using check_connected()\n      t5558: add tests for creationToken heuristic\n      bundle-uri: parse bundle.heuristic=creationToken\n      bundle-uri: parse bundle.<id>.creationToken values\n      bundle-uri: download in creationToken order\n      clone: set fetch.bundleURI if appropriate\n      bundle-uri: drop bundle.flag from design doc\n      fetch: fetch from an external bundle URI\n      bundle-uri: store fetch.bundleCreationToken\n      bundle-uri: test missing bundles with heuristic\n\nElijah Newren (16):\n      ls-files: add missing documentation for --resolve-undo option\n      ls-files: clarify descriptions of file selection options\n      ls-files: clarify descriptions of status tags for -t\n      ls-files: guide folks to --exclude-standard over other --exclude* options\n      t6426: fix TODO about making test more comprehensive\n      rebase: mark --update-refs as requiring the merge backend\n      rebase: flag --apply and --merge as incompatible\n      rebase: remove --allow-empty-message from incompatible opts\n      rebase: fix docs about incompatibilities with --root\n      rebase: fix incompatiblity checks for --[no-]reapply-cherry-picks\n      rebase: add coverage of other incompatible options\n      rebase: clarify the OPT_CMDMODE incompatibilities\n      rebase: fix formatting of rebase --reapply-cherry-picks option in docs\n      rebase: put rebase_options initialization in single place\n      rebase: provide better error message for apply options vs. merge config\n      name-rev: fix names by dropping taggerdate workaround\n\nEmily Shaffer (4):\n      run-command: allow stdin for run_processes_parallel\n      hook API: support passing stdin to hooks, convert am's 'post-rewrite'\n      sequencer: use the new hook API for the simpler \"post-rewrite\" call\n      hook: support a --to-stdin=<path> option\n\nEric Sunshine (4):\n      t1509: fix failing \"root work tree\" test due to owner-check\n      t1509: make \"setup\" test more robust\n      t1509: facilitate repeated script invocations\n      githooks: discuss Git operations in foreign repositories\n\nEric Wong (2):\n      format-patch: support format.mboxrd with --stdout\n      delta-islands: free island_marks and bitmaps\n\nGlen Choo (2):\n      read-tree + fetch tests: test failing \"--super-prefix\" interaction\n      docs: document zero bits in index \"mode\"\n\nGwyneth Morgan (2):\n      request-pull: filter out SSH/X.509 tag signatures\n      signature-format.txt: note SSH and X.509 signature delimiters\n\nHarshil-Jani (2):\n      mingw: remove duplicate `USE_NED_ALLOCATOR` directive\n      mingw: remove msysGit/MSYS1 support\n\nJeff Hostetler (2):\n      fsmonitor: fix race seen in t7527\n      fsmonitor: eliminate call to deprecated FSEventStream function\n\nJeff King (74):\n      git-jump: move valid-mode check earlier\n      pack-bitmap.c: break out of the bitmap loop early if not tracing\n      pack-bitmap.c: trace bitmap ignore logs when midx-bitmap is found\n      git-compat-util: avoid redefining system function names\n      git-compat-util: undefine system names before redeclaring them\n      server_supports_v2(): use a separate function for die_on_error\n      ls-refs: use repository parameter to iterate refs\n      blob: drop unused parts of parse_blob_buffer()\n      list-objects: drop process_gitlink() function\n      ws: drop unused parameter from ws_blank_line()\n      xdiff: drop unused parameter in def_ff()\n      xdiff: mark unused parameter in xdl_call_hunk_func()\n      diff: mark unused parameters in callbacks\n      list-objects-filter: mark unused parameters in virtual functions\n      userdiff: mark unused parameter in internal callback\n      ref-filter: reject arguments to %(HEAD)\n      ref-filter: factor out \"%(foo) does not take arguments\" errors\n      ref-filter: factor out \"unrecognized %(foo) arg\" errors\n      ref-filter: truncate atom names in error messages\n      ref-filter: convert email atom parser to use err_bad_arg()\n      test-bundle-uri: drop unused variables\n      diff: use filespec path to set up tempfiles for ext-diff\n      diff: clean up external-diff argv setup\n      diff: drop \"name\" parameter from prepare_temp_file()\n      convert trivial uses of strncmp() to starts_with()\n      convert trivial uses of strncmp() to skip_prefix()\n      object-file: inline calls to read_object()\n      streaming: inline call to read_object_file_extended()\n      read_object_file_extended(): drop lookup_replace option\n      repo_read_object_file(): stop wrapping read_object_file_extended()\n      packfile: inline custom read_object()\n      object-file: fix indent-with-space\n      t/interop: report which vanilla git command failed\n      http-push: prefer CURLOPT_UPLOAD to CURLOPT_PUT\n      http: prefer CURLOPT_SEEKFUNCTION to CURLOPT_IOCTLFUNCTION\n      http: support CURLOPT_PROTOCOLS_STR\n      t1007: modernize malformed object tests\n      t1006: stop using 0-padded timestamps\n      t7030: stop using invalid tag name\n      t: use hash-object --literally when created malformed objects\n      fsck: provide a function to fsck buffer without object struct\n      hash-object: use fsck for object checks\n      hash-object: fix descriptor leak with --literally\n      fsck: do not assume NUL-termination of buffers\n      t/lib-httpd: bump required apache version to 2.2\n      t/lib-httpd: bump required apache version to 2.4\n      t/lib-httpd: drop SSLMutex config\n      t/lib-httpd: increase ssl key size to 2048 bits\n      http-push: prefer CURLOPT_UPLOAD to CURLOPT_PUT\n      http: prefer CURLOPT_SEEKFUNCTION to CURLOPT_IOCTLFUNCTION\n      http: support CURLOPT_PROTOCOLS_STR\n      doc/ls-remote: cosmetic cleanups for examples\n      doc/ls-remote: clarify pattern format\n      shorten_unambiguous_ref(): avoid integer truncation\n      shorten_unambiguous_ref(): use NUM_REV_PARSE_RULES constant\n      shorten_unambiguous_ref(): avoid sscanf()\n      add basic http proxy tests\n      t0066: drop setup of \"dir5\"\n      t5541: run \"used receive-pack service\" test earlier\n      t5541: stop marking \"used receive-pack service\" test as v0 only\n      t5541: simplify and move \"no empty path components\" test\n      t5551: drop redundant grep for Accept-Language\n      t5551: lower-case headers in expected curl trace\n      t5551: handle HTTP/2 when checking curl trace\n      t5551: stop forcing clone to run with v0 protocol\n      t5551: handle v2 protocol when checking curl trace\n      t5551: handle v2 protocol in upload-pack service test\n      t5551: simplify expected cookie file\n      t5551: handle v2 protocol in cookie test\n      t5551: drop curl trace lines without headers\n      t/lib-httpd: respect $HTTPD_PROTO in expect_askpass()\n      t/lib-httpd: enable HTTP/2 \"h2\" protocol, not just h2c\n      t5559: fix test failures with LIB_HTTPD_SSL\n      t5559: make SSL/TLS the default\n\nJiang Xin (3):\n      t1301: fix wrong template dir for git-init\n      t1301: use test_when_finished for cleanup\n      t1301: do not change $CWD in \"shared=all\" test case\n\nJohannes Schindelin (24):\n      bisect--helper: handle states directly\n      Turn `git bisect` into a full built-in\n      t0021: use Windows-friendly `pwd`\n      tests(mingw): avoid very slow `mingw_test_cmp`\n      ci: only run win+VS build & tests in Git for Windows' fork\n      bisect--helper: simplify exit code computation\n      bisect: verify that a bogus option won't try to start a bisection\n      bisect run: fix the error message\n      bisect: remove Cogito-related code\n      bisect: no longer try to clean up left-over `.git/head-name` files\n      fsck: document the new `gitattributes` message IDs\n      attr: adjust a mismatched data type\n      attr: adjust a mismatched data type\n      Git 2.31.7\n      Git 2.32.6\n      Git 2.33.7\n      Git 2.34.7\n      Git 2.35.7\n      Git 2.36.5\n      Git 2.37.6\n      Git 2.38.4\n      Git 2.39.2\n      t7510: add a test case that does not need gpg\n      gpg: do show gpg's error message upon failure\n\nJohannes Sixt (1):\n      t3920: don't ignore errors of more than one command with `|| true`\n\nJohn Cai (4):\n      docs: link generating patch sections\n      attr: fix instructions on how to check attrs\n      diff: consolidate diff algorithm option parsing\n      diff: teach diff to read algorithm from diff driver\n\nJonathan Tan (5):\n      http-fetch: invoke trace2_cmd_name()\n      object-file: remove OBJECT_INFO_IGNORE_LOOSE\n      object-file: refactor map_loose_object_1()\n      object-file: emit corruption errors when detected\n      commit: don't lazy-fetch commits\n\nJunio C Hamano (42):\n      Git 2.30.7\n      Git 2.31.6\n      Git 2.32.5\n      Git 2.33.6\n      Git 2.34.6\n      Git 2.35.6\n      Git 2.36.4\n      Git 2.37.5\n      Git 2.38.3\n      Git 2.39.1\n      Start the 2.40 cycle\n      The first batch for 2.40\n      The second batch\n      The third batch\n      The fourth batch\n      The fifth batch\n      The sixth batch\n      format-patch: unleak \"-v <num>\"\n      The seventh batch\n      branch: document `-f` and linked worktree behaviour\n      checkout: document -b/-B to highlight the differences from \"git branch\"\n      The eighth batch\n      The ninth batch\n      The tenth batch\n      The eleventh batch\n      The twelfth batch\n      The thirteenth batch\n      Git 2.30.8\n      The fourteenth batch\n      The fifteenth batch\n      Prepare for 2.39.3 just in case\n      The sixteenth batch\n      rev-list: clarify git-log default date format\n      test-genzeros: avoid raw write(2)\n      format.attach: allow empty value to disable multi-part messages\n      The seventeenth batch\n      Git 2.40-rc0\n      A few more topics post 2.40-rc0\n      A bit more before 2.40-rc1\n      A bit more before 2.40-rc1\n      Git 2.40-rc1\n      Git 2.40-rc2\n\nKarthik Nayak (2):\n      t0003: move setup for `--all` into new block\n      attr: add flag `--source` to work with tree-ish\n\nKostya Farber (1):\n      t5000: modernise archive and :(glob) test\n\nKyle Meyer (2):\n      send-email: relay '-v N' to format-patch\n      doc/git-branch: fix --force description typo\n\nKyle Zhao (3):\n      merge-tree.c: add --merge-base=<commit> option\n      merge-tree.c: allow specifying the merge-base when --stdin is passed\n      docs: fix description of the `--merge-base` option\n\nLars Kellogg-Stedman (1):\n      line-range: fix infinite loop bug with '$' regex\n\nM Hickford (2):\n      Documentation: clarify that cache forgets credentials if the system restarts\n      credential: new attribute password_expiry_utc\n\nMartin Ågren (1):\n      git-cat-file.txt: fix list continuations rendering literally\n\nMathias Krause (1):\n      grep: fall back to interpreter if JIT memory allocation fails\n\nMatthias Aßhauer (1):\n      fetch: choose a sensible default with --jobs=0 again\n\nPatrick Steinhardt (28):\n      attr: fix overflow when upserting attribute with overly long name\n      attr: fix out-of-bounds read with huge attribute names\n      attr: fix integer overflow when parsing huge attribute names\n      attr: fix out-of-bounds write when parsing huge number of attributes\n      attr: fix out-of-bounds read with unreasonable amount of patterns\n      attr: fix integer overflow with more than INT_MAX macros\n      attr: harden allocation against integer overflows\n      attr: fix silently splitting up lines longer than 2048 bytes\n      attr: ignore attribute lines exceeding 2048 bytes\n      attr: ignore overly large gitattributes files\n      pretty: fix out-of-bounds write caused by integer overflow\n      pretty: fix out-of-bounds read when left-flushing with stealing\n      pretty: fix out-of-bounds read when parsing invalid padding format\n      pretty: fix adding linefeed when placeholder is not expanded\n      pretty: fix integer overflow in wrapping format\n      utf8: fix truncated string lengths in `utf8_strnwidth()`\n      utf8: fix returning negative string width\n      utf8: fix overflow when returning string width\n      utf8: fix checking for glyph width in `strbuf_utf8_replace()`\n      utf8: refactor `strbuf_utf8_replace` to not rely on preallocated buffer\n      pretty: restrict input lengths for padding and wrapping formats\n      fsck: refactor `fsck_blob()` to allow for more checks\n      fsck: pull out function to check a set of blobs\n      fsck: move checks for gitattributes\n      fsck: implement checks for gitattributes\n      refs: fix corruption by not correctly syncing packed-refs to disk\n      apply: fix writing behind newly created symbolic links\n      delta-islands: fix segfault when freeing island marks\n\nPeter Grayson (1):\n      diff: fix regression with --stat and unmerged file\n\nPhilip Oakley (6):\n      doc: pretty-formats: separate parameters from placeholders\n      doc: pretty-formats: delineate `%<|(` parameter values\n      doc: pretty-formats document negative column alignments\n      doc: pretty-formats describe use of ellipsis in truncation\n      doc: pretty-formats note wide char limitations, and add tests\n      .gitattributes: include `text` attribute for eol attributes\n\nPhilippe Blain (6):\n      git-cherry-pick.txt: do not use 'ORIG_HEAD' in example\n      git-reset.txt: mention 'ORIG_HEAD' in the Description\n      git-merge.txt: mention 'ORIG_HEAD' in the Description\n      revisions.txt: be explicit about commands writing 'ORIG_HEAD'\n      git-rebase.txt: add a note about 'ORIG_HEAD' being overwritten\n      branch: improve advice when --recurse-submodules fails\n\nPhillip Wood (5):\n      ci(github): restore \"print test failures\" step name\n      rebase: cleanup \"--exec\" option handling\n      rebase -i: check labels and refs when parsing todo list\n      rebase -i: match whole word in is_command()\n      rebase -i: fix parsing of \"fixup -C<commit>\"\n\nRené Scharfe (31):\n      t5317: stop losing return codes of git ls-files\n      t5317: demonstrate failure to handle multiple --filter options\n      pack-objects: fix handling of multiple --filter options\n      pack-objects: simplify --filter handling\n      list-objects-filter: remove OPT_PARSE_LIST_OBJECTS_FILTER_INIT()\n      t4205: don't exit test script on failure\n      diff: factor out add_diff_options()\n      diff: use add_diff_options() in diff_opt_parse()\n      diff: remove parseopts member from struct diff_options\n      list-objects-filter: plug pattern_list leak\n      t3920: support CR-eating grep\n      reflog: clear leftovers in reflog_expiry_cleanup()\n      commit: skip already cleared parents in clear_commit_marks_1()\n      am: don't pass strvec to apply_parse_options()\n      object-file: inline write_buffer()\n      use enhanced basic regular expressions on macOS\n      mingw: make argv2 in try_shell_exec() non-const\n      factor out BARF_UNLESS_COPYABLE\n      do full type check in BARF_UNLESS_COPYABLE\n      add DUP_ARRAY\n      use DUP_ARRAY\n      ls-tree: fix expansion of repeated %(path)\n      ls-tree: remove dead store and strbuf for quote_c_style()\n      read-cache: use size_t for {base,df}_name_compare()\n      pack-objects: use strcspn(3) in name_cmp_len()\n      cache-tree: fix strbuf growth in prime_cache_tree_rec()\n      test-ctype: test isascii\n      test-ctype: test islower and isupper\n      test-ctype: test iscntrl, ispunct, isxdigit and isprint\n      archive: add --mtime\n      range-diff: avoid compiler warning when char is unsigned\n\nRubén Justo (1):\n      branch: force-copy a branch to itself via @{-1} is a no-op\n\nRudy Rigot (1):\n      status: modernize git-status \"slow untracked files\" advice\n\nSZEDER Gábor (1):\n      tests: make 'test_oid' print trailing newline\n\nSean Allred (3):\n      var: do not print usage() with a correct invocation\n      var: allow GIT_EDITOR to return null\n      var: add GIT_SEQUENCE_EDITOR variable\n\nSeija (1):\n      maintenance: compare output of pthread functions for inequality with 0\n\nSeija Kijin (6):\n      git: remove duplicate includes\n      win32: use _endthreadex to terminate threads, not ExitThread\n      win32: prepare pthread.c for change by formatting\n      win32: close handles of threads that have been joined\n      merge: break out of all_strategy loop when strategy is found\n      compat/winansi: check for errors of CreateThread() correctly\n\nSiddharth Asthana (2):\n      cat-file: add mailmap support to -s option\n      cat-file: add mailmap support to --batch-check option\n\nSimon Gerber (1):\n      help.c: fix autocorrect in work tree for bare repository\n\nSven Strickroth (1):\n      submodule: accept -v for the update command\n\nTaylor Blau (5):\n      ci: avoid unnecessary builds\n      t5619: demonstrate clone_local() with ambiguous transport\n      clone: delay picking a transport until after get_repo_path()\n      dir-iterator: prevent top-level symlinks without FOLLOW_SYMLINKS\n      dir-iterator: drop unused `DIR_ITERATOR_FOLLOW_SYMLINKS`\n\nTeng Long (5):\n      pack-bitmap.c: remove unnecessary \"open_pack_index()\" calls\n      pack-bitmap.c: avoid exposing absolute paths\n      ls-tree: cleanup the redundant SPACE\n      t3104: remove shift code in 'test_ls_tree_format'\n      range-diff: let '--abbrev' option takes effect\n\nThierry Reding (1):\n      am: allow passing --no-verify flag\n\nTorsten Bögershausen (1):\n      t0003: call dd with portable blocksize\n\nWes Lord (1):\n      new-command.txt: update reference to builtin docs\n\nWilliam Sprent (1):\n      dir: check for single file cone patterns\n\nYoichi Nakayama (2):\n      git-jump: add an optional argument '--stdout'\n      git-jump: invoke emacs/emacsclient\n\nYukai Chou (1):\n      doc: fix non-existent config name\n\nYutaro Ohno (1):\n      doc: add \"git switch -c\" as another option on detached HEAD\n\nZhang Yi (1):\n      t9700: modernize test scripts\n\nZheNing Hu (1):\n      scalar: show progress if stderr refers to a terminal\n\nidriss fekir (1):\n      trace.c, git.c: remove unnecessary parameter to trace_repo_setup()\n\nÆvar Arnfjörð Bjarmason (90):\n      bisect tests: test for v2.30.0 \"bisect run\" regressions\n      bisect: refactor bisect_run() to match CodingGuidelines\n      bisect test: test exit codes on bad usage\n      bisect--helper: emit usage for \"git bisect\"\n      bisect; remove unused \"git-bisect.sh\" and \".gitignore\" entry\n      tests: mark tests as passing with SANITIZE=leak\n      {reset,merge}: call discard_index() before returning\n      commit: discard partial cache before (re-)reading it\n      read-cache.c: clear and free \"sparse_checkout_patterns\"\n      dir.c: free \"ident\" and \"exclude_per_dir\" in \"struct untracked_cache\"\n      built-ins & libs & helpers: add/move destructors, fix leaks\n      unpack-file: fix ancient leak in create_temp_file()\n      revision API: call graph_clear() in release_revisions()\n      ls-files: fix a --with-tree memory leak\n      sequencer.c: fix \"opts->strategy\" leak in read_strategy_opts()\n      connected.c: free the \"struct packed_git\"\n      rebase: don't leak on \"--abort\"\n      cherry-pick: free \"struct replay_opts\" members\n      revert: fix parse_options_concat() leak\n      built-ins: use free() not UNLEAK() if trivial, rm dead code\n      t5314: check exit code of \"git\"\n      t7600: don't ignore \"rev-parse\" exit code in helper\n      t4023: fix ignored exit codes of git\n      Makefile: use sha1collisiondetection by default on OSX and Darwin\n      bundle: don't segfault on \"git bundle <subcmd>\"\n      protocol v2: add server-side \"bundle-uri\" skeleton\n      t: create test harness for 'bundle-uri' command\n      clone: request the 'bundle-uri' command when available\n      bundle-uri client: add boolean transfer.bundleURI setting\n      bundle-uri client: add helper for testing server\n      submodule absorbgitdirs tests: add missing \"Migrating git...\" tests\n      submodule.c & submodule--helper: pass along \"super_prefix\" param\n      submodule--helper: don't use global --super-prefix in \"absorbgitdirs\"\n      submodule--helper: convert \"foreach\" to its own \"--super-prefix\"\n      submodule--helper: convert \"sync\" to its own \"--super-prefix\"\n      submodule--helper: convert \"status\" to its own \"--super-prefix\"\n      submodule--helper: convert \"{update,clone}\" to their own \"--super-prefix\"\n      read-tree: add \"--super-prefix\" option, eliminate global\n      builtin/bundle.c: remove superfluous \"newargc\" variable\n      bundle <cmd>: have usage_msg_opt() note the missing \"<file>\"\n      builtin/difftool.c: { 0 }-initialize rather than using memset()\n      sparse-index.c: expand_to_path() can assume non-NULL \"istate\"\n      sparse-index API: BUG() out on NULL ensure_full_index()\n      read-cache.c: refactor set_new_index_sparsity() for subsequent commit\n      bisect--helper: make the order consistently `argc, argv`\n      ls-tree: don't use \"show_tree_data\" for \"fast\" callbacks\n      ls-tree: use a \"struct options\"\n      ls-tree: fold \"show_tree_data\" into \"cb\" struct\n      ls-tree: make \"line_termination\" less generic\n      env-helper: move this built-in to \"test-tool env-helper\"\n      cache API: add a \"INDEX_STATE_INIT\" macro/function, add release_index()\n      treewide: always have a valid \"index_state.repo\" member\n      add: remove \"add.interactive.useBuiltin\" & Perl \"git add--interactive\"\n      add API: remove run_add_interactive() wrapper function\n      docs & comments: replace mentions of \"git-add--interactive.perl\"\n      tests: mark tests as passing with SANITIZE=leak\n      bundle.c: don't leak the \"args\" in the \"struct child_process\"\n      commit-graph: use free_commit_graph() instead of UNLEAK()\n      clone: use free() instead of UNLEAK()\n      various: add missing clear_pathspec(), fix leaks\n      name-rev: don't xstrdup() an already dup'd string\n      repack: fix leaks on error with \"goto cleanup\"\n      worktree: fix a trivial leak in prune_worktrees()\n      http-backend.c: fix \"dir\" and \"cmd_arg\" leaks in cmd_main()\n      http-backend.c: fix cmd_main() memory leak, refactor reg{exec,free}()\n      commit-graph: fix a parse_options_concat() leak\n      show-branch: free() allocated \"head\" before return\n      builtin/merge.c: use fixed strings, not \"strbuf\", fix leak\n      builtin/merge.c: free \"&buf\" on \"Your local changes...\" error\n      grep.c: refactor free_grep_patterns()\n      grep API: plug memory leaks by freeing \"header_list\"\n      receive-pack: release the linked \"struct command *\" list\n      push: refactor refspec_append_mapped() for subsequent leak-fix\n      push: free_refs() the \"local_refs\" in set_refspecs()\n      rebase: use \"cleanup\" pattern in do_interactive_rebase()\n      sequencer.c: split up sequencer_remove_state()\n      sequencer API users: fix get_replay_opts() leaks\n      builtin/revert.c: move free-ing of \"revs\" to replay_opts_release()\n      builtin/rebase.c: fix \"options.onto_name\" leak\n      sequencer.c: always free() the \"msgbuf\" in do_pick_commit()\n      builtin/rebase.c: free() \"options.strategy_opts\"\n      commit.c: free() revs.commit in get_fork_point()\n      config.h: remove unused git_configset_add_parameters()\n      run-command.c: remove dead assignment in while-loop\n      builtin/rm.c: use narrower \"USE_THE_INDEX_VARIABLE\"\n      cocci & cache.h: fully apply \"active_nr\" part of index-compatibility\n      cocci & cache.h: apply pending \"index_cache_pos\" rule\n      cocci & cache-tree.h: migrate \"write_cache_as_tree\" to \"*_index_*\"\n      cache-tree API: remove redundant update_main_cache_tree()\n      cocci & cache.h: remove \"USE_THE_INDEX_COMPATIBILITY_MACROS\"\n\nĐoàn Trần Công Danh (6):\n      bisect: fix output regressions in v2.30.0\n      bisect run: keep some of the post-v2.30.0 output\n      bisect-run: verify_good: account for non-negative exit status\n      bisect--helper: identify as bisect when report error\n      bisect--helper: log: allow arbitrary number of arguments\n      date.c: allow ISO 8601 reduced precision times\n\n"},{"id":"473223","messageId":"bff58f23-6188-9b1e-b23a-fc3d94e9f72f@gmail.com","threadId":"59352","inReplyTo":"xmqqy1o8wdgi.fsf@gitster.g","subject":"'BUG' in builtin add -p (was :Re: [ANNOUNCE] Git v2.40.0-rc2)","fromName":"Philippe Blain","fromEmail":"levraiphilippeblain@gmail.com","sentAt":"2023-03-08T20:51:31Z","receivedAt":"2023-03-08T20:51:39Z","isPatch":false,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"Hi Dscho,\n\nLe 2023-03-07 à 14:47, Junio C Hamano a écrit :\n> A release candidate Git v2.40.0-rc2 is now available for testing at\n> the usual places.  It is comprised of 461 non-merge commits since\n> v2.39.0, contributed by 78 people, 30 of which are new faces [*].\n> \n\n> ----------------------------------------------------------------\n> \n> Git v2.40 Release Notes (draft)\n> ===============================\n> \n\n>  * Finally retire the scripted \"git add -p/-i\" implementation and have\n>    everybody use the one reimplemented in C.\n\nI just hit a 'BUG' in the builtin add -p, I'll try to write a reproducer later but\nwanted to send a heads up now in case you can reproduced easily on your own with the below info.\nNote that this is not new in 2.40-rc2, I'm still on 2.39.1.\n\nBasically I have an unmerged path from a conflicted 'git checkout $branch -m'. I resolved\nthe conflict, but did not run 'git add'. And then I ran (in the 'doc' directory of the repository)\n'git restore -S -p ../doc/path/to/file' and got:\n\n```\nBUG: add-patch.c:498: diff starts with unexpected line:\n* Unmerged path doc/path/to/file\n\nAborted (core dumped)\n\n```\n\nand the backtrace from the core dump is the below:\n\n\n```\nReading symbols from /home/me/bin/git...\n[New LWP 4172500]\n[Thread debugging using libthread_db enabled]\nUsing host libthread_db library \"/lib64/libthread_db.so.1\".\nCore was generated by `git restore -S -p path/to/file'.\nProgram terminated with signal SIGABRT, Aborted.\n#0  0x000014d138b0b7ff in raise () from /lib64/libc.so.6\n(gdb) bt\n#0  0x000014d138b0b7ff in raise () from /lib64/libc.so.6\n#1  0x000014d138af5c35 in abort () from /lib64/libc.so.6\n#2  0x0000000000703b75 in BUG_vfl (file=0x779d41 \"add-patch.c\", line=498, fmt=0x779d50 \"diff starts with unexpected line:\\n%.*s\\n\", params=0x7ffdd37529f0) at usage.c:320\n#3  0x0000000000703c39 in BUG_fl (file=0x779d41 \"add-patch.c\", line=498, fmt=0x779d50 \"diff starts with unexpected line:\\n%.*s\\n\") at usage.c:330\n#4  0x000000000051089a in parse_diff (s=0x7ffdd3752d90, ps=0x7ffdd3753910) at add-patch.c:497\n#5  0x0000000000515339 in run_add_p (r=0xa5b3a0 <the_repo>, mode=ADD_P_RESET, revision=0xec35e0 \"HEAD\", ps=0x7ffdd3753910) at add-patch.c:1758\n#6  0x0000000000408511 in run_add_interactive (revision=0xec35e0 \"HEAD\", patch_mode=0x74119d \"--patch=reset\", pathspec=0x7ffdd3753910) at builtin/add.c:273\n#7  0x0000000000427f4b in checkout_paths (opts=0x7ffdd3753600, new_branch_info=0x7ffdd37533a0) at builtin/checkout.c:528\n#8  0x000000000042c24d in checkout_main (argc=1, argv=0x7ffdd3753d40, prefix=0xebe58b \"doc/\", opts=0x7ffdd3753600, options=0xec0d80, usagestr=0xa342c0 <restore_usage>, new_branch_info=0x7ffdd37533a0)\n    at builtin/checkout.c:1820\n#9  0x000000000042cd1e in cmd_restore (argc=4, argv=0x7ffdd3753d40, prefix=0xebe58b \"doc/\") at builtin/checkout.c:1953\n#10 0x0000000000406a83 in run_builtin (p=0xa371d8 <commands+2520>, argc=4, argv=0x7ffdd3753d40) at git.c:466\n#11 0x0000000000406e68 in handle_builtin (argc=4, argv=0x7ffdd3753d40) at git.c:721\n#12 0x00000000004070b6 in run_argv (argcp=0x7ffdd3753bcc, argv=0x7ffdd3753bc0) at git.c:788\n#13 0x00000000004075cf in cmd_main (argc=4, argv=0x7ffdd3753d40) at git.c:926\n#14 0x000000000050a80b in main (argc=5, argv=0x7ffdd3753d38) at common-main.c:57\n\n```\n\nHope this helps,\n\nPhilippe.\n"},{"id":"473266","messageId":"ZAmfqC9WMl3XeyEr@coredump.intra.peff.net","threadId":"59352","inReplyTo":"bff58f23-6188-9b1e-b23a-fc3d94e9f72f@gmail.com","subject":"[PATCH] add-patch: handle \"* Unmerged path\" lines","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2023-03-09T08:58:16Z","receivedAt":"2023-03-09T09:01:10Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Mar 08, 2023 at 03:51:31PM -0500, Philippe Blain wrote:\n\n> >  * Finally retire the scripted \"git add -p/-i\" implementation and have\n> >    everybody use the one reimplemented in C.\n> \n> I just hit a 'BUG' in the builtin add -p, I'll try to write a reproducer later but\n> wanted to send a heads up now in case you can reproduced easily on your own with the below info.\n> Note that this is not new in 2.40-rc2, I'm still on 2.39.1.\n> \n> Basically I have an unmerged path from a conflicted 'git checkout $branch -m'. I resolved\n> the conflict, but did not run 'git add'. And then I ran (in the 'doc' directory of the repository)\n> 'git restore -S -p ../doc/path/to/file' and got:\n\nThanks, a fix is below. While the escape-hatch of the perl version is\ngoing away in v2.40, people have been exposed to the bug since we\nflipped the default in v2.37.0. There's still an escape hatch in the\nform of \"git reset -p :^conflicted-path\", though I guess that is\nprobably a bit much to expect most users to realize. In practice I'd\nexpect people to just fall back to non-interactive commands for a\nmoment.\n\nSo I don't consider it urgent for v2.40, but the patch is small enough\nthat it might be OK to squeeze in.\n\n-- >8 --\nSubject: [PATCH] add-patch: handle \"* Unmerged path\" lines\n\nWhen we generate a diff with --cached, unmerged entries have no oid for\ntheir index entry:\n\n  $ git diff-index --abbrev --cached HEAD\n  :100644 000000 f719efd 0000000 U\tmy-conflict\n\nSo when we are asked to produce a patch, since we only have one side, we\njust emit a special message:\n\n  $ git diff-index --cached -p HEAD\n  * Unmerged path my-conflict\n\nThis confuses interactive-patch modes that look at cached diffs. For\nexample:\n\n  $ git reset -p\n  BUG: add-patch.c:498: diff starts with unexpected line:\n  * Unmerged path my-conflict\n\nMaking things even more confusing, you'll get that error only if the\nunmerged entry is alphabetically the first changed file. Otherwise, we\nsimply stick the unrecognized line to the end of the previous hunk.\nThere it's mostly harmless, as it eventually gets fed back to \"git\napply\", which happily ignores it. But it's still shown to the user\nattached to the hunk, which is wrong.\n\nSo let's handle these lines as a noop. There's not really anything\nuseful to do with a conflicted merge in this case, and that's what we do\nfor other cases like \"add -p\". There we get a \"diff --cc\" line, which we\naccept as starting a new file, but we refuse to use any of its hunks\n(their headers start with \"@@@\" and not \"@@ \", so we silently ignore\nthem).\n\nIt seems like simply recognizing the line and continuing in our parsing\nloop would work. But we actually need to run the rest of the loop body\nto handle matching up our colored/filtered output. But that code assumes\nthat we have some active file_diff we're working on. So instead, we'll\njust insert a dummy entry into our array. This ends up the same as if we\nsaw a \"diff --cc\" line (a file with no hunks).\n\nReported-by: Philippe Blain <levraiphilippeblain@gmail.com>\nSigned-off-by: Jeff King <peff@peff.net>\n---\nThis patch just fixes the immediate bug. There's some possible future\nwork:\n\n  - we could print a warning that the path is ignored. We don't do that\n    for \"diff --cc\" entries, either, though often those involve an index\n    refresh that will print \"my-conflict: needs merge\" or similar.\n\n    Doing so would require parsing the path name from the line. We don't\n    seem to quote it in any way, though. So a name like \"foo\\nbar\" would\n    probably produce confusing output (though this patch would do the\n    right thing; we'd have a dummy entry for \"foo\", and then just\n    tack the useless \"bar\" line onto it). We should decide what the diff\n    side should produce before we start trying to parse it here.\n\n  - arguably we could shrink the list to only non-conflicted entries\n    beforehand. That's what the \"patch\" menu item does if you run a full\n    add--interactive. But it would be slower (you have to run an extra\n    diff now). On the other hand, that is what the perl version did (and\n    it consistently printed \"ignoring unmerged: foo\", and then said \"No\n    changes\".\n\n  - it's a little weird that the interactive-patch parser will complain\n    if the first line of the diff is garbage, but not if it sees garbage\n    later on. If we were more strict, that would have triggered the BUG()\n    rather than tacking the unknown line to the hunk (and we _should_ be\n    able to recognize arbitrary hunk lines by their \"[-+ ]\" prefixes).\n\n    But there may be corner cases I'm not thinking of, so I left it for\n    now.\n\n add-patch.c                |  3 ++-\n t/t3701-add-interactive.sh | 21 +++++++++++++++++++++\n 2 files changed, 23 insertions(+), 1 deletion(-)\n\ndiff --git a/add-patch.c b/add-patch.c\nindex a86a92e1646..d7fc4f4cd21 100644\n--- a/add-patch.c\n+++ b/add-patch.c\n@@ -483,7 +483,8 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)\n \t\tif (!eol)\n \t\t\teol = pend;\n \n-\t\tif (starts_with(p, \"diff \")) {\n+\t\tif (starts_with(p, \"diff \") ||\n+\t\t    starts_with(p, \"* Unmerged path \")) {\n \t\t\tcomplete_file(marker, hunk);\n \t\t\tALLOC_GROW_BY(s->file_diff, s->file_diff_nr, 1,\n \t\t\t\t   file_diff_alloc);\ndiff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh\nindex 3a99837d9b1..e80e2b377c1 100755\n--- a/t/t3701-add-interactive.sh\n+++ b/t/t3701-add-interactive.sh\n@@ -1075,4 +1075,25 @@ test_expect_success 'show help from add--helper' '\n \ttest_cmp expect actual\n '\n \n+test_expect_success 'reset -p with unmerged files' '\n+\ttest_when_finished \"git checkout --force main\" &&\n+\ttest_commit one conflict &&\n+\tgit checkout -B side HEAD^ &&\n+\ttest_commit two conflict &&\n+\ttest_must_fail git merge one &&\n+\n+\t# this is a noop with only an unmerged entry\n+\tgit reset -p &&\n+\n+\t# add files that sort before and after unmerged entry\n+\techo a >a &&\n+\techo z >z &&\n+\tgit add a z &&\n+\n+\t# confirm that we can reset those files\n+\tprintf \"%s\\n\" y y | git reset -p &&\n+\tgit diff-index --cached --diff-filter=u HEAD >staged &&\n+\ttest_must_be_empty staged\n+'\n+\n test_done\n-- \n2.40.0.rc2.537.g928a61c97db\n\n"},{"id":"473304","messageId":"xmqqcz5hby0p.fsf@gitster.g","threadId":"59352","inReplyTo":"ZAmfqC9WMl3XeyEr@coredump.intra.peff.net","subject":"Re: [PATCH] add-patch: handle \"* Unmerged path\" lines","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-03-09T18:05:58Z","receivedAt":"2023-03-09T18:06:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> So let's handle these lines as a noop. There's not really anything\n> useful to do with a conflicted merge in this case, and that's what we do\n> for other cases like \"add -p\". There we get a \"diff --cc\" line, which we\n> accept as starting a new file, but we refuse to use any of its hunks\n> (their headers start with \"@@@\" and not \"@@ \", so we silently ignore\n> them).\n>\n> It seems like simply recognizing the line and continuing in our parsing\n> loop would work. But we actually need to run the rest of the loop body\n> to handle matching up our colored/filtered output. But that code assumes\n> that we have some active file_diff we're working on. So instead, we'll\n> just insert a dummy entry into our array. This ends up the same as if we\n> saw a \"diff --cc\" line (a file with no hunks).\n\nOK.\n\n> Reported-by: Philippe Blain <levraiphilippeblain@gmail.com>\n> Signed-off-by: Jeff King <peff@peff.net>\n> ---\n> This patch just fixes the immediate bug. There's some possible future\n> work:\n>\n>   - we could print a warning that the path is ignored. We don't do that\n>     for \"diff --cc\" entries, either, though often those involve an index\n>     refresh that will print \"my-conflict: needs merge\" or similar.\n>\n>     Doing so would require parsing the path name from the line. We don't\n>     seem to quote it in any way, though. So a name like \"foo\\nbar\" would\n>     probably produce confusing output (though this patch would do the\n>     right thing; we'd have a dummy entry for \"foo\", and then just\n>     tack the useless \"bar\" line onto it). We should decide what the diff\n>     side should produce before we start trying to parse it here.\n\nWe should write a name like \"foo\\ndiff --git a/foo b/foo\" off as \"if\nit hurts, don't do it\" ;-).\n\n>   - arguably we could shrink the list to only non-conflicted entries\n>     beforehand. That's what the \"patch\" menu item does if you run a full\n>     add--interactive. But it would be slower (you have to run an extra\n>     diff now). On the other hand, that is what the perl version did (and\n>     it consistently printed \"ignoring unmerged: foo\", and then said \"No\n>     changes\".\n\nWe already lost scripted version so it is not a solace that it\nworked correctly X-<.  I do not know what to think that it took this\nlong for people to hit this issue after 1fc18798 (Merge branch\n'js/use-builtin-add-i', 2022-05-30).  The work to reimplement \"add\n-i\" in C started at f83dff60 (Start to implement a built-in version\nof `git add --interactive`, 2019-11-13) and looking at the output of \n\n    $ git log --format='%cI %h %s' --merges --grep=\"add-[ip]\"\n\nit seems that we have caught and fixed more bugs before we made it\nthe default than after, and all the more recent fixes are on the\nsmaller side, so I think we are in a good shape.\n\n>   - it's a little weird that the interactive-patch parser will complain\n>     if the first line of the diff is garbage, but not if it sees garbage\n>     later on. If we were more strict, that would have triggered the BUG()\n>     rather than tacking the unknown line to the hunk (and we _should_ be\n>     able to recognize arbitrary hunk lines by their \"[-+ ]\" prefixes).\n\nThere is recount_edited_hunk() but I am not sure if it can be relied\nupon (I've seen emacs's diff edit mode miscounting lines).\n\nAnother weird thing is that we do not complain if a patch does not\nhave any hunk, but I guess we are lucky---that is what this fix\ntakes advantage of ;-).\n\n>     But there may be corner cases I'm not thinking of, so I left it for\n>     now.\n>\n>  add-patch.c                |  3 ++-\n>  t/t3701-add-interactive.sh | 21 +++++++++++++++++++++\n>  2 files changed, 23 insertions(+), 1 deletion(-)\n>\n> diff --git a/add-patch.c b/add-patch.c\n> index a86a92e1646..d7fc4f4cd21 100644\n> --- a/add-patch.c\n> +++ b/add-patch.c\n> @@ -483,7 +483,8 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)\n>  \t\tif (!eol)\n>  \t\t\teol = pend;\n>  \n> -\t\tif (starts_with(p, \"diff \")) {\n> +\t\tif (starts_with(p, \"diff \") ||\n> +\t\t    starts_with(p, \"* Unmerged path \")) {\n>  \t\t\tcomplete_file(marker, hunk);\n>  \t\t\tALLOC_GROW_BY(s->file_diff, s->file_diff_nr, 1,\n>  \t\t\t\t   file_diff_alloc);\n> diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh\n> index 3a99837d9b1..e80e2b377c1 100755\n> --- a/t/t3701-add-interactive.sh\n> +++ b/t/t3701-add-interactive.sh\n> @@ -1075,4 +1075,25 @@ test_expect_success 'show help from add--helper' '\n>  \ttest_cmp expect actual\n>  '\n>  \n> +test_expect_success 'reset -p with unmerged files' '\n> +\ttest_when_finished \"git checkout --force main\" &&\n> +\ttest_commit one conflict &&\n> +\tgit checkout -B side HEAD^ &&\n> +\ttest_commit two conflict &&\n> +\ttest_must_fail git merge one &&\n> +\n> +\t# this is a noop with only an unmerged entry\n> +\tgit reset -p &&\n> +\n> +\t# add files that sort before and after unmerged entry\n> +\techo a >a &&\n> +\techo z >z &&\n> +\tgit add a z &&\n> +\n> +\t# confirm that we can reset those files\n> +\tprintf \"%s\\n\" y y | git reset -p &&\n> +\tgit diff-index --cached --diff-filter=u HEAD >staged &&\n> +\ttest_must_be_empty staged\n> +'\n> +\n>  test_done\n"},{"id":"473344","messageId":"ZAr4g63CnHADBvXJ@coredump.intra.peff.net","threadId":"59352","inReplyTo":"xmqqcz5hby0p.fsf@gitster.g","subject":"Re: [PATCH] add-patch: handle \"* Unmerged path\" lines","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2023-03-10T09:29:39Z","receivedAt":"2023-03-10T09:33:00Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Mar 09, 2023 at 10:05:58AM -0800, Junio C Hamano wrote:\n\n> >   - we could print a warning that the path is ignored. We don't do that\n> >     for \"diff --cc\" entries, either, though often those involve an index\n> >     refresh that will print \"my-conflict: needs merge\" or similar.\n> >\n> >     Doing so would require parsing the path name from the line. We don't\n> >     seem to quote it in any way, though. So a name like \"foo\\nbar\" would\n> >     probably produce confusing output (though this patch would do the\n> >     right thing; we'd have a dummy entry for \"foo\", and then just\n> >     tack the useless \"bar\" line onto it). We should decide what the diff\n> >     side should produce before we start trying to parse it here.\n> \n> We should write a name like \"foo\\ndiff --git a/foo b/foo\" off as \"if\n> it hurts, don't do it\" ;-).\n\nYeah, I don't have a huge amount of sympathy for people with such names.\nAny time there's parsing ambiguity like this, it makes me wonder if\nthere are security implications, of course. But it seems pretty unlikely\nhere. You'd need some combination like:\n \n  - a system that does diffs of untrusted content\n\n  - it allows diffs using \"--cached\", and allows unmerged paths\n\n  - it mixes the resulting output with other trusted lines that do\n    interesting things.\n\nI'd be really interested to hear of such a system if it exists. It seems\nlike a unicorn. :)\n\nStill, on principle, it feels like the diff output ought to be quoting\nthe name in the usual way.\n\n> >   - arguably we could shrink the list to only non-conflicted entries\n> >     beforehand. That's what the \"patch\" menu item does if you run a full\n> >     add--interactive. But it would be slower (you have to run an extra\n> >     diff now). On the other hand, that is what the perl version did (and\n> >     it consistently printed \"ignoring unmerged: foo\", and then said \"No\n> >     changes\".\n> \n> We already lost scripted version so it is not a solace that it\n> worked correctly X-<.\n\nHeh. I meant it less as solace (and I do think that failing to print\n\"ignoring unmerged\" lines is a real, if minor, regression). I more meant\nthat the perl version happily ran an extra \"diff\" to determine the set\nof unmerged files up front, and nobody seemed to be sad about the extra\ncost.\n\n> I do not know what to think that it took this\n> long for people to hit this issue after 1fc18798 (Merge branch\n> 'js/use-builtin-add-i', 2022-05-30).  The work to reimplement \"add\n> -i\" in C started at f83dff60 (Start to implement a built-in version\n> of `git add --interactive`, 2019-11-13) and looking at the output of \n> \n>     $ git log --format='%cI %h %s' --merges --grep=\"add-[ip]\"\n> \n> it seems that we have caught and fixed more bugs before we made it\n> the default than after, and all the more recent fixes are on the\n> smaller side, so I think we are in a good shape.\n\nI am not too surprised. I am an avid \"-p\" user who has been running with\nthe builtin version since before it became the default, and hadn't\nnoticed any of this yet. To trigger the BUG you need:\n\n  - unmerged files, which are already skipped by \"-p\" anyway\n\n  - to use \"reset -p\" or similar to do an index-only manipulation (and\n    I'd wager 90+% of \"-p\" usage is via \"add -p\")\n\n  - have an unmerged file sort lexically at the front of the modified\n    paths\n\nWhich is a bit specific. Just the first one is enough to notice the\nlack of \"ignoring unmerged\" lines for \"add -p\", but since the index\nrefresh reports the path, I don't think I noticed that the wording was\nslightly different.\n\nIn short, I feel OK saying that any bug we haven't flushed out at this\npoint is going to be either obscure or minor.\n\n> >   - it's a little weird that the interactive-patch parser will complain\n> >     if the first line of the diff is garbage, but not if it sees garbage\n> >     later on. If we were more strict, that would have triggered the BUG()\n> >     rather than tacking the unknown line to the hunk (and we _should_ be\n> >     able to recognize arbitrary hunk lines by their \"[-+ ]\" prefixes).\n> \n> There is recount_edited_hunk() but I am not sure if it can be relied\n> upon (I've seen emacs's diff edit mode miscounting lines).\n\nI would expect that to complain of unknown lines, too, but it doesn't\nseem to (it looks like it just skips them). Maybe that is a feature, but\nI'd think it would be nice to notice when the user forgets to add a\nspace at the beginning of a context line. I guess the diff doesn't apply\nthen. :)\n\n> Another weird thing is that we do not complain if a patch does not\n> have any hunk, but I guess we are lucky---that is what this fix\n> takes advantage of ;-).\n\nYeah. If it barfed on that, then \"add -p\" would complain whenever you\nhad unmerged files, which I think people _would_ have noticed.\n\nI don't have immediate plans to work on any of this, but just to write\ndown my notes for later, I think we may want to:\n\n  - handle quoting in \"diff --cached\" output for unmerged lines\n\n  - explicitly mention unmerged files that are ignored. The test I added\n    here in t3701 could be modified to check its stderr.\n\n    That can happen either by checking them up front with an extra diff,\n    or by just noticing the \"diff --cc\" and \"* Unmerged\" lines while\n    parsing the regular diff.\n\n  - Either way, once these are handled explicitly, we can probably add\n    an assertion that we don't have files without any hunks/mode\n    changes.\n\n  - Look into whether recount_edited_hunk() should be more picky about\n    its input (or if that would annoy people who leave extra cruft in\n    the file).\n\n-Peff\n"}]}