Re: [PATCH v4 06/11] replace: bypass the type check if -f option is used
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 4, 2013, 20:44 UTC
- Message-ID
- <xmqq4na0mi51.fsf@gitster.dls.corp.google.com>
- In-Reply-To
- <20130903071026.29838.76437.chriscool@tuxfamily.org>
Christian Couder <chriscool@tuxfamily.org> writes:
Show 6 quoted lines
> If -f option, which means '--force', is used, we can allow an object > to be replaced with one of a different type, as the user should know > what (s)he is doing. > > Signed-off-by: Christian Couder <chriscool@tuxfamily.org> > ---
This does not matter in a larger picture, but between 1/11 and this patch, there is a window where an operation that has been useful in some workflows becomes unavailable to the user.
For future reference, it would be better to do this as a part of 1/11, to make sure that there always is an escape hatch available to the users.
Show 16 quoted lines
> builtin/replace.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/builtin/replace.c b/builtin/replace.c
> index 9a94769..95736d9 100644
> --- a/builtin/replace.c
> +++ b/builtin/replace.c
> @@ -103,7 +103,7 @@ static int replace_object(const char *object_ref, const char *replace_ref,
>
> obj_type = sha1_object_info(object, NULL);
> repl_type = sha1_object_info(repl, NULL);
> - if (obj_type != repl_type)
> + if (!force && obj_type != repl_type)
> die("Objects must be of the same type.\n"
> "'%s' points to a replaced object of type '%s'\n"
> "while '%s' points to a replacement object of type '%s'.",