]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
3 years agomerge-tree: implement real merges
Elijah Newren [Sat, 18 Jun 2022 00:20:47 +0000 (00:20 +0000)] 
merge-tree: implement real merges

This adds the ability to perform real merges rather than just trivial
merges (meaning handling three way content merges, recursive ancestor
consolidation, renames, proper directory/file conflict handling, and so
forth).  However, unlike `git merge`, the working tree and index are
left alone and no branch is updated.

The only output is:
  - the toplevel resulting tree printed on stdout
  - exit status of 0 (clean), 1 (conflicts present), anything else
    (merge could not be performed; unknown if clean or conflicted)

This output is meant to be used by some higher level script, perhaps in
a sequence of steps like this:

   NEWTREE=$(git merge-tree --write-tree $BRANCH1 $BRANCH2)
   test $? -eq 0 || die "There were conflicts..."
   NEWCOMMIT=$(git commit-tree $NEWTREE -p $BRANCH1 -p $BRANCH2)
   git update-ref $BRANCH1 $NEWCOMMIT

Note that higher level scripts may also want to access the
conflict/warning messages normally output during a merge, or have quick
access to a list of files with conflicts.  That is not available in this
preliminary implementation, but subsequent commits will add that
ability (meaning that NEWTREE would be a lot more than a tree in the
case of conflicts).

This also marks the traditional trivial merge of merge-tree as
deprecated.  The trivial merge not only had limited applicability, the
output format was also difficult to work with (and its format
undocumented), and will generally be less performant than real merges.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agomerge-tree: add option parsing and initial shell for real merge function
Elijah Newren [Sat, 18 Jun 2022 00:20:46 +0000 (00:20 +0000)] 
merge-tree: add option parsing and initial shell for real merge function

Let merge-tree accept a `--write-tree` parameter for choosing real
merges instead of trivial merges, and accept an optional
`--trivial-merge` option to get the traditional behavior.  Note that
these accept different numbers of arguments, though, so these names
need not actually be used.

Note that real merges differ from trivial merges in that they handle:
  - three way content merges
  - recursive ancestor consolidation
  - renames
  - proper directory/file conflict handling
  - etc.
Basically all the stuff you'd expect from `git merge`, just without
updating the index and working tree.  The initial shell added here does
nothing more than die with "real merges are not yet implemented", but
that will be fixed in subsequent commits.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agomerge-tree: move logic for existing merge into new function
Elijah Newren [Sat, 18 Jun 2022 00:20:45 +0000 (00:20 +0000)] 
merge-tree: move logic for existing merge into new function

In preparation for adding a non-trivial merge capability to merge-tree,
move the existing merge logic for trivial merges into a new function.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agomerge-tree: rename merge_trees() to trivial_merge_trees()
Elijah Newren [Sat, 18 Jun 2022 00:20:44 +0000 (00:20 +0000)] 
merge-tree: rename merge_trees() to trivial_merge_trees()

merge-recursive.h defined its own merge_trees() function, different than
the one found in builtin/merge-tree.c.  That was okay in the past, but
we want merge-tree to be able to use the merge-ort functions, which will
end up including merge-recursive.h.  Rename the function found in
builtin/merge-tree.c to avoid the conflict.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoGit 2.37-rc2 v2.37.0-rc2
Junio C Hamano [Wed, 22 Jun 2022 16:07:56 +0000 (09:07 -0700)] 
Git 2.37-rc2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'tb/cruft-packs'
Junio C Hamano [Wed, 22 Jun 2022 16:06:37 +0000 (09:06 -0700)] 
Merge branch 'tb/cruft-packs'

Docfix.

* tb/cruft-packs:
  gc: simplify --cruft description

3 years agoMerge branch 'jp/prompt-clear-before-upstream-mark'
Junio C Hamano [Tue, 21 Jun 2022 17:07:50 +0000 (10:07 -0700)] 
Merge branch 'jp/prompt-clear-before-upstream-mark'

Bash command line prompt (in contrib/) update.

* jp/prompt-clear-before-upstream-mark:
  git-prompt: fix expansion of branch colour codes
  git-prompt: make colourization consistent

3 years agogc: simplify --cruft description
René Scharfe [Sun, 19 Jun 2022 05:38:50 +0000 (07:38 +0200)] 
gc: simplify --cruft description

Remove duplicate "loose objects".

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoname-rev: prefix annotate-stdin with '--' in message
Alexander Shopov [Mon, 20 Jun 2022 16:44:34 +0000 (18:44 +0200)] 
name-rev: prefix annotate-stdin with '--' in message

This is an option rather than command.  Make the message convey this
similar to the other messages in the file.

Signed-off-by: Alexander Shopov <ash@kambanaria.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoGit 2.37-rc1 v2.37.0-rc1
Junio C Hamano [Sat, 18 Jun 2022 00:15:13 +0000 (17:15 -0700)] 
Git 2.37-rc1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'cb/path-owner-check-with-sudo-plus'
Junio C Hamano [Sat, 18 Jun 2022 00:12:31 +0000 (17:12 -0700)] 
Merge branch 'cb/path-owner-check-with-sudo-plus'

"sudo git foo" used to consider a repository owned by the original
user a safe one to access; it now also considers a repository owned
by root a safe one, too (after all, if an attacker can craft a
malicious repository owned by root, the box is 0wned already).

* cb/path-owner-check-with-sudo-plus:
  git-compat-util: allow root to access both SUDO_UID and root owned

3 years agogit-compat-util: allow root to access both SUDO_UID and root owned
Carlo Marcelo Arenas Belón [Fri, 17 Jun 2022 20:23:38 +0000 (13:23 -0700)] 
git-compat-util: allow root to access both SUDO_UID and root owned

Previous changes introduced a regression which will prevent root for
accessing repositories owned by thyself if using sudo because SUDO_UID
takes precedence.

Loosen that restriction by allowing root to access repositories owned
by both uid by default and without having to add a safe.directory
exception.

A previous workaround that was documented in the tests is no longer
needed so it has been removed together with its specially crafted
prerequisite.

Helped-by: Johanness 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>
3 years agoi18n: fix mismatched camelCase config variables
Jiang Xin [Fri, 17 Jun 2022 10:03:09 +0000 (18:03 +0800)] 
i18n: fix mismatched camelCase config variables

Some config variables are combinations of multiple words, and we
typically write them in camelCase forms in manpage and translatable
strings. It's not easy to find mismatches for these camelCase config
variables during code reviews, but occasionally they are identified
during localization translations.

To check for mismatched config variables, I introduced a new feature
in the helper program for localization[^1]. The following mismatched
config variables have been identified by running the helper program,
such as "git-po-helper check-pot".

Lowercase in manpage should use camelCase:

 * Documentation/config/http.txt: http.pinnedpubkey

Lowercase in translable strings should use camelCase:

 * builtin/fast-import.c:  pack.indexversion
 * builtin/gc.c:           gc.logexpiry
 * builtin/index-pack.c:   pack.indexversion
 * builtin/pack-objects.c: pack.indexversion
 * builtin/repack.c:       pack.writebitmaps
 * commit.c:               i18n.commitencoding
 * gpg-interface.c:        user.signingkey
 * http.c:                 http.postbuffer
 * submodule-config.c:     submodule.fetchjobs

Mismatched camelCases, choose the former:

 * Documentation/config/transfer.txt: transfer.credentialsInUrl
   remote.c:                          transfer.credentialsInURL

[^1]: https://github.com/git-l10n/git-po-helper

Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoAnother batch of fixes before -rc1
Junio C Hamano [Fri, 17 Jun 2022 17:33:42 +0000 (10:33 -0700)] 
Another batch of fixes before -rc1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'jk/bug-fl-va-list-fix'
Junio C Hamano [Fri, 17 Jun 2022 17:33:32 +0000 (10:33 -0700)] 
Merge branch 'jk/bug-fl-va-list-fix'

