]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
12 months agoMerge branch 'bc/clone-empty-repo-via-protocol-v0'
Junio C Hamano [Fri, 19 May 2023 16:27:06 +0000 (09:27 -0700)] 
Merge branch 'bc/clone-empty-repo-via-protocol-v0'

The server side of "git clone" now advertises the necessary hints
to clients to help them to clone from an empty repository and learn
object hash algorithm and the (unborn) branch pointed at by HEAD,
even over the older v0/v1 protocol.

* bc/clone-empty-repo-via-protocol-v0:
  upload-pack: advertise capabilities when cloning empty repos

12 months agoMerge branch 'jc/send-email-pre-process-fix'
Junio C Hamano [Fri, 19 May 2023 16:27:06 +0000 (09:27 -0700)] 
Merge branch 'jc/send-email-pre-process-fix'

When "git send-email" that uses the validate hook is fed a message
without and then with Message-ID, it failed to auto-assign a unique
Message-ID to the former and instead reused the Message-ID from the
latter, which has been corrected.  This was a fix for a recent
regression caught before the release, so no need to mention it in
the release notes.

* jc/send-email-pre-process-fix:
  t9001: mark the script as no longer leak checker clean
  send-email: clear the $message_id after validation

12 months agoMerge branch 'tb/run-command-needs-alloc-h'
Junio C Hamano [Fri, 19 May 2023 16:27:06 +0000 (09:27 -0700)] 
Merge branch 'tb/run-command-needs-alloc-h'

Fix the build problem with NO_PTHREADS defined, a fallout from
recent header file shuffling.

* tb/run-command-needs-alloc-h:
  run-command.c: fix missing include under `NO_PTHREADS`

12 months agot9001: mark the script as no longer leak checker clean
Junio C Hamano [Wed, 17 May 2023 21:10:39 +0000 (14:10 -0700)] 
t9001: mark the script as no longer leak checker clean

The test uses "format-patch --thread" which is known to leak the
generated message ID list.

Plugging these leaks involves straightening out the memory ownership
rules around rev_info.message_id and rev_info.ref_message_ids, and
is beyond the scope of send-email fix, so for now mark the test as
leaky to unblock the topic before the release.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agosend-email: clear the $message_id after validation
Junio C Hamano [Wed, 17 May 2023 21:10:39 +0000 (14:10 -0700)] 
send-email: clear the $message_id after validation

Recently git-send-email started parsing the same message twice, once
to validate _all_ the message before sending even the first one, and
then after the validation hook is happy and each message gets sent,
to read the contents to find out where to send to etc.

Unfortunately, the effect of reading the messages for validation
lingered even after the validation is done.  Namely $message_id gets
assigned if exists in the input files but the variable is global,
and it is not cleared before pre_process_file runs.  This causes
reading a message without a message-id followed by reading a message
with a message-id to misbehave---the sub reports as if the message
had the same id as the previously written one.

Clear the variable before starting to read the headers in
pre_process_file.

Tested-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoupload-pack: advertise capabilities when cloning empty repos
brian m. carlson [Wed, 17 May 2023 19:24:43 +0000 (19:24 +0000)] 
upload-pack: advertise capabilities when cloning empty repos

When cloning an empty repository, protocol versions 0 and 1 currently
offer nothing but the header and flush packets for the /info/refs
endpoint. This means that no capabilities are provided, so the client
side doesn't know what capabilities are present.

