]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
3 years agot921*: test scalar behavior starting maintenance
Derrick Stolee [Fri, 27 Jan 2023 20:06:02 +0000 (20:06 +0000)] 
t921*: test scalar behavior starting maintenance

A user recently reported issues with 'scalar register' and 'scalar
clone' in that they failed when the system had permissions locked down
so both 'crontab' and 'systemctl' commands failed when trying to enable
background maintenance.

This hard error is undesirable, but let's create tests that demonstrate
this behavior before modiying the behavior. We can use
GIT_TEST_MAINT_SCHEDULER to guarantee failure and check the exit code
and error message.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot: allow 'scalar' in test_must_fail
Derrick Stolee [Fri, 27 Jan 2023 20:06:01 +0000 (20:06 +0000)] 
t: allow 'scalar' in test_must_fail

This will enable scalar tests to use the test_must_fail helper, when
necessary.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoThe eleventh batch
Junio C Hamano [Fri, 27 Jan 2023 16:51:41 +0000 (08:51 -0800)] 
The eleventh batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'cw/fetch-remote-group-with-duplication'
Junio C Hamano [Fri, 27 Jan 2023 16:51:41 +0000 (08:51 -0800)] 
Merge branch 'cw/fetch-remote-group-with-duplication'

"git fetch <group>", when "<group>" of remotes lists the same
remote twice, unnecessarily failed when parallel fetching was
enabled, which has been corrected.

* cw/fetch-remote-group-with-duplication:
  fetch: fix duplicate remote parallel fetch bug

3 years agoMerge branch 'jc/doc-branch-update-checked-out-branch'
Junio C Hamano [Fri, 27 Jan 2023 16:51:41 +0000 (08:51 -0800)] 
Merge branch 'jc/doc-branch-update-checked-out-branch'

Document that "branch -f <branch>" disables only the safety to
avoid recreating an existing branch.

* jc/doc-branch-update-checked-out-branch:
  branch: document `-f` and linked worktree behaviour

3 years agoMerge branch 'jk/hash-object-literally-fd-leak'
Junio C Hamano [Fri, 27 Jan 2023 16:51:41 +0000 (08:51 -0800)] 
Merge branch 'jk/hash-object-literally-fd-leak'

Leakfix.

* jk/hash-object-literally-fd-leak:
  hash-object: fix descriptor leak with --literally

3 years agoMerge branch 'pb/branch-advice-recurse-submodules'
Junio C Hamano [Fri, 27 Jan 2023 16:51:40 +0000 (08:51 -0800)] 
Merge branch 'pb/branch-advice-recurse-submodules'

Improve advice message given when "git branch --recurse-submodules"
fails.

* pb/branch-advice-recurse-submodules:
  branch: improve advice when --recurse-submodules fails

3 years agoMerge branch 'km/send-email-with-v-reroll-count'
Junio C Hamano [Fri, 27 Jan 2023 16:51:40 +0000 (08:51 -0800)] 
Merge branch 'km/send-email-with-v-reroll-count'

"git send-email -v 3" used to be expanded to "git send-email
--validate 3" when the user meant to pass them down to
"format-patch", which has been corrected.

* km/send-email-with-v-reroll-count:
  send-email: relay '-v N' to format-patch

3 years agoMerge branch 'cb/grep-pcre-ucp'
Junio C Hamano [Fri, 27 Jan 2023 16:51:40 +0000 (08:51 -0800)] 
Merge branch 'cb/grep-pcre-ucp'

"grep -P" learned to use Unicode Character Property to grok
character classes when processing \b and \w etc.

* cb/grep-pcre-ucp:
  grep: correctly identify utf-8 characters with \{b,w} in -P

3 years agoMerge branch 'sa/cat-file-mailmap--batch-check'
Junio C Hamano [Fri, 27 Jan 2023 16:51:40 +0000 (08:51 -0800)] 
Merge branch 'sa/cat-file-mailmap--batch-check'

Docfix.

* sa/cat-file-mailmap--batch-check:
  git-cat-file.txt: fix list continuations rendering literally

3 years agoMerge branch 'ab/cache-api-cleanup-users'
Junio C Hamano [Fri, 27 Jan 2023 16:51:38 +0000 (08:51 -0800)] 
Merge branch 'ab/cache-api-cleanup-users'

Updates the users of the cache API.

* ab/cache-api-cleanup-users:
  treewide: always have a valid "index_state.repo" member

3 years agoThe tenth batch
Junio C Hamano [Mon, 23 Jan 2023 21:39:26 +0000 (13:39 -0800)] 
The tenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'zh/scalar-progress'
Junio C Hamano [Mon, 23 Jan 2023 21:39:52 +0000 (13:39 -0800)] 
Merge branch 'zh/scalar-progress'

"scalar" learned to give progress bar.

* zh/scalar-progress:
  scalar: show progress if stderr refers to a terminal

3 years agoMerge branch 'ds/omit-trailing-hash-in-index'
Junio C Hamano [Mon, 23 Jan 2023 21:39:52 +0000 (13:39 -0800)] 
Merge branch 'ds/omit-trailing-hash-in-index'

Quickfix for a topic already in 'master'.

* ds/omit-trailing-hash-in-index:
  t1600: fix racy index.skipHash test

3 years agoMerge branch 'jc/format-patch-v-unleak'
Junio C Hamano [Mon, 23 Jan 2023 21:39:52 +0000 (13:39 -0800)] 
Merge branch 'jc/format-patch-v-unleak'

Plug a small leak.

* jc/format-patch-v-unleak:
  format-patch: unleak "-v <num>"

3 years agoMerge branch 'sk/win32-close-handle-upon-pthread-join'
Junio C Hamano [Mon, 23 Jan 2023 21:39:51 +0000 (13:39 -0800)] 
Merge branch 'sk/win32-close-handle-upon-pthread-join'

Pthread emulation on Win32 leaked thread handle when a thread is
joined.

* sk/win32-close-handle-upon-pthread-join:
  win32: close handles of threads that have been joined
  win32: prepare pthread.c for change by formatting

3 years agoMerge branch 'rs/use-enhanced-bre-on-macos'
Junio C Hamano [Mon, 23 Jan 2023 21:39:51 +0000 (13:39 -0800)] 
Merge branch 'rs/use-enhanced-bre-on-macos'

Newer regex library macOS stopped enabling GNU-like enhanced BRE,
where '\(A\|B\)' works as alternation, unless explicitly asked with
the REG_ENHANCED flag.  "git grep" now can be compiled to do so, to
retain the old behaviour.

* rs/use-enhanced-bre-on-macos:
  use enhanced basic regular expressions on macOS