Fix buggy va_list usage in recent code.

* jk/bug-fl-va-list-fix:
  bug_fl(): correctly initialize trace2 va_list

3 years agoMerge branch 'ab/credentials-in-url-more'
Junio C Hamano [Fri, 17 Jun 2022 17:33:32 +0000 (10:33 -0700)] 
Merge branch 'ab/credentials-in-url-more'

Rename fetch.credentialsInUrl to transfer.credentialsInUrl as the
single configuration variable should work both in pushing and
fetching.

* ab/credentials-in-url-more:
  transfer doc: move fetch.credentialsInUrl to "transfer" config namespace
  fetch doc: note "pushurl" caveat about "credentialsInUrl", elaborate

3 years agoMerge branch 'js/ci-github-workflow-markup'
Junio C Hamano [Fri, 17 Jun 2022 17:33:32 +0000 (10:33 -0700)] 
Merge branch 'js/ci-github-workflow-markup'

Recent CI update hides certain failures in test jobs, which has
been corrected.

* js/ci-github-workflow-markup:
  ci(github): also mark up compile errors
  ci(github): use grouping also in the `win-build` job
  ci(github): bring back the 'print test failures' step

3 years agoMerge branch 'js/misc-fixes'
Junio C Hamano [Fri, 17 Jun 2022 17:33:31 +0000 (10:33 -0700)] 
Merge branch 'js/misc-fixes'

Assorted fixes to problems found by Coverity.

* js/misc-fixes:
  relative_url(): fix incorrect condition
  pack-mtimes: avoid closing a bogus file descriptor
  read_index_from(): avoid memory leak
  submodule--helper: avoid memory leak when fetching submodules
  submodule-config: avoid memory leak
  fsmonitor: avoid memory leak in `fsm_settings__get_incompatible_msg()`

3 years agoMerge branch 'jc/cocci-cleanup'
Junio C Hamano [Fri, 17 Jun 2022 17:33:31 +0000 (10:33 -0700)] 
Merge branch 'jc/cocci-cleanup'

Remove a coccinelle rule that is no longer relevant.

* jc/cocci-cleanup:
  cocci: retire is_null_sha1() rule

3 years agoMerge branch 'ds/more-test-coverage'
Junio C Hamano [Fri, 17 Jun 2022 17:33:31 +0000 (10:33 -0700)] 
Merge branch 'ds/more-test-coverage'

Improve test coverage with a handful of tests.

* ds/more-test-coverage:
  cache-tree: remove cache_tree_find_path()
  pack-write: drop always-NULL parameter
  t5329: test 'git gc --cruft' without '--prune=now'
  t2107: test 'git update-index --verbose'

3 years agoMerge branch 'jk/perf-lib-test-titles'
Junio C Hamano [Fri, 17 Jun 2022 17:33:31 +0000 (10:33 -0700)] 
Merge branch 'jk/perf-lib-test-titles'

Show test titles to the performance test output again.

* jk/perf-lib-test-titles:
  perf-lib: fix missing test titles in output

3 years agobug_fl(): correctly initialize trace2 va_list
Jeff King [Thu, 16 Jun 2022 20:04:25 +0000 (16:04 -0400)] 
bug_fl(): correctly initialize trace2 va_list

The code added 0cc05b044f (usage.c: add a non-fatal bug() function to go
with BUG(), 2022-06-02) sets up two va_list variables: one to output to
stderr, and one to trace2. But the order of initialization is wrong:

  va_list ap, cp;
  va_copy(cp, ap);
  va_start(ap, fmt);

We copy the contents of "ap" into "cp" before it is initialized, meaning
it is full of garbage. The two should be swapped.

However, there's another bug, noticed by Johannes Schindelin: we forget
to call va_end() for the copy. So instead of just fixing the copy's
initialization, let's do two separate start/end pairs. This is allowed
by the standard, and we don't need to use copy here since we have access
to the original varargs. Matching the pairs with the calls makes it more
obvious that everything is being done correctly.

Note that we do call bug_fl() in the tests, but it didn't trigger this
problem because our format string doesn't have any placeholders. So even
though we were passing a garbage va_list through the stack, nobody ever
needed to look at it. We can easily adjust one of the trace2 tests to
trigger this, both for bug() and for BUG(). The latter isn't broken, but
it's nice to exercise both a bit more. Without the fix in this patch
(but with the test change), the bug() case causes a segfault.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorelative_url(): fix incorrect condition
Johannes Schindelin [Wed, 15 Jun 2022 23:35:44 +0000 (23:35 +0000)] 
relative_url(): fix incorrect condition

In 63e95beb085c (submodule: port resolve_relative_url from shell to C,
2016-04-15), we added a loop over `url` where we are looking for `../`
or `./` components.

The loop condition we used is the pointer `url` itself, which is clearly
not what we wanted.

Pointed out by Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agopack-mtimes: avoid closing a bogus file descriptor
Johannes Schindelin [Wed, 15 Jun 2022 23:35:43 +0000 (23:35 +0000)] 
pack-mtimes: avoid closing a bogus file descriptor

In 94cd775a6c52 (pack-mtimes: support reading .mtimes files,
2022-05-20), code was added to close the file descriptor corresponding
to the mtimes file.

However, it is possible that opening that file failed, in which case we
are closing a file descriptor with the value `-1`. Let's guard that
`close()` call.

Reported by Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoread_index_from(): avoid memory leak
Johannes Schindelin [Wed, 15 Jun 2022 23:35:42 +0000 (23:35 +0000)] 
read_index_from(): avoid memory leak

In 998330ac2e7c (read-cache: look for shared index files next to the
index, too, 2021-08-26), we added code that allocates memory to store
the base path of a shared index, but we never released that memory.

Reported by Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agosubmodule--helper: avoid memory leak when fetching submodules
Johannes Schindelin [Wed, 15 Jun 2022 23:35:41 +0000 (23:35 +0000)] 
submodule--helper: avoid memory leak when fetching submodules

In c51f8f94e5b3 (submodule--helper: run update procedures from C,
2021-08-24), we added code that first obtains the default remote, and
then adds that to a `strvec`.

However, we never released the default remote's memory.

Reported by Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agosubmodule-config: avoid memory leak
Johannes Schindelin [Wed, 15 Jun 2022 23:35:39 +0000 (23:35 +0000)] 
submodule-config: avoid memory leak

In 961b130d20c9 (branch: add --recurse-submodules option for branch
creation, 2022-01-28), a funny pattern was introduced where first some
struct is `xmalloc()`ed, then we resize an array whose element type is
the same struct, and then the first struct's contents are copied into
the last element of that array.

Crucially, the `xmalloc()`ed memory never gets released.

Let's avoid that memory leak and that memory allocation dance altogether
by first reallocating the array, then using a pointer to the last array
element to go forward.

Reported by Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agofsmonitor: avoid memory leak in `fsm_settings__get_incompatible_msg()`
Johannes Schindelin [Wed, 15 Jun 2022 23:35:36 +0000 (23:35 +0000)] 
fsmonitor: avoid memory leak in `fsm_settings__get_incompatible_msg()`

Reported by Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocache-tree: remove cache_tree_find_path()
Derrick Stolee [Thu, 16 Jun 2022 13:13:50 +0000 (13:13 +0000)] 
cache-tree: remove cache_tree_find_path()

This reverts 080ab56a46 (cache-tree: implement cache_tree_find_path(),
2022-05-23). The cache_tree_find_path() method was never actually called
in the topic that added it. I cannot find any reference to it in any of
my forks, so this appears to not be needed at the moment.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agopack-write: drop always-NULL parameter
Derrick Stolee [Thu, 16 Jun 2022 13:13:49 +0000 (13:13 +0000)] 
pack-write: drop always-NULL parameter

