]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
3 years agot9001-send-email.sh: fix expected absolute paths on Windows
Johannes Sixt [Mon, 24 May 2021 19:38:09 +0000 (21:38 +0200)] 
t9001-send-email.sh: fix expected absolute paths on Windows

Git for Windows is a native Windows program that works with native
absolute paths in the drive letter style C:\dir. The auxiliary
infrastructure is based on MSYS2, which uses POSIX style /C/dir.

When we test for output of absolute paths produced by git.exe, we
usally have to expect C:\dir style paths. To produce such expected
paths, we have to use $(pwd) in the test scripts; the alternative,
$PWD, produces a POSIX style path. ($PWD is a shell variable, and the
shell is bash, an MSYS2 program, and operates in the POSIX realm.)

There are two recently added tests that were written to expect C:\dir
paths. The output that is tested is produced by `git send-email`, but
behind the scenes, this is a Perl script, which also works in the
POSIX realm and produces /C/dir style output.

In the first test case that is changed here, replace $(pwd) by $PWD
so that the expected path is constructed using /C/dir style.

The second test case sets core.hooksPath to an absolute path. Since
the test script talks to native git.exe, it is supposed to place a
C:/dir style path into the configuration; therefore, keep $(pwd).
When this configuration value is consumed by the Perl script, it is
transformed to /C/dir style by the MSYS2 layer and echoed back in
this form in the error message. Hence, do use $PWD for the expected
value.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agogit-send-email: improve --validate error output
Ævar Arnfjörð Bjarmason [Tue, 6 Apr 2021 14:00:37 +0000 (16:00 +0200)] 
git-send-email: improve --validate error output

Improve the output we emit on --validate error to:

 * Say "FILE:LINE" instead of "FILE: LINE", to match "grep -n",
   compiler error messages etc.

 * Don't say "patch contains a" after just mentioning the filename,
   just leave it at "FILE:LINE: is longer than[...]. The "contains a"
   sounded like we were talking about the file in general, when we're
   actually checking it line-by-line.

 * Don't just say "rejected by sendemail-validate hook", but combine
   that with the system_or_msg() output to say what exit code the hook
   died with.

I had an aborted attempt to make the line length checker note all
lines that were longer than the limit. I didn't think that was worth
the effort, but I've left in the testing change to check that we die
as soon as we spot the first long line.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agogit-send-email: refactor duplicate $? checks into a function
Ævar Arnfjörð Bjarmason [Tue, 6 Apr 2021 14:00:36 +0000 (16:00 +0200)] 
git-send-email: refactor duplicate $? checks into a function

Refactor the duplicate checking of $? into a function. There's an
outstanding series[1] wanting to add a third use of system() in this
file, let's not copy this boilerplate anymore when that happens.

1. http://lore.kernel.org/git/87y2esg22j.fsf@evledraar.gmail.com

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agogit-send-email: test full --validate output
Ævar Arnfjörð Bjarmason [Tue, 6 Apr 2021 14:00:35 +0000 (16:00 +0200)] 
git-send-email: test full --validate output

Change the tests that grep substrings out of the output to use a full
test_cmp, in preparation for improving the output.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agogit-send-email: replace "map" in void context with "for"
Ævar Arnfjörð Bjarmason [Fri, 2 Apr 2021 11:34:33 +0000 (13:34 +0200)] 
git-send-email: replace "map" in void context with "for"

While using "map" instead of "for" or "map" instead of "grep" and
vice-versa makes for interesting trivia questions when interviewing
Perl programmers, it doesn't make for very readable code. Let's
refactor this loop initially added in 8fd5bb7f44b (git send-email: add
--annotate option, 2008-11-11) to be a for-loop instead.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoThe fifth batch
Junio C Hamano [Tue, 30 Mar 2021 21:33:34 +0000 (14:33 -0700)] 
The fifth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'jc/doc-format-patch-clarify'
Junio C Hamano [Tue, 30 Mar 2021 21:35:38 +0000 (14:35 -0700)] 
Merge branch 'jc/doc-format-patch-clarify'

Explain pieces of the format-patch output upfront before the rest
of the documentation starts referring to them.

* jc/doc-format-patch-clarify:
  format-patch: give an overview of what a "patch" message is

3 years agoMerge branch 'ab/detox-gettext-tests'
Junio C Hamano [Tue, 30 Mar 2021 21:35:38 +0000 (14:35 -0700)] 
Merge branch 'ab/detox-gettext-tests'

Testfix.

* ab/detox-gettext-tests:
  mktag tests: fix broken "&&" chain

3 years agoMerge branch 'hx/pack-objects-chunk-comment'
Junio C Hamano [Tue, 30 Mar 2021 21:35:37 +0000 (14:35 -0700)] 
Merge branch 'hx/pack-objects-chunk-comment'

Comment update.

* hx/pack-objects-chunk-comment:
  pack-objects: fix comment of reused_chunk.difference

3 years agoMerge branch 'rf/send-email-hookspath'
Junio C Hamano [Tue, 30 Mar 2021 21:35:37 +0000 (14:35 -0700)] 
Merge branch 'rf/send-email-hookspath'

"git send-email" learned to honor the core.hooksPath configuration.

* rf/send-email-hookspath:
  git-send-email: Respect core.hooksPath setting

3 years agoMerge branch 'ab/remove-rebase-usebuiltin'
Junio C Hamano [Tue, 30 Mar 2021 21:35:37 +0000 (14:35 -0700)] 
Merge branch 'ab/remove-rebase-usebuiltin'

Remove the final hint that we used to have a scripted "git rebase".

* ab/remove-rebase-usebuiltin:
  rebase: remove transitory rebase.useBuiltin setting & env

3 years agoMerge branch 'cs/http-use-basic-after-failed-negotiate'
Junio C Hamano [Tue, 30 Mar 2021 21:35:37 +0000 (14:35 -0700)] 
Merge branch 'cs/http-use-basic-after-failed-negotiate'

When accessing a server with a URL like https://user:pass@site/, we
did not to fall back to the basic authentication with the
credential material embedded in the URL after the "Negotiate"
authentication failed.  Now we do.

* cs/http-use-basic-after-failed-negotiate:
  remote-curl: fall back to basic auth if Negotiate fails

3 years agoMerge branch 'ab/diff-no-index-tests'
Junio C Hamano [Tue, 30 Mar 2021 21:35:37 +0000 (14:35 -0700)] 
Merge branch 'ab/diff-no-index-tests'

More test coverage over "diff --no-index".

* ab/diff-no-index-tests:
  diff --no-index tests: test mode normalization
  diff --no-index tests: add test for --exit-code

3 years agoMerge branch 'ab/read-tree'
Junio C Hamano [Tue, 30 Mar 2021 21:35:37 +0000 (14:35 -0700)] 
Merge branch 'ab/read-tree'

Code simplification by removing support for a caller that is long gone.

* ab/read-tree:
  tree.h API: simplify read_tree_recursive() signature
  tree.h API: expose read_tree_1() as read_tree_at()
  archive: stop passing "stage" through read_tree_recursive()
  ls-files: refactor away read_tree()
  ls-files: don't needlessly pass around stage variable
  tree.c API: move read_tree() into builtin/ls-files.c
  ls-files tests: add meaningful --with-tree tests
  show tests: add test for "git show <tree>"

3 years agoMerge branch 'bs/asciidoctor-installation-hints'
Junio C Hamano [Tue, 30 Mar 2021 21:35:36 +0000 (14:35 -0700)] 
Merge branch 'bs/asciidoctor-installation-hints'

Doc update.

* bs/asciidoctor-installation-hints:
  INSTALL: note on using Asciidoctor to build doc

3 years agoMerge branch 'mt/checkout-remove-nofollow'
Junio C Hamano [Tue, 30 Mar 2021 21:35:36 +0000 (14:35 -0700)] 
Merge branch 'mt/checkout-remove-nofollow'

When "git checkout" removes a path that does not exist in the
commit it is checking out, it wasn't careful enough not to follow
symbolic links, which has been corrected.