3 years agoMerge branch 'ab/test-env-helper'
Junio C Hamano [Mon, 23 Jan 2023 21:39:51 +0000 (13:39 -0800)] 
Merge branch 'ab/test-env-helper'

Remove "git env--helper" and demote it to a test-tool subcommand.

* ab/test-env-helper:
  env-helper: move this built-in to "test-tool env-helper"

3 years agoMerge branch 'kn/attr-from-tree'
Junio C Hamano [Mon, 23 Jan 2023 21:39:50 +0000 (13:39 -0800)] 
Merge branch 'kn/attr-from-tree'

"git check-attr" learned to take an optional tree-ish to read the
.gitattributes file from.

* kn/attr-from-tree:
  attr: add flag `--source` to work with tree-ish
  t0003: move setup for `--all` into new block

3 years agoMerge branch 'rs/ls-tree-path-expansion-fix'
Junio C Hamano [Mon, 23 Jan 2023 21:39:50 +0000 (13:39 -0800)] 
Merge branch 'rs/ls-tree-path-expansion-fix'

"git ls-tree --format='%(path) %(path)' $tree $path" showed the
path three times, which has been corrected.

* rs/ls-tree-path-expansion-fix:
  ls-tree: remove dead store and strbuf for quote_c_style()
  ls-tree: fix expansion of repeated %(path)

3 years agoMerge branch 'en/t6426-todo-cleanup'
Junio C Hamano [Mon, 23 Jan 2023 21:39:49 +0000 (13:39 -0800)] 
Merge branch 'en/t6426-todo-cleanup'

Test clean-up.

* en/t6426-todo-cleanup:
  t6426: fix TODO about making test more comprehensive

3 years agoMerge branch 'ab/cache-api-cleanup'
Junio C Hamano [Mon, 23 Jan 2023 21:39:49 +0000 (13:39 -0800)] 
Merge branch 'ab/cache-api-cleanup'

Code clean-up to tighten the use of in-core index in the API.

* ab/cache-api-cleanup:
  cache API: add a "INDEX_STATE_INIT" macro/function, add release_index()
  read-cache.c: refactor set_new_index_sparsity() for subsequent commit
  sparse-index API: BUG() out on NULL ensure_full_index()
  sparse-index.c: expand_to_path() can assume non-NULL "istate"
  builtin/difftool.c: { 0 }-initialize rather than using memset()

3 years agoThe ninth batch
Junio C Hamano [Sun, 22 Jan 2023 00:35:14 +0000 (16:35 -0800)] 
The ninth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'yc/doc-fetch-fix'
Junio C Hamano [Sun, 22 Jan 2023 01:22:01 +0000 (17:22 -0800)] 
Merge branch 'yc/doc-fetch-fix'

Doc fix.

* yc/doc-fetch-fix:
  doc: fix non-existent config name

3 years agoMerge branch 'ab/bisect-cleanup'
Junio C Hamano [Sun, 22 Jan 2023 01:22:00 +0000 (17:22 -0800)] 
Merge branch 'ab/bisect-cleanup'

Code clean-up.

* ab/bisect-cleanup:
  bisect: no longer try to clean up left-over `.git/head-name` files
  bisect: remove Cogito-related code
  bisect run: fix the error message
  bisect: verify that a bogus option won't try to start a bisection
  bisect--helper: make the order consistently `argc, argv`
  bisect--helper: simplify exit code computation

3 years agoMerge branch 'tl/ls-tree-code-clean-up'
Junio C Hamano [Sun, 22 Jan 2023 01:22:00 +0000 (17:22 -0800)] 
Merge branch 'tl/ls-tree-code-clean-up'

Code clean-up.

* tl/ls-tree-code-clean-up:
  t3104: remove shift code in 'test_ls_tree_format'
  ls-tree: cleanup the redundant SPACE
  ls-tree: make "line_termination" less generic
  ls-tree: fold "show_tree_data" into "cb" struct
  ls-tree: use a "struct options"
  ls-tree: don't use "show_tree_data" for "fast" callbacks

3 years agoMerge branch 'ph/parse-date-reduced-precision'
Junio C Hamano [Sun, 22 Jan 2023 01:22:00 +0000 (17:22 -0800)] 
Merge branch 'ph/parse-date-reduced-precision'

Loosen date parsing heuristics.

* ph/parse-date-reduced-precision:
  date.c: allow ISO 8601 reduced precision times

3 years agoMerge branch 'pw/rebase-exec-cleanup'
Junio C Hamano [Sun, 22 Jan 2023 01:22:00 +0000 (17:22 -0800)] 
Merge branch 'pw/rebase-exec-cleanup'

Code clean-up.

* pw/rebase-exec-cleanup:
  rebase: cleanup "--exec" option handling

3 years agoMerge branch 'pb/doc-orig-head'
Junio C Hamano [Sun, 22 Jan 2023 01:22:00 +0000 (17:22 -0800)] 
Merge branch 'pb/doc-orig-head'

Document ORIG_HEAD a bit more.

* pb/doc-orig-head:
  git-rebase.txt: add a note about 'ORIG_HEAD' being overwritten
  revisions.txt: be explicit about commands writing 'ORIG_HEAD'
  git-merge.txt: mention 'ORIG_HEAD' in the Description
  git-reset.txt: mention 'ORIG_HEAD' in the Description
  git-cherry-pick.txt: do not use 'ORIG_HEAD' in example

3 years agoMerge branch 'yo/doc-use-more-switch-c'
Junio C Hamano [Sun, 22 Jan 2023 01:21:59 +0000 (17:21 -0800)] 
Merge branch 'yo/doc-use-more-switch-c'

Doc update.

* yo/doc-use-more-switch-c:
  doc: add "git switch -c" as another option on detached HEAD

3 years agoMerge branch 'sk/merge-filtering-strategies-micro-optim'
Junio C Hamano [Sun, 22 Jan 2023 01:21:59 +0000 (17:21 -0800)] 
Merge branch 'sk/merge-filtering-strategies-micro-optim'

Micro optimization.

* sk/merge-filtering-strategies-micro-optim:
  merge: break out of all_strategy loop when strategy is found

3 years agoMerge branch 'jk/interop-error'
Junio C Hamano [Sun, 22 Jan 2023 01:21:59 +0000 (17:21 -0800)] 
Merge branch 'jk/interop-error'

Test helper improvement.

* jk/interop-error:
  t/interop: report which vanilla git command failed

3 years agoMerge branch 'ar/bisect-doc-update'
Junio C Hamano [Sun, 22 Jan 2023 01:21:59 +0000 (17:21 -0800)] 
Merge branch 'ar/bisect-doc-update'