write_mtimes_file() takes an mtimes parameter as its first option, but
the only caller passes a NULL constant. Drop this parameter to simplify
logic. This can be reverted if that parameter is needed in the future.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot5329: test 'git gc --cruft' without '--prune=now'
Derrick Stolee [Thu, 16 Jun 2022 13:13:48 +0000 (13:13 +0000)] 
t5329: test 'git gc --cruft' without '--prune=now'

Replace a 'git repack --cruft -d' with the wrapper 'git gc --cruft' to
exercise some logic in builtin/gc.c that adds the '--cruft' option to
the underlying 'git repack' command.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot2107: test 'git update-index --verbose'
Derrick Stolee [Thu, 16 Jun 2022 13:13:47 +0000 (13:13 +0000)] 
t2107: test 'git update-index --verbose'

The '--verbose' option reports what is being added and removed from the
index, but has not been tested up to this point. Augment the tests in
t2107 to check the '--verbose' option in some scenarios.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoperf-lib: fix missing test titles in output
Jeff King [Thu, 16 Jun 2022 07:09:32 +0000 (03:09 -0400)] 
perf-lib: fix missing test titles in output

Commit 5dccd9155f (t/perf: add iteration setup mechanism to perf-lib,
2022-04-04) modified the parameter parsing of test_wrapper() such that
the test title was no longer in $1, and is instead in $test_title_.

We correctly pass the new variable to the code which outputs the title
to the log, but missed the spot in test_wrapper() where the title is
written to the ".descr" file which is used to produce the final output
table. As a result, all of the titles are missing from that table (or
worse, using whatever was left in $1):

  $ ./p0000-perf-lib-sanity.sh
  [...]
  Test           this tree
  ------------------------------
  0000.1:        0.01(0.01+0.00)
  0000.2:        0.01(0.00+0.01)
  0000.4:        0.00(0.00+0.00)
  0000.5: true   0.00(0.00+0.00)
  0000.7:        0.00(0.00+0.00)
  0000.8:        0.00(0.00+0.00)

After this patch, we get the pre-5dccd9155f output:

  Test                                                       this tree
  --------------------------------------------------------------------------
  0000.1: test_perf_default_repo works                       0.00(0.00+0.00)
  0000.2: test_checkout_worktree works                       0.01(0.00+0.01)
  0000.4: export a weird var                                 0.00(0.00+0.00)
  0000.5: éḿíẗ ńöń-ÁŚĆÍÍ ćḧáŕáćẗéŕś                          0.00(0.00+0.00)
  0000.7: important variables available in subshells         0.00(0.00+0.00)
  0000.8: test-lib-functions correctly loaded in subshells   0.00(0.00+0.00)

Signed-off-by: Jeff King <peff@peff.net>
Acked-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agobuiltin/rebase: remove a redundant space in l10n string
Fangyi Zhou [Thu, 16 Jun 2022 17:18:58 +0000 (17:18 +0000)] 
builtin/rebase: remove a redundant space in l10n string

Found in l10n.

Signed-off-by: Fangyi Zhou <me@fangyi.io>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoFixes and updates post -rc0
Junio C Hamano [Wed, 15 Jun 2022 22:09:35 +0000 (15:09 -0700)] 
Fixes and updates post -rc0

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'fs/ssh-default-key-command-doc'
Junio C Hamano [Wed, 15 Jun 2022 22:09:28 +0000 (15:09 -0700)] 
Merge branch 'fs/ssh-default-key-command-doc'

Doc update.

* fs/ssh-default-key-command-doc:
  gpg docs: explain better use of ssh.defaultKeyCommand

3 years agoMerge branch 'po/rebase-preserve-merges'
Junio C Hamano [Wed, 15 Jun 2022 22:09:28 +0000 (15:09 -0700)] 
Merge branch 'po/rebase-preserve-merges'

Various error messages that talk about the removal of
"--preserve-merges" in "rebase" have been strengthened, and "rebase
--abort" learned to get out of a state that was left by an earlier
use of the option.

* po/rebase-preserve-merges:
  rebase: translate a die(preserve-merges) message
  rebase: note `preserve` merges may be a pull config option
  rebase: help users when dying with `preserve-merges`
  rebase.c: state preserve-merges has been removed

3 years agoMerge branch 'jc/revert-show-parent-info'
Junio C Hamano [Wed, 15 Jun 2022 22:09:27 +0000 (15:09 -0700)] 
Merge branch 'jc/revert-show-parent-info'

"git revert" learns "--reference" option to use more human-readable
reference to the commit it reverts in the message template it
prepares for the user.

* jc/revert-show-parent-info:
  revert: --reference should apply only to 'revert', not 'cherry-pick'
  revert: optionally refer to commit in the "reference" format

3 years agotests: add LIBCURL prerequisite to tests needing libcurl
Ævar Arnfjörð Bjarmason [Wed, 15 Jun 2022 10:36:32 +0000 (12:36 +0200)] 
tests: add LIBCURL prerequisite to tests needing libcurl

Add and use a LIBCURL prerequisite for tests added in
6dcbdc0d661 (remote: create fetch.credentialsInUrl config,
2022-06-06).

These tests would get as far as emitting a couple of the warnings we
were testing for, but would then die as we had no "git-remote-https"
program compiled.

It would be more consistent with other prerequisites (e.g. PERL for
NO_PERL) to name this "CURL", but since e9184b0789a (t5561: skip tests
if curl is not available, 2018-04-03) we've had that prerequisite
defined for checking of we have the curl(1) program.

The existing "CURL" prerequisite is only used in one place, and we
should probably name it "CURL_PROGRAM", then rename "LIBCURL" to
"CURL" as a follow-up, but for now (pre-v2.37.0) let's aim for the
most minimal fix possible.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agopush: fix capitalisation of the option name autoSetupMerge
Fangyi Zhou [Wed, 15 Jun 2022 15:35:44 +0000 (15:35 +0000)] 
push: fix capitalisation of the option name autoSetupMerge

This was found during l10n process by Jiang Xin.

Reported-by: Jiang Xin <worldhello.net@gmail.com>
Signed-off-by: Fangyi Zhou <me@fangyi.io>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agotransfer doc: move fetch.credentialsInUrl to "transfer" config namespace
Ævar Arnfjörð Bjarmason [Wed, 15 Jun 2022 10:44:12 +0000 (12:44 +0200)] 
transfer doc: move fetch.credentialsInUrl to "transfer" config namespace

Rename the "fetch.credentialsInUrl" configuration variable introduced
in 6dcbdc0d661 (remote: create fetch.credentialsInUrl config,
2022-06-06) to "transfer".

There are existing exceptions, but generally speaking the
"<namespace>.<var>" configuration should only apply to command
described in the "namespace" (and its sub-commands, so e.g. "clone.*"
or "fetch.*" might also configure "git-remote-https").

But in the case of "fetch.credentialsInUrl" we've got a configuration
variable that configures the behavior of all of "clone", "push" and
"fetch", someone adjusting "fetch.*" configuration won't expect to
have the behavior of "git push" altered, especially as we have the
pre-existing "{transfer,fetch,receive}.fsckObjects", which configures
different parts of the transfer dialog.

So let's move this configuration variable to the "transfer" namespace
before it's exposed in a release. We could add all of
"{transfer,fetch,pull}.credentialsInUrl" at some other time, but once
we have "fetch" configure "pull" such an arrangement would would be a
confusing mess, as we'd at least need to have "fetch" configure
"push" (but not the other way around), or change existing behavior.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Acked-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agofetch doc: note "pushurl" caveat about "credentialsInUrl", elaborate
Ævar Arnfjörð Bjarmason [Wed, 15 Jun 2022 10:44:11 +0000 (12:44 +0200)] 
fetch doc: note "pushurl" caveat about "credentialsInUrl", elaborate

Amend the documentation and release notes entry for the
"fetch.credentialsInUrl" feature added in 6dcbdc0d661 (remote: create
fetch.credentialsInUrl config, 2022-06-06), it currently doesn't
detect passwords in `remote.<name>.pushurl` configuration. We
shouldn't lull users into a false sense of security, so we need to
mention that prominently.