* mt/checkout-remove-nofollow:
  checkout: don't follow symlinks when removing entries
  symlinks: update comment on threaded_check_leading_path()

3 years agoSync with v2.31.1
Junio C Hamano [Fri, 26 Mar 2021 21:59:47 +0000 (14:59 -0700)] 
Sync with v2.31.1

3 years agoThe fourth batch
Junio C Hamano [Fri, 26 Mar 2021 21:58:49 +0000 (14:58 -0700)] 
The fourth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'cm/rebase-i-fixup-amend-reword'
Junio C Hamano [Fri, 26 Mar 2021 21:59:03 +0000 (14:59 -0700)] 
Merge branch 'cm/rebase-i-fixup-amend-reword'

"git commit --fixup=<commit>", which was to tweak the changes made
to the contents while keeping the original log message intact,
learned "--fixup=(amend|reword):<commit>", that can be used to
tweak both the message and the contents, and only the message,
respectively.

* cm/rebase-i-fixup-amend-reword:
  doc/git-commit: add documentation for fixup=[amend|reword] options
  t3437: use --fixup with options to create amend! commit
  t7500: add tests for --fixup=[amend|reword] options
  commit: add a reword suboption to --fixup
  commit: add amend suboption to --fixup to create amend! commit
  sequencer: export and rename subject_length()

3 years agoMerge branch 'cm/rebase-i-updates'
Junio C Hamano [Fri, 26 Mar 2021 21:59:03 +0000 (14:59 -0700)] 
Merge branch 'cm/rebase-i-updates'

Follow-up fixes to "cm/rebase-i" topic.

* cm/rebase-i-updates:
  doc/rebase -i: fix typo in the documentation of 'fixup' command
  t/t3437: fixup the test 'multiple fixup -c opens editor once'
  t/t3437: use named commits in the tests
  t/t3437: simplify and document the test helpers
  t/t3437: check the author date of fixed up commit
  t/t3437: remove the dependency of 'expected-message' file from tests
  t/t3437: fixup here-docs in the 'setup' test
  t/lib-rebase: update the documentation of FAKE_LINES
  rebase -i: clarify and fix 'fixup -c' rebase-todo help
  sequencer: rename a few functions
  sequencer: fixup the datatype of the 'flag' argument

3 years agoMerge branch 'cm/rebase-i'
Junio C Hamano [Fri, 26 Mar 2021 21:59:03 +0000 (14:59 -0700)] 
Merge branch 'cm/rebase-i'

"rebase -i" is getting cleaned up and also enhanced.

* cm/rebase-i:
  doc/git-rebase: add documentation for fixup [-C|-c] options
  rebase -i: teach --autosquash to work with amend!
  t3437: test script for fixup [-C|-c] options in interactive rebase
  rebase -i: add fixup [-C | -c] command
  sequencer: use const variable for commit message comments
  sequencer: pass todo_item to do_pick_commit()
  rebase -i: comment out squash!/fixup! subjects from squash message
  sequencer: factor out code to append squash message
  rebase -i: only write fixup-message when it's needed

3 years agoMerge branch 'js/http-pki-credential-store'
Junio C Hamano [Fri, 26 Mar 2021 21:59:02 +0000 (14:59 -0700)] 
Merge branch 'js/http-pki-credential-store'

The http codepath learned to let the credential layer to cache the
password used to unlock a certificate that has successfully been
used.

* js/http-pki-credential-store:
  http: drop the check for an empty proxy password before approving
  http: store credential when PKI auth is used

3 years agoMerge branch 'ab/make-cleanup'
Junio C Hamano [Fri, 26 Mar 2021 21:59:02 +0000 (14:59 -0700)] 
Merge branch 'ab/make-cleanup'

Reorganize Makefile to allow building git.o and other essential
objects without extra stuff needed only for testing.

* ab/make-cleanup:
  Makefile: add {program,xdiff,test,git,fuzz}-objs & objects targets
  Makefile: split OBJECTS into OBJECTS and GIT_OBJS
  Makefile: sort OBJECTS assignment for subsequent change
  Makefile: split up long OBJECTS line
  Makefile: guard against TEST_OBJS in the environment

3 years agoGit 2.31.1 v2.31.1
Junio C Hamano [Fri, 19 Mar 2021 22:07:58 +0000 (15:07 -0700)] 
Git 2.31.1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoThe third patch
Junio C Hamano [Wed, 24 Mar 2021 21:36:01 +0000 (14:36 -0700)] 
The third patch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'nk/diff-index-fsmonitor'
Junio C Hamano [Wed, 24 Mar 2021 21:36:27 +0000 (14:36 -0700)] 
Merge branch 'nk/diff-index-fsmonitor'

"git diff-index" codepath has been taught to trust fsmonitor status
to reduce number of lstat() calls.

* nk/diff-index-fsmonitor:
  fsmonitor: add perf test for git diff HEAD
  fsmonitor: add assertion that fsmonitor is valid to check_removed
  fsmonitor: skip lstat deletion check during git diff-index

3 years agoMerge branch 'jk/fail-prereq-testfix'
Junio C Hamano [Wed, 24 Mar 2021 21:36:27 +0000 (14:36 -0700)] 
Merge branch 'jk/fail-prereq-testfix'

GIT_TEST_FAIL_PREREQS is a mechanism to skip test pieces with
prerequisites to catch broken tests that depend on the side effects
of optional pieces, but did not work at all when negative
prerequisites were involved.

* jk/fail-prereq-testfix:
  t: annotate !PTHREADS tests with !FAIL_PREREQS

3 years agoMerge branch 'tb/geometric-repack'
Junio C Hamano [Wed, 24 Mar 2021 21:36:27 +0000 (14:36 -0700)] 
Merge branch 'tb/geometric-repack'

"git repack" so far has been only capable of repacking everything
under the sun into a single pack (or split by size).  A cleverer
strategy to reduce the cost of repacking a repository has been
introduced.

* tb/geometric-repack:
  builtin/pack-objects.c: ignore missing links with --stdin-packs
  builtin/repack.c: reword comment around pack-objects flags
  builtin/repack.c: be more conservative with unsigned overflows
  builtin/repack.c: assign pack split later
  t7703: test --geometric repack with loose objects
  builtin/repack.c: do not repack single packs with --geometric
  builtin/repack.c: add '--geometric' option
  packfile: add kept-pack cache for find_kept_pack_entry()
  builtin/pack-objects.c: rewrite honor-pack-keep logic
  p5303: measure time to repack with keep
  p5303: add missing &&-chains
  builtin/pack-objects.c: add '--stdin-packs' option
  revision: learn '--no-kept-objects'
  packfile: introduce 'find_kept_pack_entry()'

3 years agoMerge branch 'tb/push-simple-uses-branch-merge-config'
Junio C Hamano [Wed, 24 Mar 2021 21:36:27 +0000 (14:36 -0700)] 
Merge branch 'tb/push-simple-uses-branch-merge-config'

Doc update.

* tb/push-simple-uses-branch-merge-config:
  Documentation/git-push.txt: correct configuration typo

3 years agopack-objects: fix comment of reused_chunk.difference
Han Xin [Tue, 23 Mar 2021 03:20:50 +0000 (11:20 +0800)] 
pack-objects: fix comment of reused_chunk.difference

As record_reused_object(offset, offset - hashfile_total(out)) said,
reused_chunk.difference should be the offset of original packfile minus
the offset of the generated packfile. But the comment presented an opposite way.

Signed-off-by: Han Xin <hanxin.hx@alibaba-inc.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoformat-patch: give an overview of what a "patch" message is
Junio C Hamano [Wed, 24 Mar 2021 17:35:40 +0000 (10:35 -0700)] 
format-patch: give an overview of what a "patch" message is

The text says something called a "patch" is prepared one for each
commit, it is suitable for e-mail submission, and "am" is the
command to use it, but does not say what the "patch" really is.

The description in the page also refers to the "three-dash" line,
but it is unclear what it is, unless the reader is given a more
detailed overview of what the "patch" is.

