<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/sequencer.c, branch v2.50.1</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.50.1</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.50.1'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2025-05-27T20:59:11Z</updated>
<entry>
<title>Merge branch 'en/sequencer-comment-messages'</title>
<updated>2025-05-27T20:59:11Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2025-05-27T20:59:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=80f49f2ae749bce60e79751d1cd0890aca86fca0'/>
<id>urn:sha1:80f49f2ae749bce60e79751d1cd0890aca86fca0</id>
<content type='text'>
Prefix '#' to the commit title in the "rebase -i" todo file, just
like a merge commit being replayed.

* en/sequencer-comment-messages:
  sequencer: make it clearer that commit descriptions are just comments
</content>
</entry>
<entry>
<title>Merge branch 'js/misc-fixes'</title>
<updated>2025-05-27T20:59:11Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2025-05-27T20:59:10Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=f9cdaa2860e20f3f36595646b7a82082aa772df8'/>
<id>urn:sha1:f9cdaa2860e20f3f36595646b7a82082aa772df8</id>
<content type='text'>
Assorted fixes for issues found with CodeQL.

* js/misc-fixes:
  sequencer: stop pretending that an assignment is a condition
  bundle-uri: avoid using undefined output of `sscanf()`
  commit-graph: avoid using stale stack addresses
  trace2: avoid "futile conditional"
  Avoid redundant conditions
  fetch: avoid unnecessary work when there is no current branch
  has_dir_name(): make code more obvious
  upload-pack: rename `enum` to reflect the operation
  commit-graph: avoid malloc'ing a local variable
  fetch: carefully clear local variable's address after use
  commit: simplify code
</content>
</entry>
<entry>
<title>Merge branch 'ly/sequencer-rearrange-leakfix'</title>
<updated>2025-05-27T20:59:07Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2025-05-27T20:59:07Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=6261489cdba61715ee9e0716d7a8a7fc63c53e49'/>
<id>urn:sha1:6261489cdba61715ee9e0716d7a8a7fc63c53e49</id>
<content type='text'>
Leakfix.

* ly/sequencer-rearrange-leakfix:
  sequencer: fix memory leak if `todo_list_rearrange_squash()` failed
</content>
</entry>
<entry>
<title>Merge branch 'jk/oidmap-cleanup'</title>
<updated>2025-05-19T23:02:47Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2025-05-19T23:02:47Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a9dcacbf2a74537916f61dd8c5f2dd2c1b4eb58a'/>
<id>urn:sha1:a9dcacbf2a74537916f61dd8c5f2dd2c1b4eb58a</id>
<content type='text'>
Code cleanup.

* jk/oidmap-cleanup:
  raw_object_store: drop extra pointer to replace_map
  oidmap: add size function
  oidmap: rename oidmap_free() to oidmap_clear()
</content>
</entry>
<entry>
<title>Merge branch 'pw/sequencer-reflog-use-after-free'</title>
<updated>2025-05-19T23:02:44Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2025-05-19T23:02:44Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=0b8d22fd4030832fa64933721fa162feaa9c69d9'/>
<id>urn:sha1:0b8d22fd4030832fa64933721fa162feaa9c69d9</id>
<content type='text'>
Use-after-free fix in the sequencer.

* pw/sequencer-reflog-use-after-free:
  sequencer: rework reflog message handling
  sequencer: move reflog message functions
</content>
</entry>
<entry>
<title>sequencer: make it clearer that commit descriptions are just comments</title>
<updated>2025-05-16T19:28:27Z</updated>
<author>
<name>Elijah Newren</name>
<email>newren@gmail.com</email>
</author>
<published>2025-05-16T16:26:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e42667241de12840ef58c0ba1c060b86c850bae0'/>
<id>urn:sha1:e42667241de12840ef58c0ba1c060b86c850bae0</id>
<content type='text'>
Every once in a while, users report that editing the commit summaries
in the todo list does not get reflected in the rebase operation,
suggesting that users are (a) only using one-line commit messages, and
(b) not understanding that the commit summaries are merely helpful
comments to help them find the right hashes.

It may be difficult to correct users' poor commit messages, but we can
at least try to make it clearer that the commit summaries are not
directives of some sort by inserting a comment character.  Hopefully
that leads to them looking a little further and noticing the hints at
the bottom to use 'reword' or 'edit' directives.

Yes, this change may look funny at first since it hardcodes '#' rather
than using comment_line_str.  However:

  * comment_line_str exists to allow disambiguation between lines in
    a commit message and lines that are instructions to users editing
    the commit message.  No such disambiguation is needed for these
    comments that occur on the same line after existing directives
  * the exact "comment" character(s) on regular pick lines used aren't
    actually important; I could have used anything, including completely
    random variable length text for each line and it'd work because we
    ignore everything after 'pick' and the hash.
  * The whole point of this change is to signal to users that they
    should NOT be editing any part of the line after the hash (and if
    they do so, their edits will be ignored), while the whole point of
    comment_line_str is to allow highly flexible editing.  So making
    it more general by using comment_line_str actually feels
    counterproductive.
  * The character for merge directives absolutely must be '#'; that
    has been deeply hardcoded for a long time (see below), and will
    break if some other comment character is used instead.  In a
    desire to have pick and merge directives be similar, I use the
    same comment character for both.
  * Perhaps merge directives could be fixed to not be inflexible about
    the comment character used, if someone feels highly motivated, but
    I think that should be done in a separate follow-on patch.

