]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
23 months agousage.c: add a non-fatal bug() function to go with BUG()
Ævar Arnfjörð Bjarmason [Thu, 2 Jun 2022 12:25:33 +0000 (14:25 +0200)] 
usage.c: add a non-fatal bug() function to go with BUG()

Add a bug() function to use in cases where we'd like to indicate a
runtime BUG(), but would like to defer the BUG() call because we're
possibly accumulating more bug() callers to exhaustively indicate what
went wrong.

We already have this sort of facility in various parts of the
codebase, just in the form of ad-hoc re-inventions of the
functionality that this new API provides. E.g. this will be used to
replace optbug() in parse-options.c, and the 'error("BUG:[...]' we do
in a loop in builtin/receive-pack.c.

Unlike the code this replaces we'll log to trace2 with this new bug()
function (as with other usage.c functions, including BUG()), we'll
also be able to avoid calls to xstrfmt() in some cases, as the bug()
function itself accepts variadic sprintf()-like arguments.

Any caller to bug() can follow up such calls with BUG_if_bug(),
which will BUG() out (i.e. abort()) if there were any preceding calls
to bug(), callers can also decide not to call BUG_if_bug() and leave
the resulting BUG() invocation until exit() time. There are currently
no bug() API users that don't call BUG_if_bug() themselves after a
for-loop, but allowing for not calling BUG_if_bug() keeps the API
flexible. As the tests and documentation here show we'll catch missing
BUG_if_bug() invocations in our exit() wrapper.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
23 months agocommon-main.c: move non-trace2 exit() behavior out of trace2.c
Ævar Arnfjörð Bjarmason [Thu, 2 Jun 2022 12:25:32 +0000 (14:25 +0200)] 
common-main.c: move non-trace2 exit() behavior out of trace2.c

Change the exit() wrapper added in ee4512ed481 (trace2: create new
combined trace facility, 2019-02-22) so that we'll split up the trace2
logging concerns from wanting to wrap the "exit()" function itself for
other purposes.

This makes more sense structurally, as we won't seem to conflate
non-trace2 behavior with the trace2 code. I'd previously added an
explanation for this in 368b5843158 (common-main.c: call exit(), don't
return, 2021-12-07), that comment is being adjusted here.

Now the only thing we'll do if we're not using trace2 is to truncate
the "code" argument to the lowest 8 bits.

We only need to do that truncation on non-POSIX systems, but in
ee4512ed481 that "if defined(__MINGW32__)" code added in
47e3de0e796 (MinGW: truncate exit()'s argument to lowest 8 bits,
2009-07-05) was made to run everywhere. It might be good for clarify
to narrow that down by an "ifdef" again, but I'm not certain that in
the interim we haven't had some other non-POSIX systems rely the
behavior. On a POSIX system taking the lowest 8 bits is implicit, see
exit(3)[1] and wait(2)[2]. Let's leave a comment about that instead.

1. https://man7.org/linux/man-pages/man3/exit.3.html
2. https://man7.org/linux/man-pages/man2/wait.2.html

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
23 months agoSixth batch
Junio C Hamano [Wed, 1 Jun 2022 02:10:00 +0000 (19:10 -0700)] 
Sixth batch

Fast-tracking GitHub CI Windows build fixes.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
23 months agoMerge branch 'jc/http-clear-finished-pointer'
Junio C Hamano [Wed, 1 Jun 2022 02:10:35 +0000 (19:10 -0700)] 
Merge branch 'jc/http-clear-finished-pointer'

Meant to go with js/ci-gcc-12-fixes.

* jc/http-clear-finished-pointer:
  http.c: clear the 'finished' member once we are done with it

23 months agoMerge branch 'js/ci-gcc-12-fixes'
Junio C Hamano [Wed, 1 Jun 2022 02:10:35 +0000 (19:10 -0700)] 
Merge branch 'js/ci-gcc-12-fixes'

Fixes real problems noticed by gcc 12 and works around false
positives.

* js/ci-gcc-12-fixes:
  dir.c: avoid "exceeds maximum object size" error with GCC v12.x
  nedmalloc: avoid new compile error
  compat/win32/syslog: fix use-after-realloc

23 months agoFifth batch
Junio C Hamano [Tue, 31 May 2022 06:24:12 +0000 (23:24 -0700)] 
Fifth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
23 months agoMerge branch 'js/use-builtin-add-i'
Junio C Hamano [Tue, 31 May 2022 06:24:03 +0000 (23:24 -0700)] 
Merge branch 'js/use-builtin-add-i'

"git add -i" was rewritten in C some time ago and has been in
testing; the reimplementation is now exposed to general public by
default.

* js/use-builtin-add-i:
  add -i: default to the built-in implementation
  t2016: require the PERL prereq only when necessary

23 months agoMerge branch 'jc/t6424-failing-merge-preserve-local-changes'
Junio C Hamano [Tue, 31 May 2022 06:24:03 +0000 (23:24 -0700)] 
Merge branch 'jc/t6424-failing-merge-preserve-local-changes'

The tests that ensured merges stop when interfering local changes
are present did not make sure that local changes are preserved; now
they do.

* jc/t6424-failing-merge-preserve-local-changes:
  t6424: make sure a failed merge preserves local changes

23 months agoMerge branch 'cc/http-curlopt-resolve'
Junio C Hamano [Tue, 31 May 2022 06:24:02 +0000 (23:24 -0700)] 
Merge branch 'cc/http-curlopt-resolve'

With the new http.curloptResolve configuration, the CURLOPT_RESOLVE
mechanism that allows cURL based applications to use pre-resolved
IP addresses for the requests is exposed to the scripts.

* cc/http-curlopt-resolve:
  http: add custom hostname to IP address resolutions

23 months agohttp.c: clear the 'finished' member once we are done with it
Junio C Hamano [Thu, 26 May 2022 19:37:31 +0000 (12:37 -0700)] 
http.c: clear the 'finished' member once we are done with it

In http.c, the run_active_slot() function allows the given "slot" to
make progress by calling step_active_slots() in a loop repeatedly,
and the loop is not left until the request held in the slot
completes.

Ages ago, we used to use the slot->in_use member to get out of the
loop, which misbehaved when the request in "slot" completes (at
which time, the result of the request is copied away from the slot,
and the in_use member is cleared, making the slot ready to be
reused), and the "slot" gets reused to service a different request
(at which time, the "slot" becomes in_use again, even though it is
for a different request).  The loop terminating condition mistakenly
thought that the original request has yet to be completed.

Today's code, after baa7b67d (HTTP slot reuse fixes, 2006-03-10)
fixed this issue, uses a separate "slot->finished" member that is
set in run_active_slot() to point to an on-stack variable, and the
code that completes the request in finish_active_slot() clears the
on-stack variable via the pointer to signal that the particular
request held by the slot has completed.  It also clears the in_use
member (as before that fix), so that the slot itself can safely be
reused for an unrelated request.

One thing that is not quite clean in this arrangement is that,
unless the slot gets reused, at which point the finished member is
reset to NULL, the member keeps the value of &finished, which
becomes a dangling pointer into the stack when run_active_slot()
returns.  Clear the finished member before the control leaves the
function, which has a side effect of unconfusing compilers like
recent GCC 12 that is over-eager to warn against such an assignment.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
23 months agoFourth batch
Junio C Hamano [Thu, 26 May 2022 21:51:40 +0000 (14:51 -0700)] 
Fourth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
23 months agoMerge branch 'ac/remote-v-with-object-list-filters'
Junio C Hamano [Thu, 26 May 2022 21:51:32 +0000 (14:51 -0700)] 
Merge branch 'ac/remote-v-with-object-list-filters'

"git remote -v" now shows the list-objects-filter used during
fetching from the remote, if available.

* ac/remote-v-with-object-list-filters:
  builtin/remote.c: teach `-v` to list filters for promisor remotes

23 months agoMerge branch 'cb/path-owner-check-with-sudo'
Junio C Hamano [Thu, 26 May 2022 21:51:32 +0000 (14:51 -0700)] 
Merge branch 'cb/path-owner-check-with-sudo'

With a recent update to refuse access to repositories of other
people by default, "sudo make install" and "sudo git describe"
stopped working.  This series intends to loosen it while keeping
the safety.