Add a brief paragraph to give an overview of what the output looks
like.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agomktag tests: fix broken "&&" chain
Ævar Arnfjörð Bjarmason [Wed, 24 Mar 2021 02:11:52 +0000 (03:11 +0100)] 
mktag tests: fix broken "&&" chain

Remove a stray "xb" I inadvertently introduced in 780aa0a21e0 (tests:
remove last uses of GIT_TEST_GETTEXT_POISON=false, 2021-02-11).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agogit-send-email: Respect core.hooksPath setting
Robert Foss [Tue, 23 Mar 2021 17:33:27 +0000 (18:33 +0100)] 
git-send-email: Respect core.hooksPath setting

get-send-email currently makes the assumption that the
'sendemail-validate' hook exists inside of the repository.

Since the introduction of 'core.hooksPath' configuration option in
867ad08a261 (hooks: allow customizing where the hook directory is,
2016-05-04), this is no longer true.

Instead of assuming a hardcoded repo relative path, query
git for the actual path of the hooks directory.

Signed-off-by: Robert Foss <robert.foss@linaro.org>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorebase: remove transitory rebase.useBuiltin setting & env
Ævar Arnfjörð Bjarmason [Tue, 23 Mar 2021 15:23:58 +0000 (16:23 +0100)] 
rebase: remove transitory rebase.useBuiltin setting & env

Remove the rebase.useBuiltin setting and the now-obsolete
GIT_TEST_REBASE_USE_BUILTIN test flag.

This was left in place after my d03ebd411c6 (rebase: remove the
rebase.useBuiltin setting, 2019-03-18) to help anyone who'd used the
experimental flag and wanted to know that it was the default, or that
they should transition their test environment to use the builtin
rebase unconditionally.

It's been more than long enough for those users to get a headsup about
this. So remove all the scaffolding that was left inplace after
d03ebd411c6. I'm also removing the documentation entry, if anyone
still has this left in their configuration they can do some source
archaeology to figure out what it used to do, which makes more sense
than exposing every git user reading the documentation to this legacy
configuration switch.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoThe second batch
Junio C Hamano [Mon, 22 Mar 2021 21:00:00 +0000 (14:00 -0700)] 
The second batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'bc/clone-bare-with-conflicting-config'
Junio C Hamano [Mon, 22 Mar 2021 21:00:25 +0000 (14:00 -0700)] 
Merge branch 'bc/clone-bare-with-conflicting-config'

"git -c core.bare=false clone --bare ..." would have segfaulted,
which has been corrected.

* bc/clone-bare-with-conflicting-config:
  builtin/init-db: handle bare clones when core.bare set to false

3 years agoMerge branch 'jk/filter-branch-sha256'
Junio C Hamano [Mon, 22 Mar 2021 21:00:25 +0000 (14:00 -0700)] 
Merge branch 'jk/filter-branch-sha256'

Code clean-up.

* jk/filter-branch-sha256:
  filter-branch: drop $_x40 glob
  filter-branch: drop multiple-ancestor warning
  t7003: test ref rewriting explicitly

3 years agoMerge branch 'ps/update-ref-trans-hook-doc'
Junio C Hamano [Mon, 22 Mar 2021 21:00:25 +0000 (14:00 -0700)] 
Merge branch 'ps/update-ref-trans-hook-doc'

Doc update.

* ps/update-ref-trans-hook-doc:
  githooks.txt: clarify documentation on reference-transaction hook
  githooks.txt: replace mentions of SHA-1 specific properties

3 years agoMerge branch 'rr/mailmap-entry-self'
Junio C Hamano [Mon, 22 Mar 2021 21:00:25 +0000 (14:00 -0700)] 
Merge branch 'rr/mailmap-entry-self'

* rr/mailmap-entry-self:
  Add entry for Ramkumar Ramachandra

3 years agoMerge branch 'jr/doc-ignore-typofix'
Junio C Hamano [Mon, 22 Mar 2021 21:00:25 +0000 (14:00 -0700)] 
Merge branch 'jr/doc-ignore-typofix'

Doc cleanup.

* jr/doc-ignore-typofix:
  doc: .gitignore documentation typofix

3 years agoMerge branch 'sv/t9801-test-path-is-file-cleanup'
Junio C Hamano [Mon, 22 Mar 2021 21:00:24 +0000 (14:00 -0700)] 
Merge branch 'sv/t9801-test-path-is-file-cleanup'

Test cleanup.

* sv/t9801-test-path-is-file-cleanup:
  t9801: replace test -f with test_path_is_file

3 years agoMerge branch 'dl/cat-file-doc-cleanup'
Junio C Hamano [Mon, 22 Mar 2021 21:00:24 +0000 (14:00 -0700)] 
Merge branch 'dl/cat-file-doc-cleanup'

Doc cleanup.

* dl/cat-file-doc-cleanup:
  git-cat-file.txt: remove references to "sha1"
  git-cat-file.txt: monospace args, placeholders and filenames

3 years agoMerge branch 'rs/pretty-describe'
Junio C Hamano [Mon, 22 Mar 2021 21:00:24 +0000 (14:00 -0700)] 
Merge branch 'rs/pretty-describe'

"git log --format='...'" learned "%(describe)" placeholder.

* rs/pretty-describe:
  archive: expand only a single %(describe) per archive
  pretty: document multiple %(describe) being inconsistent
  t4205: assert %(describe) test coverage
  pretty: add merge and exclude options to %(describe)
  pretty: add %(describe)

3 years agoMerge branch 'dl/stash-show-untracked'
Junio C Hamano [Mon, 22 Mar 2021 21:00:24 +0000 (14:00 -0700)] 
Merge branch 'dl/stash-show-untracked'

"git stash show" learned to optionally show untracked part of the
stash.

* dl/stash-show-untracked:
  stash show: learn stash.showIncludeUntracked
  stash show: teach --include-untracked and --only-untracked

3 years agoMerge branch 'en/ort-perf-batch-8'
Junio C Hamano [Mon, 22 Mar 2021 21:00:23 +0000 (14:00 -0700)] 
Merge branch 'en/ort-perf-batch-8'

Rename detection rework continues.

* en/ort-perf-batch-8:
  diffcore-rename: compute dir_rename_guess from dir_rename_counts
  diffcore-rename: limit dir_rename_counts computation to relevant dirs
  diffcore-rename: compute dir_rename_counts in stages
  diffcore-rename: extend cleanup_dir_rename_info()
  diffcore-rename: move dir_rename_counts into dir_rename_info struct
  diffcore-rename: add function for clearing dir_rename_count
  Move computation of dir_rename_count from merge-ort to diffcore-rename
  diffcore-rename: add a mapping of destination names to their indices
  diffcore-rename: provide basic implementation of idx_possible_rename()
  diffcore-rename: use directory rename guided basename comparisons

3 years agoMerge branch 'ab/grep-pcre2-allocfix'
Junio C Hamano [Mon, 22 Mar 2021 21:00:23 +0000 (14:00 -0700)] 
Merge branch 'ab/grep-pcre2-allocfix'

Updates to memory allocation code around the use of pcre2 library.

* ab/grep-pcre2-allocfix:
  grep/pcre2: move definitions of pcre2_{malloc,free}
  grep/pcre2: move back to thread-only PCREv2 structures
  grep/pcre2: actually make pcre2 use custom allocator
  grep/pcre2: use pcre2_maketables_free() function
  grep/pcre2: use compile-time PCREv2 version test
  grep/pcre2: add GREP_PCRE2_DEBUG_MALLOC debug mode
  grep/pcre2: prepare to add debugging to pcre2_malloc()
  grep/pcre2: correct reference to grep_init() in comment
  grep/pcre2: drop needless assignment to NULL
  grep/pcre2: drop needless assignment + assert() on opt->pcre2

3 years agoMerge branch 'jk/perf-in-worktrees'
Junio C Hamano [Mon, 22 Mar 2021 21:00:23 +0000 (14:00 -0700)] 
Merge branch 'jk/perf-in-worktrees'

Perf test update to work better in secondary worktrees.