Doc update.

* ar/bisect-doc-update:
  git-bisect-lk2009: update nist report link
  git-bisect-lk2009: update java code conventions link

3 years agoMerge branch 'ar/test-cleanup'
Junio C Hamano [Sun, 22 Jan 2023 01:21:59 +0000 (17:21 -0800)] 
Merge branch 'ar/test-cleanup'

Test clean-up.

* ar/test-cleanup:
  t7527: use test_when_finished in 'case insensitive+preserving'
  t6422: drop commented out code
  t6003: uncomment test '--max-age=c3, --topo-order'

3 years agoMerge branch 'jc/doc-diff-patch.txt'
Junio C Hamano [Sun, 22 Jan 2023 01:21:58 +0000 (17:21 -0800)] 
Merge branch 'jc/doc-diff-patch.txt'

Doc update.

* jc/doc-diff-patch.txt:
  docs: link generating patch sections

3 years agoMerge branch 'es/hooks-and-local-env'
Junio C Hamano [Sun, 22 Jan 2023 01:21:58 +0000 (17:21 -0800)] 
Merge branch 'es/hooks-and-local-env'

Doc update for environment variables set when hooks are invoked.

* es/hooks-and-local-env:
  githooks: discuss Git operations in foreign repositories

3 years agoMerge branch 'rs/dup-array'
Junio C Hamano [Sun, 22 Jan 2023 01:21:58 +0000 (17:21 -0800)] 
Merge branch 'rs/dup-array'

Code cleaning.

* rs/dup-array:
  use DUP_ARRAY
  add DUP_ARRAY
  do full type check in BARF_UNLESS_COPYABLE
  factor out BARF_UNLESS_COPYABLE
  mingw: make argv2 in try_shell_exec() non-const

3 years agoMerge branch 'jx/t1301-updates'
Junio C Hamano [Sun, 22 Jan 2023 01:21:58 +0000 (17:21 -0800)] 
Merge branch 'jx/t1301-updates'

Test updates.

* jx/t1301-updates:
  t1301: do not change $CWD in "shared=all" test case
  t1301: use test_when_finished for cleanup
  t1301: fix wrong template dir for git-init

3 years agoThe eighth batch
Junio C Hamano [Fri, 20 Jan 2023 21:48:44 +0000 (13:48 -0800)] 
The eighth batch

The cURL one hasn't cooked for a week in 'next', but let's fast
track it so that linux-musl CI job would be happy.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'jk/read-object-cleanup'
Junio C Hamano [Fri, 20 Jan 2023 23:36:21 +0000 (15:36 -0800)] 
Merge branch 'jk/read-object-cleanup'

Code clean-up.

* jk/read-object-cleanup:
  object-file: fix indent-with-space
  packfile: inline custom read_object()
  repo_read_object_file(): stop wrapping read_object_file_extended()
  read_object_file_extended(): drop lookup_replace option
  streaming: inline call to read_object_file_extended()
  object-file: inline calls to read_object()

3 years agoMerge branch 'jk/curl-avoid-deprecated-api'
Junio C Hamano [Fri, 20 Jan 2023 23:36:21 +0000 (15:36 -0800)] 
Merge branch 'jk/curl-avoid-deprecated-api'

Deal with a few deprecation warning from cURL library.

* jk/curl-avoid-deprecated-api:
  http: support CURLOPT_PROTOCOLS_STR
  http: prefer CURLOPT_SEEKFUNCTION to CURLOPT_IOCTLFUNCTION
  http-push: prefer CURLOPT_UPLOAD to CURLOPT_PUT

3 years agofetch: fix duplicate remote parallel fetch bug
Calvin Wan [Thu, 19 Jan 2023 22:05:38 +0000 (22:05 +0000)] 
fetch: fix duplicate remote parallel fetch bug

Fetching in parallel from a remote group with a duplicated remote results
in the following:

error: cannot lock ref '<ref>': is at <oid> but expected <oid>

This doesn't happen in serial since fetching from the same remote that
has already been fetched from is a noop. Therefore, remove any duplicated
remotes after remote groups are parsed.

Signed-off-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoSync with 'maint'
Junio C Hamano [Thu, 19 Jan 2023 21:49:38 +0000 (13:49 -0800)] 
Sync with 'maint'

3 years agoSync with maint-2.38
Junio C Hamano [Thu, 19 Jan 2023 21:49:08 +0000 (13:49 -0800)] 
Sync with maint-2.38

* maint-2.38:
  attr: adjust a mismatched data type

3 years agoSync with maint-2.37
Junio C Hamano [Thu, 19 Jan 2023 21:48:26 +0000 (13:48 -0800)] 
Sync with maint-2.37

* maint-2.37:
  attr: adjust a mismatched data type

3 years agoSync with maint-2.36
Junio C Hamano [Thu, 19 Jan 2023 21:48:17 +0000 (13:48 -0800)] 
Sync with maint-2.36

* maint-2.36:
  attr: adjust a mismatched data type

3 years agoSync with maint-2.35
Junio C Hamano [Thu, 19 Jan 2023 21:48:08 +0000 (13:48 -0800)] 
Sync with maint-2.35

* maint-2.35:
  attr: adjust a mismatched data type

3 years agoSync with maint-2.34
Junio C Hamano [Thu, 19 Jan 2023 21:48:00 +0000 (13:48 -0800)] 
Sync with maint-2.34

* maint-2.34:
  attr: adjust a mismatched data type

3 years agoSync with maint-2.33
Junio C Hamano [Thu, 19 Jan 2023 21:47:42 +0000 (13:47 -0800)] 
Sync with maint-2.33

* maint-2.33:
  attr: adjust a mismatched data type

3 years agoSync with maint-2.32
Junio C Hamano [Thu, 19 Jan 2023 21:46:04 +0000 (13:46 -0800)] 
Sync with maint-2.32

* maint-2.32:
  attr: adjust a mismatched data type

3 years agoSync with maint-2.31
Junio C Hamano [Thu, 19 Jan 2023 21:45:37 +0000 (13:45 -0800)] 
Sync with maint-2.31

* maint-2.31:
  attr: adjust a mismatched data type

3 years agoSync with maint-2.30
Junio C Hamano [Thu, 19 Jan 2023 21:45:23 +0000 (13:45 -0800)] 
Sync with maint-2.30

* maint-2.30:
  attr: adjust a mismatched data type

3 years agoattr: adjust a mismatched data type
Johannes Schindelin [Thu, 12 Jan 2023 00:05:02 +0000 (01:05 +0100)] 
attr: adjust a mismatched data type