This also elaborates and clarifies the "exposes the password in
multiple ways" part of the documentation. As noted in [1] a user
unfamiliar with git's implementation won't know what to make of that
scary claim, e.g. git hypothetically have novel git-specific ways of
exposing configured credentials.

The reality is that this configuration is intended as an aid for users
who can't fully trust their OS's or system's security model, so lets
say that's what this is intended for, and mention the most common ways
passwords stored in configuration might inadvertently get exposed.

1. https://lore.kernel.org/git/220524.86ilpuvcqh.gmgdl@evledraar.gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Acked-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoadd -i tests: mark "TODO" depending on GIT_TEST_ADD_I_USE_BUILTIN
Ævar Arnfjörð Bjarmason [Tue, 14 Jun 2022 15:40:07 +0000 (17:40 +0200)] 
add -i tests: mark "TODO" depending on GIT_TEST_ADD_I_USE_BUILTIN

Fix an issue that existed before 0527ccb1b55 (add -i: default to the
built-in implementation, 2021-11-30), but which became the default
with that change, we should not be marking tests that are known to
pass as "TODO" tests.

When GIT_TEST_ADD_I_USE_BUILTIN=1 was made the default we started
passing the tests added in 0f0fba2cc87 (t3701: add a test for advanced
split-hunk editing, 2019-12-06) and 1bf01040f0c (add -p: demonstrate
failure when running 'edit' after a split, 2015-04-16).

Thus we've been emitting this sort of output:

$ prove ./t3701-add-interactive.sh
./t3701-add-interactive.sh .. ok
All tests successful.

Test Summary Report
-------------------
./t3701-add-interactive.sh (Wstat: 0 Tests: 70 Failed: 0)
  TODO passed:   45, 47
Files=1, Tests=70,  2 wallclock secs ( 0.03 usr  0.00 sys +  0.86 cusr  0.33 csys =  1.22 CPU)
Result: PASS

Which isn't just cosmetic, but due to issues with
test_expect_failure (see [1]) we could e.g. be hiding something as bad
as a segfault in the new implementation. It makes sense catch that,
especially before we put out a release with the built-in "add -i", so
let's generalize the check we were already doing in 0527ccb1b55 with a
new "ADD_I_USE_BUILTIN" prerequisite.

1. https://lore.kernel.org/git/patch-1.7-4624abc2591-20220318T002951Z-avarab@gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoGit 2.37-rc0 v2.37.0-rc0
Junio C Hamano [Mon, 13 Jun 2022 22:42:40 +0000 (15:42 -0700)] 
Git 2.37-rc0

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'gc/document-config-worktree-scope'
Junio C Hamano [Mon, 13 Jun 2022 22:53:44 +0000 (15:53 -0700)] 
Merge branch 'gc/document-config-worktree-scope'

Doc update.

* gc/document-config-worktree-scope:
  config: document and test the 'worktree' scope

3 years agoMerge branch 'js/wait-or-whine-can-fail'
Junio C Hamano [Mon, 13 Jun 2022 22:53:44 +0000 (15:53 -0700)] 
Merge branch 'js/wait-or-whine-can-fail'

We used to log an error return from wait_or_whine() as process
termination of the waited child, which was incorrect.

* js/wait-or-whine-can-fail:
  run-command: don't spam trace2_child_exit()

3 years agoMerge branch 'ab/remote-free-fix'
Junio C Hamano [Mon, 13 Jun 2022 22:53:43 +0000 (15:53 -0700)] 
Merge branch 'ab/remote-free-fix'

Use-after-free (with another forget-to-free) fix.

* ab/remote-free-fix:
  remote.c: don't dereference NULL in freeing loop
  remote.c: remove braces from one-statement "for"-loops

3 years agoMerge branch 'sn/fsmonitor-missing-clock'
Junio C Hamano [Mon, 13 Jun 2022 22:53:43 +0000 (15:53 -0700)] 
Merge branch 'sn/fsmonitor-missing-clock'

Sample watchman interface hook sometimes failed to produce
correctly formatted JSON message, which has been corrected.

* sn/fsmonitor-missing-clock:
  fsmonitor: query watchman with right valid json

3 years agoMerge branch 'zh/read-cache-copy-name-entry-fix'
Junio C Hamano [Mon, 13 Jun 2022 22:53:43 +0000 (15:53 -0700)] 
Merge branch 'zh/read-cache-copy-name-entry-fix'

Remove redundant copying (with index v3 and older) or possible
over-reading beyond end of mmapped memory (with index v4) has been
corrected.

* zh/read-cache-copy-name-entry-fix:
  read-cache.c: reduce unnecessary cache entry name copying

3 years agoMerge branch 'tb/show-ref-optim'
Junio C Hamano [Mon, 13 Jun 2022 22:53:42 +0000 (15:53 -0700)] 
Merge branch 'tb/show-ref-optim'

"git show-ref --heads" (and "--tags") still iterated over all the
refs only to discard refs outside the specified area, which has
been corrected.

* tb/show-ref-optim:
  builtin/show-ref.c: avoid over-iterating with --heads, --tags

3 years agoMerge branch 'ds/credentials-in-url'
Junio C Hamano [Mon, 13 Jun 2022 22:53:42 +0000 (15:53 -0700)] 
Merge branch 'ds/credentials-in-url'

The "fetch.credentialsInUrl" configuration variable controls what
happens when a URL with embedded login credential is used.

* ds/credentials-in-url:
  remote: create fetch.credentialsInUrl config

3 years agoMerge branch 'jt/unparse-commit-upon-graft-change'
Junio C Hamano [Mon, 13 Jun 2022 22:53:42 +0000 (15:53 -0700)] 
Merge branch 'jt/unparse-commit-upon-graft-change'

Updating the graft information invalidates the list of parents of
in-core commit objects that used to be in the graft file.

* jt/unparse-commit-upon-graft-change:
  commit,shallow: unparse commits if grafts changed

3 years agoMerge branch 'ab/hooks-regression-fix'
Junio C Hamano [Mon, 13 Jun 2022 22:53:41 +0000 (15:53 -0700)] 
Merge branch 'ab/hooks-regression-fix'

In Git 2.36 we revamped the way how hooks are invoked.  One change
that is end-user visible is that the output of a hook is no longer
directly connected to the standard output of "git" that spawns the
hook, which was noticed post release.  This is getting corrected.

* ab/hooks-regression-fix:
  hook API: fix v2.36.0 regression: hooks should be connected to a TTY
  run-command: add an "ungroup" option to run_process_parallel()

3 years agoMerge branch 'tl/ls-tree-oid-only'
Junio C Hamano [Mon, 13 Jun 2022 22:53:41 +0000 (15:53 -0700)] 
Merge branch 'tl/ls-tree-oid-only'

Add tests for a regression fixed earlier.

* tl/ls-tree-oid-only:
  ls-tree: test for the regression in 9c4d58ff2c3

3 years agoMerge branch 'pb/range-diff-with-submodule'
Junio C Hamano [Mon, 13 Jun 2022 22:53:41 +0000 (15:53 -0700)] 
Merge branch 'pb/range-diff-with-submodule'

"git -c diff.submodule=log range-diff" did not show anything for
submodules that changed in the ranges being compared, and
"git -c diff.submodule=diff range-diff" did not work correctly.
Fix this by including the "--submodule=short" output
unconditionally to be compared.

* pb/range-diff-with-submodule:
  range-diff: show submodule changes irrespective of diff.submodule

3 years agoci(github): also mark up compile errors
Johannes Schindelin [Mon, 13 Jun 2022 13:13:08 +0000 (13:13 +0000)] 
ci(github): also mark up compile errors

When GCC produces those helpful errors, we will want to present them in
the GitHub workflow runs in the most helpful manner. To that end, we
want to use workflow commands to render errors and warnings:
https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions

In the previous commit, we ensured that grouping is used for the build
in all jobs, and this allows us to piggy-back onto the `group` function
to transmogrify the output.

Note: If `set -o pipefail` was available, we could do this in a little
more elegant way. But since some of the steps are run using `dash`, we
have to do a little `{ ...; echo $? >exit.status; } | ...` dance.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoci(github): use grouping also in the `win-build` job
Johannes Schindelin [Mon, 13 Jun 2022 13:13:07 +0000 (13:13 +0000)] 
ci(github): use grouping also in the `win-build` job

We already do the same when building Git in all the other jobs.

This will allow us to piggy-back on top of grouping to mark up compiler
errors in the next commit.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoNinth batch
Junio C Hamano [Fri, 10 Jun 2022 22:05:15 +0000 (15:05 -0700)] 
Ninth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'ab/bug-if-bug'
Junio C Hamano [Fri, 10 Jun 2022 22:04:15 +0000 (15:04 -0700)] 
Merge branch 'ab/bug-if-bug'

A new bug() and BUG_if_bug() API is introduced to make it easier to
uniformly log "detect multiple bugs and abort in the end" pattern.

* ab/bug-if-bug:
  cache-tree.c: use bug() and BUG_if_bug()
  receive-pack: use bug() and BUG_if_bug()
  parse-options.c: use optbug() instead of BUG() "opts" check
  parse-options.c: use new bug() API for optbug()
  usage.c: add a non-fatal bug() function to go with BUG()
  common-main.c: move non-trace2 exit() behavior out of trace2.c

3 years agoMerge branch 'jy/gitweb-xhtml5'
Junio C Hamano [Fri, 10 Jun 2022 22:04:15 +0000 (15:04 -0700)] 
Merge branch 'jy/gitweb-xhtml5'

Update the doctype written in gitweb output to xhtml5.

* jy/gitweb-xhtml5:
  gitweb: switch to an XHTML5 DOCTYPE

3 years agoMerge branch 'jh/builtin-fsmonitor-part3'
Junio C Hamano [Fri, 10 Jun 2022 22:04:14 +0000 (15:04 -0700)] 
Merge branch 'jh/builtin-fsmonitor-part3'

More fsmonitor--daemon.

* jh/builtin-fsmonitor-part3: (30 commits)
  t7527: improve implicit shutdown testing in fsmonitor--daemon
  fsmonitor--daemon: allow --super-prefix argument
  t7527: test Unicode NFC/NFD handling on MacOS
  t/lib-unicode-nfc-nfd: helper prereqs for testing unicode nfc/nfd
  t/helper/hexdump: add helper to print hexdump of stdin
  fsmonitor: on macOS also emit NFC spelling for NFD pathname
  t7527: test FSMonitor on case insensitive+preserving file system
  fsmonitor: never set CE_FSMONITOR_VALID on submodules
  t/perf/p7527: add perf test for builtin FSMonitor
  t7527: FSMonitor tests for directory moves
  fsmonitor: optimize processing of directory events
  fsm-listen-darwin: shutdown daemon if worktree root is moved/renamed
  fsm-health-win32: force shutdown daemon if worktree root moves
  fsm-health-win32: add polling framework to monitor daemon health
  fsmonitor--daemon: stub in health thread
  fsmonitor--daemon: rename listener thread related variables
  fsmonitor--daemon: prepare for adding health thread
  fsmonitor--daemon: cd out of worktree root
  fsm-listen-darwin: ignore FSEvents caused by xattr changes on macOS
  unpack-trees: initialize fsmonitor_has_run_once in o->result
  ...

3 years agoMerge branch 'gc/zero-length-branch-config-fix'
Junio C Hamano [Fri, 10 Jun 2022 22:04:14 +0000 (15:04 -0700)] 
Merge branch 'gc/zero-length-branch-config-fix'

A misconfigured 'branch..remote' led to a bug in configuration
parsing.

* gc/zero-length-branch-config-fix:
  remote.c: reject 0-length branch names
  remote.c: don't BUG() on 0-length branch names

3 years agoMerge branch 'ab/env-array'
Junio C Hamano [Fri, 10 Jun 2022 22:04:13 +0000 (15:04 -0700)] 
Merge branch 'ab/env-array'

Rename .env_array member to .env in the child_process structure.

* ab/env-array:
  run-command API users: use "env" not "env_array" in comments & names
  run-command API: rename "env_array" to "env"

3 years agoMerge branch 'cb/buggy-gcc-12-workaround'
Junio C Hamano [Fri, 10 Jun 2022 22:04:12 +0000 (15:04 -0700)] 
Merge branch 'cb/buggy-gcc-12-workaround'

With a more targetted workaround in http.c in another topic, we may
be able to lift this blanket "GCC12 dangling-pointer warning is
broken and unsalvageable" workaround.

* cb/buggy-gcc-12-workaround:
  Revert -Wno-error=dangling-pointer

3 years agogit-prompt: fix expansion of branch colour codes
Joakim Petersen [Fri, 10 Jun 2022 00:47:37 +0000 (02:47 +0200)] 
git-prompt: fix expansion of branch colour codes

Because of the wrapping of the branch name variable $b, the colour codes
in the variable don't get applied, but are instead printed directly in
the output. Move the wrapping of $b to before colour codes are inserted
to correct this. Revert move of branch name colour codes in tests, as
the branch name is now coloured after the wrapping instead of before.

Signed-off-by: Joakim Petersen <joak-pet@online.no>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agogpg docs: explain better use of ssh.defaultKeyCommand
Fabian Stelzer [Wed, 8 Jun 2022 15:24:37 +0000 (17:24 +0200)] 
gpg docs: explain better use of ssh.defaultKeyCommand

Using `ssh-add -L` for gpg.ssh.defaultKeyCommand is not a good
recommendation. It might switch keys depending on the order of known
keys and it only supports ssh-* and no ecdsa or other keys.
Clarify that we expect a literal key prefixed by `key::`, give valid
example use cases and refer to `user.signingKey` as the preferred
option.

Signed-off-by: Fabian Stelzer <fs@gigacodes.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoci(github): bring back the 'print test failures' step
Johannes Schindelin [Wed, 8 Jun 2022 10:43:18 +0000 (10:43 +0000)] 
ci(github): bring back the 'print test failures' step

Git now shows better information in the GitHub workflow runs when a test
case failed. However, when a test case was implemented incorrectly and
therefore does not even run, nothing is shown.

Let's bring back the step that prints the full logs of the failed tests,
and to improve the user experience, print out an informational message
for readers so that they do not have to know/remember where to see the
full logs.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoSync with 'maint'
Junio C Hamano [Wed, 8 Jun 2022 21:29:30 +0000 (14:29 -0700)] 
Sync with 'maint'

3 years agoPrepare for 2.36.2
Junio C Hamano [Wed, 8 Jun 2022 01:48:52 +0000 (18:48 -0700)] 
Prepare for 2.36.2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'jc/clone-remote-name-leak-fix' into maint
Junio C Hamano [Wed, 8 Jun 2022 21:27:53 +0000 (14:27 -0700)] 
Merge branch 'jc/clone-remote-name-leak-fix' into maint

"git clone --origin X" leaked piece of memory that held value read
from the clone.defaultRemoteName configuration variable, which has
been plugged.
source: <xmqqlevl4ysk.fsf@gitster.g>

* jc/clone-remote-name-leak-fix:
  clone: plug a miniscule leak

3 years agoMerge branch 'ds/midx-normalize-pathname-before-comparison' into maint
Junio C Hamano [Wed, 8 Jun 2022 21:27:53 +0000 (14:27 -0700)] 
Merge branch 'ds/midx-normalize-pathname-before-comparison' into maint

The path taken by "git multi-pack-index" command from the end user
was compared with path internally prepared by the tool withut first
normalizing, which lead to duplicated paths not being noticed,
which has been corrected.
source: <pull.1221.v2.git.1650911234.gitgitgadget@gmail.com>

* ds/midx-normalize-pathname-before-comparison:
  cache: use const char * for get_object_directory()
  multi-pack-index: use --object-dir real path
  midx: use real paths in lookup_multi_pack_index()

3 years agoMerge branch 'ah/rebase-keep-base-fix' into maint
Junio C Hamano [Wed, 8 Jun 2022 21:27:52 +0000 (14:27 -0700)] 
Merge branch 'ah/rebase-keep-base-fix' into maint

"git rebase --keep-base <upstream> <branch-to-rebase>" computed the
commit to rebase onto incorrectly, which has been corrected.
source: <20220421044233.894255-1-alexhenrie24@gmail.com>

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

3 years agoMerge branch 'pw/test-malloc-with-sanitize-address' into maint
Junio C Hamano [Wed, 8 Jun 2022 21:27:52 +0000 (14:27 -0700)] 
Merge branch 'pw/test-malloc-with-sanitize-address' into maint

Avoid problems from interaction between malloc_check and address
sanitizer.
source: <pull.1210.git.1649507317350.gitgitgadget@gmail.com>

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

3 years agoMerge branch 'rs/commit-summary-wo-break-rewrite' into maint
Junio C Hamano [Wed, 8 Jun 2022 21:27:52 +0000 (14:27 -0700)] 
Merge branch 'rs/commit-summary-wo-break-rewrite' into maint

The commit summary shown after making a commit is matched to what
is given in "git status" not to use the break-rewrite heuristics.
source: <c35bd0aa-2e46-e710-2b39-89f18bad0097@web.de>

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

3 years agoMerge branch 'mg/detect-compiler-in-c-locale' into maint
Junio C Hamano [Wed, 8 Jun 2022 21:27:52 +0000 (14:27 -0700)] 
Merge branch 'mg/detect-compiler-in-c-locale' into maint

Build procedure fixup.
source: <f306f43f375bc9b9c98e85260587442e5d9ef0ba.1652094958.git.git@grubix.eu>

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

3 years agoMerge branch 'cb/ci-make-p4-optional' into maint
Junio C Hamano [Wed, 8 Jun 2022 21:27:51 +0000 (14:27 -0700)] 
Merge branch 'cb/ci-make-p4-optional' into maint

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.
source: <20220512223940.238367-1-gitster@pobox.com>

* 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

3 years agoMerge branch 'ab/valgrind-fixes' into maint
Junio C Hamano [Wed, 8 Jun 2022 21:27:51 +0000 (14:27 -0700)] 
Merge branch 'ab/valgrind-fixes' into maint

A bit of test framework fixes with a few fixes to issues found by
valgrind.
source: <20220512223218.237544-1-gitster@pobox.com>

* 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

3 years agoMerge branch 'jc/archive-add-file-normalize-mode' into maint
Junio C Hamano [Wed, 8 Jun 2022 21:27:51 +0000 (14:27 -0700)] 
Merge branch 'jc/archive-add-file-normalize-mode' into maint

"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).
source: <xmqqmtfme8v6.fsf@gitster.g>

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

3 years agoMerge branch 'jc/show-branch-g-current' into maint
Junio C Hamano [Wed, 8 Jun 2022 21:27:51 +0000 (14:27 -0700)] 
Merge branch 'jc/show-branch-g-current' into maint

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.
source: <xmqqh76mf7s4.fsf_-_@gitster.g>

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

3 years agoMerge branch 'jc/update-ozlabs-url' into maint
Junio C Hamano [Wed, 8 Jun 2022 21:27:50 +0000 (14:27 -0700)] 
Merge branch 'jc/update-ozlabs-url' into maint

Update URL to the gitk repository.

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

3 years agoMerge branch 'jc/http-clear-finished-pointer' into maint
Junio C Hamano [Wed, 8 Jun 2022 21:27:50 +0000 (14:27 -0700)] 
Merge branch 'jc/http-clear-finished-pointer' into maint

Meant to go with js/ci-gcc-12-fixes.
source: <xmqq7d68ytj8.fsf_-_@gitster.g>

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

3 years agoMerge branch 'js/ci-gcc-12-fixes' into maint
Junio C Hamano [Wed, 8 Jun 2022 21:27:50 +0000 (14:27 -0700)] 
Merge branch 'js/ci-gcc-12-fixes' into maint

Fixes real problems noticed by gcc 12 and works around false
positives.
source: <pull.1238.git.1653351786.gitgitgadget@gmail.com>

* 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

3 years agoconfig: document and test the 'worktree' scope
Glen Choo [Tue, 7 Jun 2022 21:24:04 +0000 (21:24 +0000)] 
config: document and test the 'worktree' scope

Test that "git config --show-scope" shows the "worktree" scope, and add
it to the list of scopes in Documentation/git-config.txt.

"git config --help" does not need to be updated because it already
mentions "worktree".

Signed-off-by: Glen Choo <chooglen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agococci: retire is_null_sha1() rule
Junio C Hamano [Tue, 7 Jun 2022 21:50:50 +0000 (14:50 -0700)] 
cocci: retire is_null_sha1() rule

Since 8d4d86b0 (cache: remove null_sha1, 2019-08-18) removed the
is_null_sha1() function, rewrite rules to correct callers of the
function to use is_null_oid() instead has become irrelevant, as any
new callers of the function will get caught by the compiler much
more quickly without spending cycles on Coccinelle.

Remove these rules.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoEighth batch
Junio C Hamano [Tue, 7 Jun 2022 21:11:05 +0000 (14:11 -0700)] 
Eighth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'jc/all-negative-pathspec'
Junio C Hamano [Tue, 7 Jun 2022 21:10:59 +0000 (14:10 -0700)] 
Merge branch 'jc/all-negative-pathspec'

A git subcommand like "git add -p" spawns a separate git process
while relaying its command line arguments.  A pathspec with only
negative elements was mistakenly passed with an empty string, which
has been corrected.

* jc/all-negative-pathspec:
  pathspec: correct an empty string used as a pathspec element

3 years agoMerge branch 'js/scalar-diagnose'
Junio C Hamano [Tue, 7 Jun 2022 21:10:57 +0000 (14:10 -0700)] 
Merge branch 'js/scalar-diagnose'

Implementation of "scalar diagnose" subcommand.

* js/scalar-diagnose:
  scalar: teach `diagnose` to gather loose objects information
  scalar: teach `diagnose` to gather packfile info
  scalar diagnose: include disk space information
  scalar: implement `scalar diagnose`
  scalar: validate the optional enlistment argument
  archive --add-virtual-file: allow paths containing colons
  archive: optionally add "virtual" files

3 years agoMerge branch 'rs/document-archive-prefix'
Junio C Hamano [Tue, 7 Jun 2022 21:10:57 +0000 (14:10 -0700)] 
Merge branch 'rs/document-archive-prefix'

The documentation on the interaction between "--add-file" and
"--prefix" options of "git archive" has been improved.

* rs/document-archive-prefix:
  archive: improve documentation of --prefix

3 years agoMerge branch 'fh/transport-push-leakfix'
Junio C Hamano [Tue, 7 Jun 2022 21:10:57 +0000 (14:10 -0700)] 
Merge branch 'fh/transport-push-leakfix'

Leakfix.

* fh/transport-push-leakfix:
  transport: free local and remote refs in transport_push()
  transport: unify return values and exit point from transport_push()
  transport: remove unnecessary indenting in transport_push()

3 years agoMerge branch 'js/ci-github-workflow-markup'
Junio C Hamano [Tue, 7 Jun 2022 21:10:57 +0000 (14:10 -0700)] 
Merge branch 'js/ci-github-workflow-markup'

Update the GitHub workflow support to make it quicker to get to the
failing test.