* jk/perf-in-worktrees:
  t/perf: avoid copying worktree files from test repo
  t/perf: handle worktrees as test repos

3 years agoMerge branch 'ds/commit-graph-generation-config'
Junio C Hamano [Mon, 22 Mar 2021 21:00:23 +0000 (14:00 -0700)] 
Merge branch 'ds/commit-graph-generation-config'

A new configuration variable has been introduced to allow choosing
which version of the generation number gets used in the
commit-graph file.

* ds/commit-graph-generation-config:
  commit-graph: use config to specify generation type
  commit-graph: create local repository pointer

3 years agoMerge branch 'ab/remote-write-config-in-camel-case'
Junio C Hamano [Mon, 22 Mar 2021 21:00:23 +0000 (14:00 -0700)] 
Merge branch 'ab/remote-write-config-in-camel-case'

Update C code that sets a few configuration variables when a remote
is configured so that it spells configuration variable names in the
canonical camelCase.

* ab/remote-write-config-in-camel-case:
  remote: write camel-cased *.pushRemote on rename
  remote: add camel-cased *.tagOpt key, like clone

3 years agoMerge branch 'mt/cleanly-die-upon-missing-required-filter'
Junio C Hamano [Mon, 22 Mar 2021 21:00:22 +0000 (14:00 -0700)] 
Merge branch 'mt/cleanly-die-upon-missing-required-filter'

We had a code to diagnose and die cleanly when a required
clean/smudge filter is missing, but an assert before that
unnecessarily fired, hiding the end-user facing die() message.

* mt/cleanly-die-upon-missing-required-filter:
  convert: fail gracefully upon missing clean cmd on required filter

3 years agoMerge branch 'jk/open-dotgitx-with-nofollow'
Junio C Hamano [Mon, 22 Mar 2021 21:00:22 +0000 (14:00 -0700)] 
Merge branch 'jk/open-dotgitx-with-nofollow'

It does not make sense to make ".gitattributes", ".gitignore" and
".mailmap" symlinks, as they are supposed to be usable from the
object store (think: bare repositories where HEAD:.mailmap etc. are
used).  When these files are symbolic links, we used to read the
contents of the files pointed by them by mistake, which has been
corrected.

* jk/open-dotgitx-with-nofollow:
  mailmap: do not respect symlinks for in-tree .mailmap
  exclude: do not respect symlinks for in-tree .gitignore
  attr: do not respect symlinks for in-tree .gitattributes
  exclude: add flags parameter to add_patterns()
  attr: convert "macro_ok" into a flags field
  add open_nofollow() helper

3 years agodiff --no-index tests: test mode normalization
Ævar Arnfjörð Bjarmason [Sun, 21 Mar 2021 22:36:20 +0000 (23:36 +0100)] 
diff --no-index tests: test mode normalization

When "git diff --no-index X Y" is run the modes of the files being
differ are normalized by canon_mode() in fill_filespec().

I recently broke that behavior in a patch of mine[1] which would pass
all tests, or not, depending on the umask of the git.git checkout.

Let's test for this explicitly. Arguably this should not be the
behavior of "git diff --no-index". We aren't diffing our own objects
or the index, so it might be useful to show mode differences between
files.

On the other hand diff(1) does not do that, and it would be needlessly
distracting when e.g. diffing an extracted tar archive whose contents
is the same, but whose file modes are different.

1. https://lore.kernel.org/git/20210316155829.31242-2-avarab@gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoremote-curl: fall back to basic auth if Negotiate fails
Christopher Schenk [Mon, 22 Mar 2021 11:51:16 +0000 (11:51 +0000)] 
remote-curl: fall back to basic auth if Negotiate fails

When the username and password are supplied in a url like this
https://myuser:secret@git.exampe/myrepo.git and the server supports the
negotiate authenticaten method, git does not fall back to basic auth and
libcurl hardly tries to authenticate with the negotiate method.

Stop using the Negotiate authentication method after the first failure
because if it fails on the first try it will never succeed.

Signed-off-by: Christopher Schenk <christopher@cschenk.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agodiff --no-index tests: add test for --exit-code
Ævar Arnfjörð Bjarmason [Sun, 21 Mar 2021 22:36:19 +0000 (23:36 +0100)] 
diff --no-index tests: add test for --exit-code

Add a test for --exit-code working with --no-index. There's no reason
to suppose it wouldn't, but we weren't testing for it anywhere in our
tests. Let's fix that blind spot.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agotree.h API: simplify read_tree_recursive() signature
Ævar Arnfjörð Bjarmason [Sat, 20 Mar 2021 22:37:51 +0000 (23:37 +0100)] 
tree.h API: simplify read_tree_recursive() signature

Simplify the signature of read_tree_recursive() to omit the "base",
"baselen" and "stage" arguments. No callers of it use these parameters
for anything anymore.

The last function to call read_tree_recursive() with a non-"" path was
read_tree_recursive() itself, but that was changed in
ffd31f661d5 (Reimplement read_tree_recursive() using
tree_entry_interesting(), 2011-03-25).

The last user of the "stage" parameter went away in the last commit,
and even that use was mere boilerplate.

So let's remove those and rename the read_tree_recursive() function to
just read_tree(). We had another read_tree() function that I've
refactored away in preceding commits, since all in-tree users read
trees recursively with a callback we can change the name to signify
that this is the norm.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agotree.h API: expose read_tree_1() as read_tree_at()
Ævar Arnfjörð Bjarmason [Sat, 20 Mar 2021 22:37:50 +0000 (23:37 +0100)] 
tree.h API: expose read_tree_1() as read_tree_at()

Rename the static read_tree_1() function to read_tree_at(). This
function works just like read_tree_recursive(), except you provide
your own strbuf.

This step doesn't make much sense now, but in follow-up commits I'll
remove the base/baselen/stage arguments to read_tree_recursive(). At
that point an anticipated in-tree user[1] for the old
read_tree_recursive() couldn't provide a path to start the
traversal.

Let's give them a function to do so with an API that makes more sense
for them, by taking a strbuf we should be able to avoid more casting
and/or reallocations in the future.

1. https://lore.kernel.org/git/xmqqft106sok.fsf@gitster.g

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoarchive: stop passing "stage" through read_tree_recursive()
Ævar Arnfjörð Bjarmason [Sat, 20 Mar 2021 22:37:49 +0000 (23:37 +0100)] 
archive: stop passing "stage" through read_tree_recursive()

The "stage" variable being passed around in the archive code has only
ever been an elaborate way to hardcode the value "0".

This code was added in its original form in e4fbbfe9ecc (Add
git-zip-tree, 2006-08-26), at which point a hardcoded "0" would be
passed down through read_tree_recursive() to write_zip_entry().

It was then diligently added to the "struct directory" in
ed22b4173bd (archive: support filtering paths with glob, 2014-09-21),
but we were still not doing anything except passing it around as-is.

Let's stop doing that in the code internal to archive.c, we'll still
feed "0" to read_tree_recursive() itself, but won't use it. That we're
providing it at all to read_tree_recursive() will be changed in a
follow-up commit.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agols-files: refactor away read_tree()
Ævar Arnfjörð Bjarmason [Sat, 20 Mar 2021 22:37:48 +0000 (23:37 +0100)] 
ls-files: refactor away read_tree()

Refactor away the read_tree() function into its only user,
overlay_tree_on_index().

First, change read_one_entry_opt() to use the strbuf parameter
read_tree_recursive() passes down in place. This finishes up a partial
refactoring started in 6a0b0b6de99 (tree.c: update read_tree_recursive
callback to pass strbuf as base, 2014-11-30).

Moving the rest into overlay_tree_on_index() makes this index juggling
we're doing easier to read.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agols-files: don't needlessly pass around stage variable
Ævar Arnfjörð Bjarmason [Sat, 20 Mar 2021 22:37:47 +0000 (23:37 +0100)] 
ls-files: don't needlessly pass around stage variable

Now that read_tree() has been moved to ls-files.c we can get rid of
the stage != 1 case that'll never happen.