On platforms where `size_t` does not have the same width as `unsigned
long`, passing a pointer to the former when a pointer to the latter is
expected can lead to problems.

Windows and 32-bit Linux are among the affected platforms.

In this instance, we want to store the size of the blob that was read in
that variable. However, `read_blob_data_from_index()` passes that
pointer to `read_object_file()` which expects an `unsigned long *`.
Which means that on affected platforms, the variable is not fully
populated and part of its value is left uninitialized. (On Big-Endian
platforms, this problem would be even worse.)

The consequence is that depending on the uninitialized memory's
contents, we may erroneously reject perfectly fine attributes.

Let's address this by passing a pointer to a variable of the expected
data type.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agohash-object: fix descriptor leak with --literally
Jeff King [Thu, 19 Jan 2023 01:57:56 +0000 (20:57 -0500)] 
hash-object: fix descriptor leak with --literally

In hash_object(), we open a descriptor for each file to hash (whether we
got the filename from the command line or --stdin-paths), but never
close it. For the traditional code path, which feeds the result to
index_fd(), this is OK; it closes the descriptor for us.

But 5ba9a93b39 (hash-object: add --literally option, 2014-09-11) added a
second code path, which does not close the descriptor. There we need to
do so ourselves.

You can see the problem in a clone of git.git like this:

  $ git ls-files -s | grep ^100644 | cut -f2 |
    git hash-object --stdin-paths --literally >/dev/null
  fatal: could not open 'builtin/var.c' for reading: Too many open files

After this patch, it completes successfully. I didn't bother with a
test, as it's a pain to deal with descriptor limits portably, and the
fix is so trivial.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agobranch: document `-f` and linked worktree behaviour
Junio C Hamano [Thu, 19 Jan 2023 07:23:46 +0000 (23:23 -0800)] 
branch: document `-f` and linked worktree behaviour

"git branch -f name start" forces to recreate the named branch, but
the forcing does not defeat the "do not touch a branch that is
checked out elsewhere" safety valve.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agogrep: correctly identify utf-8 characters with \{b,w} in -P
Carlo Marcelo Arenas Belón [Sun, 8 Jan 2023 15:52:17 +0000 (07:52 -0800)] 
grep: correctly identify utf-8 characters with \{b,w} in -P

When UTF is enabled for a PCRE match, the corresponding flags are
added to the pcre2_compile() call, but PCRE2_UCP wasn't included.

This prevents extending the meaning of the character classes to
include those new valid characters and therefore result in failed
matches for expressions that rely on that extention, for ex:

  $ git grep -P '\bÆvar'

Add PCRE2_UCP so that \w will include Æ and therefore \b could
correctly match the beginning of that word.

This has an impact on performance that has been estimated to be
between 20% to 40% and that is shown through the added performance
test.

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Acked-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agobranch: improve advice when --recurse-submodules fails
Philippe Blain [Mon, 16 Jan 2023 17:41:48 +0000 (17:41 +0000)] 
branch: improve advice when --recurse-submodules fails

'git branch --recurse-submodules start from-here' fails if any submodule
present in 'from-here' is not yet cloned (under
submodule.propagateBranches=true). We then give this advice:

   "You may try updating the submodules using 'git checkout from-here && git submodule update --init'"

If 'submodule.recurse' is set, 'git checkout from-here' will also fail since
it will try to recursively checkout the submodules.

Improve the advice by adding '--no-recurse-submodules' to the checkout
command.

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
Reviewed-by: Glen Choo <chooglen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agogit-cat-file.txt: fix list continuations rendering literally
Martin Ågren [Wed, 18 Jan 2023 08:27:49 +0000 (09:27 +0100)] 
git-cat-file.txt: fix list continuations rendering literally

With Asciidoctor, all of the '+' introduced in a797c0ea04 ("cat-file:
add mailmap support to --batch-check option", 2022-12-20) render
literally rather than functioning as list continuations. With asciidoc,
this renders just fine. It's not too surprising that there is room for
ambiguity and surprises here, since we have lists within lists.

Simply replacing all of these '+' with empty lines makes this render
fine using both tools. Except, in the third hunk, where after this inner
'*' list ends, we want to continue with more contents of the outer list
item (`--batch-command=<format>`). We can solve any ambiguity here and
make this clear to both tools by wrapping the inner list in an open
block (using "--").

For consistency, let's wrap all three of these inner lists from
a797c0ea04 in open blocks. This also future-proofs us a little -- if we
ever gain more contents after any of those first two lists, as we did
already in a797c0ea04 for the third list, we're prepared and should
render fine with both asciidoc and Asciidoctor from the start.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agotreewide: always have a valid "index_state.repo" member
Ævar Arnfjörð Bjarmason [Tue, 17 Jan 2023 13:57:00 +0000 (14:57 +0100)] 
treewide: always have a valid "index_state.repo" member

When the "repo" member was added to "the_index" in [1] the
repo_read_index() was made to populate it, but the unpopulated
"the_index" variable didn't get the same treatment.

Let's do that in initialize_the_repository() when we set it up, and
likewise for all of the current callers initialized an empty "struct
index_state".

This simplifies code that needs to deal with "the_index" or a custom
"struct index_state", we no longer need to second-guess this part of
the "index_state" deep in the stack. A recent example of such
second-guessing is the "istate->repo ? istate->repo : the_repository"
code in [2]. We can now simply use "istate->repo".

We're doing this by making use of the INDEX_STATE_INIT() macro (and
corresponding function) added in [3], which now have mandatory "repo"
arguments.

Because we now call index_state_init() in repository.c's
initialize_the_repository() we don't need to handle the case where we
have a "repo->index" whose "repo" member doesn't match the "repo"
we're setting up, i.e. the "Complete the double-reference" code in
repo_read_index() being altered here. That logic was originally added
in [1], and was working around the lack of what we now have in
initialize_the_repository().

For "fsmonitor-settings.c" we can remove the initialization of a NULL
"r" argument to "the_repository". This was added back in [4], and was
needed at the time for callers that would pass us the "r" from an
"istate->repo". Before this change such a change to
"fsmonitor-settings.c" would segfault all over the test suite (e.g. in
t0002-gitfile.sh).