* js/ci-github-workflow-markup:
  ci: call `finalize_test_case_output` a little later
  ci(github): mention where the full logs can be found
  ci: use `--github-workflow-markup` in the GitHub workflow
  ci(github): avoid printing test case preamble twice
  ci(github): skip the logs of the successful test cases
  ci: optionally mark up output in the GitHub workflow
  ci/run-build-and-tests: add some structure to the GitHub workflow output
  ci: make it easier to find failed tests' logs in the GitHub workflow
  ci/run-build-and-tests: take a more high-level view
  test(junit): avoid line feeds in XML attributes
  tests: refactor --write-junit-xml code
  ci: fix code style

3 years agoMerge branch 'ab/plug-leak-in-revisions'
Junio C Hamano [Tue, 7 Jun 2022 21:10:56 +0000 (14:10 -0700)] 
Merge branch 'ab/plug-leak-in-revisions'

Plug the memory leaks from the trickiest API of all, the revision
walker.

* ab/plug-leak-in-revisions: (27 commits)
  revisions API: add a TODO for diff_free(&revs->diffopt)
  revisions API: have release_revisions() release "topo_walk_info"
  revisions API: have release_revisions() release "date_mode"
  revisions API: call diff_free(&revs->pruning) in revisions_release()
  revisions API: release "reflog_info" in release revisions()
  revisions API: clear "boundary_commits" in release_revisions()
  revisions API: have release_revisions() release "prune_data"
  revisions API: have release_revisions() release "grep_filter"
  revisions API: have release_revisions() release "filter"
  revisions API: have release_revisions() release "cmdline"
  revisions API: have release_revisions() release "mailmap"
  revisions API: have release_revisions() release "commits"
  revisions API users: use release_revisions() for "prune_data" users
  revisions API users: use release_revisions() with UNLEAK()
  revisions API users: use release_revisions() in builtin/log.c
  revisions API users: use release_revisions() in http-push.c
  revisions API users: add "goto cleanup" for release_revisions()
  stash: always have the owner of "stash_info" free it
  revisions API users: use release_revisions() needing REV_INFO_INIT
  revision.[ch]: document and move code declared around "init"
  ...

3 years agoMerge branch 'yw/cmake-updates'
Junio C Hamano [Tue, 7 Jun 2022 21:10:56 +0000 (14:10 -0700)] 
Merge branch 'yw/cmake-updates'

CMake updates.

* yw/cmake-updates:
  cmake: remove (_)UNICODE def on Windows in CMakeLists.txt
  cmake: add pcre2 support
  cmake: fix CMakeLists.txt on Linux

3 years agorun-command: don't spam trace2_child_exit()
Josh Steadmon [Tue, 7 Jun 2022 18:21:57 +0000 (11:21 -0700)] 
run-command: don't spam trace2_child_exit()

In rare cases[1], wait_or_whine() cannot determine a child process's
status (and will return -1 in this case). This can cause Git to issue
trace2 child_exit events despite the fact that the child may still be
running. In pathological cases, we've seen > 80 million exit events in
our trace logs for a single child process.

Fix this by only issuing trace2 events in finish_command_in_signal() if
we get a value other than -1 from wait_or_whine(). This can lead to
missing child_exit events in such a case, but that is preferable to
duplicating events on a scale that threatens to fill the user's
filesystem with invalid trace logs.

[1]: This can happen when:

* waitpid() returns -1 and errno != EINTR
* waitpid() returns an invalid PID
* the status set by waitpid() has neither the WIFEXITED() nor
  WIFSIGNALED() flags

Signed-off-by: Josh Steadmon <steadmon@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agohook API: fix v2.36.0 regression: hooks should be connected to a TTY
Ævar Arnfjörð Bjarmason [Tue, 7 Jun 2022 08:48:20 +0000 (10:48 +0200)] 
hook API: fix v2.36.0 regression: hooks should be connected to a TTY

Fix a regression reported[1] against f443246b9f2 (commit: convert
{pre-commit,prepare-commit-msg} hook to hook.h, 2021-12-22): Due to
using the run_process_parallel() API in the earlier 96e7225b310 (hook:
add 'run' subcommand, 2021-12-22) we'd capture the hook's stderr and
stdout, and thus lose the connection to the TTY in the case of
e.g. the "pre-commit" hook.

As a preceding commit notes GNU parallel's similar --ungroup option
also has it emit output faster. While we're unlikely to have hooks
that emit truly massive amounts of output (or where the performance
thereof matters) it's still informative to measure the overhead. In a
similar "seq" test we're now ~30% faster:

$ cat .git/hooks/seq-hook; git hyperfine -L rev origin/master,HEAD~0 -s 'make CFLAGS=-O3' './git hook run seq-hook'
#!/bin/sh

seq 100000000
Benchmark 1: ./git hook run seq-hook' in 'origin/master
  Time (mean ± σ):     787.1 ms ±  13.6 ms    [User: 701.6 ms, System: 534.4 ms]
  Range (min … max):   773.2 ms … 806.3 ms    10 runs

Benchmark 2: ./git hook run seq-hook' in 'HEAD~0
  Time (mean ± σ):     603.4 ms ±   1.6 ms    [User: 573.1 ms, System: 30.3 ms]
  Range (min … max):   601.0 ms … 606.2 ms    10 runs

Summary
  './git hook run seq-hook' in 'HEAD~0' ran
    1.30 ± 0.02 times faster than './git hook run seq-hook' in 'origin/master'

1. https://lore.kernel.org/git/CA+dzEBn108QoMA28f0nC8K21XT+Afua0V2Qv8XkR8rAeqUCCZw@mail.gmail.com/

Reported-by: Anthony Sottile <asottile@umich.edu>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
[jc: minor fix-up to tests for consistency]
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoremote.c: don't dereference NULL in freeing loop
Ævar Arnfjörð Bjarmason [Tue, 7 Jun 2022 15:50:04 +0000 (17:50 +0200)] 
remote.c: don't dereference NULL in freeing loop

Fix a bug in fd3cb0501e1 (remote: move static variables into
per-repository struct, 2021-11-17) where we'd free(remote->pushurl[i])
after having NULL'd out remote->pushurl. itself. We free
"remote->pushurl" in the next "for"-loop, so doing this appears to
have been a copy/paste error.

Before this change GCC 12's -fanalyzer would correctly note that we'd
dereference NULL in this case, this change fixes that:

remote.c: In function ‘remote_clear’:
remote.c:153:17: error: dereference of NULL ‘*remote.pushurl’ [CWE-476] [-Werror=analyzer-null-dereference]
  153 |                 free((char *)remote->pushurl[i]);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      [...]

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoremote.c: remove braces from one-statement "for"-loops
Ævar Arnfjörð Bjarmason [Tue, 7 Jun 2022 15:50:03 +0000 (17:50 +0200)] 
remote.c: remove braces from one-statement "for"-loops

Remove braces that don't follow the CodingGuidelines from code added
in fd3cb0501e1 (remote: move static variables into per-repository
struct, 2021-11-17). A subsequent commit will edit code adjacent to
this.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorun-command: add an "ungroup" option to run_process_parallel()
Ævar Arnfjörð Bjarmason [Tue, 7 Jun 2022 08:48:19 +0000 (10:48 +0200)] 
run-command: add an "ungroup" option to run_process_parallel()

Extend the parallel execution API added in c553c72eed6 (run-command:
add an asynchronous parallel child processor, 2015-12-15) to support a
mode where the stdout and stderr of the processes isn't captured and
output in a deterministic order, instead we'll leave it to the kernel
and stdio to sort it out.

This gives the API same functionality as GNU parallel's --ungroup
option. As we'll see in a subsequent commit the main reason to want
this is to support stdout and stderr being connected to the TTY in the
case of jobs=1, demonstrated here with GNU parallel:

$ parallel --ungroup 'test -t {} && echo TTY || echo NTTY' ::: 1 2
TTY
TTY
$ parallel 'test -t {} && echo TTY || echo NTTY' ::: 1 2
NTTY
NTTY

