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

Re: [PATCH 1/5] Teach cherry-pick to skip redundant commits if asked

From
David A. Greene <greened@obbligato.org>
Date
Jan 12, 2016, 03:10 UTC
Message-ID
<87oacra3wq.fsf@waller.obbligato.org>
In-Reply-To
<xmqqr3hnx6e2.fsf@gitster.mtv.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 18 quoted lines
>> +		OPT_END(),
>>  		OPT_END(),
>>  		OPT_END(),
>>  		OPT_END(),
>> @@ -106,6 +112,7 @@ static void parse_args(int argc, const char **argv, struct replay_opts *opts)
>>  			OPT_BOOL(0, "allow-empty", &opts->allow_empty, N_("preserve initially empty commits")),
>>  			OPT_BOOL(0, "allow-empty-message", &opts->allow_empty_message, N_("allow commits with empty messages")),
>>  			OPT_BOOL(0, "keep-redundant-commits", &opts->keep_redundant_commits, N_("keep redundant, empty commits")),
>> +			OPT_BOOL(0, "skip-redundant-commits", &opts->skip_redundant_commits, N_("skip redundant, empty commits")),
>>  			OPT_END(),
>>  		};
>
> This however makes me wonder what should happen when both are
> specified.  Shouldn't this patch change the keep_redundant_commits
> field from a bool to a tristate that tells us what to do with
> redundant ones?  int/enum opts.redundant_commit can take 0 (fail,
> which would be the default), 1 (keep) or 2 (skip), or something
> like that.
This makes good sense.
Show 11 quoted lines
>> diff --git a/sequencer.c b/sequencer.c
>> index 8c58fa2..12361e7 100644
>> --- a/sequencer.c
>> +++ b/sequencer.c
>> @@ -185,6 +185,7 @@ static void print_advice(int show_hint, struct replay_opts *opts)
>>  		else
>>  			advise(_("after resolving the conflicts, mark the corrected paths\n"
>>  				 "with 'git add <paths>' or 'git rm <paths>'\n"
>> +
>
> ???
Oops.  :)
Show 9 quoted lines
>> @@ -614,6 +615,28 @@ static int do_pick_commit(struct commit *commit, struct replay_opts *opts)
>>  		res = allow;
>>  		goto leave;
>>  	}
>> +
>> +	// If told, do not try to commit things that don't make any
>> +	// changes.
>
> No C++/C99 comments, please.
Will fix.
Show 22 quoted lines
>> +	if (opts->skip_redundant_commits) {
>> +		int index_unchanged = is_index_unchanged();
>> +		if (index_unchanged < 0) {
>> +			// Something bad happened readhing HEAD or the
>> +			// index.  Abort.
>> +			res = index_unchanged;
>> +			goto leave;
>> +		}
>> +		if (index_unchanged) {
>> +			fputs(_("Skipping redundant commit "), stderr);
>> +			fputs(find_unique_abbrev(commit->object.oid.hash,
>> +						 GIT_SHA1_HEXSZ),
>> +			      stderr);
>> +			fputs("\n", stderr);
>
> This is a bad i18n; we do not know the sentence "Skipping commit X"
> is translated to have X at the end of the sentence in all languages.
>
> 	fprintf(stderr, _("Skipping ... %s\n"), find_unique_abbrev(...));
>
> would allow it to be tranlated to "Commit X is getting skipped", for
> example.
Ok, thank you for the guidance.
Show 20 quoted lines
>> diff --git a/sequencer.h b/sequencer.h
>> index 5ed5cb1..ad6145d 100644
>> --- a/sequencer.h
>> +++ b/sequencer.h
>> @@ -34,6 +34,7 @@ struct replay_opts {
>>  	int allow_empty;
>>  	int allow_empty_message;
>>  	int keep_redundant_commits;
>> +	int skip_redundant_commits;
>
> Continuing from the top-part of the comments, this may be better to
> be:
>
> 	enum {
>             REPLAY_REDUNDANT_FAIL = 0,
>             REPLAY_REDUNDANT_KEEP,
>             REPLAY_REDUNDANT_SKIP
> 	} redundant_commits;
>
> or something like that.
Agreed.

I've also resumed work on my earlier rebase --keep-redundant-commits change. I think I'm going to reorganize things and send the cherry-pick changes separate from the rebase changes since the latter depends on the former. Then all of the redundant commit work on rebase can be in one series for review.

                        -David
Previous: Junio C HamanoNext: David Greene
Message 4 of 9 in “Teach cherry-pick and rebase to ignore redundant commits”
  1. Teach cherry-pick and rebase to ignore redundant commitsDavid Greene, Jan 11, 2016
  2. 1/5 Teach cherry-pick to skip redundant commits if askedDavid Greene, Jan 11, 2016
  3. Junio C HamanoJan 11, 2016
  4. David A. GreeneJan 12, 2016
  5. 2/5 Add test for cherry-pick --skip-redundant-commitsDavid Greene, Jan 11, 2016
  6. 3/5 Add --skip-redundant-commits option to rebaseDavid Greene, Jan 11, 2016
  7. 4/5 Add test for redundant rebaseDavid Greene, Jan 11, 2016
  8. 5/5 Add test for rebase with merges amd redundant commitsDavid Greene, Jan 11, 2016
  9. Eric SunshineJan 11, 2016

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.