This change has wider eventual implications for
"fsmonitor-settings.c". The reason the other lazy loading behavior in
it is required (starting with "if (!r->settings.fsmonitor) ..." is
because of the previously passed "r" being "NULL".

I have other local changes on top of this which move its configuration
reading to "prepare_repo_settings()" in "repo-settings.c", as we could
now start to rely on it being called for our "r". But let's leave all
of that for now, and narrowly remove this particular part of the
lazy-loading.

1. 1fd9ae517c4 (repository: add repo reference to index_state,
   2021-01-23)
2. ee1f0c242ef (read-cache: add index.skipHash config option,
   2023-01-06)
3. 2f6b1eb794e (cache API: add a "INDEX_STATE_INIT" macro/function,
   add release_index(), 2023-01-12)
4. 1e0ea5c4316 (fsmonitor: config settings are repository-specific,
   2022-03-25)

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Acked-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'ds/omit-trailing-hash-in-index' into ab/cache-api-cleanup-users
Junio C Hamano [Tue, 17 Jan 2023 22:31:40 +0000 (14:31 -0800)] 
Merge branch 'ds/omit-trailing-hash-in-index' into ab/cache-api-cleanup-users

* ds/omit-trailing-hash-in-index:
  t1600: fix racy index.skipHash test

3 years agoMerge branch 'ab/cache-api-cleanup' into ab/cache-api-cleanup-users
Junio C Hamano [Tue, 17 Jan 2023 22:31:26 +0000 (14:31 -0800)] 
Merge branch 'ab/cache-api-cleanup' into ab/cache-api-cleanup-users

* ab/cache-api-cleanup:
  cache API: add a "INDEX_STATE_INIT" macro/function, add release_index()
  read-cache.c: refactor set_new_index_sparsity() for subsequent commit
  sparse-index API: BUG() out on NULL ensure_full_index()
  sparse-index.c: expand_to_path() can assume non-NULL "istate"
  builtin/difftool.c: { 0 }-initialize rather than using memset()

3 years agohttp: support CURLOPT_PROTOCOLS_STR
Jeff King [Tue, 17 Jan 2023 03:04:48 +0000 (22:04 -0500)] 
http: support CURLOPT_PROTOCOLS_STR

The CURLOPT_PROTOCOLS (and matching CURLOPT_REDIR_PROTOCOLS) flag was
deprecated in curl 7.85.0, and using it generate compiler warnings as of
curl 7.87.0. The path forward is to use CURLOPT_PROTOCOLS_STR, but we
can't just do so unilaterally, as it was only introduced less than a
year ago in 7.85.0.

Until that version becomes ubiquitous, we have to either disable the
deprecation warning or conditionally use the "STR" variant on newer
versions of libcurl. This patch switches to the new variant, which is
nice for two reasons:

  - we don't have to worry that silencing curl's deprecation warnings
    might cause us to miss other more useful ones

  - we'd eventually want to move to the new variant anyway, so this gets
    us set up (albeit with some extra ugly boilerplate for the
    conditional)

There are a lot of ways to split up the two cases. One way would be to
abstract the storage type (strbuf versus a long), how to append
(strbuf_addstr vs bitwise OR), how to initialize, which CURLOPT to use,
and so on. But the resulting code looks pretty magical:

  GIT_CURL_PROTOCOL_TYPE allowed = GIT_CURL_PROTOCOL_TYPE_INIT;
  if (...http is allowed...)
GIT_CURL_PROTOCOL_APPEND(&allowed, "http", CURLOPT_HTTP);

and you end up with more "#define GIT_CURL_PROTOCOL_TYPE" macros than
actual code.

On the other end of the spectrum, we could just implement two separate
functions, one that handles a string list and one that handles bits. But
then we end up repeating our list of protocols (http, https, ftp, ftp).

This patch takes the middle ground. The run-time code is always there to
handle both types, and we just choose which one to feed to curl.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agohttp: prefer CURLOPT_SEEKFUNCTION to CURLOPT_IOCTLFUNCTION
Jeff King [Tue, 17 Jan 2023 03:04:44 +0000 (22:04 -0500)] 
http: prefer CURLOPT_SEEKFUNCTION to CURLOPT_IOCTLFUNCTION

The IOCTLFUNCTION option has been deprecated, and generates a compiler
warning in recent versions of curl. We can switch to using SEEKFUNCTION
instead. It was added in 2008 via curl 7.18.0; our INSTALL file already
indicates we require at least curl 7.19.4.

But there's one catch: curl says we should use CURL_SEEKFUNC_{OK,FAIL},
and those didn't arrive until 7.19.5. One workaround would be to use a
bare 0/1 here (or define our own macros).  But let's just bump the
minimum required version to 7.19.5. That version is only a minor version
bump from our existing requirement, and is only a 2 month time bump for
versions that are almost 13 years old. So it's not likely that anybody
cares about the distinction.

Switching means we have to rewrite the ioctl functions into seek
functions. In some ways they are simpler (seeking is the only
operation), but in some ways more complex (the ioctl allowed only a full
rewind, but now we can seek to arbitrary offsets).

Curl will only ever use SEEK_SET (per their documentation), so I didn't
bother implementing anything else, since it would naturally be
completely untested. This seems unlikely to change, but I added an
assertion just in case.

Likewise, I doubt curl will ever try to seek outside of the buffer sizes
we've told it, but I erred on the defensive side here, rather than do an
out-of-bounds read.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agohttp-push: prefer CURLOPT_UPLOAD to CURLOPT_PUT
Jeff King [Tue, 17 Jan 2023 03:04:38 +0000 (22:04 -0500)] 
http-push: prefer CURLOPT_UPLOAD to CURLOPT_PUT

The two options do exactly the same thing, but the latter has been
deprecated and in recent versions of curl may produce a compiler
warning. Since the UPLOAD form is available everywhere (it was
introduced in the year 2000 by curl 7.1), we can just switch to it.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot1600: fix racy index.skipHash test
Derrick Stolee [Tue, 17 Jan 2023 14:49:27 +0000 (09:49 -0500)] 
t1600: fix racy index.skipHash test

The test 1600.6 can fail under --stress due to mtime collisions. Most of
the tests include a removal of the index file to guarantee that the
index is updated. However, the submodule test addded in ee1f0c242ef
(read-cache: add index.skipHash config option, 2023-01-06) did not
include this removal. Thus, on rare occasions, the test can fail because
the index still has a non-null trailing hash, as detected by the helper
added in da9acde14ed (test-lib-functions: add helper for trailing hash,
2023-01-06).

By removing the submodule's index before the 'git -C sub add a' command,
we guarantee that the index is rewritten with the new index.skipHash
config option.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoSync with 'maint'
Junio C Hamano [Tue, 17 Jan 2023 14:59:22 +0000 (06:59 -0800)] 
Sync with 'maint'

3 years agoattr: adjust a mismatched data type
Johannes Schindelin [Thu, 12 Jan 2023 00:05:02 +0000 (01:05 +0100)] 
attr: adjust a mismatched data type

On platforms where `size_t` does not have the same width as `unsigned
long`, passing a pointer to the former when a pointer to the latter is
expected can lead to problems.

Windows and 32-bit Linux are among the affected platforms.

In this instance, we want to store the size of the blob that was read in
that variable. However, `read_blob_data_from_index()` passes that
pointer to `read_object_file()` which expects an `unsigned long *`.
Which means that on affected platforms, the variable is not fully
populated and part of its value is left uninitialized. (On Big-Endian
platforms, this problem would be even worse.)

The consequence is that depending on the uninitialized memory's
contents, we may erroneously reject perfectly fine attributes.

Let's address this by passing a pointer to a variable of the expected
data type.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoSync with 2.39.1
Junio C Hamano [Mon, 16 Jan 2023 20:11:58 +0000 (12:11 -0800)] 
Sync with 2.39.1

3 years agoThe seventh batch
Junio C Hamano [Mon, 16 Jan 2023 18:56:31 +0000 (10:56 -0800)] 
The seventh batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'jk/strncmp-to-api-funcs'
Junio C Hamano [Mon, 16 Jan 2023 20:07:47 +0000 (12:07 -0800)] 
Merge branch 'jk/strncmp-to-api-funcs'

Code clean-up.

* jk/strncmp-to-api-funcs:
  convert trivial uses of strncmp() to skip_prefix()
  convert trivial uses of strncmp() to starts_with()

3 years agoMerge branch 'ar/dup-words-fixes'
Junio C Hamano [Mon, 16 Jan 2023 20:07:47 +0000 (12:07 -0800)] 
Merge branch 'ar/dup-words-fixes'

Typofixes.

* ar/dup-words-fixes:
  *: fix typos which duplicate a word

3 years agoMerge branch 'ds/omit-trailing-hash-in-index'
Junio C Hamano [Mon, 16 Jan 2023 20:07:47 +0000 (12:07 -0800)] 
Merge branch 'ds/omit-trailing-hash-in-index'

Introduce an optional configuration to allow the trailing hash that
protects the index file from bit flipping.

* ds/omit-trailing-hash-in-index:
  features: feature.manyFiles implies fast index writes
  test-lib-functions: add helper for trailing hash
  read-cache: add index.skipHash config option
  hashfile: allow skipping the hash function

3 years agoMerge branch 'ws/single-file-cone'
Junio C Hamano [Mon, 16 Jan 2023 20:07:47 +0000 (12:07 -0800)] 
Merge branch 'ws/single-file-cone'

The logic to see if we are using the "cone" mode by checking the
sparsity patterns has been tightened to avoid mistaking a pattern
that names a single file as specifying a cone.

* ws/single-file-cone:
  dir: check for single file cone patterns

3 years agoMerge branch 'jk/ext-diff-with-relative'
Junio C Hamano [Mon, 16 Jan 2023 20:07:46 +0000 (12:07 -0800)] 
Merge branch 'jk/ext-diff-with-relative'

"git diff --relative" did not mix well with "git diff --ext-diff",
which has been corrected.

* jk/ext-diff-with-relative:
  diff: drop "name" parameter from prepare_temp_file()
  diff: clean up external-diff argv setup
  diff: use filespec path to set up tempfiles for ext-diff

3 years agoMerge branch 'ds/bundle-uri-4'
Junio C Hamano [Mon, 16 Jan 2023 20:07:46 +0000 (12:07 -0800)] 
Merge branch 'ds/bundle-uri-4'

Code clean-up.

* ds/bundle-uri-4:
  test-bundle-uri: drop unused variables

3 years agoMerge branch 'tr/am--no-verify'
Junio C Hamano [Mon, 16 Jan 2023 20:07:46 +0000 (12:07 -0800)] 
Merge branch 'tr/am--no-verify'

Conditionally skip the pre-applypatch and applypatch-msg hooks when
applying patches with 'git am'.

* tr/am--no-verify:
  am: allow passing --no-verify flag

3 years agoMerge branch 'tb/ci-concurrency'
Junio C Hamano [Mon, 16 Jan 2023 20:07:46 +0000 (12:07 -0800)] 
Merge branch 'tb/ci-concurrency'

Avoid unnecessary builds in CI, with settings configured in
ci-config.

* tb/ci-concurrency:
  ci: avoid unnecessary builds

3 years agoMerge branch 'pw/ci-print-failure-name-fix'
Junio C Hamano [Mon, 16 Jan 2023 20:07:45 +0000 (12:07 -0800)] 
Merge branch 'pw/ci-print-failure-name-fix'

(cosmetic) CI regression fix.

* pw/ci-print-failure-name-fix:
  ci(github): restore "print test failures" step name

3 years agoMerge branch 'es/t1509-root-fixes'
Junio C Hamano [Mon, 16 Jan 2023 20:07:45 +0000 (12:07 -0800)] 
Merge branch 'es/t1509-root-fixes'

Test fixes.

* es/t1509-root-fixes:
  t1509: facilitate repeated script invocations
  t1509: make "setup" test more robust
  t1509: fix failing "root work tree" test due to owner-check

3 years agofsck: document the new `gitattributes` message IDs
Johannes Schindelin [Thu, 12 Jan 2023 19:43:31 +0000 (20:43 +0100)] 
fsck: document the new `gitattributes` message IDs

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocache API: add a "INDEX_STATE_INIT" macro/function, add release_index()
Ævar Arnfjörð Bjarmason [Thu, 12 Jan 2023 12:55:27 +0000 (13:55 +0100)] 
cache API: add a "INDEX_STATE_INIT" macro/function, add release_index()

Hopefully in some not so distant future, we'll get advantages from always
initializing the "repo" member of the "struct index_state". To make
that easier let's introduce an initialization macro & function.

The various ad-hoc initialization of the structure can then be changed
over to it, and we can remove the various "0" assignments in
discard_index() in favor of calling index_state_init() at the end.

While not strictly necessary, let's also change the CALLOC_ARRAY() of
various "struct index_state *" to use an ALLOC_ARRAY() followed by
index_state_init() instead.

We're then adding the release_index() function and converting some
callers (including some of these allocations) over to it if they
either won't need to use their "struct index_state" again, or are just
about to call index_state_init().

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Acked-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoscalar: show progress if stderr refers to a terminal
ZheNing Hu [Wed, 11 Jan 2023 13:14:20 +0000 (13:14 +0000)] 
scalar: show progress if stderr refers to a terminal

Sometimes when users use scalar to download a monorepo with a long
commit history, they want to check the progress bar to know how long
they still need to wait during the fetch process, but scalar
suppresses this output by default.

So let's check whether scalar stderr refer to a terminal, if so,
show progress, otherwise disable it.

Signed-off-by: ZheNing Hu <adlternative@gmail.com>
Acked-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoformat-patch: unleak "-v <num>"
Junio C Hamano [Sun, 15 Jan 2023 08:03:39 +0000 (00:03 -0800)] 
format-patch: unleak "-v <num>"

The "subject_prefix" member of "struct revision" usually is set to a
borrowed string (either a string literal like "PATCH" that appear in
the program text as a hardcoded default, or the value of
"format.subjectprefix") and is never freed when the containing
revision structure is released.  The "-v <num>" codepath however
violates this rule and stores a pointer to an allocated string to
this member, relinquishing the responsibility to free it when it is
done using the revision structure, leading to a small one-time leak.

Instead, keep track of the string it allocates to let the revision
structure borrow, and clean it up when it is done.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agols-tree: remove dead store and strbuf for quote_c_style()
René Scharfe [Sat, 14 Jan 2023 15:03:16 +0000 (16:03 +0100)] 
ls-tree: remove dead store and strbuf for quote_c_style()

Stop initializing "name" because it is set again before use.

Let quote_c_style() write directly to "sb" instead of taking a detour
through "quoted".  This avoids an allocation and a string copy.  The
result is the same because the function only appends.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agols-tree: fix expansion of repeated %(path)
René Scharfe [Sat, 14 Jan 2023 14:37:53 +0000 (15:37 +0100)] 
ls-tree: fix expansion of repeated %(path)

expand_show_tree() borrows the base strbuf given to us by read_tree() to
build the full path of the current entry when handling %(path).  Only
its indirect caller, show_tree_fmt(), removes the added entry name.
That works fine as long as %(path) is only included once in the format
string, but accumulates duplicates if it's repeated:

   $ git ls-tree --format='%(path) %(path) %(path)' HEAD M*
   Makefile MakefileMakefile MakefileMakefileMakefile

Reset the length after each use to get the same expansion every time;
here's the behavior with this patch:

   $ ./git ls-tree --format='%(path) %(path) %(path)' HEAD M*
   Makefile Makefile Makefile

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot6426: fix TODO about making test more comprehensive
Elijah Newren [Sat, 14 Jan 2023 18:49:46 +0000 (18:49 +0000)] 
t6426: fix TODO about making test more comprehensive

t6426.7 (a rename/add testcase) long had a TODO/FIXME comment about
how the test could be improved (with some commented out sample code
that had a few small errors), but those improvements were blocked on
other changes still in progress.  The necessary changes were put in
place years ago but the comment was forgotten.  Remove and fix the
commented out code section and finally remove the big TODO/FIXME
comment.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoenv-helper: move this built-in to "test-tool env-helper"
Ævar Arnfjörð Bjarmason [Thu, 12 Jan 2023 16:03:21 +0000 (17:03 +0100)] 
env-helper: move this built-in to "test-tool env-helper"

Since [1] there has been no reason for keeping "git env--helper" a
built-in. The reason it was a built-in to begin with was to support
the GIT_TEST_GETTEXT_POISON mode removed in that commit. I.e. unlike
the rest of "test-tool" it would potentially be called by the
installed git via "git-sh-i18n.sh".

As none of that applies since [1] we should stop carrying this
technical debt, and move it to t/helper/*. As this mostly move-only
change shows this has the nice bonus that we'll stop wasting time
translating the internal-only strings it emits.

Even though this was a built-in, it was intentionally never
documented, see its introduction in [2]. It never saw use outside of
the test suite, except for the "GIT_TEST_GETTEXT_POISON" use-case
noted above.

1. d162b25f956 (tests: remove support for GIT_TEST_GETTEXT_POISON,
   2021-01-20)
2. b4f207f3394 (env--helper: new undocumented builtin wrapping
   git_env_*(), 2019-06-21)

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoattr: add flag `--source` to work with tree-ish
Karthik Nayak [Sat, 14 Jan 2023 08:30:38 +0000 (09:30 +0100)] 
attr: add flag `--source` to work with tree-ish

The contents of the .gitattributes files may evolve over time, but "git
check-attr" always checks attributes against them in the working tree
and/or in the index. It may be beneficial to optionally allow the users
to check attributes taken from a commit other than HEAD against paths.

Add a new flag `--source` which will allow users to check the
attributes against a commit (actually any tree-ish would do). When the
user uses this flag, we go through the stack of .gitattributes files but
instead of checking the current working tree and/or in the index, we
check the blobs from the provided tree-ish object. This allows the
command to also be used in bare repositories.

Since we use a tree-ish object, the user can pass "--source
HEAD:subdirectory" and all the attributes will be looked up as if
subdirectory was the root directory of the repository.

We cannot simply use the `<rev>:<path>` syntax without the `--source`
flag, similar to how it is used in `git show` because any non-flag
parameter before `--` is treated as an attribute and any parameter after
`--` is treated as a pathname.

The change involves creating a new function `read_attr_from_blob`, which
given the path reads the blob for the path against the provided source and
parses the attributes line by line. This function is plugged into
`read_attr()` function wherein we go through the stack of attributes
files.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Toon Claes <toon@iotcl.com>
Co-authored-by: toon@iotcl.com
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot0003: move setup for `--all` into new block
Karthik Nayak [Sat, 14 Jan 2023 08:30:37 +0000 (09:30 +0100)] 
t0003: move setup for `--all` into new block

There is some setup code which is used by multiple tests being setup in
`attribute test: --all option`. This means when we run "sh
./t0003-attributes.sh --run=setup,<num>" there is a chance of failing
since we missed this setup block.

So to ensure that setups are independent of test logic, move this to a
new setup block.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Co-authored-by: toon@iotcl.com
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agodoc: fix non-existent config name
Yukai Chou [Sat, 14 Jan 2023 01:12:12 +0000 (09:12 +0800)] 
doc: fix non-existent config name

Replace non-existent `branch.<name>.fetch` to `remote.<repository>.fetch`, in
the first example in `git-fetch` doc, which was introduced in
d504f6975d (modernize fetch/merge/pull examples, 2009-10-21).

Rename placeholder `<name>` to `<repository>`, to be consistent with all other
uses in git docs, except that `git-config.txt` uses `remote.<name>.fetch` in
its "Variables" section.

Also add missing monospace markups.

Signed-off-by: Yukai Chou <muzimuzhi@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot3104: remove shift code in 'test_ls_tree_format'
Teng Long [Thu, 12 Jan 2023 09:11:35 +0000 (17:11 +0800)] 
t3104: remove shift code in 'test_ls_tree_format'

In t3104-ls-tree-format.sh, There is a legacy 'shift 2' code
and the relevant code block no longer depends on it anymore,
so let's remove it for a small cleanup.

Signed-off-by: Teng Long <dyroneteng@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agols-tree: cleanup the redundant SPACE
Teng Long [Thu, 12 Jan 2023 09:11:34 +0000 (17:11 +0800)] 
ls-tree: cleanup the redundant SPACE

An redundant space was found in ls-tree.c, which is no doubt
a small change, but it might be OK to make a commit on its own.

Signed-off-by: Teng Long <dyroneteng@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agols-tree: make "line_termination" less generic
Ævar Arnfjörð Bjarmason [Thu, 12 Jan 2023 09:11:33 +0000 (17:11 +0800)] 
ls-tree: make "line_termination" less generic

The "ls-tree" command isn't capable of ending "lines" with anything
except '\n' or '\0', and in the latter case we can avoid calling
write_name_quoted_relative() entirely. Let's do that, less for
optimization and more for clarity, the write_name_quoted_relative()
API itself does much the same thing.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Teng Long <dyroneteng@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agols-tree: fold "show_tree_data" into "cb" struct
Ævar Arnfjörð Bjarmason [Thu, 12 Jan 2023 09:11:32 +0000 (17:11 +0800)] 
ls-tree: fold "show_tree_data" into "cb" struct

After the the preceding two commits the only user of the
"show_tree_data" struct needed it along with the "options" member,
let's instead fold all of that into a "show_tree_data" struct that
we'll use only for that callback.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Teng Long <dyroneteng@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agols-tree: use a "struct options"
Ævar Arnfjörð Bjarmason [Thu, 12 Jan 2023 09:11:31 +0000 (17:11 +0800)] 
ls-tree: use a "struct options"

As a first step towards being able to turn this code into an API some
day let's change the "static" options in builtin/ls-tree.c into a
"struct ls_tree_options" that can be constructed dynamically without
the help of parse_options().

Because we're now using non-static variables for this we'll need to
clear_pathspec() at the end of cmd_ls_tree(), least various tests
start failing under SANITIZE=leak. The memory leak was already there
before, now it's just being brought to the surface.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Teng Long <dyroneteng@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agols-tree: don't use "show_tree_data" for "fast" callbacks
Ævar Arnfjörð Bjarmason [Thu, 12 Jan 2023 09:11:30 +0000 (17:11 +0800)] 
ls-tree: don't use "show_tree_data" for "fast" callbacks

As noted in [1] the code that made it in as part of
9c4d58ff2c3 (ls-tree: split up "fast path" callbacks, 2022-03-23) was
a "maybe a good idea, maybe not" RFC-quality patch. I hadn't looked
very carefully at the resulting patterns.

The implementation shared the "struct show_tree_data data", which was
introduced in e81517155e0 (ls-tree: introduce struct "show_tree_data",
2022-03-23) both for use in 455923e0a15 (ls-tree: introduce "--format"
option, 2022-03-23), and because the "fat" callback hadn't been split
up as 9c4d58ff2c3 did.

Now that that's been done we can see that most of what
show_tree_common() was doing could be done lazily by the callbacks
themselves, who in the pre-image were often using an odd mis-match of
their own arguments and those same arguments stuck into the "data"
structure. Let's also have the callers initialize the "type", rather
than grabbing it from the "data" structure afterwards.

1. https://lore.kernel.org/git/cover-0.7-00000000000-20220310T134811Z-avarab@gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Teng Long <dyronteng@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agobisect: no longer try to clean up left-over `.git/head-name` files
Johannes Schindelin [Thu, 12 Jan 2023 15:19:14 +0000 (16:19 +0100)] 
bisect: no longer try to clean up left-over `.git/head-name` files

As per the code comment, the `.git/head-name` files were cleaned up for
backwards-compatibility: an old version of `git bisect` could have left
them behind.

Now, just how old would such a version be? As of 0f497e75f05 (Eliminate
confusing "won't bisect on seeked tree" failure, 2008-02-23), `git
bisect` does not write that file anymore. Which corresponds to Git
v1.5.4.4.

Even if the likelihood is non-nil that there might still be users out
there who use such an old version to start a bisection, but then decide
to continue bisecting with a current Git version, it is highly
improbable.

So let's remove that code, at long last.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agobisect: remove Cogito-related code
Johannes Schindelin [Thu, 12 Jan 2023 15:19:13 +0000 (16:19 +0100)] 
bisect: remove Cogito-related code

Once upon a time, there was this idea that Git would not actually be a
single coherent program, but rather a set of low-level programs that
users cobble together via shell scripts, or develop high-level user
interfaces for Git, or both.

Cogito was such a high-level user interface, incidentally implemented
via shell scripts that cobble together Git calls.

It did turn out relatively quickly that Git would much rather provide a
useful high-level user interface itself.

As of April 19th, 2007, Cogito was therefore discontinued (see
https://lore.kernel.org/git/20070419124648.GL4489@pasky.or.cz/).

Nevertheless, for almost 15 years after that announcement, Git carried
special code in `git bisect` to accommodate Cogito.

Since it is beyond doubt that there are no more Cogito users, let's
remove the last remnant of Cogito-accommodating code.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agobisect run: fix the error message
Johannes Schindelin [Thu, 12 Jan 2023 15:19:12 +0000 (16:19 +0100)] 
bisect run: fix the error message

In d1bbbe45df8 (bisect--helper: reimplement `bisect_run` shell function
in C, 2021-09-13), we ported the `bisect run` subcommand to C, including
the part that prints out an error message when the implicit `git bisect
bad` or `git bisect good` failed.

However, the error message was supposed to print out whether the state
was "good" or "bad", but used a bogus (because non-populated) `args`
variable for it. This was fixed in [1], but as of [2] (when
`bisect--helper` was changed to the present `bisect-state') the error
message still talks about implementation details that should not
concern end users.

Fix that, and add a regression test to ensure that the intended form of
the error message.

1. 80c2e9657f2 (bisect--helper: report actual bisect_state() argument
   on error, 2022-01-18
2. f37d0bdd42d (bisect: fix output regressions in v2.30.0, 2022-11-10)

Helped-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agobisect: verify that a bogus option won't try to start a bisection
Johannes Schindelin [Thu, 12 Jan 2023 15:19:11 +0000 (16:19 +0100)] 
bisect: verify that a bogus option won't try to start a bisection

We do not want `git bisect --bogus-option` to start a bisection. To
verify that, we look for the tell-tale error message `You need to start
by "git bisect start"` and fail if it was found.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>