However, this does pose a problem when working with SHA-256
repositories, since we use the capabilities to know the remote side's
object format (hash algorithm).  As of 8b214c2e9d ("clone: propagate
object-format when cloning from void", 2023-04-05), this has been fixed
for protocol v2, since there we always read the hash algorithm from the
remote.

Fortunately, the push version of the protocol already indicates a clue
for how to solve this.  When the /info/refs endpoint is accessed for a
push and the remote is empty, we include a dummy "capabilities^{}" ref
pointing to the all-zeros object ID.  The protocol documentation already
indicates this should _always_ be sent, even for fetches and clones, so
let's just do that, which means we'll properly announce the hash
algorithm as part of the capabilities.  This just works with the
existing code because we share the same ref code for fetches and clones,
and libgit2, JGit, and dulwich do as well.

There is one minor issue to fix, though.  If we called send_ref with
namespaces, we would return NULL with the capabilities entry, which
would cause a crash.  Instead, let's refactor out a function to print
just the ref itself without stripping the namespace and use it for our
special capabilities entry.

Add several sets of tests for HTTP as well as for local clones.  The
behavior can be slightly different for HTTP versus a local or SSH clone
because of the stateless-rpc functionality, so it's worth testing both.

Signed-off-by: brian m. carlson <bk2204@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoA bit more before -rc1
Junio C Hamano [Wed, 17 May 2023 17:13:09 +0000 (10:13 -0700)] 
A bit more before -rc1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoMerge branch 'jc/attr-source-tree'
Junio C Hamano [Wed, 17 May 2023 17:11:41 +0000 (10:11 -0700)] 
Merge branch 'jc/attr-source-tree'

"git --attr-source=<tree> cmd $args" is a new way to have any
command to read attributes not from the working tree but from the
given tree object.

* jc/attr-source-tree:
  attr: teach "--attr-source=<tree>" global option to "git"

12 months agoimap-send: include strbuf.h
Christian Hesse [Wed, 17 May 2023 07:06:32 +0000 (09:06 +0200)] 
imap-send: include strbuf.h

We make liberal use of the strbuf API functions and types, but the
inclusion of <strbuf.h> comes indirectly by including <http.h>,
which does not happen if you build with NO_CURL.

Signed-off-by: Christian Hesse <mail@eworm.de>
Helped-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agorun-command.c: fix missing include under `NO_PTHREADS`
Taylor Blau [Tue, 16 May 2023 21:33:43 +0000 (17:33 -0400)] 
run-command.c: fix missing include under `NO_PTHREADS`

Git 2.41-rc0 fails to compile run-command.c with `NO_PTHREADS` defined,
i.e.

  $ make NO_PTHREADS=1 run-command.o

as `ALLOC_GROW()` macro is used in the `atexit()` emulation but the
macro definition is not available.

This bisects to 36bf195890 (alloc.h: move ALLOC_GROW() functions from
cache.h, 2023-02-24), which replaced includes of <cache.h> with
<alloc.h>, which is the new home of `ALLOC_GROW()` (and
`ALLOC_GROW_BY()`).

We can see that run-command.c is the only one that try to use these
macros without including <alloc.h>.

  $ git grep -l -e '[^_]ALLOC_GROW(' -e 'ALLOC_GROW_BY(' \*.c | sort >/tmp/1
  $ git grep -l 'alloc\.h' \*.c | sort >/tmp/2
  $ comm -23 /tmp/[12]
  compat/simple-ipc/ipc-unix-socket.c
  run-command.c

The "compat/" file only talks about the macro in the comment,
and is not broken.

We could fix this by conditionally including "alloc.h" when
`NO_PTHREADS` is defined.  But we have relatively few examples of
conditional includes throughout the tree[^1].

Instead, include "alloc.h" unconditionally in run-command.c to allow it
to successfully compile even when NO_PTHREADS is defined.

[^1]: With `git grep -E -A1 '#if(n)?def' -- **/*.c | grep '#include' -B1`.

Reported-by: Randall S. Becker <randall.becker@nexbridge.ca>
Co-authored-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoGit 2.41-rc0 v2.41.0-rc0
Junio C Hamano [Mon, 15 May 2023 20:58:34 +0000 (13:58 -0700)] 
Git 2.41-rc0

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoMerge branch 'ps/fetch-output-format'
Junio C Hamano [Mon, 15 May 2023 20:59:07 +0000 (13:59 -0700)] 
Merge branch 'ps/fetch-output-format'

"git fetch" learned the "--porcelain" option that emits what it did
in a machine-parseable format.

* ps/fetch-output-format:
  fetch: introduce machine-parseable "porcelain" output format
  fetch: move option related variables into main function
  fetch: lift up parsing of "fetch.output" config variable
  fetch: introduce `display_format` enum
  fetch: refactor calculation of the display table width
  fetch: print left-hand side when fetching HEAD:foo
  fetch: add a test to exercise invalid output formats
  fetch: split out tests for output format
  fetch: fix `--no-recurse-submodules` with multi-remote fetches

12 months agoMerge branch 'sg/retire-unused-cocci'
Junio C Hamano [Mon, 15 May 2023 20:59:06 +0000 (13:59 -0700)] 
Merge branch 'sg/retire-unused-cocci'

Retire a rather expensive-to-run Coccinelle check patch.

* sg/retire-unused-cocci:
  cocci: remove 'unused.cocci'

12 months agoMerge branch 'sl/diff-files-sparse'
Junio C Hamano [Mon, 15 May 2023 20:59:06 +0000 (13:59 -0700)] 
Merge branch 'sl/diff-files-sparse'

Teach "diff-files" not to expand sparse-index unless needed.

* sl/diff-files-sparse:
  diff-files: integrate with sparse index
  t1092: add tests for `git diff-files`

12 months agoMerge branch 'ds/merge-tree-use-config'
Junio C Hamano [Mon, 15 May 2023 20:59:06 +0000 (13:59 -0700)] 
Merge branch 'ds/merge-tree-use-config'

Allow git forges to disable replace-refs feature while running "git
merge-tree".

* ds/merge-tree-use-config:
  merge-tree: load default git config

12 months agoMerge branch 'js/subtree-fully-spelt-quiet-and-debug-options'
Junio C Hamano [Mon, 15 May 2023 20:59:06 +0000 (13:59 -0700)] 
Merge branch 'js/subtree-fully-spelt-quiet-and-debug-options'

"git subtree" (in contrib/) update.

* js/subtree-fully-spelt-quiet-and-debug-options:
  subtree: support long global flags

12 months agoMerge branch 'ar/test-cleanup-unused-file-creation'
Junio C Hamano [Mon, 15 May 2023 20:59:06 +0000 (13:59 -0700)] 
Merge branch 'ar/test-cleanup-unused-file-creation'

Test fix.

* ar/test-cleanup-unused-file-creation:
  test: rev-parse-upstream: add missing cmp

12 months agoMerge branch 'jk/test-verbose-no-more'
Junio C Hamano [Mon, 15 May 2023 20:59:05 +0000 (13:59 -0700)] 
Merge branch 'jk/test-verbose-no-more'

Retire "verbose" helper function from the test framework.

* jk/test-verbose-no-more:
  t: drop "verbose" helper function
  t7001: use "ls-files --format" instead of "cut"
  t7001: avoid git on upstream of pipe

12 months agoMerge branch 'tl/push-branches-is-an-alias-for-all'
Junio C Hamano [Mon, 15 May 2023 20:59:05 +0000 (13:59 -0700)] 
Merge branch 'tl/push-branches-is-an-alias-for-all'

"git push --all" gained an alias "git push --branches".

* tl/push-branches-is-an-alias-for-all:
  t5583: fix shebang line
  push: introduce '--branches' option

12 months agoMerge branch 'jc/name-rev-deprecate-stdin-further'
Junio C Hamano [Mon, 15 May 2023 20:59:05 +0000 (13:59 -0700)] 
Merge branch 'jc/name-rev-deprecate-stdin-further'

The "--stdin" option of "git name-rev" has been replaced with
the "--annotate-stdin" option more than a year ago.  We stop
advertising it in the "git name-rev -h" output.

* jc/name-rev-deprecate-stdin-further:
  name-rev: make --stdin hidden

12 months agoMerge branch 'jc/t9800-fix-use-of-show-s-raw'
Junio C Hamano [Mon, 15 May 2023 20:59:05 +0000 (13:59 -0700)] 
Merge branch 'jc/t9800-fix-use-of-show-s-raw'

A test fix.

* jc/t9800-fix-use-of-show-s-raw:
  t9800: correct misuse of 'show -s --raw' in a test

12 months agoMerge branch 'jc/dirstat-plug-leaks'
Junio C Hamano [Mon, 15 May 2023 20:59:04 +0000 (13:59 -0700)] 
Merge branch 'jc/dirstat-plug-leaks'

"git diff --dirstat" leaked memory, which has been plugged.

* jc/dirstat-plug-leaks:
  diff: plug leaks in dirstat
  diff: refactor common tail part of dirstat computation

12 months agoMerge branch 'ds/fsck-bitmap'
Junio C Hamano [Mon, 15 May 2023 20:59:04 +0000 (13:59 -0700)] 
Merge branch 'ds/fsck-bitmap'

"git fsck" learned to detect bit-flip breakages in the reachability
bitmap files.

* ds/fsck-bitmap:
  fsck: use local repository
  fsck: verify checksums of all .bitmap files

12 months agoMerge branch 'js/gitk-fixes-from-gfw'
Junio C Hamano [Mon, 15 May 2023 20:59:04 +0000 (13:59 -0700)] 
Merge branch 'js/gitk-fixes-from-gfw'

Gitk updates from GfW project.

* js/gitk-fixes-from-gfw:
  gitk: escape file paths before piping to git log
  gitk: prevent overly long command lines

12 months agoMerge branch 'fc/doc-use-datestamp-in-commit'
Junio C Hamano [Mon, 15 May 2023 20:59:04 +0000 (13:59 -0700)] 
Merge branch 'fc/doc-use-datestamp-in-commit'

An earlier change broke "doc-diff", which has been corrected.

* fc/doc-use-datestamp-in-commit:
  doc-diff: drop SOURCE_DATE_EPOCH override
  doc: doc-diff: specify date

12 months agoMerge branch 'ar/config-count-tests-updates'
Junio C Hamano [Mon, 15 May 2023 20:59:04 +0000 (13:59 -0700)] 
Merge branch 'ar/config-count-tests-updates'

Test updates.

* ar/config-count-tests-updates:
  t1300: add tests for missing keys
  t1300: check stderr for "ignores pairs" tests
  t1300: drop duplicate test

12 months agoMerge branch 'kh/doc-interpret-trailers-updates'
Junio C Hamano [Mon, 15 May 2023 20:59:03 +0000 (13:59 -0700)] 
Merge branch 'kh/doc-interpret-trailers-updates'

Doc update.

* kh/doc-interpret-trailers-updates:
  doc: interpret-trailers: fix example
  doc: interpret-trailers: don’t use deprecated config
  doc: interpret-trailers: use input redirection
  doc: interpret-trailers: don’t use heredoc in examples

12 months agoMerge branch 'gc/trace-bare-repo-setup'
Junio C Hamano [Mon, 15 May 2023 20:59:03 +0000 (13:59 -0700)] 
Merge branch 'gc/trace-bare-repo-setup'

The tracing mechanism learned to notice and report when
auto-discovered bare repositories are being used, as allowing so
without explicitly stating the user intends to do so (with setting
GIT_DIR for example) can be used with social engineering as an
attack vector.

* gc/trace-bare-repo-setup:
  setup: trace bare repository setups

12 months agoMerge branch 'mc/send-email-header-cmd'
Junio C Hamano [Mon, 15 May 2023 20:59:03 +0000 (13:59 -0700)] 
Merge branch 'mc/send-email-header-cmd'

"git send-email" learned "--header-cmd=<cmd>" that can inject
arbitrary e-mail header lines to the outgoing messages.

* mc/send-email-header-cmd:
  send-email: detect empty blank lines in command output
  send-email: add --header-cmd, --no-header-cmd options
  send-email: extract execute_cmd from recipients_cmd

12 months agoMerge branch 'jc/doc-clarify-git-default-hash-variable'
Junio C Hamano [Mon, 15 May 2023 20:59:03 +0000 (13:59 -0700)] 
Merge branch 'jc/doc-clarify-git-default-hash-variable'

The documentation was misleading about the interaction between
GIT_DEFAULT_HASH and "git clone", which has been clarified to
stress that the variable is to be ignored by the command.

* jc/doc-clarify-git-default-hash-variable:
  doc: GIT_DEFAULT_HASH is and will be ignored during "clone"

12 months agoMerge branch 'rj/branch-unborn-in-other-worktrees'
Junio C Hamano [Mon, 15 May 2023 20:59:02 +0000 (13:59 -0700)] 
Merge branch 'rj/branch-unborn-in-other-worktrees'

Error messages given when working on an unborn branch that is
checked out in another worktree have been improved.

* rj/branch-unborn-in-other-worktrees:
  branch: avoid unnecessary worktrees traversals
  branch: rename orphan branches in any worktree
  branch: description for orphan branch errors
  branch: use get_worktrees() in copy_or_rename_branch()
  branch: test for failures while renaming branches

12 months agot5583: fix shebang line
Elijah Newren [Fri, 12 May 2023 15:09:16 +0000 (15:09 +0000)] 
t5583: fix shebang line

The shebang was missing the leading `/` character, resulting in:

    $ ./t5583-push-branches.sh
    bash: ./t5583-push-branches.sh: cannot execute: required file not found

Add the missing character so the test can run.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoMerge branch 'mh/credential-password-expiry-wincred'
Junio C Hamano [Thu, 11 May 2023 19:16:16 +0000 (12:16 -0700)] 
Merge branch 'mh/credential-password-expiry-wincred'

Teach the recently invented "password expiry time" trait to the
wincred credential helper.

* mh/credential-password-expiry-wincred:
  credential/wincred: store password_expiry_utc

12 months agoMerge branch 'mh/use-wincred-from-system'
Junio C Hamano [Thu, 11 May 2023 19:16:15 +0000 (12:16 -0700)] 
Merge branch 'mh/use-wincred-from-system'

Code clean-up.

* mh/use-wincred-from-system:
  credential/wincred: include wincred.h

12 months agomerge-tree: load default git config
Derrick Stolee [Wed, 10 May 2023 19:07:34 +0000 (19:07 +0000)] 
merge-tree: load default git config

The 'git merge-tree' command handles creating root trees for merges
without using the worktree. This is a critical operation in many Git
hosts, as they typically store bare repositories.

This builtin does not load the default Git config, which can have
several important ramifications.

In particular, one config that is loaded by default is
core.useReplaceRefs. This is typically disabled in Git hosts due to
the ability to spoof commits in strange ways.

Since this config is not loaded specifically during merge-tree, users
were previously able to use refs/replace/ references to make pull
requests that looked valid but introduced malicious content. The
resulting merge commit would have the correct commit history, but the
malicious content would exist in the root tree of the merge.

The fix is simple: load the default Git config in cmd_merge_tree().
This may also fix other behaviors that are effected by reading default
config. The only possible downside is a little extra computation time
spent reading config. The config parsing is placed after basic argument
parsing so it does not slow down usage errors.

Helped-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agofetch: introduce machine-parseable "porcelain" output format
Patrick Steinhardt [Wed, 10 May 2023 12:34:36 +0000 (14:34 +0200)] 
fetch: introduce machine-parseable "porcelain" output format

The output of git-fetch(1) is obviously designed for consumption by
users, only: we neatly columnize data, we abbreviate reference names, we
print neat arrows and we don't provide information about actual object
IDs that have changed. This makes the output format basically unusable
in the context of scripted invocations of git-fetch(1) that want to
learn about the exact changes that the command performs.

Introduce a new machine-parseable "porcelain" output format that is
supposed to fix this shortcoming. This output format is intended to
provide information about every reference that is about to be updated,
the old object ID that the reference has been pointing to and the new
object ID it will be updated to. Furthermore, the output format provides
the same flags as the human-readable format to indicate basic conditions
for each reference update like whether it was a fast-forward update, a
branch deletion, a rejected update or others.

The output format is quite simple:

```
<flag> <old-object-id> <new-object-id> <local-reference>\n
```

We assume two conditions which are generally true:

    - The old and new object IDs have fixed known widths and cannot
      contain spaces.

    - References cannot contain newlines.

With these assumptions, the output format becomes unambiguously
parseable. Furthermore, given that this output is designed to be
consumed by scripts, the machine-readable data is printed to stdout
instead of stderr like the human-readable output is. This is mostly done
so that other data printed to stderr, like error messages or progress
meters, don't interfere with the parseable data.

A notable ommission here is that the output format does not include the
remote from which a reference was fetched, which might be important
information especially in the context of multi-remote fetches. But as
such a format would require us to print the remote for every single
reference update due to parallelizable fetches it feels wasteful for the
most likely usecase, which is when fetching from a single remote.

In a similar spirit, a second restriction is that this cannot be used
with `--recurse-submodules`. This is because any reference updates would
be ambiguous without also printing the repository in which the update
happens.

Considering that both multi-remote and submodule fetches are user-facing
features, using them in conjunction with `--porcelain` that is intended
for scripting purposes is likely not going to be useful in the majority
of cases. With that in mind these restrictions feel acceptable. If
usecases for either of these come up in the future though it is easy
enough to add a new "porcelain-v2" format that adds this information.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agofetch: move option related variables into main function
Patrick Steinhardt [Wed, 10 May 2023 12:34:32 +0000 (14:34 +0200)] 
fetch: move option related variables into main function

The options of git-fetch(1) which we pass to `parse_options()` are
declared globally in `builtin/fetch.c`. This means we're forced to use
global variables for all the options, which is more likely to cause
confusion than explicitly passing state around.

Refactor the code to move the options into `cmd_fetch()`. Move variables
that were previously forced to be declared globally and which are only
used by `cmd_fetch()` into function-local scope.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agofetch: lift up parsing of "fetch.output" config variable
Patrick Steinhardt [Wed, 10 May 2023 12:34:28 +0000 (14:34 +0200)] 
fetch: lift up parsing of "fetch.output" config variable

Parsing the display format happens inside of `display_state_init()`. As
we only need to check for a simple config entry, this is a natural
location to put this code as it means that display-state logic is neatly
contained in a single location.

We're about to introduce a new "porcelain" output format though that is
intended to be parseable by machines, for example inside of a script.
This format can be enabled by passing the `--porcelain` switch to
git-fetch(1). As a consequence, we'll have to add a second callsite that
influences the output format, which will become awkward to handle.

Refactor the code such that callers are expected to pass the display
format that is to be used into `display_state_init()`. This allows us to
lift up the code into the main function, where we can then hook it into
command line options parser in a follow-up commit.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agofetch: introduce `display_format` enum
Patrick Steinhardt [Wed, 10 May 2023 12:34:24 +0000 (14:34 +0200)] 
fetch: introduce `display_format` enum

We currently have two different display formats in git-fetch(1) with the
"full" and "compact" formats. This is tracked with a boolean value that
simply denotes whether the display format is supposed to be compacted
or not. This works reasonably well while there are only two formats, but
we're about to introduce another format that will make this a bit more
awkward to use.

Introduce a `enum display_format` that is more readily extensible.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agofetch: refactor calculation of the display table width
Patrick Steinhardt [Wed, 10 May 2023 12:34:20 +0000 (14:34 +0200)] 
fetch: refactor calculation of the display table width

When displaying reference updates, we try to print the references in a
neat table. As the table's width is determined its contents we thus need
to precalculate the overall width before we can start printing updated
references.

The calculation is driven by `display_state_init()`, which invokes
`refcol_width()` for every reference that is to be printed. This split
is somewhat confusing. For one, we filter references that shall be
attributed to the overall width in both places. And second, we
needlessly recalculate the maximum line length based on the terminal
columns and display format for every reference.

Refactor the code so that the complete width calculations are neatly
contained in `refcol_width()`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agofetch: print left-hand side when fetching HEAD:foo
Patrick Steinhardt [Wed, 10 May 2023 12:34:15 +0000 (14:34 +0200)] 
fetch: print left-hand side when fetching HEAD:foo

`store_updated_refs()` parses the remote reference for two purposes:

    - It gets used as a note when writing FETCH_HEAD.

    - It is passed through to `display_ref_update()` to display
      updated references in the following format:

      ```
       * branch               master          -> master
      ```

In most cases, the parsed remote reference is the prettified reference
name and can thus be used for both cases. But if the remote reference is
HEAD, the parsed remote reference becomes empty. This is intended when
we write the FETCH_HEAD, where we skip writing the note in that case.
But when displaying the updated references this leads to inconsistent
output where the left-hand side of reference updates is missing in some
cases:

```
$ git fetch origin HEAD HEAD:explicit-head :implicit-head main
From https://github.com/git/git
 * branch                  HEAD       -> FETCH_HEAD
 * [new ref]                          -> explicit-head
 * [new ref]                          -> implicit-head
 * branch                  main       -> FETCH_HEAD
```

This behaviour has existed ever since the table-based output has been
introduced for git-fetch(1) via 165f390250 (git-fetch: more terse fetch
output, 2007-11-03) and was never explicitly documented either in the
commit message or in any of our tests. So while it may not be a bug per
se, it feels like a weird inconsistency and not like it was a concious
design decision.

The logic of how we compute the remote reference name that we ultimately
pass to `display_ref_update()` is not easy to follow. There are three
different cases here:

    - When the remote reference name is "HEAD" we set the remote
      reference name to the empty string. This is the case that causes
      the left-hand side to go missing, where we would indeed want to
      print "HEAD" instead of the empty string. This is what
      `prettify_refname()` would return.

    - When the remote reference name has a well-known prefix then we
      strip this prefix. This matches what `prettify_refname()` does.

    - Otherwise, we keep the fully qualified reference name. This also
      matches what `prettify_refname()` does.

As the return value of `prettify_refname()` would do the correct thing
for us in all three cases, we can thus fix the inconsistency by passing
through the full remote reference name to `display_ref_update()`, which
learns to call `prettify_refname()`. At the same time, this also
simplifies the code a bit.

Note that this patch also changes formatting of the block that computes
the "kind" (which is the category like "branch" or "tag") and "what"
(which is the prettified reference name like "master" or "v1.0")
variables. This is done on purpose so that it is part of the diff,
hopefully making the change easier to comprehend.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agofetch: add a test to exercise invalid output formats
Patrick Steinhardt [Wed, 10 May 2023 12:34:11 +0000 (14:34 +0200)] 
fetch: add a test to exercise invalid output formats

Add a testcase that exercises the logic when an invalid output format is
passed via the `fetch.output` configuration.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agofetch: split out tests for output format
Patrick Steinhardt [Wed, 10 May 2023 12:34:07 +0000 (14:34 +0200)] 
fetch: split out tests for output format

We're about to introduce a new porcelain mode for the output of
git-fetch(1). As part of that we'll be introducing a set of new tests
that only relate to the output of this command.

Split out tests that exercise the output format of git-fetch(1) so that
it becomes easier to verify this functionality as a standalone unit. As
the tests assume that the default branch is called "main" we set up the
corresponding GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME environment variable
accordingly.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agofetch: fix `--no-recurse-submodules` with multi-remote fetches
Patrick Steinhardt [Wed, 10 May 2023 12:34:02 +0000 (14:34 +0200)] 
fetch: fix `--no-recurse-submodules` with multi-remote fetches

When running `git fetch --no-recurse-submodules`, the exectation is that
we don't fetch any submodules. And while this works for fetches of a
single remote, it doesn't when fetching multiple remotes at once. The
result is that we do recurse into submodules even though the user has
explicitly asked us not to.

This is because while we pass on `--recurse-submodules={yes,on-demand}`
if specified by the user, we don't pass on `--no-recurse-submodules` to
the subprocess spawned to perform the submodule fetch.

Fix this by also forwarding this flag as expected.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoThe eighteenth batch
Junio C Hamano [Wed, 10 May 2023 16:14:45 +0000 (09:14 -0700)] 
The eighteenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoMerge branch 'sd/doc-gitignore-and-rm-cached'
Junio C Hamano [Wed, 10 May 2023 17:23:29 +0000 (10:23 -0700)] 
Merge branch 'sd/doc-gitignore-and-rm-cached'

Doc update.

* sd/doc-gitignore-and-rm-cached:
  docs: clarify git rm --cached function in gitignore note

12 months agoMerge branch 'fc/doc-man-lift-title-length-limit'
Junio C Hamano [Wed, 10 May 2023 17:23:29 +0000 (10:23 -0700)] 
Merge branch 'fc/doc-man-lift-title-length-limit'

The titles of manual pages used to be chomped at an unreasonably
short limit, which has been removed.

* fc/doc-man-lift-title-length-limit:
  doc: manpage: remove maximum title length

12 months agoMerge branch 'fc/doc-drop-custom-callout-format'
Junio C Hamano [Wed, 10 May 2023 17:23:29 +0000 (10:23 -0700)] 
Merge branch 'fc/doc-drop-custom-callout-format'

Our custom callout formatter is no longer used in the documentation
formatting toolchain, as the upstream default ones give better
output these days.

* fc/doc-drop-custom-callout-format:
  doc: remove custom callouts format

12 months agoMerge branch 'mh/credential-oauth-refresh-token'
Junio C Hamano [Wed, 10 May 2023 17:23:28 +0000 (10:23 -0700)] 
Merge branch 'mh/credential-oauth-refresh-token'

The credential subsystem learns to help OAuth framework.

* mh/credential-oauth-refresh-token:
  credential: new attribute oauth_refresh_token

12 months agoMerge branch 'ah/doc-attributes-text'
Junio C Hamano [Wed, 10 May 2023 17:23:28 +0000 (10:23 -0700)] 
Merge branch 'ah/doc-attributes-text'

Doc update to clarify how text and eol attributes interact to
specify the end-of-line conversion.

* ah/doc-attributes-text:
  docs: rewrite the documentation of the text and eol attributes

12 months agoMerge branch 'ar/test-cleanup-unused-file-creation-part2'
Junio C Hamano [Wed, 10 May 2023 17:23:28 +0000 (10:23 -0700)] 
Merge branch 'ar/test-cleanup-unused-file-creation-part2'

Test cleanup.

* ar/test-cleanup-unused-file-creation-part2:
  t2019: don't create unused files
  t1502: don't create unused files
  t1450: don't create unused files
  t1300: don't create unused files
  t1300: fix config file syntax error descriptions
  t0300: don't create unused file

12 months agoMerge branch 'ms/send-email-feed-header-to-validate-hook'
Junio C Hamano [Wed, 10 May 2023 17:23:28 +0000 (10:23 -0700)] 
Merge branch 'ms/send-email-feed-header-to-validate-hook'

"git send-email" learned to give the e-mail headers to the validate
hook by passing an extra argument from the command line.

* ms/send-email-feed-header-to-validate-hook:
  send-email: expose header information to git-send-email's sendemail-validate hook
  send-email: refactor header generation functions

12 months agoMerge branch 'hx/negotiator-non-recursive'
Junio C Hamano [Wed, 10 May 2023 17:23:27 +0000 (10:23 -0700)] 
Merge branch 'hx/negotiator-non-recursive'

The implementation of the default "negotiator", used to find common
ancestor over the network for object tranfer, used to be recursive;
it was updated to be iterative to conserve stackspace usage.

* hx/negotiator-non-recursive:
  negotiator/skipping: fix some problems in mark_common()
  negotiator/default: avoid stack overflow

12 months agoMerge branch 'ma/gittutorial-fixes'
Junio C Hamano [Wed, 10 May 2023 17:23:27 +0000 (10:23 -0700)] 
Merge branch 'ma/gittutorial-fixes'

Doc fixes.

* ma/gittutorial-fixes:
  gittutorial: wrap literal examples in backticks
  gittutorial: drop early mention of origin

12 months agoMerge branch 'tb/credential-long-lines'
Junio C Hamano [Wed, 10 May 2023 17:23:27 +0000 (10:23 -0700)] 
Merge branch 'tb/credential-long-lines'

The implementation of credential helpers used fgets() over fixed
size buffers to read protocol messages, causing the remainder of
the folded long line to trigger unexpected behaviour, which has
been corrected.

* tb/credential-long-lines:
  contrib/credential: embiggen fixed-size buffer in wincred
  contrib/credential: avoid fixed-size buffer in libsecret
  contrib/credential: .gitignore libsecret build artifacts
  contrib/credential: remove 'gnome-keyring' credential helper
  contrib/credential: avoid fixed-size buffer in osxkeychain
  t/lib-credential.sh: ensure credential helpers handle long headers
  credential.c: store "wwwauth[]" values in `credential_read()`

12 months agoMerge branch 'rs/test-ctype-eof'
Junio C Hamano [Wed, 10 May 2023 17:23:27 +0000 (10:23 -0700)] 
Merge branch 'rs/test-ctype-eof'

ctype tests have been taught to test EOF, too.

* rs/test-ctype-eof:
  test-ctype: check EOF

12 months agoThe seventeenth batch
Junio C Hamano [Tue, 9 May 2023 22:53:05 +0000 (15:53 -0700)] 
The seventeenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoMerge branch 'ob/t3501-retitle'
Junio C Hamano [Tue, 9 May 2023 23:45:46 +0000 (16:45 -0700)] 
Merge branch 'ob/t3501-retitle'

Retitle a test script with an overly narrow name.

* ob/t3501-retitle:
  t/t3501-revert-cherry-pick.sh: clarify scope of the file

12 months agoMerge branch 'jw/send-email-update-gmail-insn'
Junio C Hamano [Tue, 9 May 2023 23:45:46 +0000 (16:45 -0700)] 
Merge branch 'jw/send-email-update-gmail-insn'

Doc update to drop use of deprecated app-specific password against
gmail.

* jw/send-email-update-gmail-insn:
  send-email docs: Remove mention of discontinued gmail feature

12 months agoMerge branch 'ob/messages-capitalize-exception'
Junio C Hamano [Tue, 9 May 2023 23:45:46 +0000 (16:45 -0700)] 
Merge branch 'ob/messages-capitalize-exception'

Message update.

* ob/messages-capitalize-exception:
  messages: capitalization and punctuation exceptions

12 months agoMerge branch 'ob/sequencer-i18n-fix'
Junio C Hamano [Tue, 9 May 2023 23:45:46 +0000 (16:45 -0700)] 
Merge branch 'ob/sequencer-i18n-fix'

Message update.

* ob/sequencer-i18n-fix:
  sequencer: actually translate report in do_exec()

12 months agoMerge branch 'en/header-split-cache-h-part-2'
Junio C Hamano [Tue, 9 May 2023 23:45:45 +0000 (16:45 -0700)] 
Merge branch 'en/header-split-cache-h-part-2'

More header clean-up.

* en/header-split-cache-h-part-2: (22 commits)
  reftable: ensure git-compat-util.h is the first (indirect) include
  diff.h: reduce unnecessary includes
  object-store.h: reduce unnecessary includes
  commit.h: reduce unnecessary includes
  fsmonitor: reduce includes of cache.h
  cache.h: remove unnecessary headers
  treewide: remove cache.h inclusion due to previous changes
  cache,tree: move basic name compare functions from read-cache to tree
  cache,tree: move cmp_cache_name_compare from tree.[ch] to read-cache.c
  hash-ll.h: split out of hash.h to remove dependency on repository.h
  tree-diff.c: move S_DIFFTREE_IFXMIN_NEQ define from cache.h
  dir.h: move DTYPE defines from cache.h
  versioncmp.h: move declarations for versioncmp.c functions from cache.h
  ws.h: move declarations for ws.c functions from cache.h
  match-trees.h: move declarations for match-trees.c functions from cache.h
  pkt-line.h: move declarations for pkt-line.c functions from cache.h
  base85.h: move declarations for base85.c functions from cache.h
  copy.h: move declarations for copy.c functions from cache.h
  server-info.h: move declarations for server-info.c functions from cache.h
  packfile.h: move pack_window and pack_entry from cache.h
  ...

12 months agoMerge branch 'mh/fix-detect-compilers-with-nondigit-versions'
Junio C Hamano [Tue, 9 May 2023 23:45:45 +0000 (16:45 -0700)] 
Merge branch 'mh/fix-detect-compilers-with-nondigit-versions'

The detect-compilers script to help auto-tweaking the build system
had trouble working with compilers whose version number has extra
suffixes.  The script has been taught that certain suffixes (like
"-win32" in "gcc 10-win32") can be safely stripped as they share
the same features and bugs with the version without the suffix.

* mh/fix-detect-compilers-with-nondigit-versions:
  Handle some compiler versions containing a dash

12 months agoMerge branch 'jk/parse-commit-with-malformed-ident'
Junio C Hamano [Tue, 9 May 2023 23:45:44 +0000 (16:45 -0700)] 
Merge branch 'jk/parse-commit-with-malformed-ident'

The commit object parser has been taught to be a bit more lenient
to parse timestamps on the author/committer line with a malformed
author/committer ident.

* jk/parse-commit-with-malformed-ident:
  parse_commit(): describe more date-parsing failure modes
  parse_commit(): handle broken whitespace-only timestamp
  parse_commit(): parse timestamp from end of line
  t4212: avoid putting git on left-hand side of pipe

12 months agodiff-files: integrate with sparse index
Shuqi Liang [Tue, 9 May 2023 19:42:41 +0000 (15:42 -0400)] 
diff-files: integrate with sparse index

Remove full index requirement for `git diff-files`. Refactor the
ensure_expanded and ensure_not_expanded functions by introducing a
common helper function, ensure_index_state. Add test to ensure the index
is no expanded in `git diff-files`.

The `p2000` tests demonstrate a ~96% execution time reduction for 'git
diff-files' and a ~97% execution time reduction for 'git diff-files'
for a file using a sparse index:

Test                                               before  after
-----------------------------------------------------------------------
2000.94: git diff-files (full-v3)                  0.09    0.08 -11.1%
2000.95: git diff-files (full-v4)                  0.09    0.09 +0.0%
2000.96: git diff-files (sparse-v3)                0.52    0.02 -96.2%
2000.97: git diff-files (sparse-v4)                0.51    0.02 -96.1%
2000.98: git diff-files -- f2/f4/a (full-v3)       0.06    0.07 +16.7%
2000.99: git diff-files -- f2/f4/a (full-v4)       0.08    0.08 +0.0%
2000.100: git diff-files -- f2/f4/a (sparse-v3)    0.46    0.01 -97.8%
2000.101: git diff-files -- f2/f4/a (sparse-v4)    0.51    0.02 -96.1%

Signed-off-by: Shuqi Liang <cheskaqiqi@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agot1092: add tests for `git diff-files`
Shuqi Liang [Tue, 9 May 2023 19:42:40 +0000 (15:42 -0400)] 
t1092: add tests for `git diff-files`

Before integrating the 'git diff-files' builtin with the sparse index
feature, add tests to t1092-sparse-checkout-compatibility.sh to ensure
it currently works with sparse-checkout and will still work with sparse
index after that integration.

When adding tests against a sparse-checkout definition, we test two
modes: all changes are within the sparse-checkout cone and some changes
are outside the sparse-checkout cone.

In order to have staged changes outside of the sparse-checkout cone,
make a directory called 'folder1' and copy `a` into 'folder1/a'.
'folder1/a' is identical to `a` in the base commit. These make
'folder1/a' in the index, while leaving it outside of the
sparse-checkout definition. Change content inside 'folder1/a' in order
to test 'folder1/a' being present on-disk with modifications.

Signed-off-by: Shuqi Liang <cheskaqiqi@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agotest: rev-parse-upstream: add missing cmp
Felipe Contreras [Tue, 9 May 2023 00:02:46 +0000 (18:02 -0600)] 
test: rev-parse-upstream: add missing cmp

It seems pretty clear 5236fce6b4 (t1507: stop losing return codes of git
commands, 2019-12-20) missed a test_cmp.

Cc: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agot: drop "verbose" helper function
Jeff King [Mon, 8 May 2023 19:04:57 +0000 (15:04 -0400)] 
t: drop "verbose" helper function

We have a small helper function called "verbose", with the idea that you
can write:

  verbose foo

to get a message to stderr when the "foo" command fails, even if it does
not produce any output itself. This goes back to 8ad1652418 (t5304: use
helper to report failure of "test foo = bar", 2014-10-10). It does work,
but overall it has not been a big success for two reasons:

  1. Test writers have to remember to put it there (and the resulting
     test code is longer as a result).

  2. It doesn't handle the opposite case (we expect "foo" to fail, but
     it succeeds), leading to inconsistencies in tests (which you can
     see in many hunks of this patch, e.g. ones involving "has_cr").

