Re: [PATCH v6 9/9] sequencer: fallback to sane label in making rebase todo list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Mon, 11 Nov 2019, Doan Tran Cong Danh wrote:

> In later stage of rebasing, we will make a ref in
> refs/rewritten/<label>, this label is extracted from the subject of
> current merge commit.
>
> If that subject has forbidden character for refname, git couldn't create
> the rewritten ref. One such case is the merge commit subject has
> a multibyte character encoded in ISO-2022-JP.
>
> Provide a sane fallback in order to help git-rebase works in such case
>
> Signed-off-by: Doan Tran Cong Danh <congdanhqx@xxxxxxxxx>
> ---

There was an alternative patch under discussion, one that also addressed
problem like e.g. characters that are illegal in Windows file names:
https://github.com/gitgitgadget/git/pull/327

Unfortunately, the reviews asked for an extensive revision for which I have
not been able to find the time to implement them.

Having said that, I think that the solution proposed over there is more
complete, and maybe even more robust (nothing in your patch prevents
`label-<hex-oid>` to _already_ having been taken by another label).

Ciao,
Dscho

>  sequencer.c            | 11 +++++++++--
>  t/t3434-rebase-i18n.sh |  2 +-
>  2 files changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/sequencer.c b/sequencer.c
> index 2f32b44f52..f664ba727e 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -4560,6 +4560,7 @@ static int make_script_with_merges(struct pretty_print_context *pp,
>  	while ((commit = get_revision(revs))) {
>  		struct commit_list *to_merge;
>  		const char *p1, *p2;
> +		const char *hex_oid;
>  		struct object_id *oid;
>  		int is_empty;
>
> @@ -4607,9 +4608,15 @@ static int make_script_with_merges(struct pretty_print_context *pp,
>  			if (isspace(*p1))
>  				*(char *)p1 = '-';
>
> +		hex_oid = oid_to_hex(&commit->object.oid);
> +
> +		if (check_refname_format(label.buf, REFNAME_ALLOW_ONELEVEL) < 0) {
> +			strbuf_reset(&label);
> +			strbuf_addf(&label, "label-%s", hex_oid);
> +		}
> +
>  		strbuf_reset(&buf);
> -		strbuf_addf(&buf, "%s -C %s",
> -			    cmd_merge, oid_to_hex(&commit->object.oid));
> +		strbuf_addf(&buf, "%s -C %s", cmd_merge, hex_oid);
>
>  		/* label the tips of merged branches */
>  		for (; to_merge; to_merge = to_merge->next) {
> diff --git a/t/t3434-rebase-i18n.sh b/t/t3434-rebase-i18n.sh
> index 4b5b128cd6..c7c835cde9 100755
> --- a/t/t3434-rebase-i18n.sh
> +++ b/t/t3434-rebase-i18n.sh
> @@ -45,7 +45,7 @@ test_expect_success 'rebase --rebase-merges update encoding eucJP to UTF-8' '
>  	compare_msg eucJP.txt eucJP UTF-8
>  '
>
> -test_expect_failure 'rebase --rebase-merges update encoding eucJP to ISO-2022-JP' '
> +test_expect_success 'rebase --rebase-merges update encoding eucJP to ISO-2022-JP' '
>  	git switch -c merge-eucJP-ISO-2022-JP first &&
>  	git config i18n.commitencoding eucJP &&
>  	git merge -F "$TEST_DIRECTORY/t3434/eucJP.txt" second &&
> --
> 2.24.0.164.g78daf050de.dirty
>
>




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux