<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/range-diff.h, branch jch</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=jch</id>
<link rel='self' href='https://git.shady.money/git/atom?h=jch'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2025-09-25T18:34:11Z</updated>
<entry>
<title>range-diff: rename other_arg to log_arg</title>
<updated>2025-09-25T18:34:11Z</updated>
<author>
<name>Kristoffer Haugsbakk</name>
<email>code@khaugsbakk.name</email>
</author>
<published>2025-09-25T17:07:34Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=71fd6c695cd9fc9cc0a829d1579c7584c2ad9e18'/>
<id>urn:sha1:71fd6c695cd9fc9cc0a829d1579c7584c2ad9e18</id>
<content type='text'>
Rename `other_arg` to `log_arg` in `range_diff_options` and
related places.

“Other argument” comes from bd361918 (range-diff: pass through --notes
to `git log`, 2019-11-20) which introduced Git notes handling to
git-range-diff(1) by passing that option on to git-log(1). And that kind
of name might be fine in a local context. However, it was initially
spread among multiple files, and is now[1] part of the
`range_diff_options` struct. It is, prima facie, difficult to guess what
“other” means, especially when just looking at the struct.

But with a little reading we find out that it is used for `--[no-]notes`
and `--diff-merges`, which are both passed on to git-log(1). We should
just rename it to reflect this role; `log_arg` suggests, along with the
`strvec` type, that it is used to pass extra arguments to git-log(1).

† 1: since f1ce6c19 (range-diff: combine all options in a single data
     structure, 2021-02-05)

Suggested-by: Junio C Hamano &lt;gitster@pobox.com&gt;
Signed-off-by: Kristoffer Haugsbakk &lt;code@khaugsbakk.name&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>range-diff: add configurable memory limit for cost matrix</title>
<updated>2025-08-29T16:46:07Z</updated>
<author>
<name>Paulo Casaretto</name>
<email>pcasaretto@gmail.com</email>
</author>
<published>2025-08-29T16:02:54Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=00727249ec8404c68391ec58e9c9f0d8a88d5ca0'/>
<id>urn:sha1:00727249ec8404c68391ec58e9c9f0d8a88d5ca0</id>
<content type='text'>
When comparing large commit ranges (e.g., 250,000+ commits), range-diff
attempts to allocate an n×n cost matrix that can exhaust available
memory. For example, with 256,784 commits (n = 513,568), the matrix
would require approximately 256GB of memory (513,568² × 4 bytes),
causing either immediate segmentation faults due to integer overflow or
system hangs.

Add a memory limit check in get_correspondences() before allocating the
cost matrix. This check uses the total size in bytes (n² × sizeof(int))
and compares it against a configurable maximum, preventing both
excessive memory usage and integer overflow issues.

The limit is configurable via a new --max-memory option that accepts
human-readable sizes (e.g., "1G", "500M"). The default is 4GB for 64 bit
systems and 2GB for 32 bit systems. This allows comparing ranges of
approximately 32,000 (16,000) commits - generous for real-world use cases
while preventing impractical operations.

When the limit is exceeded, range-diff now displays a clear error
message showing both the requested memory size and the maximum allowed,
formatted in human-readable units for better user experience.

Example usage:
  git range-diff --max-memory=1G branch1...branch2
  git range-diff --max-memory=500M base..topic1 base..topic2

This approach was chosen over alternatives:
- Pre-counting commits: Would require spawning additional git processes
  and reading all commits twice
- Limiting by commit count: Less precise than actual memory usage
- Streaming approach: Would require significant refactoring of the
  current algorithm

This issue was previously discussed in:
https://lore.kernel.org/git/RFC-cover-v2-0.5-00000000000-20211210T122901Z-avarab@gmail.com/

Acked-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Paulo Casaretto &lt;pcasaretto@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>range-diff: optionally include merge commits' diffs in the analysis</title>
<updated>2024-12-16T16:45:48Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2024-12-16T14:11:21Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=f8043236c6c9cb9e943a87ab2e55e8e394796727'/>
<id>urn:sha1:f8043236c6c9cb9e943a87ab2e55e8e394796727</id>
<content type='text'>
The `git log` command already offers support for including diffs for
merges, via the `--diff-merges=&lt;format&gt;` option.

Let's add corresponding support for `git range-diff`, too. This makes it
more convenient to spot differences between commit ranges that contain
merges.

This is especially true in scenarios with non-trivial merges, i.e.
merges introducing changes other than, or in addition to, what merge ORT
would have produced. Merging a topic branch that changes a function
signature into a branch that added a caller of that function, for
example, would require the merge commit itself to adjust that caller to
the modified signature.

In my code reviews, I found the `--diff-merges=remerge` option
particularly useful.

Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>format-patch: run range-diff with larger creation-factor</title>
<updated>2024-05-06T18:57:22Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-05-06T16:40:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c22d41d641711879c57299244ae13b6c4a215fee'/>
<id>urn:sha1:c22d41d641711879c57299244ae13b6c4a215fee</id>
<content type='text'>
We see too often that a range-diff added to format-patch output
shows too many "unmatched" patches.  This is because the default
value for creation-factor is set to a relatively low value.