Most importantly, we added a136f6d8ff (test-lib.sh: support -x option
for shell-tracing, 2014-10-10) at the same time, and it does roughly the
same thing. The output is not quite as succinct as "verbose", and you
have to watch out for stray shell-traces ending up in stderr. But it
solves both of the problems above, and has clearly become the preferred
tool.

Let's consider the "verbose" function a failed experiment and remove the
last few callers (which are all many years old, and have been dwindling
as we remove them from scripts we touch for other reasons). It will be
one less thing for new test writers to see and wonder if they should be
using themselves.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agot7001: use "ls-files --format" instead of "cut"
Jeff King [Mon, 8 May 2023 19:01:46 +0000 (15:01 -0400)] 
t7001: use "ls-files --format" instead of "cut"

Since ls-files recently learned a "--format" option, we can use that
rather than asking for all of "--stage" and then pulling out the bits we
want with "cut". That's simpler and avoids two extra processes (one for
cut, and one for the subshell to hold the intermediate result).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agot7001: avoid git on upstream of pipe
Jeff King [Mon, 8 May 2023 19:01:12 +0000 (15:01 -0400)] 
t7001: avoid git on upstream of pipe

We generally avoid git on the left-hand side of a pipe, because it loses
the exit code of the command (and thus we'd miss things like segfaults
or unexpected failures). In the cases in t7001, we wouldn't expect
failures (they are just inspecting the repository state, and are not the
main point of the test), but it doesn't hurt to be careful.