Let's not use read_tree_recursive() as a pass-through to pass "stage =
1" either. For now we'll pass an unused "stage = 0" for consistency
with other read_tree_recursive() callers, that argument will be
removed in a follow-up commit.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agotree.c API: move read_tree() into builtin/ls-files.c
Ævar Arnfjörð Bjarmason [Sat, 20 Mar 2021 22:37:46 +0000 (23:37 +0100)] 
tree.c API: move read_tree() into builtin/ls-files.c

Since the read_tree() API was added around the same time as
read_tree_recursive() in 94537c78a82 (Move "read_tree()" to
"tree.c"[...], 2005-04-22) and b12ec373b8e ([PATCH] Teach read-tree
about commit objects, 2005-04-20) things have gradually migrated over
to the read_tree_recursive() version.

Now builtin/ls-files.c is the last user of this code, let's move all
the relevant code there. This allows for subsequent simplification of
it, and an eventual move to read_tree_recursive().

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agols-files tests: add meaningful --with-tree tests
Ævar Arnfjörð Bjarmason [Sat, 20 Mar 2021 22:37:45 +0000 (23:37 +0100)] 
ls-files tests: add meaningful --with-tree tests

Add tests for "ls-files --with-tree". There was effectively no
coverage for any normal usage of this command, only the tests added in
54e1abce90e (Add test case for ls-files --with-tree, 2007-10-03) for
an obscure bug.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoshow tests: add test for "git show <tree>"
Ævar Arnfjörð Bjarmason [Sat, 20 Mar 2021 22:37:44 +0000 (23:37 +0100)] 
show tests: add test for "git show <tree>"

Add missing tests for showing a tree with "git show". Let's test for
showing a tree, two trees, and that doing so doesn't recurse.

The only tests for this code added in 5d7eeee2ac6 (git-show: grok
blobs, trees and tags, too, 2006-12-14) were the tests in
t7701-repack-unpack-unreachable.sh added in ccc1297226b (repack:
modify behavior of -A option to leave unreferenced objects unpacked,
2008-05-09).

Let's add this common mode of operation to the "show" tests
themselves. It's more obvious, and the tests in
t7701-repack-unpack-unreachable.sh happily pass if we start buggily
emitting trees recursively.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'tb/git-mv-icase-fix'
Junio C Hamano [Fri, 19 Mar 2021 22:25:40 +0000 (15:25 -0700)] 
Merge branch 'tb/git-mv-icase-fix'

Fix a corner case bug in "git mv" on case insensitive systems,
which was introduced in 2.29 timeframe.

* tb/git-mv-icase-fix:
  git mv foo FOO ; git mv foo bar gave an assert

3 years agoThe first batch in 2.32 cycle
Junio C Hamano [Fri, 19 Mar 2021 22:07:58 +0000 (15:07 -0700)] 
The first batch in 2.32 cycle

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'rs/xcalloc-takes-nelem-first'
Junio C Hamano [Fri, 19 Mar 2021 22:25:39 +0000 (15:25 -0700)] 
Merge branch 'rs/xcalloc-takes-nelem-first'

Code cleanup.

* rs/xcalloc-takes-nelem-first:
  fix xcalloc() argument order

3 years agoMerge branch 'ah/make-fuzz-all-doc-update'
Junio C Hamano [Fri, 19 Mar 2021 22:25:39 +0000 (15:25 -0700)] 
Merge branch 'ah/make-fuzz-all-doc-update'

Update insn in Makefile comments to run fuzz-all target.

* ah/make-fuzz-all-doc-update:
  Makefile: update 'make fuzz-all' docs to reflect modern clang

3 years agoMerge branch 'jk/slimmed-down'
Junio C Hamano [Fri, 19 Mar 2021 22:25:38 +0000 (15:25 -0700)] 
Merge branch 'jk/slimmed-down'

Unused code removal.

* jk/slimmed-down:
  vcs-svn: remove header files as well

3 years agoMerge branch 'rs/calloc-array'
Junio C Hamano [Fri, 19 Mar 2021 22:25:38 +0000 (15:25 -0700)] 
Merge branch 'rs/calloc-array'

CALLOC_ARRAY() macro replaces many uses of xcalloc().

* rs/calloc-array:
  cocci: allow xcalloc(1, size)
  use CALLOC_ARRAY
  git-compat-util.h: drop trailing semicolon from macro definition

3 years agoMerge branch 'rs/avoid-null-statement-after-macro-call'
Junio C Hamano [Fri, 19 Mar 2021 22:25:38 +0000 (15:25 -0700)] 
Merge branch 'rs/avoid-null-statement-after-macro-call'

Fix macros that can silently inject unintended null-statements.

* rs/avoid-null-statement-after-macro-call:
  mem-pool: drop trailing semicolon from macro definition
  block-sha1: drop trailing semicolon from macro definition

3 years agoMerge branch 'km/config-doc-typofix'
Junio C Hamano [Fri, 19 Mar 2021 22:25:38 +0000 (15:25 -0700)] 
Merge branch 'km/config-doc-typofix'

Docfix.

* km/config-doc-typofix:
  config.txt: add missing period

3 years agoMerge branch 'jt/clone-unborn-head'
Junio C Hamano [Fri, 19 Mar 2021 22:25:37 +0000 (15:25 -0700)] 
Merge branch 'jt/clone-unborn-head'

Test fix.

* jt/clone-unborn-head:
  t5606: run clone branch name test with protocol v2

3 years agoMerge branch 'js/fsmonitor-unpack-fix'
Junio C Hamano [Fri, 19 Mar 2021 22:25:37 +0000 (15:25 -0700)] 
Merge branch 'js/fsmonitor-unpack-fix'

The data structure used by fsmonitor interface was not properly
duplicated during an in-core merge, leading to use-after-free etc.

* js/fsmonitor-unpack-fix:
  fsmonitor: do not forget to release the token in `discard_index()`
  fsmonitor: fix memory corruption in some corner cases

3 years agoMerge branch 'jk/bisect-peel-tag-fix'
Junio C Hamano [Fri, 19 Mar 2021 22:25:37 +0000 (15:25 -0700)] 
Merge branch 'jk/bisect-peel-tag-fix'

"git bisect" reimplemented more in C during 2.30 timeframe did not
take an annotated tag as a good/bad endpoint well.  This regression
has been corrected.

* jk/bisect-peel-tag-fix:
  bisect: peel annotated tags to commits

3 years agoMerge branch 'jh/fsmonitor-prework'
Junio C Hamano [Fri, 19 Mar 2021 22:25:37 +0000 (15:25 -0700)] 
Merge branch 'jh/fsmonitor-prework'

The fsmonitor interface read from its input without making sure
there is something to read from.  This bug is new in 2.31
timeframe.

* jh/fsmonitor-prework:
  fsmonitor: avoid global-buffer-overflow READ when checking trivial response

3 years agoMerge branch 'jc/calloc-fix'
Junio C Hamano [Fri, 19 Mar 2021 22:25:37 +0000 (15:25 -0700)] 
Merge branch 'jc/calloc-fix'

Code clean-up.

* jc/calloc-fix:
  xcalloc: use CALLOC_ARRAY() when applicable

3 years agobuiltin/pack-objects.c: ignore missing links with --stdin-packs
Taylor Blau [Fri, 19 Mar 2021 15:40:52 +0000 (11:40 -0400)] 
builtin/pack-objects.c: ignore missing links with --stdin-packs

When 'git pack-objects --stdin-packs' encounters a commit in a pack, it
marks it as a starting point of a best-effort reachability traversal
that is used to populate the name-hash of the objects listed in the
given packs.

The traversal expects that it should be able to walk the ancestors of
all commits in a pack without issue. Ordinarily this is the case, but it
is possible to having missing parents from an unreachable part of the
repository. In that case, we'd consider any missing objects in the
unreachable portion of the graph to be junk.

