Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
876029b
branch: add --forked filter for --list mode
HaraldNordgren Aug 5, 2026
7969faa
branch: convert delete_branches() to a flags argument
HaraldNordgren Aug 5, 2026
cdbcde9
branch: let delete_branches skip unmerged branches on bulk refusal
HaraldNordgren Aug 5, 2026
5e528a3
branch: prepare delete_branches for a bulk caller
HaraldNordgren Aug 5, 2026
15bcdf4
branch: add --delete-merged <pattern>
HaraldNordgren Aug 5, 2026
3d1f0df
branch: add branch.<name>.deleteMerged opt-out
HaraldNordgren Aug 5, 2026
25285a6
branch: add --dry-run for --delete-merged
HaraldNordgren Aug 5, 2026
ca57102
loose: load loose object map for the correct source
pks-t Aug 7, 2026
8a1ba94
setup: detangle loading of loose object maps
pks-t Aug 7, 2026
30bc6f0
setup: handle ODB-related environment variables in `odb_new()`
pks-t Aug 7, 2026
c1d233b
setup: defer object database creation
pks-t Aug 7, 2026
335fe25
odb/source: introduce function to map source type to name
pks-t Aug 7, 2026
e927cfe
odb: make creation of on-disk structures pluggable
pks-t Aug 7, 2026
bc27e75
doc: interpret-trailers: stop fixating on RFC 822
LemmingAvalanche Aug 9, 2026
abb0d85
doc: interpret-trailers: replace “lines” with “metadata”
LemmingAvalanche Aug 9, 2026
500257f
doc: interpret-trailers: use “metadata” in Name as well
LemmingAvalanche Aug 9, 2026
33691bc
doc: interpret-trailers: not just for commit messages
LemmingAvalanche Aug 9, 2026
c88d60d
doc: interpret-trailers: explain the format after the intro
LemmingAvalanche Aug 9, 2026
fd39e5a
doc: interpret-trailers: explain key format
LemmingAvalanche Aug 9, 2026
fddec1f
doc: interpret-trailers: add key format example
LemmingAvalanche Aug 9, 2026
1e4200e
doc: interpret-trailers: join new-trailers again
LemmingAvalanche Aug 9, 2026
4d45e57
doc: interpret-trailers: commit to “trailer block” term
LemmingAvalanche Aug 9, 2026
cb65736
doc: interpret-trailers: rewrite new-trailers paragraphs
LemmingAvalanche Aug 9, 2026
4515c86
doc: interpret-trailers: document comment line treatment
LemmingAvalanche Aug 9, 2026
006933a
Merge branch 'hn/branch-delete-merged'
gitster Aug 20, 2026
2f66146
Merge branch 'ps/odb-make-creation-pluggable'
gitster Aug 20, 2026
3f66491
Merge branch 'kh/doc-trailers'
gitster Aug 20, 2026
1a3e64c
The 16th batch
gitster Aug 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Documentation/RelNotes/2.56.0.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ UI, Workflows & Features
automatically run 'git bisect reset' to jump back to the original
state or to the found culprit.

* The 'git branch' command has been taught the '--delete-merged' option
to remove local branches that are already merged into their tracked
remote-tracking branches.


Performance, Internal Implementation, Development Support etc.
--------------------------------------------------------------
Expand Down Expand Up @@ -371,6 +375,12 @@ Performance, Internal Implementation, Development Support etc.
Calls to write(3p) in send_sideband() and cat_blob() have been
refactored to use writev(3p) wrappers to reduce syscall overhead.

* The creation of the on-disk data structures for the object database
has been made pluggable, allowing future backends to customize their
setup. As part of this, the initialization of the object database
has been deferred, and the loading of the loose-object map has been
detangled from repository initialization.


Fixes since v2.55
-----------------
Expand Down Expand Up @@ -596,3 +606,9 @@ Fixes since v2.55
* Documentation for 'git replay' has been updated to refer to its
configuration variables.
(merge 48c0549f5c kh/doc-replay-config later to maint).

* Documentation for 'git interpret-trailers' has been updated to explain
the format of trailer keys (alphanumeric characters and hyphens),
replace outdated terminology, define key terms upfront, and document
how comment lines in the input are treated.
(merge 4515c86fd9 kh/doc-trailers later to maint).
7 changes: 7 additions & 0 deletions Documentation/config/branch.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,10 @@ for details).
`git branch --edit-description`. Branch description is
automatically added to the `format-patch` cover letter or
`request-pull` summary.

`branch.<name>.deleteMerged`::
If set to `false`, branch _<name>_ is exempt from
`git branch --delete-merged`. Useful for a topic branch you
intend to develop further after an initial round has been
merged upstream. Defaults to true. Explicit deletion via
`git branch -d` is unaffected.
52 changes: 51 additions & 1 deletion Documentation/git-branch.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ git branch [--color[=<when>] | --no-color] [--show-current]
[--column[=<options>] | --no-column] [--sort=<key>]
[--merged [<commit>]] [--no-merged [<commit>]]
[--contains [<commit>]] [--no-contains [<commit>]]
[(--forked <branch>)...]
[--points-at <object>] [--format=<format>]
[(-r|--remotes) | (-a|--all)]
[--list] [<pattern>...]
Expand All @@ -24,6 +25,7 @@ git branch (-m|-M) [<old-branch>] <new-branch>
git branch (-c|-C) [<old-branch>] <new-branch>
git branch (-d|-D) [-r] <branch-name>...
git branch --edit-description [<branch-name>]
git branch [--dry-run] (--delete-merged <pattern>)... [<branch-pattern>...]

DESCRIPTION
-----------
Expand Down Expand Up @@ -51,7 +53,8 @@ merged into the named commit (i.e. the branches whose tip commits are
reachable from the named commit) will be listed. With `--no-merged` only
branches not merged into the named commit will be listed. If the _<commit>_
argument is missing it defaults to `HEAD` (i.e. the tip of the current
branch).
branch). With `--forked`, only branches whose configured upstream matches
the given branch or pattern will be listed.

The command's second form creates a new branch head named _<branch-name>_
which points to the current `HEAD`, or _<start-point>_ if given. As a
Expand Down Expand Up @@ -199,6 +202,45 @@ This option is only applicable in non-verbose mode.
Print the name of the current branch. In detached `HEAD` state,
nothing is printed.

`--delete-merged <pattern>`::
Delete local branches whose configured upstream matches
_<pattern>_, but only when their tip is reachable from that
upstream. In other words, the work on the branch has already
landed on the upstream it tracks, so the local copy is no longer
needed. _<pattern>_ may name a ref, a remote (using the branch its
`HEAD` points at), or a shell-style glob. The option can be
repeated to widen the upstream match.
Optional _<branch-pattern>_ arguments limit which local branches
are considered, e.g. `git branch --delete-merged 'origin/*'
'topic-*'`.
+
A branch is not deleted when:
+
--
* its configured upstream ref no longer exists,
* it is checked out in any worktree,
* pushing it to the remote configured by
`branch.<name>.remote` would update its upstream, so it cannot be
distinguished from a branch that just looks fully merged right
after a pull; this is determined by the remote's configured push and
fetch refspecs,
* it is the local upstream of a branch that is not being deleted, or
* `branch.<name>.deleteMerged` is set to `false`.
--
+
When such a local upstream branch has its own upstream deleted by the
same operation, its upstream configuration is cleared.
+
A branch whose work has not yet been merged into its upstream is
silently skipped. Delete it with `git branch -D` if you want to
remove it anyway.

`--dry-run`::
With `--delete-merged`, print which branches would be
deleted and exit without touching any ref. Useful for
sanity-checking a wide pattern like `'origin/*'` before
committing to the deletion.

`-v`::
`-vv`::
`--verbose`::
Expand Down Expand Up @@ -311,6 +353,14 @@ superproject's "origin/main", but tracks the submodule's "origin/main".
Only list branches whose tips are not reachable from
_<commit>_ (`HEAD` if not specified). Implies `--list`.

`--forked <branch>`::
Only list branches whose configured upstream matches
_<branch>_. The argument can be a ref (e.g. `origin/main`,
`master`), a remote name like `origin` for the branch its
`origin/HEAD` points at, or a shell-style glob (e.g.
`'origin/*'`). The option can be repeated to widen the
filter. Implies `--list`.

`--points-at <object>`::
Only list branches of _<object>_.

Expand Down
88 changes: 64 additions & 24 deletions Documentation/git-interpret-trailers.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ git-interpret-trailers(1)

NAME
----
git-interpret-trailers - Add or parse structured information in commit messages
git-interpret-trailers - Add or parse metadata in commit messages

SYNOPSIS
--------
Expand All @@ -14,9 +14,15 @@ git interpret-trailers [--in-place] [--trim-empty]

DESCRIPTION
-----------
Add or parse _trailer_ lines that look similar to RFC 822 e-mail
headers, at the end of the otherwise free-form part of a commit
message. For example, in the following commit message
Add or parse trailer metadata at the end of the otherwise
free-form part of a commit message, or any other kind of text.

A _trailer_ in its simplest form is a key-value pair with a colon as a
separator. The _key_ consists of ASCII alphanumeric characters and
hyphens (`-`). A _trailer block_ consists of one or more trailers. The
trailer block needs to be preceded by a blank line, where a _blank line_
is either an empty or a whitespace-only line. For example, in the
following commit message

------------------------------------------------
subject
Expand Down Expand Up @@ -54,10 +60,18 @@ are applied to each input and the way any existing trailer in
the input is changed. They also make it possible to
automatically add some trailers.

By default, a `<key>=<value>` or `<key>:<value>` argument given
using `--trailer` will be appended after the existing trailers only if
the last trailer has a different (_<key>_, _<value>_) pair (or if there
is no existing trailer). The _<key>_ and _<value>_ parts will be trimmed
Let's consider new trailers added with `--trailer`.
By default, the new trailer will appear at the end of the trailer block.
Also by default, this new trailer will only be added
if the last trailer is different to it.
A trailer block will be created with only that trailer if a trailer
block does not already exist. Recall that a trailer block needs to be
preceded by a blank line, so a blank line will be inserted before the
new trailer block in that case.

This is how the new trailer is added: a `<key>=<value>` or
`<key>:<value>` argument given using `--trailer` will be appended after
the existing trailers. The _<key>_ and _<value>_ parts will be trimmed
to remove starting and trailing whitespace, and the resulting trimmed
_<key>_ and _<value>_ will appear in the output like this:

Expand All @@ -68,6 +82,16 @@ key: value
This means that the trimmed _<key>_ and _<value>_ will be separated by
"`:`{nbsp}" (one colon followed by one space).

Existing trailers are extracted from the input by looking for the
trailer block. A trailer block is a group of one or more lines that (i)
is all trailers, or (ii) contains at least one Git-generated or
user-configured trailer and consists of at
least 25% trailers.
The trailer block is by definition at the end of the commit message.
The message in turn is either (i) at the end of the input, or (ii) the
last non-whitespace lines before a line that starts with `---` (followed
by a space or the end of the line).

For convenience, a _<key-alias>_ can be configured to make using `--trailer`
shorter to type on the command line. This can be configured using the
`trailer.<key-alias>.key` configuration variable. The _<key-alias>_ must be a prefix
Expand All @@ -81,20 +105,6 @@ trailer.sign.key "Signed-off-by: "
in your configuration, you only need to specify `--trailer="sign: foo"`
on the command line instead of `--trailer="Signed-off-by: foo"`.

By default the new trailer will appear at the end of all the existing
trailers. If there is no existing trailer, the new trailer will appear
at the end of the input. A blank line will be added before the new
trailer if there isn't one already.

Existing trailers are extracted from the input by looking for
a group of one or more lines that (i) is all trailers, or (ii) contains at
least one Git-generated or user-configured trailer and consists of at
least 25% trailers.
The group must be preceded by one or more empty (or whitespace-only) lines.
The group must either be at the end of the input or be the last
non-whitespace lines before a line that starts with `---` (followed by a
space or the end of the line).

When reading trailers, there can be no whitespace before or inside the
_<key>_, but any number of regular space and tab characters are allowed
between the _<key>_ and the separator. There can be whitespaces before,
Expand All @@ -107,8 +117,15 @@ key: This is a very long value, with spaces and
newlines in it.
------------------------------------------------

Note that trailers do not follow (nor are they intended to follow) many of the
rules for RFC 822 headers. For example they do not follow the encoding rule.
OTHER RULES
-----------

What was covered in the previous section are the rules that are relevant
for regular use. The following points are included for completeness.

This command ignores comment lines (see `core.commentString` in
linkgit:git-config[1]). This is for use with the `prepare-commit-msg`
and `commit-msg` hooks.

OPTIONS
-------
Expand Down Expand Up @@ -402,6 +419,29 @@ mv "\$1.new" "\$1"
$ chmod +x .git/hooks/commit-msg
------------

* Here we try to use three different trailer keys. But it fails because
two of them are not recognized as trailer keys.
+
----
$ cat msg.txt
subject

Skapad-på: some-branch
Hash-in-v6.11: 45c12d3269fe48f22834320c782ffe86c3560f2c
Reviewed-by: Alice <alice@example.com>
$ git interpret-trailers --only-trailers <msg.txt
$
----
+
Recall that a trailer key has to consist of only ASCII alphanumeric
characters and hyphens, and this does not hold for the two first
supposed trailer keys. And now none are recognized as trailers because
the candidate trailer block has at least one non-trailer line, even
though `Reviewed-by` is a valid trailer key. Recall that a trailer block
has to either (i) be all trailers, or (ii) consist of at least one
Git-generated or user-configured trailer (and some other conditions).
And (ii) is not satisfied since we have not configured any trailer keys.

SEE ALSO
--------
linkgit:git-commit[1], linkgit:git-format-patch[1], linkgit:git-config[1]
Expand Down
Loading