In all but one case here we're piping "ls-files --stage" to cut off the
pathname (since we compare entries before and after moving). Let's pull
that into a helper function to avoid repeating the slightly awkward
replacement.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoMerge gitk changes into js/gitk-fixes-from-gfw
Junio C Hamano [Mon, 8 May 2023 16:16:57 +0000 (09:16 -0700)] 
Merge gitk changes into js/gitk-fixes-from-gfw

* .tmp-gitk:
  gitk: escape file paths before piping to git log
  gitk: prevent overly long command lines

12 months agogitk: escape file paths before piping to git log
Nico Rieck [Tue, 24 Jan 2023 11:23:17 +0000 (11:23 +0000)] 
gitk: escape file paths before piping to git log

We just started piping the file paths via `stdin` instead of passing
them via the command-line, to avoid running into command-line
limitations.

However, since we now pipe the file paths, we need to take care of
special characters.

This fixes https://github.com/git-for-windows/git/issues/2293

Signed-off-by: Nico Rieck <nico.rieck@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agogitk: prevent overly long command lines
Johannes Schindelin [Tue, 24 Jan 2023 11:23:16 +0000 (11:23 +0000)] 
gitk: prevent overly long command lines

To avoid running into command line limitations, some of Git's commands
support the `--stdin` option.

Let's use exactly this option in the three rev-list/log invocations in
gitk that would otherwise possibly run the danger of trying to invoke a
too-long command line.

While it is easy to redirect either stdin or stdout in Tcl/Tk scripts,
what we need here is both. We need to capture the output, yet we also
need to pipe in the revs/files arguments via stdin (because stdin does
not have any limit, unlike the command line). To help this, we use the
neat Tcl feature where you can capture stdout and at the same time feed
a fixed string as stdin to the spawned process.

One non-obvious aspect about this change is that the `--stdin` option
allows to specify revs, the double-dash, and files, but *no* other
options such as `--not`. This is addressed by prefixing the "negative"
revs with `^` explicitly rather than relying on the `--not` option
(thanks for coming up with that idea, Max!).

This fixes https://github.com/git-for-windows/git/issues/1987

Analysis-and-initial-patch-by: Max Kirillov <max@max630.net>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agosubtree: support long global flags
Josh Soref [Sun, 7 May 2023 03:09:48 +0000 (03:09 +0000)] 
subtree: support long global flags

The documentation at e75d1da38a claimed support, but it was never present

Signed-off-by: Josh Soref <jsoref@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agopush: introduce '--branches' option
Teng Long [Sat, 6 May 2023 11:34:08 +0000 (19:34 +0800)] 
push: introduce '--branches' option