This should be handled gracefully: since the traversal is best-effort
(i.e., we don't strictly need to fill in all of the name-hash fields),
we should simply ignore any missing links.

This patch does that (by setting the 'ignore_missing_links' bit on the
rev_info struct), and ensures we don't regress in the future by adding a
test which demonstrates this case.

It is a little over-eager, since it will also ignore missing links in
reachable parts of the packs (which would indicate a corrupted
repository), but '--stdin-packs' is explicitly *not* about reachability.
So this step isn't making anything worse for a repository which contains
packs missing reachable objects (since we never drop objects with
'--stdin-packs').

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoINSTALL: note on using Asciidoctor to build doc
Bagas Sanjaya [Fri, 19 Mar 2021 11:00:45 +0000 (18:00 +0700)] 
INSTALL: note on using Asciidoctor to build doc

Note on using Asciidoctor to build documentation suite.

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot: annotate !PTHREADS tests with !FAIL_PREREQS
Jeff King [Wed, 17 Mar 2021 22:47:03 +0000 (18:47 -0400)] 
t: annotate !PTHREADS tests with !FAIL_PREREQS

Some tests in t5300 and t7810 expect us to complain about a "--threads"
argument when Git is compiled without pthread support. Running these
under GIT_TEST_FAIL_PREREQS produces a confusing failure: we pretend to
the tests that there is no pthread support, so they expect the warning,
but of course the actual build is perfectly happy to respect the
--threads argument.

We never noticed before the recent a926c4b904 (tests: remove most uses
of C_LOCALE_OUTPUT, 2021-02-11), because the tests also were marked as
requiring the C_LOCALE_OUTPUT prerequisite. Which means they'd never
have run in FAIL_PREREQS mode, since it would always pretend that the
locale prereq was not satisfied.

These tests can't possibly work in this mode; it is a mismatch between
what the tests expect and what the build was told to do. So let's just
mark them to be skipped, using the special prereq introduced by
dfe1a17df9 (tests: add a special setup where prerequisites fail,
2019-05-13).

Reported-by: Son Luong Ngoc <sluongng@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agofsmonitor: add perf test for git diff HEAD
Nipunn Koorapati [Wed, 17 Mar 2021 21:22:23 +0000 (21:22 +0000)] 
fsmonitor: add perf test for git diff HEAD

Update the xargs call so that if your large repo contains
symlinks, test-tool chmtime failure does not end the script.

On Linux
Test                                                          this tree           upstream/master
---------------------------------------------------------------------------------------------------------
7519.4: status (fsmonitor=fsmonitor-watchman)                 0.52(0.43+0.10)     0.53(0.49+0.05) +1.9%
7519.5: status -uno (fsmonitor=fsmonitor-watchman)            0.21(0.15+0.07)     0.22(0.13+0.09) +4.8%
7519.6: status -uall (fsmonitor=fsmonitor-watchman)           1.65(0.93+0.71)     1.69(1.03+0.65) +2.4%
7519.7: status (dirty) (fsmonitor=fsmonitor-watchman)         11.99(11.34+1.58)   11.95(11.02+1.79) -0.3%
7519.8: diff (fsmonitor=fsmonitor-watchman)                   0.25(0.17+0.26)     0.25(0.18+0.26) +0.0%
7519.9: diff HEAD (fsmonitor=fsmonitor-watchman)              0.39(0.25+0.34)     0.89(0.35+0.74) +128.2%
7519.10: diff -- 0_files (fsmonitor=fsmonitor-watchman)       0.16(0.13+0.04)     0.16(0.12+0.05) +0.0%
7519.11: diff -- 10_files (fsmonitor=fsmonitor-watchman)      0.16(0.12+0.05)     0.16(0.12+0.05) +0.0%
7519.12: diff -- 100_files (fsmonitor=fsmonitor-watchman)     0.16(0.12+0.05)     0.16(0.12+0.05) +0.0%
7519.13: diff -- 1000_files (fsmonitor=fsmonitor-watchman)    0.16(0.11+0.06)     0.16(0.12+0.05) +0.0%
7519.14: diff -- 10000_files (fsmonitor=fsmonitor-watchman)   0.18(0.13+0.06)     0.17(0.10+0.08) -5.6%
7519.15: add (fsmonitor=fsmonitor-watchman)                   2.25(1.53+0.68)     2.25(1.47+0.74) +0.0%
7519.18: status (fsmonitor=disabled)                          0.88(0.73+1.03)     0.89(0.67+1.08) +1.1%
7519.19: status -uno (fsmonitor=disabled)                     0.45(0.43+0.89)     0.45(0.34+0.98) +0.0%
7519.20: status -uall (fsmonitor=disabled)                    1.88(1.16+1.58)     1.88(1.22+1.51) +0.0%
7519.21: status (dirty) (fsmonitor=disabled)                  7.53(7.05+2.11)     7.53(6.98+2.04) +0.0%
7519.22: diff (fsmonitor=disabled)                            0.42(0.37+0.92)     0.42(0.38+0.91) +0.0%
7519.23: diff HEAD (fsmonitor=disabled)                       0.44(0.41+0.90)     0.44(0.40+0.91) +0.0%
7519.24: diff -- 0_files (fsmonitor=disabled)                 0.13(0.09+0.05)     0.13(0.09+0.05) +0.0%
7519.25: diff -- 10_files (fsmonitor=disabled)                0.13(0.10+0.04)     0.13(0.10+0.04) +0.0%
7519.26: diff -- 100_files (fsmonitor=disabled)               0.13(0.09+0.05)     0.13(0.10+0.04) +0.0%
7519.27: diff -- 1000_files (fsmonitor=disabled)              0.13(0.09+0.06)     0.13(0.09+0.05) +0.0%
7519.28: diff -- 10000_files (fsmonitor=disabled)             0.14(0.11+0.05)     0.14(0.10+0.05) +0.0%
7519.29: add (fsmonitor=disabled)                             2.43(1.61+1.64)     2.43(1.69+1.57) +0.0%

On linux (2.29.2 vs w/ this patch):
nipunn@nipunn-dbx:~/src/server3$ strace -f -c git diff 2>&1 | grep lstat
  0.04    0.000063           3        20         6 lstat
nipunn@nipunn-dbx:~/src/server3$ strace -f -c git diff HEAD 2>&1 | grep lstat
 94.98    5.242262          10    523783        13 lstat
nipunn@nipunn-dbx:~/src/server3$ strace -f -c ../git/bin-wrappers/git diff 2>&1 | grep lstat
  0.38    0.000032           5         7         3 lstat
nipunn@nipunn-dbx:~/src/server3$ strace -f -c ../git/bin-wrappers/git diff HEAD 2>&1 | grep lstat
 99.44    0.741892           9     81634        10 lstat

On mac (2.29.2 vs w/ this patch):
nipunn-mbp:server nipunn$ sudo dtruss -L -f -c git diff 2>&1 | grep "^lstat64 "
lstat64                                         8
nipunn-mbp:server nipunn$ sudo dtruss -L -f -c git diff HEAD 2>&1 | grep "^lstat64 "
lstat64                                    120242
nipunn-mbp:server nipunn$ sudo dtruss -L -f -c ../git/bin-wrappers/git diff 2>&1 | grep "^lstat64 "
lstat64                                         4
nipunn-mbp:server nipunn$ sudo dtruss -L -f -c ../git/bin-wrappers/git diff HEAD 2>&1 | grep "^lstat64 "
lstat64                                      4497

There are still a bunch of lstats - on directories, but not every file. Progress!

Signed-off-by: Nipunn Koorapati <nipunn@dropbox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agofsmonitor: add assertion that fsmonitor is valid to check_removed
Nipunn Koorapati [Wed, 17 Mar 2021 21:22:22 +0000 (21:22 +0000)] 
fsmonitor: add assertion that fsmonitor is valid to check_removed

Validate that fsmonitor is valid to futureproof against bugs where
check_removed might be called from places that haven't refreshed.

Signed-off-by: Nipunn Koorapati <nipunn@dropbox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agofsmonitor: skip lstat deletion check during git diff-index
Nipunn Koorapati [Wed, 17 Mar 2021 21:22:21 +0000 (21:22 +0000)] 
fsmonitor: skip lstat deletion check during git diff-index

Teach git to honor fsmonitor rather than issuing an lstat
when checking for dirty local deletes. Eliminates O(files)
lstats during `git diff HEAD`

Signed-off-by: Nipunn Koorapati <nipunn@dropbox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocheckout: don't follow symlinks when removing entries
Matheus Tavares [Thu, 18 Mar 2021 18:43:47 +0000 (15:43 -0300)] 
checkout: don't follow symlinks when removing entries

At 1d718a5108 ("do not overwrite untracked symlinks", 2011-02-20),
symlink.c:check_leading_path() started returning different codes for
FL_ENOENT and FL_SYMLINK. But one of its callers, unlink_entry(), was
not adjusted for this change, so it started to follow symlinks on the
leading path of to-be-removed entries. Fix that and add a regression
test.

Note that since 1d718a5108 check_leading_path() no longer differentiates
the case where it found a symlink in the path's leading components from
the cases where it found a regular file or failed to lstat() the
component. So, a side effect of this current patch is that
unlink_entry() now returns early in all of these three cases. And
because we no longer try to unlink such paths, we also don't get the
warning from remove_or_warn().

For the regular file and symlink cases, it's questionable whether the
warning was useful in the first place: unlink_entry() removes tracked
paths that should no longer be present in the state we are checking out
to. If the path had its leading dir replaced by another file, it means
that the basename already doesn't exist, so there is no need for a
warning. Sure, we are leaving a regular file or symlink behind at the
path's dirname, but this file is either untracked now (so again, no
need to warn), or it will be replaced by a tracked file during the next
phase of this checkout operation.