Here are (some of?) the locations where '#' has already been hardcoded
for a long time for merges:

  1) In check_label_or_ref_arg():
	case TODO_LABEL:
		/*
		 * '#' is not a valid label as the merge command uses it to
		 * separate merge parents from the commit subject.
		 */

  2) In do_merge():

	/*
	 * For octopus merges, the arg starts with the list of revisions to be
	 * merged. The list is optionally followed by '#' and the oneline.
	 */
	merge_arg_len = oneline_offset = arg_len;
	for (p = arg; p - arg &lt; arg_len; p += strspn(p, " \t\n")) {
		if (!*p)
			break;
		if (*p == '#' &amp;&amp; (!p[1] || isspace(p[1]))) {

  3) In label_oid():

		if ((buf-&gt;len == the_hash_algo-&gt;hexsz &amp;&amp;
		     !get_oid_hex(label, &amp;dummy)) ||
		    (buf-&gt;len == 1 &amp;&amp; *label == '#') ||
		    hashmap_get_from_hash(&amp;state-&gt;labels,
					  strihash(label), label)) {
			/*
			 * If the label already exists, or if the label is a
			 * valid full OID, or the label is a '#' (which we use
			 * as a separator between merge heads and oneline), we
			 * append a dash and a number to make it unique.
			 */

Signed-off-by: Elijah Newren &lt;newren@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>sequencer: fix memory leak if `todo_list_rearrange_squash()` failed</title>
<updated>2025-05-15T20:53:33Z</updated>
<author>
<name>Lidong Yan</name>
<email>502024330056@smail.nju.edu.cn</email>
</author>
<published>2025-05-14T13:53:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=044511f889b1989840339a322f84e50dfa3bf6e0'/>
<id>urn:sha1:044511f889b1989840339a322f84e50dfa3bf6e0</id>
<content type='text'>
In sequencer.c:todo_list_rearrange_squash, if it fails, memory
allocated in `next`, `tail`, `subjects` and `subject2item` will leak.
Jump to cleanup label before return could fix this leak problem.

Signed-off-by: Lidong Yan &lt;502024330056@smail.nju.edu.cn&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>sequencer: stop pretending that an assignment is a condition</title>
<updated>2025-05-15T20:46:49Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2025-05-15T13:11:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=22488332393646cfa4263bcb24836f492876406e'/>
<id>urn:sha1:22488332393646cfa4263bcb24836f492876406e</id>
<content type='text'>
In 3e81bccdf3 (sequencer: factor out todo command name parsing,
2019-06-27), a `return` statement was introduced that basically was a
long sequence of conditions, combined with `&amp;&amp;`, except for the last
condition which is not really a condition but an assignment.

The point of this construct was to return 1 (i.e. `true`) from the
function if all of those conditions held true, and also assign the `bol`
pointer to the end of the parsed command.

Some static analyzers are really unhappy about such constructs. And
human readers are at least puzzled, if not confused, by seeing a single
`=` inside a chain of conditions where they would have expected to see
`==` instead and, based on experience, immediately suspect a typo.

Let's help all of this by turning this into the more verbose, more
readable form of an `if` construct that both assigns the pointer as well
as returns 1 if all of the conditions hold true.

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>oidmap: rename oidmap_free() to oidmap_clear()</title>
<updated>2025-05-12T20:06:26Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2025-05-12T18:50:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=274464683462d04363d2107822b0f9d2d5a27623'/>
<id>urn:sha1:274464683462d04363d2107822b0f9d2d5a27623</id>
<content type='text'>
This function does not free the oidmap struct itself; it just drops all
items from the map (using hashmap_clear_() internally). It should be
called oidmap_clear(), per CodingGuidelines.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>sequencer: rework reflog message handling</title>
<updated>2025-05-09T20:29:23Z</updated>
<author>
<name>Phillip Wood</name>
<email>phillip.wood@dunelm.org.uk</email>
</author>
<published>2025-05-09T16:22:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=5dbaec628d6dfbdc4db9ac528d2b77cc4286d70a'/>
<id>urn:sha1:5dbaec628d6dfbdc4db9ac528d2b77cc4286d70a</id>
<content type='text'>
It has been reported that "git rebase --rebase-merges" can create
corrupted reflog entries like

    e9c962f2ea0 HEAD@{8}: &lt;binary&gt;�: Merged in &lt;branch&gt; (pull request #4441)

This is due to a use-after-free bug that happens because
reflog_message() uses a static `struct strbuf` and is not called to
update the current reflog message stored in `ctx-&gt;reflog_message` when
creating the merge. This means `ctx-&gt;reflog_message` points to a stale
reflog message that has been freed by subsequent call to
reflog_message() by a command such as `reset` that used the return value
directly rather than storing the result in `ctx-&gt;reflog_message`.

Fix this by creating the reflog message nearer to where the commit is
created and storing it in a local variable which is passed as an
additional parameter to run_git_commit() rather than storing the message
in `struct replay_ctx`. This makes it harder to forget to call
`reflog_message()` before creating a commit and using a variable with a
narrower scope means that a stale value cannot carried across a from one
iteration of the loop to the next which should prevent any similar
use-after-free bugs in the future.

A existing test is modified to demonstrate that merges are now created
with the correct reflog message.

Reported-by: Kristoffer Haugsbakk &lt;code@khaugsbakk.name&gt;
Signed-off-by: Phillip Wood &lt;phillip.wood@dunelm.org.uk&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