* cb/path-owner-check-with-sudo:
  t0034: add negative tests and allow git init to mostly work under sudo
  git-compat-util: avoid failing dir ownership checks if running privileged
  t: regression git needs safe.directory when using sudo

23 months agoMerge branch 'cg/tools-for-git-doc'
Junio C Hamano [Thu, 26 May 2022 21:51:31 +0000 (14:51 -0700)] 
Merge branch 'cg/tools-for-git-doc'

A new doc that lists tips for tools to work with Git's codebase.

* cg/tools-for-git-doc:
  Documentation/ToolsForGit.txt: Tools for developing Git

23 months agoMerge branch 'tk/simple-autosetupmerge'
Junio C Hamano [Thu, 26 May 2022 21:51:30 +0000 (14:51 -0700)] 
Merge branch 'tk/simple-autosetupmerge'

"git -c branch.autosetupmerge=simple branch $A $B" will set the $B
as $A's upstream only when $A and $B shares the same name, and "git
-c push.default=simple" on branch $A would push to update the
branch $A at the remote $B came from.  Also more places use the
sole remote, if exists, before defaulting to 'origin'.

* tk/simple-autosetupmerge:
  push: new config option "push.autoSetupRemote" supports "simple" push
  push: default to single remote even when not named origin
  branch: new autosetupmerge option 'simple' for matching branches

23 months agoThird batch
Junio C Hamano [Wed, 25 May 2022 23:24:26 +0000 (16:24 -0700)] 
Third batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
23 months agoMerge branch 'tb/receive-pack-code-cleanup'
Junio C Hamano [Wed, 25 May 2022 23:42:49 +0000 (16:42 -0700)] 
Merge branch 'tb/receive-pack-code-cleanup'

Code clean-up.

* tb/receive-pack-code-cleanup:
  builtin/receive-pack.c: remove redundant 'if'

23 months agoMerge branch 'jc/avoid-redundant-submodule-fetch'
Junio C Hamano [Wed, 25 May 2022 23:42:49 +0000 (16:42 -0700)] 
Merge branch 'jc/avoid-redundant-submodule-fetch'

"git fetch --recurse-submodules" from multiple remotes (either from
a remote group, or "--all") used to make one extra "git fetch" in
the submodules, which has been corrected.

* jc/avoid-redundant-submodule-fetch:
  fetch: do not run a redundant fetch from submodule

23 months agoMerge branch 'os/fetch-check-not-current-branch'
Junio C Hamano [Wed, 25 May 2022 23:42:48 +0000 (16:42 -0700)] 
Merge branch 'os/fetch-check-not-current-branch'

The way "git fetch" without "--update-head-ok" ensures that HEAD in
no worktree points at any ref being updated was too wasteful, which
has been optimized a bit.

* os/fetch-check-not-current-branch:
  fetch: limit shared symref check only for local branches

23 months agoMerge branch 'pb/ggg-in-mfc-doc'
Junio C Hamano [Wed, 25 May 2022 23:42:48 +0000 (16:42 -0700)] 
Merge branch 'pb/ggg-in-mfc-doc'

Documentation update.

* pb/ggg-in-mfc-doc:
  MyFirstContribution: drop PR description for GGG single-patch contributions
  MyFirstContribution: reference "The cover letter" in GitGitGadget section
  MyFirstContribution: reference "The cover letter" in "Preparing Email"
  MyFirstContribution: add standalone section on cover letter
  MyFirstContribution: add "Anatomy of a Patch Series" section

23 months agoMerge branch 'jt/fetch-peek-optional-section'
Junio C Hamano [Wed, 25 May 2022 23:42:48 +0000 (16:42 -0700)] 
Merge branch 'jt/fetch-peek-optional-section'

"git fetch" unnecessarily failed when an unexpected optional
section appeared in the output, which has been corrected.

* jt/fetch-peek-optional-section:
  fetch-pack: make unexpected peek result non-fatal

23 months agoMerge branch 'jc/show-branch-g-current'
Junio C Hamano [Wed, 25 May 2022 23:42:47 +0000 (16:42 -0700)] 
Merge branch 'jc/show-branch-g-current'

The "--current" option of "git show-branch" should have been made
incompatible with the "--reflog" mode, but this was not enforced,
which has been corrected.

* jc/show-branch-g-current:
  show-branch: -g and --current are incompatible

23 months agoMerge branch 'ep/coverage-report-wants-test-to-have-run'
Junio C Hamano [Wed, 25 May 2022 23:42:47 +0000 (16:42 -0700)] 
Merge branch 'ep/coverage-report-wants-test-to-have-run'

"make coverage-report" without first running "make coverage" did
not produce any meaningful result, which has been corrected.

* ep/coverage-report-wants-test-to-have-run:
  Makefile: add a prerequisite to the coverage-report target

2 years agodir.c: avoid "exceeds maximum object size" error with GCC v12.x
Johannes Schindelin [Tue, 24 May 2022 00:23:06 +0000 (00:23 +0000)] 
dir.c: avoid "exceeds maximum object size" error with GCC v12.x

Technically, the pointer difference `end - start` _could_ be negative,
and when cast to an (unsigned) `size_t` that would cause problems. In
this instance, the symptom is:

dir.c: In function 'git_url_basename':
dir.c:3087:13: error: 'memchr' specified bound [9223372036854775808, 0]
       exceeds maximum object size 9223372036854775807
       [-Werror=stringop-overread]
    CC ewah/bitmap.o
 3087 |         if (memchr(start, '/', end - start) == NULL
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

While it is a bit far-fetched to think that `end` (which is defined as
`repo + strlen(repo)`) and `start` (which starts at `repo` and never
steps beyond the NUL terminator) could result in such a negative
difference, GCC has no way of knowing that.

See also https://gcc.gnu.org/bugzilla//show_bug.cgi?id=85783.

Let's just add a safety check, primarily for GCC's benefit.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agonedmalloc: avoid new compile error
Johannes Schindelin [Tue, 24 May 2022 00:23:04 +0000 (00:23 +0000)] 
nedmalloc: avoid new compile error

GCC v12.x complains thusly:

compat/nedmalloc/nedmalloc.c: In function 'DestroyCaches':
compat/nedmalloc/nedmalloc.c:326:12: error: the comparison will always
                              evaluate as 'true' for the address of 'caches'
                              will never be NULL [-Werror=address]
  326 |         if(p->caches)
      |            ^
compat/nedmalloc/nedmalloc.c:196:22: note: 'caches' declared here
  196 |         threadcache *caches[THREADCACHEMAXCACHES];
      |                      ^~~~~~

... and it is correct, of course.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agocompat/win32/syslog: fix use-after-realloc
Johannes Schindelin [Tue, 24 May 2022 00:23:03 +0000 (00:23 +0000)] 
compat/win32/syslog: fix use-after-realloc

Git for Windows' SDK recently upgraded to GCC v12.x which points out
that the `pos` variable might be used even after the corresponding
memory was `realloc()`ed and therefore potentially no longer valid.

Since a subset of this SDK is used in Git's CI/PR builds, we need to fix
this to continue to be able to benefit from the CI/PR runs.

Note: This bug has been with us since 2a6b149c64f6 (mingw: avoid using
strbuf in syslog, 2011-10-06), and while it looks tempting to replace
the hand-rolled string manipulation with a `strbuf`-based one, that
commit's message explains why we cannot do that: The `syslog()` function
is called as part of the function in `daemon.c` which is set as the
`die()` routine, and since `strbuf_grow()` can call that function if it
runs out of memory, this would cause a nasty infinite loop that we do
not want to re-introduce.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoSecond batch
Junio C Hamano [Mon, 23 May 2022 21:39:45 +0000 (14:39 -0700)] 
Second batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMerge branch 'jc/archive-add-file-normalize-mode'
Junio C Hamano [Mon, 23 May 2022 21:39:54 +0000 (14:39 -0700)] 
Merge branch 'jc/archive-add-file-normalize-mode'

"git archive --add-file=<path>" picked up the raw permission bits
from the path and propagated to zip output in some cases, without
normalization, which has been corrected (tar output did not have
this issue).

* jc/archive-add-file-normalize-mode:
  archive: do not let on-disk mode leak to zip archives

2 years agoMerge branch 'ab/valgrind-fixes'
Junio C Hamano [Mon, 23 May 2022 21:39:54 +0000 (14:39 -0700)] 
Merge branch 'ab/valgrind-fixes'

A bit of test framework fixes with a few fixes to issues found by
valgrind.

* ab/valgrind-fixes:
  commit-graph.c: don't assume that stat() succeeds
  object-file: fix a unpack_loose_header() regression in 3b6a8db3b03
  log test: skip a failing mkstemp() test under valgrind
  tests: using custom GIT_EXEC_PATH breaks --valgrind tests

2 years agoMerge branch 'ab/commit-plug-leaks'
Junio C Hamano [Mon, 23 May 2022 21:39:54 +0000 (14:39 -0700)] 
Merge branch 'ab/commit-plug-leaks'

Leakfix in the top-level called-once function.

* ab/commit-plug-leaks:
  commit: fix "author_ident" leak

2 years agoFirst batch for 2.37
Junio C Hamano [Fri, 20 May 2022 22:23:57 +0000 (15:23 -0700)] 
First batch for 2.37

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMerge branch 'cb/ci-make-p4-optional'
Junio C Hamano [Fri, 20 May 2022 22:27:00 +0000 (15:27 -0700)] 
Merge branch 'cb/ci-make-p4-optional'

macOS CI jobs have been occasionally flaky due to tentative version
skew between perforce and the homebrew packager.  Instead of
failing the whole CI job, just let it skip the p4 tests when this
happens.

* cb/ci-make-p4-optional:
  ci: use https, not http to download binaries from perforce.com
  ci: reintroduce prevention from perforce being quarantined in macOS
  ci: avoid brew for installing perforce
  ci: make failure to find perforce more user friendly

2 years agoMerge branch 'tk/p4-metadata-coding-strategies'
Junio C Hamano [Fri, 20 May 2022 22:27:00 +0000 (15:27 -0700)] 
Merge branch 'tk/p4-metadata-coding-strategies'

"git p4" updates.

* tk/p4-metadata-coding-strategies:
  git-p4: improve encoding handling to support inconsistent encodings

2 years agoMerge branch 'ep/equals-null-cocci'
Junio C Hamano [Fri, 20 May 2022 22:26:59 +0000 (15:26 -0700)] 
Merge branch 'ep/equals-null-cocci'

Merges up ep/maint-equals-null-cocci to the current codebase.

* ep/equals-null-cocci:
  tree-wide: apply equals-null.cocci

2 years agoMerge branch 'ep/maint-equals-null-cocci'
Junio C Hamano [Fri, 20 May 2022 22:26:59 +0000 (15:26 -0700)] 
Merge branch 'ep/maint-equals-null-cocci'

Introduce and apply coccinelle rule to discourage an explicit
comparison between a pointer and NULL, and applies the clean-up to
the maintenance track.

* ep/maint-equals-null-cocci:
  tree-wide: apply equals-null.cocci
  tree-wide: apply equals-null.cocci
  contrib/coccinnelle: add equals-null.cocci

2 years agoMerge branch 'ds/sparse-colon-path'
Junio C Hamano [Fri, 20 May 2022 22:26:58 +0000 (15:26 -0700)] 
Merge branch 'ds/sparse-colon-path'

"git show :<path>" learned to work better with the sparse-index
feature.

* ds/sparse-colon-path:
  rev-parse: integrate with sparse index
  object-name: diagnose trees in index properly
  object-name: reject trees found in the index
  show: integrate with the sparse index
  t1092: add compatibility tests for 'git show'

2 years agoMerge branch 'vd/sparse-stash'
Junio C Hamano [Fri, 20 May 2022 22:26:58 +0000 (15:26 -0700)] 
Merge branch 'vd/sparse-stash'

Teach "git stash" to work better with sparse index entries.

* vd/sparse-stash:
  unpack-trees: preserve index sparsity
  stash: apply stash using 'merge_ort_nonrecursive()'
  read-cache: set sparsity when index is new
  sparse-index: expose 'is_sparse_index_allowed()'
  stash: integrate with sparse index
  stash: expand sparse-checkout compatibility testing

2 years agoMerge branch 'cd/bisect-messages-from-pre-flight-states'
Junio C Hamano [Fri, 20 May 2022 22:26:58 +0000 (15:26 -0700)] 
Merge branch 'cd/bisect-messages-from-pre-flight-states'

"git bisect" was too silent before it is ready to start computing
the actual bisection, which has been corrected.

* cd/bisect-messages-from-pre-flight-states:
  bisect: output bisect setup status in bisect log
  bisect: output state before we are ready to compute bisection

2 years agoMerge branch 'jc/update-ozlabs-url'
Junio C Hamano [Fri, 20 May 2022 22:26:58 +0000 (15:26 -0700)] 
Merge branch 'jc/update-ozlabs-url'

* jc/update-ozlabs-url:
  SubmittingPatches: use more stable git.ozlabs.org URL

2 years agoMerge branch 'gc/pull-recurse-submodules'
Junio C Hamano [Fri, 20 May 2022 22:26:57 +0000 (15:26 -0700)] 
Merge branch 'gc/pull-recurse-submodules'

"git pull" without "--recurse-submodules=<arg>" made
submodule.recurse take precedence over fetch.recurseSubmodules by
mistake, which has been corrected.

* gc/pull-recurse-submodules:
  pull: do not let submodule.recurse override fetch.recurseSubmodules

2 years agoMerge branch 'mg/detect-compiler-in-c-locale'
Junio C Hamano [Fri, 20 May 2022 22:26:56 +0000 (15:26 -0700)] 
Merge branch 'mg/detect-compiler-in-c-locale'

Build procedure fixup.

* mg/detect-compiler-in-c-locale:
  detect-compiler: make detection independent of locale

2 years agoMerge branch 'js/trace2-doc-fixes'
Junio C Hamano [Fri, 20 May 2022 22:26:56 +0000 (15:26 -0700)] 
Merge branch 'js/trace2-doc-fixes'

Trace2 documentation updates.

* js/trace2-doc-fixes:
  trace2 docs: add missing full stop
  trace2 docs: clarify what `varargs` is all about
  trace2 docs: fix a JSON formatted example
  trace2 docs: surround more terms in backticks
  trace2 docs: "printf" is not an English word
  trace2 docs: a couple of grammar fixes

2 years agoMerge branch 'mv/log-since-as-filter'
Junio C Hamano [Fri, 20 May 2022 22:26:56 +0000 (15:26 -0700)] 
Merge branch 'mv/log-since-as-filter'

"git log --since=X" will stop traversal upon seeing a commit that
is older than X, but there may be commits behind it that is younger
than X when the commit was created with a faulty clock.  A new
option is added to keep digging without stopping, and instead
filter out commits with timestamp older than X.

* mv/log-since-as-filter:
  log: "--since-as-filter" option is a non-terminating "--since" variant

2 years agoMerge branch 'rs/external-diff-tempfile'
Junio C Hamano [Fri, 20 May 2022 22:26:55 +0000 (15:26 -0700)] 
Merge branch 'rs/external-diff-tempfile'

The temporary files fed to external diff command are now generated
inside a new temporary directory under the same basename.

* rs/external-diff-tempfile:
  diff: use mks_tempfile_dt()
  tempfile: add mks_tempfile_dt()

2 years agoMerge branch 'kf/p4-multiple-remotes'
Junio C Hamano [Fri, 20 May 2022 22:26:55 +0000 (15:26 -0700)] 
Merge branch 'kf/p4-multiple-remotes'

"git p4" update.

* kf/p4-multiple-remotes:
  git-p4: fix issue with multiple perforce remotes

2 years agoMerge branch 'tk/p4-with-explicity-sync'
Junio C Hamano [Fri, 20 May 2022 22:26:55 +0000 (15:26 -0700)] 
Merge branch 'tk/p4-with-explicity-sync'

"git p4" update.

* tk/p4-with-explicity-sync:
  git-p4: support explicit sync of arbitrary existing git-p4 refs

2 years agoMerge branch 'tk/p4-utf8-bom'
Junio C Hamano [Fri, 20 May 2022 22:26:54 +0000 (15:26 -0700)] 
Merge branch 'tk/p4-utf8-bom'

"git p4" update.

* tk/p4-utf8-bom:
  git-p4: preserve utf8 BOM when importing from p4 to git

2 years agoMerge branch 'cg/vscode-with-gdb'
Junio C Hamano [Fri, 20 May 2022 22:26:54 +0000 (15:26 -0700)] 
Merge branch 'cg/vscode-with-gdb'

VS code configuration updates.

* cg/vscode-with-gdb:
  contrib/vscode/: debugging with VS Code and gdb

2 years agoMerge branch 'sa/t1011-use-helpers'
Junio C Hamano [Fri, 20 May 2022 22:26:54 +0000 (15:26 -0700)] 
Merge branch 'sa/t1011-use-helpers'

A GSoC practice.

* sa/t1011-use-helpers:
  t1011: replace test -f with test_path_is_file

2 years agoMerge branch 'km/t3501-use-test-helpers'
Junio C Hamano [Fri, 20 May 2022 22:26:54 +0000 (15:26 -0700)] 
Merge branch 'km/t3501-use-test-helpers'

Test script updates.

* km/t3501-use-test-helpers:
  t3501: remove test -f and stop ignoring git <cmd> exit code

2 years agoMerge branch 'pb/submodule-recurse-mode-enum'
Junio C Hamano [Fri, 20 May 2022 22:26:53 +0000 (15:26 -0700)] 
Merge branch 'pb/submodule-recurse-mode-enum'

Small code clean-up.

* pb/submodule-recurse-mode-enum:
  submodule.h: use a named enum for RECURSE_SUBMODULES_*

2 years agoMerge branch 'ah/convert-warning-message'
Junio C Hamano [Fri, 20 May 2022 22:26:53 +0000 (15:26 -0700)] 
Merge branch 'ah/convert-warning-message'

Update a few end-user facing messages around eol conversion.

* ah/convert-warning-message:
  convert: clarify line ending conversion warning

2 years agoMerge branch 'gf/unused-includes'
Junio C Hamano [Fri, 20 May 2022 22:26:53 +0000 (15:26 -0700)] 
Merge branch 'gf/unused-includes'

Remove unused includes.

* gf/unused-includes:
  apply.c: remove unnecessary include
  serve.c: remove unnecessary include

2 years agoMerge branch 'gf/shorthand-version-and-help'
Junio C Hamano [Fri, 20 May 2022 22:26:52 +0000 (15:26 -0700)] 
Merge branch 'gf/shorthand-version-and-help'

"git -v" and "git -h" are now understood as "git --version" and
"git --help".

* gf/shorthand-version-and-help:
  cli: add -v and -h shorthands

2 years agoMerge branch 'rs/t7812-pcre2-ws-bug-test'
Junio C Hamano [Fri, 20 May 2022 22:26:52 +0000 (15:26 -0700)] 
Merge branch 'rs/t7812-pcre2-ws-bug-test'

A test to ensure workaround for an earlier pcre2 bug does work.

* rs/t7812-pcre2-ws-bug-test:
  t7812: test PCRE2 whitespace bug

2 years agoMerge branch 'ds/do-not-call-bug-on-bad-refs'
Junio C Hamano [Fri, 20 May 2022 22:26:52 +0000 (15:26 -0700)] 
Merge branch 'ds/do-not-call-bug-on-bad-refs'

Code clean-up.

* ds/do-not-call-bug-on-bad-refs:
  clone: die() instead of BUG() on bad refs

2 years agoMerge branch 'sg/safe-directory-tests-and-docs'
Junio C Hamano [Fri, 20 May 2022 22:26:52 +0000 (15:26 -0700)] 
Merge branch 'sg/safe-directory-tests-and-docs'

New tests for the safe.directory mechanism.

* sg/safe-directory-tests-and-docs:
  safe.directory: document and check that it's ignored in the environment
  t0033-safe-directory: check when 'safe.directory' is ignored
  t0033-safe-directory: check the error message without matching the trash dir

2 years agot6424: make sure a failed merge preserves local changes
Junio C Hamano [Thu, 19 May 2022 18:59:53 +0000 (11:59 -0700)] 
t6424: make sure a failed merge preserves local changes

We do make sure that an attempt to merge with various forms of local
changes will "fail", but the point of stopping the merge is so that
we refrain from discarding uncommitted local changes that could be
precious.  Add a few more checks for each case to make sure the
local changes are left intact.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agobuiltin/receive-pack.c: remove redundant 'if'
Taylor Blau [Wed, 18 May 2022 20:26:02 +0000 (16:26 -0400)] 
builtin/receive-pack.c: remove redundant 'if'

In c7c4bdeccf (run-command API: remove "env" member, always use
"env_array", 2021-11-25), there was a push to replace

    cld.env = env->v;

with

    strvec_pushv(&cld.env_array, env->v);

The conversion in c7c4bdeccf was mostly plug-and-play, with the snag
that some instances of strvec_pushv() became guarded with a NULL check
to ensure that the second argument was non-NULL.

This conversion was slightly over-eager to add a conditional in
builtin/receive-pack.c::unpack(), since we know at the point that we
add the result of `tmp_objdir_env()` into the child process's
environment, that `tmp_objdir` is non-NULL.

This follows from the conditional just before our strvec_pushv() call
(which returns from the function if `tmp_objdir` was NULL), as well as
the call to tmp_objdir_add_as_alternate() just below, which relies on
its argument (`tmp_objdir`) being non-NULL.

In the meantime, this extra conditional isn't hurting anything. But it
is redundant and thus unnecessarily confusing. So let's remove it.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agofetch: do not run a redundant fetch from submodule
Junio C Hamano [Mon, 16 May 2022 23:53:40 +0000 (16:53 -0700)] 
fetch: do not run a redundant fetch from submodule

When 7dce19d3 (fetch/pull: Add the --recurse-submodules option,
2010-11-12) introduced the "--recurse-submodule" option, the
approach taken was to perform fetches in submodules only once, after
all the main fetching (it may usually be a fetch from a single
remote, but it could be fetching from a group of remotes using
fetch_multiple()) succeeded.  Later we added "--all" to fetch from
all defined remotes, which complicated things even more.

If your project has a submodule, and you try to run "git fetch
--recurse-submodule --all", you'd see a fetch for the top-level,
which invokes another fetch for the submodule, followed by another
fetch for the same submodule.  All but the last fetch for the
submodule come from a "git fetch --recurse-submodules" subprocess
that is spawned via the fetch_multiple() interface for the remotes,
and the last fetch comes from the code at the end.

Because recursive fetching from submodules is done in each fetch for
the top-level in fetch_multiple(), the last fetch in the submodule
is redundant.  It only matters when fetch_one() interacts with a
single remote at the top-level.

While we are at it, there is one optimization that exists in dealing
with a group of remote, but is missing when "--all" is used.  In the
former, when the group turns out to be a group of one, instead of
spawning "git fetch" as a subprocess via the fetch_multiple()
interface, we use the normal fetch_one() code path.  Do the same
when handing "--all", if it turns out that we have only one remote
defined.

Reviewed-by: Glen Choo <chooglen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agofetch: limit shared symref check only for local branches
Orgad Shaneh [Mon, 16 May 2022 08:41:41 +0000 (08:41 +0000)] 
fetch: limit shared symref check only for local branches

This check was introduced in 8ee5d73137f (Fix fetch/pull when run without
--update-head-ok, 2008-10-13) in order to protect against replacing the ref
of the active branch by mistake, for example by running git fetch origin
master:master.

It was later extended in 8bc1f39f411 (fetch: protect branches checked out
in all worktrees, 2021-12-01) to scan all worktrees.

This operation is very expensive (takes about 30s in my repository) when
there are many tags or branches, and it is executed on every fetch, even if
no local heads are updated at all.

Limit it to protect only refs/heads/* to improve fetch performance.

Signed-off-by: Orgad Shaneh <orgads@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agohttp: add custom hostname to IP address resolutions
Christian Couder [Mon, 16 May 2022 08:38:51 +0000 (10:38 +0200)] 
http: add custom hostname to IP address resolutions

Libcurl has a CURLOPT_RESOLVE easy option that allows
the result of hostname resolution in the following
format to be passed:

[+]HOST:PORT:ADDRESS[,ADDRESS]

This way, redirects and everything operating against the
HOST+PORT will use the provided ADDRESS(s).

The following format is also allowed to stop using
hostname resolutions that have already been passed:

-HOST:PORT

See https://curl.se/libcurl/c/CURLOPT_RESOLVE.html for
more details.

Let's add a corresponding "http.curloptResolve" config
option that takes advantage of CURLOPT_RESOLVE.

Each value configured for the "http.curloptResolve" key
is passed "as is" to libcurl through CURLOPT_RESOLVE, so
it should be in one of the above 2 formats. This keeps
the implementation simple and makes us consistent with
libcurl's CURLOPT_RESOLVE, and with curl's corresponding
`--resolve` command line option.

The implementation uses CURLOPT_RESOLVE only in
get_active_slot() which is called by all the HTTP
request sending functions.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agofetch-pack: make unexpected peek result non-fatal
Jonathan Tan [Mon, 16 May 2022 11:02:20 +0000 (04:02 -0700)] 
fetch-pack: make unexpected peek result non-fatal

When a Git server responds to a fetch request, it may send optional
sections before the packfile section. To handle this, the Git client
calls packet_reader_peek() (see process_section_header()) in order to
see what's next without consuming the line.

However, as implemented, Git errors out whenever what's peeked is not an
ordinary line. This is not only unexpected (here, we only need to know
whether the upcoming line is the section header we want) but causes
errors to include the name of a section header that is irrelevant to the
cause of the error. For example, at $DAYJOB, we have seen "fatal: error
reading section header 'shallow-info'" error messages when none of the
repositories involved are shallow.

Therefore, fix this so that the peek returns 1 if the upcoming line is
the wanted section header and nothing else. Because of this change,
reader->line may now be NULL later in the function, so update the error
message printing code accordingly.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agot0034: add negative tests and allow git init to mostly work under sudo
Carlo Marcelo Arenas Belón [Fri, 13 May 2022 01:00:19 +0000 (18:00 -0700)] 
t0034: add negative tests and allow git init to mostly work under sudo

Add a support library that provides one function that can be used
to run a "scriplet" of commands through sudo and that helps invoking
sudo in the slightly awkward way that is required to ensure it doesn't
block the call (if shell was allowed as tested in the prerequisite)
and it doesn't run the command through a different shell than the one
we intended.

Add additional negative tests as suggested by Junio and that use a
new workspace that is owned by root.

Document a regression that was introduced by previous commits where
root won't be able anymore to access directories they own unless
SUDO_UID is removed from their environment.

The tests document additional ways that this new restriction could
be worked around and the documentation explains why it might be instead
considered a feature, but a "fix" is planned for a future change.

Helped-by: Junio C Hamano <gitster@pobox.com>
Helped-by: Phillip Wood <phillip.wood123@gmail.com>
Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agogit-compat-util: avoid failing dir ownership checks if running privileged
Carlo Marcelo Arenas Belón [Fri, 13 May 2022 01:00:18 +0000 (18:00 -0700)] 
git-compat-util: avoid failing dir ownership checks if running privileged

bdc77d1d685 (Add a function to determine whether a path is owned by the
current user, 2022-03-02) checks for the effective uid of the running
process using geteuid() but didn't account for cases where that user was
root (because git was invoked through sudo or a compatible tool) and the
original uid that repository trusted for its config was no longer known,
therefore failing the following otherwise safe call:

  guy@renard ~/Software/uncrustify $ sudo git describe --always --dirty
  [sudo] password for guy:
  fatal: unsafe repository ('/home/guy/Software/uncrustify' is owned by someone else)

Attempt to detect those cases by using the environment variables that
those tools create to keep track of the original user id, and do the
ownership check using that instead.

This assumes the environment the user is running on after going
privileged can't be tampered with, and also adds code to restrict that
the new behavior only applies if running as root, therefore keeping the
most common case, which runs unprivileged, from changing, but because of
that, it will miss cases where sudo (or an equivalent) was used to change
to another unprivileged user or where the equivalent tool used to raise
privileges didn't track the original id in a sudo compatible way.

Because of compatibility with sudo, the code assumes that uid_t is an
unsigned integer type (which is not required by the standard) but is used
that way in their codebase to generate SUDO_UID.  In systems where uid_t
is signed, sudo might be also patched to NOT be unsigned and that might
be able to trigger an edge case and a bug (as described in the code), but
it is considered unlikely to happen and even if it does, the code would
just mostly fail safely, so there was no attempt either to detect it or
prevent it by the code, which is something that might change in the future,
based on expected user feedback.

Reported-by: Guy Maurel <guy.j@maurel.de>
Helped-by: SZEDER Gábor <szeder.dev@gmail.com>
Helped-by: Randall Becker <rsbecker@nexbridge.com>
Helped-by: Phillip Wood <phillip.wood123@gmail.com>
Suggested-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agot: regression git needs safe.directory when using sudo
Carlo Marcelo Arenas Belón [Fri, 13 May 2022 01:00:17 +0000 (18:00 -0700)] 
t: regression git needs safe.directory when using sudo

Originally reported after release of v2.35.2 (and other maint branches)
for CVE-2022-24765 and blocking otherwise harmless commands that were
done using sudo in a repository that was owned by the user.

Add a new test script with very basic support to allow running git
commands through sudo, so a reproduction could be implemented and that
uses only `git status` as a proxy of the issue reported.

Note that because of the way sudo interacts with the system, a much
more complete integration with the test framework will require a lot
more work and that was therefore intentionally punted for now.

The current implementation requires the execution of a special cleanup
function which should always be kept as the last "test" or otherwise
the standard cleanup functions will fail because they can't remove
the root owned directories that are used.  This also means that if
failures are found while running, the specifics of the failure might
not be kept for further debugging and if the test was interrupted, it
will be necessary to clean the working directory manually before
restarting by running:

  $ sudo rm -rf trash\ directory.t0034-root-safe-directory/

The test file also uses at least one initial "setup" test that creates
a parallel execution directory under the "root" sub directory, which
should be used as top level directory for all repositories that are
used in this test file.  Unlike all other tests the repository provided
by the test framework should go unused.

Special care should be taken when invoking commands through sudo, since
the environment is otherwise independent from what the test framework
setup and might have changed the values for HOME, SHELL and dropped
several relevant environment variables for your test.  Indeed `git status`
was used as a proxy because it doesn't even require commits in the
repository to work and usually doesn't require much from the environment
to run, but a future patch will add calls to `git init` and that will
fail to honor the default branch name, unless that setting is NOT
provided through an environment variable (which means even a CI run
could fail that test if enabled incorrectly).

A new SUDO prerequisite is provided that does some sanity checking
to make sure the sudo command that will be used allows for passwordless
execution as root without restrictions and doesn't mess with git's
execution path.  This matches what is provided by the macOS agents that
are used as part of GitHub actions and probably nowhere else.

Most of those characteristics make this test mostly only suitable for
CI, but it might be executed locally if special care is taken to provide
for all of them in the local configuration and maybe making use of the
sudo credential cache by first invoking sudo, entering your password if
needed, and then invoking the test with:

  $ GIT_TEST_ALLOW_SUDO=YES ./t0034-root-safe-directory.sh

If it fails to run, then it means your local setup wouldn't work for the
test because of the configuration sudo has or other system settings, and
things that might help are to comment out sudo's secure_path config, and
make sure that the account you are using has no restrictions on the
commands it can run through sudo, just like is provided for the user in
the CI.

For example (assuming a username of marta for you) something probably
similar to the following entry in your /etc/sudoers (or equivalent) file:

  marta ALL=(ALL:ALL) NOPASSWD: ALL

Reported-by: SZEDER Gábor <szeder.dev@gmail.com>
Helped-by: Phillip Wood <phillip.wood123@gmail.com>
Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMyFirstContribution: drop PR description for GGG single-patch contributions
Philippe Blain [Thu, 12 May 2022 23:43:37 +0000 (23:43 +0000)] 
MyFirstContribution: drop PR description for GGG single-patch contributions

By default, GitHub prefills the PR description using the commit message
for single-commit PRs. This results in a duplicate commit message below
the three-dash line if the contributor does not empty out the PR
description before submitting, which adds noise for reviewers.

Add a note to that effect in MyFirstContribution.txt.

This partly addresses:
https://github.com/gitgitgadget/gitgitgadget/issues/340

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMyFirstContribution: reference "The cover letter" in GitGitGadget section
Philippe Blain [Thu, 12 May 2022 23:43:36 +0000 (23:43 +0000)] 
MyFirstContribution: reference "The cover letter" in GitGitGadget section

The "Sending Patches via GitGitGadget" section mentions that the PR
title and description will be used as the cover letter, but does not
explain what is a cover letter or what should be included in it.

Refer readers to the new "The cover letter" section added in a previous
commit.

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMyFirstContribution: reference "The cover letter" in "Preparing Email"
Philippe Blain [Thu, 12 May 2022 23:43:35 +0000 (23:43 +0000)] 
MyFirstContribution: reference "The cover letter" in "Preparing Email"

The previous commit added a standalone section on the purpose of the
cover letter, drawing inspiration from the existing content of the
"Preparing Email" section.

Adjust "Preparing Email" to reference "The cover letter", to avoid
content duplication.

Also, use the imperative mode for the cover letter subject, as is done
in "The cover letter".

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMyFirstContribution: add standalone section on cover letter
Philippe Blain [Thu, 12 May 2022 23:43:34 +0000 (23:43 +0000)] 
MyFirstContribution: add standalone section on cover letter

An explanation of the purpose of the cover letter is included in the
"Sending Patches with git send-email" / "Preparing Email" section but is
missing from the "Sending Patches via GitGitGadget" section.

Add a standalone section "The cover letter" under the "Getting Started:
Anatomy of a Patch Series" header to explain what the cover letter is
used for and to draft the cover letter of the 'psuh' topic used in the
tutorial.

For now we mostly copy content from the "Sending Patches with git
send-email" section but do not adjust that section, nor the GGG section,
to reference the new section. This is done in following commits.

Also, adjust the "Preparing Email" Asciidoc anchor to avoid conflicts.

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMyFirstContribution: add "Anatomy of a Patch Series" section
Philippe Blain [Thu, 12 May 2022 23:43:33 +0000 (23:43 +0000)] 
MyFirstContribution: add "Anatomy of a Patch Series" section

Before describing how to send patches to the mailing list either with
GitGitGadget or 'git send-email', the MyFirstContribution tutorial
includes a small "Getting Ready to Share" section where the two
different methods are briefly introduced.

Use this section to also describe what a patch series looks like once
submitted, so that readers get an understanding of the end result before
diving into how to accomplish that end result.

Start by copying the "thread overview" section of a recent contribution
from the public-inbox web UI and explaining how each commit is a
separate mail, and point out the cover letter.

Subsequent commits will move the existing description of the purpose of
the cover letter from the 'git send-email' section to this "anatomy"
section.

Also, change the wording in the introductory paragraph to use
"contributions" instead of "patches", since this makes more sense when
talking about GitHub pull requests.

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agocommit: fix "author_ident" leak
Junio C Hamano [Thu, 12 May 2022 22:51:07 +0000 (15:51 -0700)] 
commit: fix "author_ident" leak

Since 4c28e4ada03 (commit: die before asking to edit the log
message, 2010-12-20), we have been "leaking" the "author_ident" when
prepare_to_commit() fails.  Instead of returning from right there,
introduce an exit status variable and jump to the clean-up label
at the end.

Instead of explicitly releasing the resource with strbuf_release(),
mark the variable with UNLEAK() at the end, together with two other
variables that are already marked as such.  If this were in a
utility function that is called number of times, but these are
different, we should explicitly release resources that grow
proportionally to the size of the problem being solved, but
cmd_commit() is like main() and there is no point in spending extra
cycles to release individual pieces of resource at the end, just
before process exit will clean everything for us for free anyway.

This fixes a leak demonstrated by e.g. "t3505-cherry-pick-empty.sh",
but unfortunately we cannot mark it or other affected tests as passing
now with "TEST_PASSES_SANITIZE_LEAK=true" as we'll need to fix many
other memory leaks before doing so.

Incidentally there are two tests that always passes the leak checker
with or without this change.  Mark them as such.

This is based on an earlier patch by Ævar, but takes a different
approach that is more maintainable.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoci: use https, not http to download binaries from perforce.com
Ævar Arnfjörð Bjarmason [Thu, 12 May 2022 22:39:40 +0000 (15:39 -0700)] 
ci: use https, not http to download binaries from perforce.com

Since 522354d70f4 (Add Travis CI support, 2015-11-27) the CI has used
http://filehost.perforce.com/perforce/ to download binaries from
filehost.perforce.com, they were then moved to this script in
657343a602e (travis-ci: move Travis CI code into dedicated scripts,
2017-09-10).

Let's use https instead for good measure. I don't think we need to
worry about the DNS or network between the GitHub CI and perforce.com
being MitM'd, but using https gives us extra validation of the payload
at least, and is one less thing to worry about when checking where
else we rely on non-TLS'd http connections.

Also, use the same download site at perforce.com for Linux and macOS
tarballs for consistency.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoci: reintroduce prevention from perforce being quarantined in macOS
Carlo Marcelo Arenas Belón [Thu, 12 May 2022 22:39:39 +0000 (15:39 -0700)] 
ci: reintroduce prevention from perforce being quarantined in macOS

5ed9fc3fc86 (ci: prevent `perforce` from being quarantined, 2020-02-27)
introduces this prevention for brew, but brew has been removed in a
previous commit, so reintroduce an equivalent option to avoid a possible
regression.

This doesn't affect github actions (as configure now) and is therefore
done silently to avoid any possible scary irrelevant messages.

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoci: avoid brew for installing perforce
Carlo Marcelo Arenas Belón [Thu, 12 May 2022 22:39:38 +0000 (15:39 -0700)] 
ci: avoid brew for installing perforce

Perfoce's cask in brew is meant[1] to be used only by humans, so replace
its use from the CI with a scripted binary download which is less likely
to fail, as it is done in Linux.

Kept the logic together so it will be less likely to break when moved
around as on the fly code changes in this area are settled, at which
point it will also feasable to ammend it to avoid some of the hardcoded
values by using similar variables to the ones Linux does.

In that same line, a POSIX sh syntax is used instead of the similar one
used in Linux in preparation for an unrelated future change that might
change the shell currently configured for it.

This change reintroduces the risk that the installed binaries might not
work because of being quarantined that was fixed with 5ed9fc3fc86 (ci:
prevent `perforce` from being quarantined, 2020-02-27) but fixing that
now was also punted for simplicity and since the affected cloud provider
is scheduled to be retired with an on the fly change, but should be
addressed if that other change is not integrated further.

The discussion on the need to keep 2 radically different versions of
the binaries to be tested with Linux vs macOS or how to upgrade to
newer versions now that brew won't do that automatically for us has
been punted for now as well.  On that line the now obsolete comment
about it in lib.sh was originally being updated by this change but
created conflicts as it is moved around by other on the fly changes,
so will be addressed independently as well.

[1] https://github.com/Homebrew/homebrew-cask/pull/122347#discussion_r856026584

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoci: make failure to find perforce more user friendly
Carlo Marcelo Arenas Belón [Thu, 12 May 2022 22:39:37 +0000 (15:39 -0700)] 
ci: make failure to find perforce more user friendly

In preparation for a future change that will make perforce installation
optional in macOS, make sure that the check for it is done without
triggering scary looking errors and add a user friendly message instead.

All other existing uses of 'type <cmd>' in our shell scripts that
check the availability of a command <cmd> send both standard output
and error stream to /dev/null to squelch "<cmd> not found" diagnostic
output, but this script left the standard error stream shown.

Redirect it just like everybody else to squelch this error message that
we fully expect to see.

Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agocommit-graph.c: don't assume that stat() succeeds
Ævar Arnfjörð Bjarmason [Thu, 12 May 2022 22:32:17 +0000 (15:32 -0700)] 
commit-graph.c: don't assume that stat() succeeds

Fix code added in 8d84097f965 (commit-graph: expire commit-graph
files, 2019-06-18) to check the return value of the stat() system
call. Not doing so caused us to use uninitialized memory in the "Bloom
generation is limited by --max-new-filters" test in
t4216-log-bloom.sh:

+ rm -f trace.event
+ pwd
+ GIT_TRACE2_EVENT=[...]/t/trash directory.t4216-log-bloom/limits/trace.event git commit-graph write --reachable --split=replace --changed-paths --max-new-filters=2
==24835== Syscall param utimensat(times[0].tv_sec) points to uninitialised byte(s)
==24835==    at 0x499E65A: __utimensat64_helper (utimensat.c:34)
==24835==    by 0x4999142: utime (utime.c:36)
==24835==    by 0x552BE0: mark_commit_graphs (commit-graph.c:2213)
==24835==    by 0x550822: write_commit_graph (commit-graph.c:2424)
==24835==    by 0x54E3A0: write_commit_graph_reachable (commit-graph.c:1681)
==24835==    by 0x4374BB: graph_write (commit-graph.c:269)
==24835==    by 0x436F7D: cmd_commit_graph (commit-graph.c:326)
==24835==    by 0x407B9A: run_builtin (git.c:465)
==24835==    by 0x406651: handle_builtin (git.c:719)
==24835==    by 0x407575: run_argv (git.c:786)
==24835==    by 0x406410: cmd_main (git.c:917)
==24835==    by 0x511F09: main (common-main.c:56)
==24835==  Address 0x1ffeffde70 is on thread 1's stack
==24835==  in frame #1, created by utime (utime.c:25)
==24835==  Uninitialised value was created by a stack allocation
==24835==    at 0x552B50: mark_commit_graphs (commit-graph.c:2201)
==24835==
[...]
error: last command exited with $?=126
not ok 137 - Bloom generation is limited by --max-new-filters

This would happen as we stat'd the non-existing
".git/objects/info/commit-graph" file. Let's fix mark_commit_graphs()
to check the stat()'s return value, and while we're at it fix another
case added in the same commit to do the same.

The caller in expire_commit_graphs() would have been less likely to
run into this, as it's operating on files it just got from readdir(),
but it could still happen due to a race with e.g. a concurrent "rm
-rf" of the commit-graph files.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoobject-file: fix a unpack_loose_header() regression in 3b6a8db3b03
Ævar Arnfjörð Bjarmason [Thu, 12 May 2022 22:32:18 +0000 (15:32 -0700)] 
object-file: fix a unpack_loose_header() regression in 3b6a8db3b03

Fix a regression in my 3b6a8db3b03 (object-file.c: use "enum" return
type for unpack_loose_header(), 2021-10-01) revealed both by running
the test suite with --valgrind, and with the amended "git fsck" test.

In practice this regression in v2.34.0 caused us to claim that we
couldn't parse the header, as opposed to not being able to unpack
it. Before the change in the C code the test_cmp added here would emit:

-error: unable to unpack header of ./objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391
+error: unable to parse header of ./objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391

I.e. we'd proceed to call parse_loose_header() on the uninitialized
"hdr" value, and it would have been very unlikely for that
uninitialized memory to be a valid git object.

The other callers of unpack_loose_header() were already checking the
enum values exhaustively. See 3b6a8db3b03 and
5848fb11acd (object-file.c: return ULHR_TOO_LONG on "header too long",
2021-10-01).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agolog test: skip a failing mkstemp() test under valgrind
Ævar Arnfjörð Bjarmason [Thu, 12 May 2022 22:32:16 +0000 (15:32 -0700)] 
log test: skip a failing mkstemp() test under valgrind

Skip a test added in f1e3df31699 (t: increase test coverage of
signature verification output, 2020-03-04) when running under
valgrind. Due to valgrind's interception of mkstemp() this test will
fail with:

+ pwd
+ TMPDIR=[...]/t/trash directory.t4202-log/bogus git log --show-signature -n1 plain-fail
==7696== VG_(mkstemp): failed to create temp file: [...]/t/trash directory.t4202-log/bogus/valgrind_proc_7696_cmdline_d545ddcf
[... 10 more similar lines omitted ..]
valgrind: Startup or configuration error:
valgrind:    Can't create client cmdline file in [...]/t/trash directory.t4202-log/bogus/valgrind_proc_7696_cmdline_6e542d1d
valgrind: Unable to start up properly.  Giving up.
error: last command exited with $?=1

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agotests: using custom GIT_EXEC_PATH breaks --valgrind tests
Ævar Arnfjörð Bjarmason [Thu, 12 May 2022 22:32:15 +0000 (15:32 -0700)] 
tests: using custom GIT_EXEC_PATH breaks --valgrind tests

Fix a regression in b7d11a0f5d2 (tests: exercise the RUNTIME_PREFIX
feature, 2021-07-24) where tests that want to set up and test a "git"
wrapper in $PATH conflicted with the t/bin/valgrind wrapper(s) doing
the same.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoarchive: do not let on-disk mode leak to zip archives
Junio C Hamano [Thu, 12 May 2022 21:31:09 +0000 (14:31 -0700)] 
archive: do not let on-disk mode leak to zip archives

When the "--add-file" option is used to add the contents from an
untracked file to the archive, the permission mode bits for these
files are sent to the archive-backend specific "write_entry()"
method as-is.  We normalize the mode bits for tracked files way
before we pass them to the write_entry() method; we should do the
same here.

This is not strictly needed for "tar" archive-backend, as it has its
own code to further clean them up, but "zip" archive-backend is not
so well prepared.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agopull: do not let submodule.recurse override fetch.recurseSubmodules
Glen Choo [Tue, 10 May 2022 19:25:47 +0000 (19:25 +0000)] 
pull: do not let submodule.recurse override fetch.recurseSubmodules

Fix a bug in "git pull" where `submodule.recurse` is preferred over
`fetch.recurseSubmodules` when performing a fetch
(Documentation/config/fetch.txt says that `fetch.recurseSubmodules`
should be preferred.). Do this by passing the value of the
"--recurse-submodules" CLI option to the underlying fetch, instead of
passing a value that combines the CLI option and config variables.

In other words, this bug occurred because builtin/pull.c is conflating
two similar-sounding, but different concepts:

- Whether "git pull" itself should care about submodules e.g. whether it
  should update the submodule worktrees after performing a merge.
- The value of "--recurse-submodules" to pass to the underlying "git
  fetch".

Thus, when `submodule.recurse` is set, the underlying "git fetch" gets
invoked with "--recurse-submodules[=value]", overriding the value of
`fetch.recurseSubmodules`.

An alternative (and more obvious) approach to fix the bug would be to
teach "git pull" to understand `fetch.recurseSubmodules`, but the
proposed solution works better because:

- We don't maintain two identical config-parsing implementions in "git
  pull" and "git fetch".
- It works better with other commands invoked by "git pull" e.g. "git
  merge" won't accidentally respect `fetch.recurseSubmodules`.

Reported-by: Huang Zou <huang.zou@schrodinger.com>
Helped-by: Philippe Blain <levraiphilippeblain@gmail.com>
Signed-off-by: Glen Choo <chooglen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agosecond 0th batch of topics from the previous cycle
Junio C Hamano [Wed, 11 May 2022 20:56:07 +0000 (13:56 -0700)] 
second 0th batch of topics from the previous cycle

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMerge branch 'rs/commit-summary-wo-break-rewrite'
Junio C Hamano [Wed, 11 May 2022 20:56:22 +0000 (13:56 -0700)] 
Merge branch 'rs/commit-summary-wo-break-rewrite'

The commit summary shown after making a commit is matched to what
is given in "git status" not to use the break-rewrite heuristics.

* rs/commit-summary-wo-break-rewrite:
  commit, sequencer: turn off break_opt for commit summary

2 years agoMerge branch 'pw/test-malloc-with-sanitize-address'
Junio C Hamano [Wed, 11 May 2022 20:56:22 +0000 (13:56 -0700)] 
Merge branch 'pw/test-malloc-with-sanitize-address'

Avoid problems from interaction between malloc_check and address
sanitizer.

* pw/test-malloc-with-sanitize-address:
  tests: make SANITIZE=address imply TEST_NO_MALLOC_CHECK

2 years agoMerge branch 'ea/rebase-code-simplify'
Junio C Hamano [Wed, 11 May 2022 20:56:22 +0000 (13:56 -0700)] 
Merge branch 'ea/rebase-code-simplify'

Code clean-up.

* ea/rebase-code-simplify:
  rebase: simplify an assignment of options.type in cmd_rebase

2 years agoMerge branch 'kt/commit-graph-plug-fp-leak-on-error'
Junio C Hamano [Wed, 11 May 2022 20:56:22 +0000 (13:56 -0700)] 
Merge branch 'kt/commit-graph-plug-fp-leak-on-error'

Fix a leak of FILE * in an error codepath.

* kt/commit-graph-plug-fp-leak-on-error:
  commit-graph: close file before returning NULL

2 years agoMerge branch 'ah/rebase-keep-base-fix'
Junio C Hamano [Wed, 11 May 2022 20:56:21 +0000 (13:56 -0700)] 
Merge branch 'ah/rebase-keep-base-fix'

"git rebase --keep-base <upstream> <branch-to-rebase>" computed the
commit to rebase onto incorrectly, which has been corrected.

* ah/rebase-keep-base-fix:
  rebase: use correct base for --keep-base when a branch is given

2 years agobisect: output bisect setup status in bisect log
Chris Down [Wed, 11 May 2022 18:00:14 +0000 (19:00 +0100)] 
bisect: output bisect setup status in bisect log

This allows seeing the current intermediate status without adding a new
good or bad commit:

    $ git bisect log | tail -1
    # status: waiting for bad commit, 1 good commit known

Signed-off-by: Chris Down <chris@chrisdown.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agobisect: output state before we are ready to compute bisection
Chris Down [Wed, 11 May 2022 18:00:09 +0000 (19:00 +0100)] 
bisect: output state before we are ready to compute bisection

Commit 73c6de06aff8 ("bisect: don't use invalid oid as rev when
starting") changes the behaviour of `git bisect` to consider invalid
oids as pathspecs again, as in the old shell implementation.

While that behaviour may be desirable, it can also cause confusion. For
example, while bisecting in a particular repo I encountered this:

    $ git bisect start d93ff48803f0 v6.3
    $

...which led to me sitting for a few moments, wondering why there's no
printout stating the first rev to check.

It turns out that the tag was actually "6.3", not "v6.3", and thus the
bisect was still silently started with only a bad rev, because
d93ff48803f0 was a valid oid and "v6.3" was silently considered to be a
pathspec.

While this behaviour may be desirable, it can be confusing, especially
with different repo conventions either using or not using "v" before
release names, or when a branch name or tag is simply misspelled on the
command line.

In order to avoid situations like this, make it more clear what we're
waiting for:

    $ git bisect start d93ff48803f0 v6.3
    status: waiting for good commit(s), bad commit known

We already have good output once the bisect process has begun in
earnest, so we don't need to do anything more there.

Signed-off-by: Chris Down <chris@chrisdown.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMerge branch 'master' of git://git.ozlabs.org/~paulus/gitk
Junio C Hamano [Wed, 11 May 2022 15:25:02 +0000 (08:25 -0700)] 
Merge branch 'master' of git://git.ozlabs.org/~paulus/gitk

* 'master' of git://git.ozlabs.org/~paulus/gitk:
  gitk: include y coord in recorded sash position
  gitk: trivial indentation fix

2 years agoSubmittingPatches: use more stable git.ozlabs.org URL
Junio C Hamano [Wed, 11 May 2022 15:10:12 +0000 (08:10 -0700)] 
SubmittingPatches: use more stable git.ozlabs.org URL

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agogitk: include y coord in recorded sash position
halilsen [Sun, 20 Feb 2022 19:47:36 +0000 (19:47 +0000)] 
gitk: include y coord in recorded sash position

6cd80496e9 ("gitk: Resize panes correctly when reducing window size",
2020-10-03) introduces a mechanism to record previously-set sash
positions to make sure that correct values are used while computing
resize proportions. However, if we are not using ttk, then sash
represents only the x coordinate and the recorded sash (`oldsash`) only
includes the x coordinate. When we need to access the y coordinate via
the recorded sash position, we generate the following Application Error
popup:

Error: expected integer but got ""

expected integer but got ""

expected integer but got ""

     while executing

"$win sash place 0 $sash0 [lindex $s0 1]"

     (procedure "resizeclistpanes" line 38)

     invoked from within

"resizeclistpanes .tf.histframe.pwclist 2818"

     (command bound to event)

To fix this, if we are not using ttk, we append the sash positions with
the y coordinates before recording them to match the use_ttk case.

Signed-off-by: Halil Sen <halil.sen@gmail.com>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
2 years agogitk: trivial indentation fix
halilsen [Sun, 20 Feb 2022 19:47:35 +0000 (19:47 +0000)] 
gitk: trivial indentation fix

No functional changes.

Signed-off-by: Halil Sen <halil.sen@gmail.com>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
2 years ago0th batch for topics from the previous cycle
Junio C Hamano [Wed, 11 May 2022 00:36:46 +0000 (17:36 -0700)] 
0th batch for topics from the previous cycle

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMerge branch 'ea/progress-partial-blame'
Junio C Hamano [Wed, 11 May 2022 00:41:11 +0000 (17:41 -0700)] 
Merge branch 'ea/progress-partial-blame'

The progress meter of "git blame" was showing incorrect numbers
when processing only parts of the file.

* ea/progress-partial-blame:
  blame: report correct number of lines in progress when using ranges

2 years agoMerge branch 'fr/vimdiff-layout'
Junio C Hamano [Wed, 11 May 2022 00:41:11 +0000 (17:41 -0700)] 
Merge branch 'fr/vimdiff-layout'

Reimplement "vimdiff[123]" mergetool drivers with a more generic
layout mechanism.

* fr/vimdiff-layout:
  mergetools: add description to all diff/merge tools
  vimdiff: add tool documentation
  vimdiff: integrate layout tests in the unit tests framework ('t' folder)
  vimdiff: new implementation with layout support

2 years agoMerge branch 'jh/p4-various-fixups'
Junio C Hamano [Wed, 11 May 2022 00:41:11 +0000 (17:41 -0700)] 
Merge branch 'jh/p4-various-fixups'

Various cleanups to "git p4".

* jh/p4-various-fixups: (22 commits)
  git-p4: sort imports
  git-p4: seperate multiple statements onto seperate lines
  git-p4: move inline comments to line above
  git-p4: only seperate code blocks by a single empty line
  git-p4: compare to singletons with "is" and "is not"
  git-p4: normalize indentation of lines in conditionals
  git-p4: ensure there is a single space around all operators
  git-p4: ensure every comment has a single #
  git-p4: remove spaces between dictionary keys and colons
  git-p4: remove redundant backslash-continuations inside brackets
  git-p4: remove extraneous spaces before function arguments
  git-p4: place a single space after every comma
  git-p4: removed brackets when assigning multiple return values
  git-p4: remove spaces around default arguments
  git-p4: remove padding from lists, tuples and function arguments
  git-p4: sort and de-duplcate pylint disable list
  git-p4: remove commented code
  git-p4: convert descriptive class and function comments into docstrings
  git-p4: improve consistency of docstring formatting
  git-p4: indent with 4-spaces
  ...

2 years agoMerge branch 'tk/untracked-cache-with-uall'
Junio C Hamano [Wed, 11 May 2022 00:41:10 +0000 (17:41 -0700)] 
Merge branch 'tk/untracked-cache-with-uall'

The performance of the "untracked cache" feature has been improved
when "--untracked-files=<mode>" and "status.showUntrackedFiles"
are combined.

* tk/untracked-cache-with-uall:
  untracked-cache: support '--untracked-files=all' if configured
  untracked-cache: test untracked-cache-bypassing behavior with -uall

2 years agoMerge branch 'ab/misc-cleanup'
Junio C Hamano [Wed, 11 May 2022 00:41:10 +0000 (17:41 -0700)] 
Merge branch 'ab/misc-cleanup'

Code clean-up.

* ab/misc-cleanup:
  alloc.[ch]: remove alloc_report() function
  object-store.h: remove unused has_sha1_file*()
  pack-bitmap-write: remove unused bitmap_reset() function
  xdiff/xmacros.h: remove unused XDL_PTRFREE
  configure.ac: remove USE_PIC comment
  run-command.h: remove always unused "clean_on_exit_handler_cbdata"