git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: Re: [PATCH 2/2] rebase --exec: make it work with --rebase-merges
Date: Fri, 03 Aug 2018 13:26:09 -0700	[thread overview]
Message-ID: <xmqqa7q3w61q.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <b29c4d979f147f38bc0a4765a953a748eec0cd6d.1533318123.git.gitgitgadget@gmail.com> (Johannes Schindelin via GitGitGadget's message of "Fri, 03 Aug 2018 10:42:08 -0700 (PDT)")

"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
writes:

> +	/*
> +	 * Insert <commands> after every pick. Here, fixup/squash chains
> +	 * are considered part of the pick, so we insert the commands *after*
> +	 * those chains if there are any.
> +	 */
> +	insert_final_commands = 1;
> +	for (i = 0; i < todo_list.nr; ) {
> +		enum todo_command command = todo_list.items[i].command;
> +		int j = 0;
> + ...
> +		/* skip fixup/squash chain, if any */
> +		for (i++; i < todo_list.nr; i++, j = 0) {

Does 'j' need to be reset to 0 in each iteration?  Nobody looks at
'j' after exiting this inner loop, and every referernce to 'j'
inside this inner loop happens _after_ it gets assigned "i+1" at the
beginning of "skip comment" loop.

For that matter, I wonder if 'j' can be a variable local to this
inner loop, not the outer loop that iterates over todo_list.items[].

> +			command = todo_list.items[i].command;
> +
> +			if (is_fixup(command))
> +				continue;
> +
> +			if (command != TODO_COMMENT)
> +				break;
> +
> +			/* skip comment if followed by any fixup/squash */
> +			for (j = i + 1; j < todo_list.nr; j++)
> +				if (todo_list.items[j].command != TODO_COMMENT)
> +					break;
> +			if (j < todo_list.nr &&
> +			    is_fixup(todo_list.items[j].command)) {
> +				i = j;
> +				continue;
> +			}
> +			break;
>  		}

  parent reply	other threads:[~2018-08-03 20:26 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-03 17:42 [PATCH 0/2] Make git rebase work with --rebase-merges and --exec Johannes Schindelin via GitGitGadget
2018-08-03 17:42 ` [PATCH 1/2] t3430: demonstrate what -r, --autosquash & --exec should do Johannes Schindelin via GitGitGadget
2018-08-03 17:42 ` [PATCH 2/2] rebase --exec: make it work with --rebase-merges Johannes Schindelin via GitGitGadget
2018-08-03 18:28   ` Junio C Hamano
2018-08-06  9:34     ` Johannes Schindelin
2018-08-06  9:50     ` Johannes Schindelin
2018-08-06 15:12       ` Junio C Hamano
2018-08-03 20:26   ` Junio C Hamano [this message]
2018-08-06  9:36     ` Johannes Schindelin
2018-08-06  9:52 ` [PATCH v2 0/2] Make git rebase work with --rebase-merges and --exec Johannes Schindelin via GitGitGadget
2018-08-06  9:52   ` [PATCH v2 1/2] t3430: demonstrate what -r, --autosquash & --exec should do Johannes Schindelin via GitGitGadget
2018-08-06  9:52   ` [PATCH v2 2/2] rebase --exec: make it work with --rebase-merges Johannes Schindelin via GitGitGadget
2018-08-06 15:23     ` Phillip Wood
2018-08-06 16:00       ` Phillip Wood
2018-08-09  9:22       ` Johannes Schindelin
2018-08-09 10:04         ` Phillip Wood
2018-08-09 13:30           ` Johannes Schindelin
2018-08-06 10:08   ` [PATCH v2 0/2] Make git rebase work with --rebase-merges and --exec Johannes Schindelin
2018-08-09  9:41   ` [PATCH v3 " Johannes Schindelin via GitGitGadget
2018-08-09  9:41     ` [PATCH v3 1/2] t3430: demonstrate what -r, --autosquash & --exec should do Johannes Schindelin via GitGitGadget
2018-08-09  9:41     ` [PATCH v3 2/2] rebase --exec: make it work with --rebase-merges Johannes Schindelin via GitGitGadget

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqa7q3w61q.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=johannes.schindelin@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).