The '--all' option of git-push built-in cmd support to push all branches
(refs under refs/heads) to remote. Under the usage, a user can easlily
work in some scenarios, for example, branches synchronization and batch
upload.

The '--all' was introduced for a long time, meanwhile, git supports to
customize the storage location under "refs/". when a new git user see
the usage like, 'git push origin --all', we might feel like we're
pushing _all_ the refs instead of just branches without looking at the
documents until we found the related description of it or '--mirror'.

To ensure compatibility, we cannot rename '--all' to another name
directly, one way is, we can try to add a new option '--heads' which be
identical with the functionality of '--all' to let the user understand
the meaning of representation more clearly. Actually, We've more or less
named options this way already, for example, in 'git-show-ref' and 'git
ls-remote'.

At the same time, we fix a related issue about the wrong help
information of '--all' option in code and add some test cases in
t5523, t5543 and t5583.

Signed-off-by: Teng Long <dyroneteng@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoattr: teach "--attr-source=<tree>" global option to "git"
John Cai [Sat, 6 May 2023 04:15:29 +0000 (04:15 +0000)] 
attr: teach "--attr-source=<tree>" global option to "git"

Earlier, 47cfc9bd (attr: add flag `--source` to work with tree-ish,
2023-01-14) taught "git check-attr" the "--source=<tree>" option to
allow it to read attribute files from a tree-ish, but did so only
for the command.  Just like "check-attr" users wanted a way to use
attributes from a tree-ish and not from the working tree files,
users of other commands (like "git diff") would benefit from the
same.

Undo most of the UI change the commit made, while keeping the
internal logic to read attributes from a given tree-ish. Expose the
internal logic via a new "--attr-source=<tree>" command line option
given to "git", so that it can be used with any git command that
runs as part of the main git process.

Additionally, add an environment variable GIT_ATTR_SOURCE that is set
when --attr-source is passed in, so that subprocesses use the same value
for the attributes source tree.

Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoname-rev: make --stdin hidden
John Cai [Sat, 6 May 2023 04:14:11 +0000 (04:14 +0000)] 
name-rev: make --stdin hidden

In 34ae3b70 (name-rev: deprecate --stdin in favor of --annotate-stdin),
we renamed --stdin to --annotate-stdin for the sake of a clearer name
for the option, and added text that indicates --stdin is deprecated. The
next step is to hide --stdin completely.

Make the option hidden. Also, update documentation to remove all
mentions of --stdin.

Signed-off-by: "John Cai" <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agot9800: correct misuse of 'show -s --raw' in a test
Junio C Hamano [Sat, 6 May 2023 21:29:55 +0000 (14:29 -0700)] 
t9800: correct misuse of 'show -s --raw' in a test

There is $(git show -s --raw --pretty=format:%at HEAD) in this test
that is meant to grab the author time of the commit.  We used to
have a bug in the command line option parser of the diff family of
commands, where "show -s --raw" was identical to "show -s".

With the "-s" bug fixed, "show -s --raw" would mean the same thing
as "show --raw", i.e. show the output from the diff machinery in the
"raw" format.  And this test will start failing, so fix it before
that happens.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agodoc-diff: drop SOURCE_DATE_EPOCH override
Jeff King [Fri, 5 May 2023 21:16:10 +0000 (17:16 -0400)] 
doc-diff: drop SOURCE_DATE_EPOCH override

The original doc-diff script set SOURCE_DATE_EPOCH to make asciidoc's
output deterministic. Otherwise, the mtime of the source files would end
up in the footer of the manpage, causing noisy and uninteresting diff
hunks.

But this has been unused since 28fde3a1f4 (doc: set actual revdate for
manpages, 2023-04-13), as the footer uses the externally-specified
GIT_DATE instead (that needs to be set consistently, too, which it now
is as of the previous commit).

Asciidoc sets several automatic attributes based on the mtime (or manual
epoch), so it's still possible to write a document that would need
SOURCE_DATE_EPOCH set to be deterministic. But if we wrote such a thing,
it's probably a mistake, and we're better off having doc-diff loudly
show it.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agodiff: plug leaks in dirstat
Junio C Hamano [Fri, 5 May 2023 21:19:17 +0000 (14:19 -0700)] 
diff: plug leaks in dirstat

The array of dirstat_file contained in the dirstat_dir structure is
not freed after the processing ends.  Unfortunately, the member that
points at the array, .files, is incremented as the gather_dirstat()
function recursively walks it, and this needs to be plugged by
remembering the beginning of the array before gather_dirstat() mucks
with it and freeing it after we are done.

We can mark t4047 as leak-free.  t4000, which is marked as
leak-free, now can exercise dirstat in it, which will happen next.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agodiff: refactor common tail part of dirstat computation
Junio C Hamano [Fri, 5 May 2023 21:19:16 +0000 (14:19 -0700)] 
diff: refactor common tail part of dirstat computation

This will become useful when we plug leaks in these two functions.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agodoc: doc-diff: specify date
Felipe Contreras [Wed, 3 May 2023 23:23:49 +0000 (17:23 -0600)] 
doc: doc-diff: specify date

Earlier we changed the manual page formatting machinery to use the
dates from the commit the documentation source was taken from,
instead of the date the manual page was produced.  When "doc-diff"
compares two commits from different dates, the different dates from
the two commits would result in unnecessary differences in the
output because of the change.

Compensate by setting a fixed date when "doc-diff" formats the pages
to be compared to work around this issue.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agodocs: clarify git rm --cached function in gitignore note
Sohom Datta [Wed, 3 May 2023 21:46:40 +0000 (21:46 +0000)] 
docs: clarify git rm --cached function in gitignore note

Explain to users that the step to untrack a file will not also prevent them
from getting added in the future.

Signed-off-by: Sohom Datta <sohom.datta@learner.manipal.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agodoc: manpage: remove maximum title length
Felipe Contreras [Wed, 3 May 2023 17:16:58 +0000 (11:16 -0600)] 
doc: manpage: remove maximum title length

DocBook Stylesheets limit the size of the manpage titles for some
reason.

Even some of the longest git commands have no trouble fitting in 80
character terminals, so it's not clear why we would want to limit titles
to 20 characters, especially when modern terminals are much bigger.

For example:

  --- a/git-credential-cache--daemon.1
  +++ b/git-credential-cache--daemon.1
  @@ -1,4 +1,4 @@
  -GIT-CREDENTIAL-CAC(1)             Git Manual             GIT-CREDENTIAL-CAC(1)
  +GIT-CREDENTIAL-CACHE--DAEMON(1)   Git Manual   GIT-CREDENTIAL-CACHE--DAEMON(1)

   NAME
          git-credential-cache--daemon - Temporarily store user credentials in
  @@ -24,4 +24,4 @@ DESCRIPTION
   GIT
          Part of the git(1) suite

  -Git omitted                       2023-05-02             GIT-CREDENTIAL-CAC(1)
  +Git omitted                       2023-05-02   GIT-CREDENTIAL-CACHE--DAEMON(1)

Moreover, asciidoctor manpage backend doesn't limit the title length, so
we probably want to do the same for docbook backends for consistency.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agodocs: rewrite the documentation of the text and eol attributes
Alex Henrie [Wed, 3 May 2023 04:46:56 +0000 (22:46 -0600)] 
docs: rewrite the documentation of the text and eol attributes

These two sentences are confusing because the description of the text
attribute sounds exactly the same as the description of the text=auto
attribute:

"Setting the text attribute on a path enables end-of-line normalization"

"When text is set to "auto", the path is marked for automatic
end-of-line conversion"

Unless the reader is already familiar with the two variants, there's a
high probability that they will think that "end-of-line normalization"
is the same thing as "automatic end-of-line conversion".

It's also not clear that the phrase "When the file has been committed
with CRLF, no conversion is done" in the paragraph for text=auto does
not apply equally to the bare text attribute which is described earlier.
Moreover, it falsely implies that normalization is only suppressed if
the file has been committed. In fact, running `git add` on a CRLF file,
adding the text=auto attribute to the file, and running `git add` again
does not do anything to the line endings either.

On top of that, in several places the documentation for the eol
attribute sounds like either it does not affect normalization on checkin
or it forces normalization on checkin. It also sounds like setting eol
(or setting a config variable) is required to turn on conversion on
checkout, but the text attribute can turn on conversion on checkout by
itself if eol is unspecified.

Rephrase the documentation of text, text=auto, eol, eol=crlf, and eol=lf
to be clear about how they are the same, how they are different, and in
what cases conversion is performed.

Helped-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agot2019: don't create unused files
Andrei Rybak [Mon, 17 Apr 2023 19:10:44 +0000 (21:10 +0200)] 
t2019: don't create unused files

Tests in t2019-checkout-ambiguous-ref.sh redirect two invocations of
"git checkout" to files "stdout" and "stderr".  Several assertions are
made using file "stderr".  File "stdout", however, is unused.

Don't redirect standard output of "git checkout" to file "stdout" in
t2019-checkout-ambiguous-ref.sh to avoid creating unnecessary files.

Signed-off-by: Andrei Rybak <rybak.a.v@gmail.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agot1502: don't create unused files
Andrei Rybak [Mon, 17 Apr 2023 19:10:43 +0000 (21:10 +0200)] 
t1502: don't create unused files

Three tests in file t1502-rev-parse-parseopt.sh use three redirections
with invocation of "git rev-parse --parseopt --".  All three tests
redirect standard output to file "out" and file "spec" to standard
input.  Two of the tests redirect standard output a second time to file
"actual", and the third test redirects standard error to file "err".
These tests check contents of files "actual" and "err", but don't use
the files named "out" for assertions.  The two tests that redirect to
standard output twice might also be confusing to the reader.