As for failing to lstat() one of the leading components, the basename
might still exist only we cannot unlink it (e.g. due to the lack of the
required permissions). Since the user expect it to be removed
(especially with checkout's --no-overlay option), add back the warning
in this more relevant case.

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agosymlinks: update comment on threaded_check_leading_path()
Matheus Tavares [Thu, 18 Mar 2021 18:43:46 +0000 (15:43 -0300)] 
symlinks: update comment on threaded_check_leading_path()

Since 1d718a5108 ("do not overwrite untracked symlinks", 2011-02-20),
the comment on top of threaded_check_leading_path() is outdated and no
longer reflects the behavior of this function. Let's updated it to avoid
confusions. While we are here, also remove some duplicated comments to
avoid similar maintenance problems.

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agofsmonitor: do not forget to release the token in `discard_index()`
Johannes Schindelin [Wed, 17 Mar 2021 15:30:49 +0000 (15:30 +0000)] 
fsmonitor: do not forget to release the token in `discard_index()`

In 56c6910028a (fsmonitor: change last update timestamp on the
index_state to opaque token, 2020-01-07), we forgot to adjust
`discard_index()` to release the "last-update" token: it is no longer a
64-bit number, but a free-form string that has been allocated.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agofsmonitor: fix memory corruption in some corner cases
Johannes Schindelin [Wed, 17 Mar 2021 15:30:48 +0000 (15:30 +0000)] 
fsmonitor: fix memory corruption in some corner cases

In 56c6910028a (fsmonitor: change last update timestamp on the
index_state to opaque token, 2020-01-07), we forgot to adjust the part
of `unpack_trees()` that copies the FSMonitor "last-update" information
that we copy from the source index to the result index since 679f2f9fdd2
(unpack-trees: skip stat on fsmonitor-valid files, 2019-11-20).

Since the "last-update" information is no longer a 64-bit number, but a
free-form string that has been allocated, we need to duplicate it rather
than just copying it.

This is important because there _are_ cases when `unpack_trees()` will
perform a oneway merge that implicitly calls `refresh_fsmonitor()`
(which will allocate that "last-update" token). This happens _after_
that token was copied into the result index. However, we _then_ call
`check_updates()` on that index, which will _also_ call
`refresh_fsmonitor()`, accessing the "last-update" string, which by now
would be released already.

In the instance that lead to this patch, this caused a segmentation
fault during a lengthy, complicated rebase involving the todo command
`reset` that (crucially) had to updated many files. Unfortunately, it
seems very hard to trigger that crash, therefore this patch is not
accompanied by a regression test.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoconfig.txt: add missing period
Kyle Meyer [Tue, 16 Mar 2021 14:40:40 +0000 (10:40 -0400)] 
config.txt: add missing period

Signed-off-by: Kyle Meyer <kyle@kyleam.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agobisect: peel annotated tags to commits
Jeff King [Tue, 16 Mar 2021 15:15:55 +0000 (11:15 -0400)] 
bisect: peel annotated tags to commits

This patch fixes a bug where git-bisect doesn't handle receiving
annotated tags as "git bisect good <tag>", etc. It's a regression in
27257bc466 (bisect--helper: reimplement `bisect_state` & `bisect_head`
shell functions in C, 2020-10-15).

The original shell code called:

  sha=$(git rev-parse --verify "$rev^{commit}") ||
          die "$(eval_gettext "Bad rev input: \$rev")"

which will peel the input to a commit (or complain if that's not
possible). But the C code just calls get_oid(), which will yield the oid
of the tag.

The fix is to peel to a commit. The error message here is a little
non-idiomatic for Git (since it starts with a capital). I've mostly left
it, as it matches the other converted messages (like the "Bad rev input"
we print when get_oid() fails), though I did add an indication that it
was the peeling that was the problem. It might be worth taking a pass
through this converted code to modernize some of the error messages.

Note also that the test does a bare "grep" (not i18ngrep) on the
expected "X is the first bad commit" output message. This matches the
rest of the test script.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot5606: run clone branch name test with protocol v2
Jonathan Tan [Wed, 17 Mar 2021 15:42:00 +0000 (08:42 -0700)] 
t5606: run clone branch name test with protocol v2

4f37d45706 ("clone: respect remote unborn HEAD", 2021-02-05) introduces
a new feature (if the remote has an unborn HEAD, e.g. when the remote
repository is empty, use it as the name of the branch) that only works
in protocol v2, but did not ensure that one of its tests always uses
protocol v2, and thus that test would fail if
GIT_TEST_PROTOCOL_VERSION=0 (or 1) is used. Therefore, add "-c
protocol.version=2" to the appropriate test.

(The rest of the tests from that commit have "-c protocol.version=2"
already added.)

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agomem-pool: drop trailing semicolon from macro definition
René Scharfe [Sat, 13 Mar 2021 16:17:37 +0000 (17:17 +0100)] 
mem-pool: drop trailing semicolon from macro definition

Allow BLOCK_GROWTH_SIZE to be used like an integer literal by removing
the trailing semicolon from its definition.  Also wrap the expression in
parentheses, to allow it to be used with operators without leading to
unexpected results.  It doesn't matter for the current use site, but
make it follow standard macro rules anyway to avoid future surprises.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoblock-sha1: drop trailing semicolon from macro definition
René Scharfe [Sat, 13 Mar 2021 16:17:30 +0000 (17:17 +0100)] 
block-sha1: drop trailing semicolon from macro definition

23119ffb4e (block-sha1: put expanded macro parameters in parentheses,
2012-07-22) added a trailing semicolon to the definition of SHA_MIX
without explanation.  It doesn't matter with the current code, but make
sure to avoid potential surprises by removing it again.

This allows the macro to be used almost like a function: Users can
combine it with operators of their choice, but still must not pass an
expression with side-effects as a parameter, as it would be evaluated
multiple times.

Signed-off-by: René Scharfe <l.s.r@web.de>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agofsmonitor: avoid global-buffer-overflow READ when checking trivial response
Andrzej Hunt [Mon, 15 Mar 2021 16:39:23 +0000 (16:39 +0000)] 
fsmonitor: avoid global-buffer-overflow READ when checking trivial response

query_result can be be an empty strbuf (STRBUF_INIT) - in that case
trying to read 3 bytes triggers a buffer overflow read (as
query_result.buf = '\0').

Therefore we need to check query_result's length before trying to read 3
bytes.

This overflow was introduced in:
  940b94f35c (fsmonitor: log invocation of FSMonitor hook to trace2, 2021-02-03)
It was found when running the test-suite against ASAN, and can be most
easily reproduced with the following command:

make GIT_TEST_OPTS="-v" DEFAULT_TEST_TARGET="t7519-status-fsmonitor.sh" \
SANITIZE=address DEVELOPER=1 test

==2235==ERROR: AddressSanitizer: global-buffer-overflow on address 0x0000019e6e5e at pc 0x00000043745c bp 0x7fffd382c520 sp 0x7fffd382bcc8
READ of size 3 at 0x0000019e6e5e thread T0
    #0 0x43745b in MemcmpInterceptorCommon(void*, int (*)(void const*, void const*, unsigned long), void const*, void const*, unsigned long) /home/abuild/rpmbuild/BUILD/llvm-11.0.0.src/build/../projects/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:842:7
    #1 0x43786d in bcmp /home/abuild/rpmbuild/BUILD/llvm-11.0.0.src/build/../projects/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:887:10
    #2 0x80b146 in fsmonitor_is_trivial_response /home/ahunt/oss-fuzz/git/fsmonitor.c:192:10
    #3 0x80b146 in query_fsmonitor /home/ahunt/oss-fuzz/git/fsmonitor.c:175:7
    #4 0x80a749 in refresh_fsmonitor /home/ahunt/oss-fuzz/git/fsmonitor.c:267:21
    #5 0x80bad1 in tweak_fsmonitor /home/ahunt/oss-fuzz/git/fsmonitor.c:429:4
    #6 0x90f040 in read_index_from /home/ahunt/oss-fuzz/git/read-cache.c:2321:3
    #7 0x8e5d08 in repo_read_index_preload /home/ahunt/oss-fuzz/git/preload-index.c:164:15
    #8 0x52dd45 in prepare_index /home/ahunt/oss-fuzz/git/builtin/commit.c:363:6
    #9 0x52a188 in cmd_commit /home/ahunt/oss-fuzz/git/builtin/commit.c:1588:15
    #10 0x4ce77e in run_builtin /home/ahunt/oss-fuzz/git/git.c:453:11
    #11 0x4ccb18 in handle_builtin /home/ahunt/oss-fuzz/git/git.c:704:3
    #12 0x4cb01c in run_argv /home/ahunt/oss-fuzz/git/git.c:771:4
    #13 0x4cb01c in cmd_main /home/ahunt/oss-fuzz/git/git.c:902:19
    #14 0x6aca8d in main /home/ahunt/oss-fuzz/git/common-main.c:52:11
    #15 0x7fb027bf5349 in __libc_start_main (/lib64/libc.so.6+0x24349)
    #16 0x4206b9 in _start /home/abuild/rpmbuild/BUILD/glibc-2.26/csu/../sysdeps/x86_64/start.S:120

0x0000019e6e5e is located 2 bytes to the left of global variable 'strbuf_slopbuf' defined in 'strbuf.c:51:6' (0x19e6e60) of size 1
  'strbuf_slopbuf' is ascii string ''
0x0000019e6e5e is located 126 bytes to the right of global variable 'signals' defined in 'sigchain.c:11:31' (0x19e6be0) of size 512
SUMMARY: AddressSanitizer: global-buffer-overflow /home/abuild/rpmbuild/BUILD/llvm-11.0.0.src/build/../projects/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:842:7 in MemcmpInterceptorCommon(void*, int (*)(void const*, void const*, unsigned long), void const*, void const*, unsigned long)
Shadow bytes around the buggy address:
  0x000080334d70: f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9 00 00 00 00
  0x000080334d80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x000080334d90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x000080334da0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x000080334db0: 00 00 00 00 00 00 00 00 00 00 00 00 f9 f9 f9 f9
=>0x000080334dc0: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9[f9]01 f9 f9 f9
  0x000080334dd0: f9 f9 f9 f9 03 f9 f9 f9 f9 f9 f9 f9 02 f9 f9 f9
  0x000080334de0: f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9
  0x000080334df0: f9 f9 f9 f9 01 f9 f9 f9 f9 f9 f9 f9 00 00 00 00
  0x000080334e00: f9 f9 f9 f9 00 00 00 00 f9 f9 f9 f9 01 f9 f9 f9
  0x000080334e10: f9 f9 f9 f9 04 f9 f9 f9 f9 f9 f9 f9 00 f9 f9 f9
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc

Signed-off-by: Andrzej Hunt <ajrhunt@google.com>
Acked-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agococci: allow xcalloc(1, size)
Junio C Hamano [Tue, 16 Mar 2021 00:56:07 +0000 (17:56 -0700)] 
cocci: allow xcalloc(1, size)

Allocating a pre-cleared single element is quite common and it is
misleading to use CALLOC_ARRAY(); these allocations that would be
affected without this change are not allocating an array.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoxcalloc: use CALLOC_ARRAY() when applicable
Junio C Hamano [Mon, 15 Mar 2021 22:05:04 +0000 (15:05 -0700)] 
xcalloc: use CALLOC_ARRAY() when applicable

These are for codebase before Git 2.31

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agodoc/git-commit: add documentation for fixup=[amend|reword] options
Charvi Mendiratta [Mon, 15 Mar 2021 07:54:36 +0000 (13:24 +0530)] 
doc/git-commit: add documentation for fixup=[amend|reword] options

Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Mentored-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Charvi Mendiratta <charvi077@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot3437: use --fixup with options to create amend! commit
Charvi Mendiratta [Mon, 15 Mar 2021 07:54:35 +0000 (13:24 +0530)] 
t3437: use --fixup with options to create amend! commit

We taught `git commit --fixup` to create "amend!" commit. Let's also
update the tests and use it to setup the rebase tests.

Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Mentored-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Charvi Mendiratta <charvi077@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot7500: add tests for --fixup=[amend|reword] options
Charvi Mendiratta [Mon, 15 Mar 2021 07:54:34 +0000 (13:24 +0530)] 
t7500: add tests for --fixup=[amend|reword] options

Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Mentored-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Charvi Mendiratta <charvi077@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocommit: add a reword suboption to --fixup
Charvi Mendiratta [Mon, 15 Mar 2021 07:54:33 +0000 (13:24 +0530)] 
commit: add a reword suboption to --fixup

`git commit --fixup=reword:<commit>` aliases
`--fixup=amend:<commit> --only`, where it creates an empty "amend!"
commit that will reword <commit> without changing its contents when
it is rebased with `--autosquash`.

Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Mentored-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Helped-by: Junio C Hamano <gitster@pobox.com>
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Charvi Mendiratta <charvi077@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocommit: add amend suboption to --fixup to create amend! commit
Charvi Mendiratta [Mon, 15 Mar 2021 07:54:32 +0000 (13:24 +0530)] 
commit: add amend suboption to --fixup to create amend! commit

`git commit --fixup=amend:<commit>` will create an "amend!" commit.
The resulting commit message subject will be "amend! ..." where
"..." is the subject line of <commit> and the initial message
body will be <commit>'s message.

The "amend!" commit when rebased with --autosquash will fixup the
contents and replace the commit message of <commit> with the
"amend!" commit's message body.

In order to prevent rebase from creating commits with an empty
message we refuse to create an "amend!" commit if commit message
body is empty.

Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Mentored-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Helped-by: Junio C Hamano <gitster@pobox.com>
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Charvi Mendiratta <charvi077@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agosequencer: export and rename subject_length()
Charvi Mendiratta [Mon, 15 Mar 2021 07:54:31 +0000 (13:24 +0530)] 
sequencer: export and rename subject_length()

This function can be used in other parts of git. Let's move the
function to commit.c and also rename it to make the name of the
function more generic.

Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Mentored-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Charvi Mendiratta <charvi077@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoGit 2.31 v2.31.0
Junio C Hamano [Mon, 15 Mar 2021 18:51:51 +0000 (11:51 -0700)] 
Git 2.31

Signed-off-by: Junio C Hamano <gitster@pobox.com>