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

[PATCH v2 0/6] Optionally restrict range-diff output to "left" or "right" range only

From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Date
Feb 5, 2021, 14:46 UTC
Message-ID
<pull.869.v2.git.1612536373.gitgitgadget@gmail.com>
In-Reply-To
<pull.869.git.1612469275.gitgitgadget@gmail.com>

One of my quite common workflows is to see whether an ancient topic branch I have lying about has made it into Git. Since my local commit OIDs have nothing to do with the OIDs of the corresponding commits in git/git, my only way is to fire up git range-diff ...upstream/master, but of course that output contains way more commits than I care about.

To help this use case, here is a patch series that teaches git range-diff the --left-only and --right-only options in the end, restricting the output to those commits and commit pairs that correspond to the commits in the first and the second range, respectively.

The first part of the series contains cleanup patches that are not strictly related to the feature I implemented here, but since I already have them, I figured I could just as well contribute them all together.

This patch series is based on js/range-diff-wo-dotdot.
Changes since v1:
 * Adjusted the comment above show_range_diff() to reflect the new
   signature.
Johannes Schindelin (6):
  range-diff: avoid leaking memory in two error code paths
  range-diff: libify the read_patches() function again
  range-diff: simplify code spawning `git log`
  range-diff: combine all options in a single data structure
  range-diff: move the diffopt initialization down one layer
  range-diff: offer --left-only/--right-only options
 Documentation/git-range-diff.txt |   9 +++
 builtin/log.c                    |  10 ++-
 builtin/range-diff.c             |  21 +++++--
 log-tree.c                       |   8 ++-
 range-diff.c                     | 101 +++++++++++++++++--------------
 range-diff.h                     |  17 ++++--
 t/t3206-range-diff.sh            |  15 +++++
 7 files changed, 120 insertions(+), 61 deletions(-)
base-commit: 35fac18ea5ccab7524501bcb4542473ef8195541
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-869%2Fdscho%2Frange-diff-left-and-right-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-869/dscho/range-diff-left-and-right-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/869
Range-diff vs v1:
 1:  5f2f06b79e20 = 1:  15f4f6abdaa2 range-diff: avoid leaking memory in two error code paths
 2:  0d25dd2a9c2d = 2:  99e466ef32d7 range-diff: libify the read_patches() function again
 3:  d6c582c25df0 = 3:  a36631b663e2 range-diff: simplify code spawning `git log`
 4:  b620be042eb3 ! 4:  7367eadfe243 range-diff: combine all options in a single data structure
     @@ range-diff.h
      +struct range_diff_options {
      +	int creation_factor;
      +	unsigned dual_color:1;
     -+	const struct diff_options *diffopt;
     -+	const struct strvec *other_arg;
     ++	const struct diff_options *diffopt; /* may be NULL */
     ++	const struct strvec *other_arg; /* may be NULL */
      +};
      +
       /*
     -  * Compare series of commits in RANGE1 and RANGE2, and emit to the
     -  * standard output.  NULL can be passed to DIFFOPT to use the built-in
     -  * default.
     +- * Compare series of commits in RANGE1 and RANGE2, and emit to the
     +- * standard output.  NULL can be passed to DIFFOPT to use the built-in
     +- * default.
     ++ * Compare series of commits in `range1` and `range2`, and emit to the
     ++ * standard output.
        */
       int show_range_diff(const char *range1, const char *range2,
      -		    int creation_factor, int dual_color,
 5:  9fa945db5f13 = 5:  a6285292b4f1 range-diff: move the diffopt initialization down one layer
 6:  1c599abdbb6f ! 6:  8357d3c94f17 range-diff: offer --left-only/--right-only options
     @@ range-diff.h
       	int creation_factor;
       	unsigned dual_color:1;
      +	unsigned left_only:1, right_only:1;
     - 	const struct diff_options *diffopt;
     - 	const struct strvec *other_arg;
     + 	const struct diff_options *diffopt; /* may be NULL */
     + 	const struct strvec *other_arg; /* may be NULL */
       };
      
       ## t/t3206-range-diff.sh ##
-- 
gitgitgadget
Previous: Taylor BlauNext: Johannes Schindelin via GitGitGadget
Message 16 of 22 in “Optionally restrict range-diff output to "left" or "right" range only”
  1. 0/6 Optionally restrict range-diff output to "left" or "right" range onlyJohannes Schindelin via GitGitGadget, Feb 4, 2021
  2. 3/6 range-diff: simplify code spawning `git log`Johannes Schindelin via GitGitGadget, Feb 4, 2021
  3. 1/6 range-diff: avoid leaking memory in two error code pathsJohannes Schindelin via GitGitGadget, Feb 4, 2021
  4. 2/6 range-diff: libify the read_patches() function againJohannes Schindelin via GitGitGadget, Feb 4, 2021
  5. 4/6 range-diff: combine all options in a single data structureJohannes Schindelin via GitGitGadget, Feb 4, 2021
  6. Eric SunshineFeb 4, 2021
  7. Johannes SchindelinFeb 5, 2021
  8. 6/6 range-diff: offer --left-only/--right-only optionsJohannes Schindelin via GitGitGadget, Feb 4, 2021
  9. 5/6 range-diff: move the diffopt initialization down one layerJohannes Schindelin via GitGitGadget, Feb 4, 2021
  10. Junio C HamanoFeb 4, 2021
  11. Taylor BlauFeb 4, 2021
  12. Junio C HamanoFeb 5, 2021
  13. Jeff KingFeb 5, 2021
  14. Johannes SchindelinFeb 8, 2021
  15. Taylor BlauFeb 5, 2021
  16. 0/6 Optionally restrict range-diff output to "left" or "right" range onlyJohannes Schindelin via GitGitGadget, Feb 5, 2021
  17. 3/6 range-diff: simplify code spawning `git log`Johannes Schindelin via GitGitGadget, Feb 5, 2021
  18. 5/6 range-diff: move the diffopt initialization down one layerJohannes Schindelin via GitGitGadget, Feb 5, 2021
  19. 2/6 range-diff: libify the read_patches() function againJohannes Schindelin via GitGitGadget, Feb 5, 2021
  20. 6/6 range-diff: offer --left-only/--right-only optionsJohannes Schindelin via GitGitGadget, Feb 5, 2021
  21. 1/6 range-diff: avoid leaking memory in two error code pathsJohannes Schindelin via GitGitGadget, Feb 5, 2021
  22. 4/6 range-diff: combine all options in a single data structureJohannes Schindelin via GitGitGadget, Feb 5, 2021

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.