Re: [GSoC][PATCH v4 15/20] rebase -i: rewrite write_basic_state() in C
- From
SZEDER Gábor <szeder.dev@gmail.com>
- Date
- Jul 30, 2018, 18:25 UTC
- Message-ID
- <20180730182516.32644-1-szeder.dev@gmail.com>
- In-Reply-To
- <20180724163221.15201-16-alban.gruin@gmail.com>
> diff --git a/sequencer.c b/sequencer.c > index 1c035ceec7..d257903db0 100644 > --- a/sequencer.c > +++ b/sequencer.c
Show 16 quoted lines
> +int write_basic_state(struct replay_opts *opts, const char *head_name,
> + const char *onto, const char *orig_head)
> +{
> + const char *quiet = getenv("GIT_QUIET");
> +
> + if (head_name)
> + write_file(rebase_path_head_name(), "%s\n", head_name);
> + if (onto)
> + write_file(rebase_path_onto(), "%s\n", onto);
> + if (orig_head)
> + write_file(rebase_path_orig_head(), "%s\n", orig_head);
> +
> + if (quiet)
> + write_file(rebase_path_quiet(), "%s\n", quiet);
> + else
> + write_file(rebase_path_quiet(), "");This is not a faithful conversion of the original. git-rebase.sh writes this 'quiet' file with:
echo "$GIT_QUIET" > "$state_dir"/quiet
which means that a single newline character was written even when $GIT_QUIET was unset/empty.
I seem to recall a case in the past, when a shell-to-C conversion accidentally dropped a newline from a similar state-file, which then caused some issues later on. But I don't remember the specifics and a quick search didn't turn up anything relevant either...
Show 24 quoted lines
> +
> + if (opts->verbose)
> + write_file(rebase_path_verbose(), "");
> + if (opts->strategy)
> + write_file(rebase_path_strategy(), "%s\n", opts->strategy);
> + if (opts->xopts_nr > 0)
> + write_strategy_opts(opts);
> +
> + if (opts->allow_rerere_auto == RERERE_AUTOUPDATE)
> + write_file(rebase_path_allow_rerere_autoupdate(), "--rerere-autoupdate\n");
> + else if (opts->allow_rerere_auto == RERERE_NOAUTOUPDATE)
> + write_file(rebase_path_allow_rerere_autoupdate(), "--no-rerere-autoupdate\n");
> +
> + if (opts->gpg_sign)
> + write_file(rebase_path_gpg_sign_opt(), "-S%s\n", opts->gpg_sign);
> + if (opts->signoff)
> + write_file(rebase_path_signoff(), "--signoff\n");
> +
> + return 0;
> +}
> +
> static int walk_revs_populate_todo(struct todo_list *todo_list,
> struct replay_opts *opts)
> {