Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
8efabc9
interpret-trailers: factor trailer rewriting
FirstLoveLife Mar 6, 2026
876b2eb
interpret-trailers: refactor create_in_place_tempfile()
phillipwood Mar 6, 2026
a4fd4c5
trailer: libify a couple of functions
FirstLoveLife Mar 6, 2026
6b2243f
trailer: append trailers without fork/exec
FirstLoveLife Mar 6, 2026
5e14869
commit, tag: parse --trailer with OPT_STRVEC
FirstLoveLife Mar 6, 2026
e4f9d6b
rebase: support --trailer
FirstLoveLife Mar 6, 2026
476365a
SubmittingPatches: spell out "replace fully to pretend to be perfect"
gitster Mar 9, 2026
8a1b789
editorconfig: fix style not applying to subdirs anymore
pks-t Mar 11, 2026
4107c0b
worktree: do not pass strbuf by value
deveshidwivedi Mar 11, 2026
f21967e
list-objects-filter-options: avoid strbuf_split_str()
deveshidwivedi Mar 11, 2026
30310f3
t3200: replace hardcoded null OID with $ZERO_OID
SiddharthShrimali Mar 11, 2026
35f220b
submodule--helper: replace malloc with xmalloc
SiddharthShrimali Mar 10, 2026
e30e944
test-lib: print escape sequence names
pabloosabaterr Mar 11, 2026
6523589
t9200: handle missing CVS with skip_all
pabloosabaterr Mar 11, 2026
05c324b
run-command: wean start_command() off the_repository
bkkaracay Mar 12, 2026
9df3be8
run-command: wean auto_maintenance() functions off the_repository
bkkaracay Mar 12, 2026
9072576
t9200: replace test -f with modern path helper
pabloosabaterr Mar 12, 2026
2d57632
Merge branch 'ps/t9200-test-path-is-helpers'
gitster Mar 19, 2026
17b9c75
Merge branch 'dd/list-objects-filter-options-wo-strbuf-split'
gitster Mar 19, 2026
432282f
Merge branch 'ss/t3200-test-zero-oid'
gitster Mar 19, 2026
2ca397f
Merge branch 'ps/editorconfig-unanchor'
gitster Mar 19, 2026
a7a079c
Merge branch 'bk/run-command-wo-the-repository'
gitster Mar 19, 2026
accd0e1
Merge branch 'lc/rebase-trailer'
gitster Mar 19, 2026
5a0ee6f
Merge branch 'jc/doc-wholesale-replace-before-next'
gitster Mar 19, 2026
80595ab
Merge branch 'ps/unit-test-c-escape-names.txt'
gitster Mar 19, 2026
39267c8
Merge branch 'ss/submodule--helper-use-xmalloc'
gitster Mar 19, 2026
7ff1e8d
The 18th batch
gitster Mar 19, 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
6 changes: 5 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ insert_final_newline = true

# The settings for C (*.c and *.h) files are mirrored in .clang-format. Keep
# them in sync.
[{*.{c,h,sh,bash,perl,pl,pm,txt,adoc},config.mak.*,Makefile,templates/hooks/*.sample}]
[{*.{c,h,sh,bash,perl,pl,pm,txt,adoc},config.mak.*,Makefile}]
indent_style = tab
tab_width = 8

[templates/hooks/*.sample]
indent_style = tab
tab_width = 8

Expand Down
23 changes: 23 additions & 0 deletions Documentation/RelNotes/2.54.0.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ UI, Workflows & Features
* "git repo structure" command learns to report maximum values on
various aspects of objects it inspects.

* "git rebase" learns "--trailer" command to drive the
interpret-trailers machinery.


Performance, Internal Implementation, Development Support etc.
--------------------------------------------------------------
Expand Down Expand Up @@ -193,6 +196,20 @@ Performance, Internal Implementation, Development Support etc.
* Reduce dependence on the global the_hash_algo and the_repository
variables of wt-status code path.

* The way combined list-object filter options are parsed has been
revamped.

* Editorconfig filename patterns were specified incorrectly, making
many source files inside subdirectories unaffected, which has been
corrected.

* The run_command() API lost its implicit dependencyon the singleton
`the_repository` instance.

* The unit test helper function was taught to use backslash +
mnemonic notation for certain control characters like "\t", instead
of octal notation like "\011".


Fixes since v2.53
-----------------
Expand Down Expand Up @@ -323,6 +340,10 @@ Fixes since v2.53
* Plug a few leaks where mmap'ed memory regions are not unmapped.
(merge a8a69bbb64 jk/unleak-mmap later to maint).

* A test now uses the symbolic constant $ZERO_OID instead of 40 "0" to
work better with SHA-256 as well as SHA-1.
(merge 30310f3cc4 ss/t3200-test-zero-oid later to maint).

* Other code cleanup, docfix, build fix, etc.
(merge d79fff4a11 jk/remote-tracking-ref-leakfix later to maint).
(merge 7a747f972d dd/t5403-modernise later to maint).
Expand Down Expand Up @@ -362,3 +383,5 @@ Fixes since v2.53
(merge 63c00a677b ss/t9123-setup-inside-test-expect-success later to maint).
(merge beca0ca4be os/doc-git-custom-commands later to maint).
(merge 4c223571be ty/patch-ids-document-lazy-eval later to maint).
(merge 476365ac85 jc/doc-wholesale-replace-before-next later to maint).
(merge 35f220b639 ss/submodule--helper-use-xmalloc later to maint).
12 changes: 12 additions & 0 deletions Documentation/SubmittingPatches
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ feedback before sending a new version, rather than sending an updated
series immediately after receiving a review. This helps collect broader
input and avoids unnecessary churn from many rapid iterations.

. These early update iterations are expected to be full replacements,
not incremental updates on top of what you posted already. If you
are correcting mistakes you made in the previous iteration that a
reviewer noticed and pointed out in their review, you _fix_ that
mistake by rewriting your history (e.g., by using "git rebase -i")
to pretend that you never made the mistake in the first place. In
other words, this is a chance to pretend to be a perfect developer,
and you are expected to take advantage of that. In the larger
picture, nobody is interested in your earlier mistakes. Just
present a logical progression made by a perfect developer who makes
no mistakes while working on the topic.

. Polish, refine, and re-send your patches to the list and to the people
who spent their time to improve your patch. Go back to step (2).

Expand Down
8 changes: 8 additions & 0 deletions Documentation/git-rebase.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,13 @@ See also INCOMPATIBLE OPTIONS below.
+
See also INCOMPATIBLE OPTIONS below.

--trailer=<trailer>::
Append the given trailer to every rebased commit message, processed
via linkgit:git-interpret-trailers[1]. This option implies
`--force-rebase`.
+
See also INCOMPATIBLE OPTIONS below.

-i::
--interactive::
Make a list of the commits which are about to be rebased. Let the
Expand Down Expand Up @@ -653,6 +660,7 @@ are incompatible with the following options:
* --[no-]reapply-cherry-picks when used without --keep-base
* --update-refs
* --root when used without --onto
* --trailer

In addition, the following pairs of options are incompatible:

Expand Down
2 changes: 1 addition & 1 deletion builtin/am.c
Original file line number Diff line number Diff line change
Expand Up @@ -1937,7 +1937,7 @@ static void am_run(struct am_state *state, int resume)
*/
if (!state->rebasing) {
am_destroy(state);
run_auto_maintenance(state->quiet);
run_auto_maintenance(the_repository, state->quiet);
}
}

Expand Down
8 changes: 6 additions & 2 deletions builtin/commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -1720,7 +1720,8 @@ int cmd_commit(int argc,
OPT_STRING(0, "fixup", &fixup_message, N_("[(amend|reword):]commit"), N_("use autosquash formatted message to fixup or amend/reword specified commit")),
OPT_STRING(0, "squash", &squash_message, N_("commit"), N_("use autosquash formatted message to squash specified commit")),
OPT_BOOL(0, "reset-author", &renew_authorship, N_("the commit is authored by me now (used with -C/-c/--amend)")),
OPT_PASSTHRU_ARGV(0, "trailer", &trailer_args, N_("trailer"), N_("add custom trailer(s)"), PARSE_OPT_NONEG),
OPT_STRVEC(0, "trailer", &trailer_args, N_("trailer"),
N_("add custom trailer(s)")),
OPT_BOOL('s', "signoff", &signoff, N_("add a Signed-off-by trailer")),
OPT_FILENAME('t', "template", &template_file, N_("use specified template file")),
OPT_BOOL('e', "edit", &edit_flag, N_("force edit of commit")),
Expand Down Expand Up @@ -1820,6 +1821,9 @@ int cmd_commit(int argc,
argc = parse_and_validate_options(argc, argv, builtin_commit_options,
builtin_commit_usage,
prefix, current_head, &s);
if (trailer_args.nr)
trailer_config_init();

if (verbose == -1)
verbose = (config_commit_verbose < 0) ? 0 : config_commit_verbose;

Expand Down Expand Up @@ -1958,7 +1962,7 @@ int cmd_commit(int argc,
git_test_write_commit_graph_or_die(the_repository->objects->sources);

repo_rerere(the_repository, 0);
run_auto_maintenance(quiet);
run_auto_maintenance(the_repository, quiet);
run_commit_hook(use_editor, repo_get_index_file(the_repository),
NULL, "post-commit", NULL);
if (amend && !no_post_rewrite) {
Expand Down
2 changes: 1 addition & 1 deletion builtin/fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -2873,7 +2873,7 @@ int cmd_fetch(int argc,
if (opt_val != 0)
git_config_push_parameter("maintenance.incremental-repack.auto=-1");
}
run_auto_maintenance(verbosity < 0);
run_auto_maintenance(the_repository, verbosity < 0);
}

cleanup:
Expand Down
14 changes: 9 additions & 5 deletions builtin/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ int cmd_gc(int argc,
struct child_process repack_cmd = CHILD_PROCESS_INIT;

repack_cmd.git_cmd = 1;
repack_cmd.close_object_store = 1;
repack_cmd.odb_to_close = the_repository->objects;
strvec_pushv(&repack_cmd.args, repack_args.v);
if (run_command(&repack_cmd))
die(FAILED_RUN, repack_args.v[0]);
Expand Down Expand Up @@ -1199,7 +1199,8 @@ static int run_write_commit_graph(struct maintenance_run_opts *opts)
{
struct child_process child = CHILD_PROCESS_INIT;

child.git_cmd = child.close_object_store = 1;
child.git_cmd = 1;
child.odb_to_close = the_repository->objects;
strvec_pushl(&child.args, "commit-graph", "write",
"--split", "--reachable", NULL);

Expand Down Expand Up @@ -1268,7 +1269,8 @@ static int maintenance_task_gc_background(struct maintenance_run_opts *opts,
{
struct child_process child = CHILD_PROCESS_INIT;

child.git_cmd = child.close_object_store = 1;
child.git_cmd = 1;
child.odb_to_close = the_repository->objects;
strvec_push(&child.args, "gc");

if (opts->auto_flag)
Expand Down Expand Up @@ -1484,7 +1486,8 @@ static int multi_pack_index_expire(struct maintenance_run_opts *opts)
{
struct child_process child = CHILD_PROCESS_INIT;

child.git_cmd = child.close_object_store = 1;
child.git_cmd = 1;
child.odb_to_close = the_repository->objects;
strvec_pushl(&child.args, "multi-pack-index", "expire", NULL);

if (opts->quiet)
Expand Down Expand Up @@ -1542,7 +1545,8 @@ static int multi_pack_index_repack(struct maintenance_run_opts *opts)
{
struct child_process child = CHILD_PROCESS_INIT;

child.git_cmd = child.close_object_store = 1;
child.git_cmd = 1;
child.odb_to_close = the_repository->objects;
strvec_pushl(&child.args, "multi-pack-index", "repack", NULL);

if (opts->quiet)
Expand Down
87 changes: 16 additions & 71 deletions builtin/interpret-trailers.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,37 +93,6 @@ static int parse_opt_parse(const struct option *opt, const char *arg,
return 0;
}

static struct tempfile *trailers_tempfile;

static FILE *create_in_place_tempfile(const char *file)
{
struct stat st;
struct strbuf filename_template = STRBUF_INIT;
const char *tail;
FILE *outfile;

if (stat(file, &st))
die_errno(_("could not stat %s"), file);
if (!S_ISREG(st.st_mode))
die(_("file %s is not a regular file"), file);
if (!(st.st_mode & S_IWUSR))
die(_("file %s is not writable by user"), file);

/* Create temporary file in the same directory as the original */
tail = strrchr(file, '/');
if (tail)
strbuf_add(&filename_template, file, tail - file + 1);
strbuf_addstr(&filename_template, "git-interpret-trailers-XXXXXX");

trailers_tempfile = xmks_tempfile_m(filename_template.buf, st.st_mode);
strbuf_release(&filename_template);
outfile = fdopen_tempfile(trailers_tempfile, "w");
if (!outfile)
die_errno(_("could not open temporary file"));

return outfile;
}

static void read_input_file(struct strbuf *sb, const char *file)
{
if (file) {
Expand All @@ -140,55 +109,31 @@ static void interpret_trailers(const struct process_trailer_options *opts,
struct list_head *new_trailer_head,
const char *file)
{
LIST_HEAD(head);
struct strbuf sb = STRBUF_INIT;
struct strbuf trailer_block_sb = STRBUF_INIT;
struct trailer_block *trailer_block;
FILE *outfile = stdout;
struct strbuf input = STRBUF_INIT;
struct strbuf out = STRBUF_INIT;
struct tempfile *tempfile = NULL;
int fd = 1;

trailer_config_init();

read_input_file(&sb, file);

if (opts->in_place)
outfile = create_in_place_tempfile(file);

trailer_block = parse_trailers(opts, sb.buf, &head);

/* Print the lines before the trailer block */
if (!opts->only_trailers)
fwrite(sb.buf, 1, trailer_block_start(trailer_block), outfile);

if (!opts->only_trailers && !blank_line_before_trailer_block(trailer_block))
fprintf(outfile, "\n");
read_input_file(&input, file);


if (!opts->only_input) {
LIST_HEAD(config_head);
LIST_HEAD(arg_head);
parse_trailers_from_config(&config_head);
parse_trailers_from_command_line_args(&arg_head, new_trailer_head);
list_splice(&config_head, &arg_head);
process_trailers_lists(&head, &arg_head);
if (opts->in_place) {
tempfile = trailer_create_in_place_tempfile(file);
if (!tempfile)
die(NULL);
fd = tempfile->fd;
}
process_trailers(opts, new_trailer_head, &input, &out);

/* Print trailer block. */
format_trailers(opts, &head, &trailer_block_sb);
free_trailers(&head);
fwrite(trailer_block_sb.buf, 1, trailer_block_sb.len, outfile);
strbuf_release(&trailer_block_sb);

/* Print the lines after the trailer block as is. */
if (!opts->only_trailers)
fwrite(sb.buf + trailer_block_end(trailer_block), 1,
sb.len - trailer_block_end(trailer_block), outfile);
trailer_block_release(trailer_block);

if (write_in_full(fd, out.buf, out.len) < 0)
die_errno(_("could not write to temporary file '%s'"), file);
if (opts->in_place)
if (rename_tempfile(&trailers_tempfile, file))
if (rename_tempfile(&tempfile, file))
die_errno(_("could not rename temporary file to %s"), file);

strbuf_release(&sb);
strbuf_release(&input);
strbuf_release(&out);
}

int cmd_interpret_trailers(int argc,
Expand Down
2 changes: 1 addition & 1 deletion builtin/merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ static void finish(struct commit *head_commit,
* We ignore errors in 'gc --auto', since the
* user should see them.
*/
run_auto_maintenance(verbosity < 0);
run_auto_maintenance(the_repository, verbosity < 0);
}
}
if (new_head && show_diffstat) {
Expand Down
2 changes: 1 addition & 1 deletion builtin/pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ static int run_fetch(const char *repo, const char **refspecs)
} else if (*refspecs)
BUG("refspecs without repo?");
cmd.git_cmd = 1;
cmd.close_object_store = 1;
cmd.odb_to_close = the_repository->objects;
return run_command(&cmd);
}

Expand Down
Loading