Another is as GNU parallel's documentation notes a potential for
optimization. As demonstrated in next commit our results with "git
hook run" will be similar, but generally speaking this shows that if
you want to run processes in parallel where the exact order isn't
important this can be a lot faster:

$ hyperfine -r 3 -L o ,--ungroup 'parallel {o} seq ::: 10000000 >/dev/null '
Benchmark 1: parallel  seq ::: 10000000 >/dev/null
  Time (mean ± σ):     220.2 ms ±   9.3 ms    [User: 124.9 ms, System: 96.1 ms]
  Range (min … max):   212.3 ms … 230.5 ms    3 runs

Benchmark 2: parallel --ungroup seq ::: 10000000 >/dev/null
  Time (mean ± σ):     154.7 ms ±   0.9 ms    [User: 136.2 ms, System: 25.1 ms]
  Range (min … max):   153.9 ms … 155.7 ms    3 runs

Summary
  'parallel --ungroup seq ::: 10000000 >/dev/null ' ran
    1.42 ± 0.06 times faster than 'parallel  seq ::: 10000000 >/dev/null '

A large part of the juggling in the API is to make the API safer for
its maintenance and consumers alike.

For the maintenance of the API we e.g. avoid malloc()-ing the
"pp->pfd", ensuring that SANITIZE=address and other similar tools will
catch any unexpected misuse.

For API consumers we take pains to never pass the non-NULL "out"
buffer to an API user that provided the "ungroup" option. The
resulting code in t/helper/test-run-command.c isn't typical of such a
user, i.e. they'd typically use one mode or the other, and would know
whether they'd provided "ungroup" or not.

We could also avoid the strbuf_init() for "buffered_output" by having
"struct parallel_processes" use a static PARALLEL_PROCESSES_INIT
initializer, but let's leave that cleanup for later.

Using a global "run_processes_parallel_ungroup" variable to enable
this option is rather nasty, but is being done here to produce as
minimal of a change as possible for a subsequent regression fix. This
change is extracted from a larger initial version[1] which ends up
with a better end-state for the API, but in doing so needed to modify
all existing callers of the API. Let's defer that for now, and
narrowly focus on what we need for fixing the regression in the
subsequent commit.

It's safe to do this with a global variable because:

 A) hook.c is the only user of it that sets it to non-zero, and before
    we'll get any other API users we'll refactor away this method of
    passing in the option, i.e. re-roll [1].

 B) Even if hook.c wasn't the only user we don't have callers of this
    API that concurrently invoke this parallel process starting API
    itself in parallel.

As noted above "A" && "B" are rather nasty, and we don't want to live
with those caveats long-term, but for now they should be an acceptable
compromise.

1. https://lore.kernel.org/git/cover-v2-0.8-00000000000-20220518T195858Z-avarab@gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agofsmonitor: query watchman with right valid json
Son Luong Ngoc [Tue, 7 Jun 2022 11:14:19 +0000 (13:14 +0200)] 
fsmonitor: query watchman with right valid json

In rare circumstances where the current git index does not carry the
last_update_token, the fsmonitor v2 hook will be invoked with an
empty string which would caused the final rendered json to be invalid.

  ["query", "/path/to/my/git/repository/", {
          "since": ,
          "fields": ["name"],
          "expression": ["not", ["dirname", ".git"]]
  }]

Which will left user with the following error message

  > git status
  failed to parse command from stdin: line 2, column 13, position 67: unexpected token near ','
  Watchman: command returned no output.
  Falling back to scanning...

Hide the "since" field in json query when "last_update_token" is empty.

Co-authored-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Son Luong Ngoc <sluongng@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agogit-prompt: make colourization consistent
Joakim Petersen [Tue, 7 Jun 2022 11:50:24 +0000 (13:50 +0200)] 
git-prompt: make colourization consistent

The short upstream state indicator inherits the colour of the last short
state indicator before it (if there is one), and the sparsity state
indicator inherits this colour as well. This behaviour was introduced by
0ec7c23cdc6 (git-prompt: make upstream state indicator location
consistent, 2022-02-27), while before this change the aforementioned
indicators were white/the default text colour. Some examples to
illustrate this behaviour (assuming all indicators are enabled and
colourization is on):
 * If there is something in the stash, both the '$' and the short
   upstream state indicator following it will be blue.
 * If the local tree has new, untracked files and there is nothing in
   the stash, both the '%' and the short upstream state indicator
   will be red.
 * If all local changes are added to the index and the stash is empty,
   both the '+' and the short upstream state indicator following it will
   be green.
 * If the local tree is clean and there is nothing in the stash, the
   short upstream state indicator will be white/${default text colour}.

This appears to be an unintended side-effect of the change, and makes
little sense semantically (e.g. why is it bad to be in sync with
upstream when you have uncommitted local changes?). The cause of the
change in colourization is that previously, the short upstream state
indicator appeared immediately after the rebase/revert/bisect/merge
state indicator (note the position of $p in $gitstring):

local f="$h$w$i$s$u"
local gitstring="$c$b${f:+$z$f}${sparse}$r$p"

Said indicator is prepended with the clear colour code, and the short
upstream state indicator is thus also uncoloured. Now, the short
upstream state indicator follows the sequence of colourized indicators,
without any clearing of colour (again note the position of $p, now in
$f):

local f="$h$w$i$s$u$p"
local gitstring="$c$b${f:+$z$f}${sparse}$r${upstream}"

If the user is in a sparse checkout, the sparsity state indicator
follows a similar pattern to the short upstream state indicator.
However, clearing colour of the colourized indicators changes how the
sparsity state indicator is colourized, as it currently inherits (and
before the change referenced also inherited) the colour of the last
short state indicator before it. Reading the commit message of the
change that introduced the sparsity state indicator, afda36dbf3b
(git-prompt: include sparsity state as well, 2020-06-21), it appears
this colourization also was unintended, so clearing the colour for said
indicator further increases consistency.

Make the colourization of these state indicators consistent by making
all colourized indicators clear their own colour. Make colouring of $c
dependent on it not being empty, as it is no longer being used to colour
the branch name. Move clearing of $b's prefix to before colourization so
it gets cleared properly when colour codes are inserted into it. These
changes make changing the layout of the prompt less prone to unintended
colour changes in the future.

Change coloured Bash prompt tests to reflect the colourization changes:
 * Move the colour codes to wrap the expected content of the expanded
   $__git_ps1_branch_name in all tests.
 * Insert a clear-colour code after the symbol for the first indicator
   in "prompt - bash color pc mode - dirty status indicator - dirty
   index and worktree", to reflect that all indicators should clear
   their own colour.

Signed-off-by: Joakim Petersen <joak-pet@online.no>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorange-diff: show submodule changes irrespective of diff.submodule
Philippe Blain [Mon, 6 Jun 2022 20:59:13 +0000 (20:59 +0000)] 
range-diff: show submodule changes irrespective of diff.submodule

After generating diffs for each range to be compared using a 'git log'
invocation, range-diff.c::read_patches looks for the "diff --git" header
in those diffs to recognize the beginning of a new change.

In a project with submodules, and with 'diff.submodule=log' set in the
config, this header is missing for the diff of a changed submodule, so
any submodule changes are quietly ignored in the range-diff.

When 'diff.submodule=diff' is set in the config, the "diff --git" header
is also missing for the submodule itself, but is shown for submodule
content changes, which can easily confuse 'git range-diff' and lead to
errors such as:

    error: git apply: bad git-diff - inconsistent old filename on line 1
    error: could not parse git header 'diff --git path/to/submodule/and/some/file/within
    '
    error: could not parse log for '@{u}..@{1}'

Force the submodule diff format to its default ("short") when invoking
'git log' to generate the patches for each range, such that submodule
changes are always detected.

Add a test, including an invocation with '--creation-factor=100' to
force the second commit in the range not to be considered a complete
rewrite, in order to verify we do indeed get the "short" format.

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>