Don't redirect standard output of "git rev-parse" to file "out" in
t1502-rev-parse-parseopt.sh to avoid creating unnecessary files.

Acked-by: Øystein Walle <oystwa@gmail.com>
Signed-off-by: Andrei Rybak <rybak.a.v@gmail.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agot1450: don't create unused files
Andrei Rybak [Mon, 17 Apr 2023 19:10:42 +0000 (21:10 +0200)] 
t1450: don't create unused files

Test 'fsck error and recovery on invalid object type' in file
t1450-fsck.sh redirects output of a failing "git fsck" invocation to
files "out" and "err" to assert presence of error messages in the output
of the command.  Commit 31deb28f5e (fsck: don't hard die on invalid
object types, 2021-10-01) changed the way assertions in this test are
performed.  The test doesn't compare the whole standard error with
prepared file "err.expect" and it doesn't assert that standard output is
empty.

Don't create unused files "err.expect" and "out" in test 'fsck error and
recovery on invalid object type'.

Signed-off-by: Andrei Rybak <rybak.a.v@gmail.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agot1300: don't create unused files
Andrei Rybak [Mon, 17 Apr 2023 19:10:41 +0000 (21:10 +0200)] 
t1300: don't create unused files

Three tests in t1300-config.sh check that "git config --get" barfs when
syntax errors are present in the config file.  The tests redirect
standard output and standard error of "git config --get" to files,
"actual" and "error" correspondingly.  They assert presence of an error
message in file "error".  However, these tests don't use file "actual"
for assertions.

Don't redirect standard output of "git config --get" to file "actual" in
t1300-config.sh to avoid creating unnecessary files.

Signed-off-by: Andrei Rybak <rybak.a.v@gmail.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agot1300: fix config file syntax error descriptions
Andrei Rybak [Mon, 17 Apr 2023 19:10:40 +0000 (21:10 +0200)] 
t1300: fix config file syntax error descriptions

Three tests in t1300-config.sh check that "git config --get" barfs when
the config file contains various syntax errors: key=value pair without
equals sign, broken section line, and broken value string.  The sample
config files include a comment describing the kind of broken syntax.
This description seems to have been copy-pasted from the "broken section
line" sample to the other two samples.

Fix descriptions of broken config file syntax in samples used in
t1300-config.sh.

Signed-off-by: Andrei Rybak <rybak.a.v@gmail.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agot0300: don't create unused file
Andrei Rybak [Mon, 17 Apr 2023 19:10:39 +0000 (21:10 +0200)] 
t0300: don't create unused file

Test 'credential config with partial URLs' in t0300-credentials.sh
contains three "git credential fill" invocations.  For two of the
invocations, the test asserts presence or absence of string "yep" in the
standard output.  For the third test it checks for an error message in
standard error.

Don't redirect standard output of "git credential" to file "stdout" in
t0300-credentials.sh to avoid creating an unnecessary file when only
standard error is checked.

Signed-off-by: Andrei Rybak <rybak.a.v@gmail.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agodoc: remove custom callouts format
Felipe Contreras [Tue, 18 Apr 2023 01:18:28 +0000 (19:18 -0600)] 
doc: remove custom callouts format

The code to render callouts for manpages comes from 17 years ago:
776e994af5 (Properly render asciidoc "callouts" in git man pages.,
2006-04-28), and it was needed back then, but DocBook Stylesheets added
support for that in 2008 [1], since 1.74.0 it hasn't been necessary.

What's worse: the format of the upstream callouts is much nicer than our
hacked version.

Compare this:

     $ git diff            (1)
     $ git diff --cached   (2)
     $ git diff HEAD       (3)

  1. Changes in the working tree not yet staged for the next
     commit.
  2. Changes between the index and your last commit; what you
     would be committing if you run git commit without -a
     option.
  3. Changes in the working tree since your last commit; what
     you would be committing if you run git commit -a

To this:

     $ git diff            (1)
     $ git diff --cached   (2)
     $ git diff HEAD       (3)

 1. Changes in the working tree not yet staged for the next commit.
 2. Changes between the index and your last commit; what you would
 be committing if you run git commit without -a option.
 3. Changes in the working tree since your last commit; what you
 would be committing if you run git commit -a

Let's drop our unnecessary inferior custom format and use the official
one.

[1] https://sourceforge.net/p/docbook/code/7842/

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoThe sixteenth batch
Junio C Hamano [Tue, 2 May 2023 17:13:50 +0000 (10:13 -0700)] 
The sixteenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoMerge branch 'tb/ban-strtok'
Junio C Hamano [Tue, 2 May 2023 17:13:35 +0000 (10:13 -0700)] 
Merge branch 'tb/ban-strtok'

Mark strtok() and strtok_r() to be banned.

* tb/ban-strtok:
  banned.h: mark `strtok()` and `strtok_r()` as banned
  t/helper/test-json-writer.c: avoid using `strtok()`
  t/helper/test-oidmap.c: avoid using `strtok()`
  t/helper/test-hashmap.c: avoid using `strtok()`
  string-list: introduce `string_list_setlen()`
  string-list: multi-delimiter `string_list_split_in_place()`

12 months agoMerge branch 'jk/blame-fake-commit-label'
Junio C Hamano [Tue, 2 May 2023 17:13:34 +0000 (10:13 -0700)] 
Merge branch 'jk/blame-fake-commit-label'

The output given by "git blame" that attributes a line to contents
taken from the file specified by the "--contents" option shows it
differently from a line attributed to the working tree file.

* jk/blame-fake-commit-label:
  blame: use different author name for fake commit generated by --contents

12 months agoMerge branch 'jk/misc-null-check-fixes'
Junio C Hamano [Tue, 2 May 2023 17:13:34 +0000 (10:13 -0700)] 
Merge branch 'jk/misc-null-check-fixes'

Code clean-up.

* jk/misc-null-check-fixes:
  fetch_bundle_uri(): drop pointless NULL check
  notes: clean up confusing NULL checks in init_notes()

12 months agoMerge branch 'en/ort-finalize-after-0-merges-fix'
Junio C Hamano [Tue, 2 May 2023 17:13:34 +0000 (10:13 -0700)] 
Merge branch 'en/ort-finalize-after-0-merges-fix'

A small API fix to the ort merge strategy backend.

* en/ort-finalize-after-0-merges-fix:
  merge-ort: fix calling merge_finalize() with no intermediate merge

12 months agoMerge branch 'ek/completion-use-read-r-to-read-literally'
Junio C Hamano [Tue, 2 May 2023 17:13:34 +0000 (10:13 -0700)] 
Merge branch 'ek/completion-use-read-r-to-read-literally'

The completion script used to use bare "read" without the "-r"
option to read the contents of various state files, which risked
getting confused with backslashes in them.  This has been
corrected.

* ek/completion-use-read-r-to-read-literally:
  completion: suppress unwanted unescaping of `read`

12 months agotest-ctype: check EOF
René Scharfe [Mon, 1 May 2023 19:51:57 +0000 (21:51 +0200)] 
test-ctype: check EOF

The character classifiers are supposed to allow passing EOF to them, a
negative value.  It isn't part of any character class.  Extend the tests
to cover that.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agofsck: use local repository
Derrick Stolee [Tue, 2 May 2023 13:27:22 +0000 (13:27 +0000)] 
fsck: use local repository

In 0d30feef3c5 (fsck: create scaffolding for rev-index checks,
2023-04-17) and later 5a6072f631d (fsck: validate .rev file header,
2023-04-17), the check_pack_rev_indexes() method was created with a
'struct repository *r' parameter. However, this parameter was unused and
instead 'the_repository' was used in its place.

Fix this situation with the obvious replacement.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>