git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 0/2] merge-tree: add new --dry-run option

From
Elijah Newren via GitGitGadget <gitgitgadget@gmail.com>
Date
May 14, 2025, 00:24 UTC
Message-ID
<pull.1920.v3.git.1747182287.gitgitgadget@gmail.com>
In-Reply-To
<pull.1920.v2.git.1747093322.gitgitgadget@gmail.com>
Changes since v2:
 * Converted locations missed in v1 in changing --mergeability-only ->
   --dry-run
Changes since v1:
 * Renamed --mergeability-only flag to --dry-run, as per suggestion from
   Junio
 * added some commit message clarifications

This adds a new flag, --dry-run, to git merge-tree, which suppresses all output and leaves only the exit status (reflecting successful merge or conflict). This is useful for Git Forges in cases where they are only interested in whether two branches can be merged, without needing the actual merge result or conflict details.

The advantage of the flag is two fold:
 * The merge machinery can exit once it detects a conflict, instead of
   continuing to compute merge result information
 * The merge machinery can avoid writing merged blobs and trees to the
   object store when in the outer layer of the merging process (more details
   in the first commit message).
Elijah Newren (2):
  merge-ort: add a new mergeability_only option
  merge-tree: add a new --dry-run flag
 Documentation/git-merge-tree.adoc |  6 +++++
 builtin/merge-tree.c              | 22 ++++++++++++++++++
 merge-ort.c                       | 38 +++++++++++++++++++++++++------
 merge-ort.h                       |  1 +
 t/t4301-merge-tree-write-tree.sh  | 38 +++++++++++++++++++++++++++++++
 5 files changed, 98 insertions(+), 7 deletions(-)
base-commit: 6c0bd1fc70efaf053abe4e57c976afdc72d15377
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1920%2Fnewren%2Fmergeability-only-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1920/newren/mergeability-only-v3
Pull-Request: https://github.com/gitgitgadget/git/pull/1920
Range-diff vs v2:
 1:  4757c4810d3 = 1:  4757c4810d3 merge-ort: add a new mergeability_only option
 2:  1d18ab7feb8 ! 2:  f11824317a8 merge-tree: add a new --dry-run flag
     @@ Documentation/git-merge-tree.adoc: OPTIONS
       	default is to include these messages if there are merge
       	conflicts, and to omit them otherwise.
       
     -+--mergeability-only::
     ++--dry-run::
      +	Disable all output from the program.  Useful when you are only
      +	interested in the exit status.  Allows merge-tree to exit
     -+	early on the first conflict it finds, and allows it to avoid
     -+	writing most objects created by merges.
     ++	early when it finds a conflict, and allows it to avoid writing
     ++	most objects created by merges.
      +
       --allow-unrelated-histories::
       	merge-tree will by default error out if the two branches specified
     @@ builtin/merge-tree.c: int cmd_merge_tree(int argc,
      +	if (dry_run && o.show_messages == -1)
      +		o.show_messages = 0;
      +	o.merge_options.mergeability_only = dry_run;
     -+	die_for_incompatible_opt2(dry_run, "--mergeability-only",
     ++	die_for_incompatible_opt2(dry_run, "--dry-run",
      +				  o.show_messages, "--messages");
     -+	die_for_incompatible_opt2(dry_run, "--mergeability-only",
     ++	die_for_incompatible_opt2(dry_run, "--dry-run",
      +				  o.name_only, "--name-only");
     -+	die_for_incompatible_opt2(dry_run, "--mergeability-only",
     ++	die_for_incompatible_opt2(dry_run, "--dry-run",
      +				  o.use_stdin, "--stdin");
     -+	die_for_incompatible_opt2(dry_run, "--mergeability-only",
     ++	die_for_incompatible_opt2(dry_run, "--dry-run",
      +				  !line_termination, "-z");
      +
       	if (xopts.nr && o.mode == MODE_TRIVIAL)
-- 
gitgitgadget
Previous: Junio C HamanoNext: Elijah Newren via GitGitGadget
Message 16 of 29 in “merge-tree: add new --mergeability-only option”
  1. 0/2 merge-tree: add new --mergeability-only optionElijah Newren via GitGitGadget, May 10, 2025
  2. 1/2 merge-ort: add a new mergeability_only optionElijah Newren via GitGitGadget, May 10, 2025
  3. 2/2 merge-tree: add a new --mergeability-only flagElijah Newren via GitGitGadget, May 10, 2025
  4. Junio C HamanoMay 12, 2025
  5. Elijah NewrenMay 12, 2025
  6. Junio C HamanoMay 12, 2025
  7. Elijah NewrenMay 12, 2025
  8. 0/2 merge-tree: add new --dry-run optionElijah Newren via GitGitGadget, May 12, 2025
  9. 1/2 merge-ort: add a new mergeability_only optionElijah Newren via GitGitGadget, May 12, 2025
  10. 2/2 merge-tree: add a new --dry-run flagElijah Newren via GitGitGadget, May 12, 2025
  11. Kristoffer HaugsbakkMay 13, 2025
  12. Elijah NewrenMay 13, 2025
  13. Junio C HamanoMay 13, 2025
  14. Elijah NewrenMay 13, 2025
  15. Junio C HamanoMay 14, 2025
  16. 0/2 merge-tree: add new --dry-run optionElijah Newren via GitGitGadget, May 14, 2025
  17. 1/2 merge-ort: add a new mergeability_only optionElijah Newren via GitGitGadget, May 14, 2025
  18. 2/2 merge-tree: add a new --dry-run flagElijah Newren via GitGitGadget, May 14, 2025
  19. Junio C HamanoMay 15, 2025
  20. Phillip WoodMay 16, 2025
  21. Elijah NewrenMay 16, 2025
  22. Kristoffer HaugsbakkMay 14, 2025
  23. 0/2 merge-tree: add new --quiet optionElijah Newren via GitGitGadget, May 16, 2025
  24. 1/2 merge-ort: add a new mergeability_only optionElijah Newren via GitGitGadget, May 16, 2025
  25. 2/2 merge-tree: add a new --quiet flagElijah Newren via GitGitGadget, May 16, 2025
  26. Kristoffer HaugsbakkMay 17, 2025
  27. Kristoffer HaugsbakkMay 17, 2025
  28. Phillip WoodMay 19, 2025
  29. Junio C HamanoMay 19, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.