It may be justified for other uses (like you have a yet-to-be-sent
new iteration of your series, and compare it against the 'seen'
branch that has an older iteration, probably with the '--left-only'
option, to pick out only your patches while ignoring the others) of
"range-diff" command, but when the command is run as part of the
format-patch, the user _knows_ and expects that the patches in the
old and the new iterations roughly correspond to each other, so we
can and should use a much higher default.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'js/range-diff-one-side-only'</title>
<updated>2021-02-18T01:21:41Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2021-02-18T01:21:41Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=dadc91ff0c15b655070ad334a27a734e91635bd5'/>
<id>urn:sha1:dadc91ff0c15b655070ad334a27a734e91635bd5</id>
<content type='text'>
The "git range-diff" command learned "--(left|right)-only" option
to show only one side of the compared range.

* js/range-diff-one-side-only:
  range-diff: offer --left-only/--right-only options
  range-diff: move the diffopt initialization down one layer
  range-diff: combine all options in a single data structure
  range-diff: simplify code spawning `git log`
  range-diff: libify the read_patches() function again
  range-diff: avoid leaking memory in two error code paths
</content>
</entry>
<entry>
<title>range-diff/format-patch: handle commit ranges other than A..B</title>
<updated>2021-02-07T05:24:55Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2021-02-05T14:44:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=359f0d754ab709c5a1ff3267bc117fb8559c62c2'/>
<id>urn:sha1:359f0d754ab709c5a1ff3267bc117fb8559c62c2</id>
<content type='text'>
In the `SPECIFYING RANGES` section of gitrevisions[7], two ways are
described to specify commit ranges that `range-diff` does not yet
accept: "&lt;commit&gt;^!" and "&lt;commit&gt;^-&lt;n&gt;".

Let's accept them, by parsing them via the revision machinery and
looking for at least one interesting and one uninteresting revision in
the resulting `pending` array.

This also finally lets us reject arguments that _do_ contain `..` but
are not actually ranges, e.g. `HEAD^{/do.. match this}`.

Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>range-diff: offer --left-only/--right-only options</title>
<updated>2021-02-07T05:14:31Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2021-02-05T14:46:13Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1e79f973266cfe0e3bab0e26e869b682078e457d'/>
<id>urn:sha1:1e79f973266cfe0e3bab0e26e869b682078e457d</id>
<content type='text'>
When comparing commit ranges, one is frequently interested only in one
side, such as asking the question "Has this patch that I submitted to
the Git mailing list been applied?": one would only care about the part
of the output that corresponds to the commits in a local branch.

To make that possible, imitate the `git rev-list` options `--left-only`
and `--right-only`.

This addresses https://github.com/gitgitgadget/git/issues/206

Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>range-diff: combine all options in a single data structure</title>
<updated>2021-02-07T05:14:31Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2021-02-05T14:46:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=f1ce6c191e9d15ce78041d8b6496c246b10d9b2d'/>
<id>urn:sha1:f1ce6c191e9d15ce78041d8b6496c246b10d9b2d</id>
<content type='text'>
This will make it easier to implement the `--left-only` and
`--right-only` options.

Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>range-diff/format-patch: refactor check for commit range</title>
<updated>2021-01-28T06:01:49Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2021-01-27T16:37:22Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=679b5916cdafdcfa9fb36c31dbf53d7e4aa0af0b'/>
<id>urn:sha1:679b5916cdafdcfa9fb36c31dbf53d7e4aa0af0b</id>
<content type='text'>
Currently, when called with exactly two arguments, `git range-diff`
tests for a literal `..` in each of the two. Likewise, the argument
provided via `--range-diff` to `git format-patch` is checked in the same
manner.

However, `&lt;commit&gt;^!` is a perfectly valid commit range, equivalent to
`&lt;commit&gt;^..&lt;commit&gt;` according to the `SPECIFYING RANGES` section of
gitrevisions[7].

In preparation for allowing more sophisticated ways to specify commit
ranges, let's refactor the check into its own function.

Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>strvec: convert remaining callers away from argv_array name</title>
<updated>2020-07-28T22:02:18Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2020-07-28T20:25:12Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c972bf4cf546a56fe1c54ddde1d33ebb9f454a0f'/>
<id>urn:sha1:c972bf4cf546a56fe1c54ddde1d33ebb9f454a0f</id>
<content type='text'>
We eventually want to drop the argv_array name and just use strvec
consistently. There's no particular reason we have to do it all at once,
or care about interactions between converted and unconverted bits.
Because of our preprocessor compat layer, the names are interchangeable
to the compiler (so even a definition and declaration using different
names is OK).

This patch converts all of the remaining files, as the resulting diff is
reasonably sized.

The conversion was done purely mechanically with:

  git ls-files '*.c' '*.h' |
  xargs perl -i -pe '
    s/ARGV_ARRAY/STRVEC/g;
    s/argv_array/strvec/g;
  '

We'll deal with any indentation/style fallouts separately.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
