From: Diane Gasselin <diane.gasselin@ensimag.imag.fr>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Axel Bonnet" <axel.bonnet@ensimag.imag.fr>,
git@vger.kernel.org,
"Clément Poulain" <clement.poulain@ensimag.imag.fr>
Subject: Re: [RFC/PATCH 3/4] textconv: support for blame
Date: Fri, 4 Jun 2010 12:34:25 +0200 [thread overview]
Message-ID: <AANLkTinfYAFAX4Hcl9lZMspju_Yk5eGll2S-z9HPdkjh@mail.gmail.com> (raw)
In-Reply-To: <7veign5oc9.fsf@alter.siamese.dyndns.org>
Le 4 juin 2010 08:00, Junio C Hamano <gitster@pobox.com> a écrit :
> Axel Bonnet <axel.bonnet@ensimag.imag.fr> writes:
>
>> @@ -2033,10 +2072,13 @@ static struct commit *fake_working_tree_commit(struct diff_options opt,
>> read_from = path;
>> }
>> mode = canon_mode(st.st_mode);
>> +
>> switch (st.st_mode & S_IFMT) {
>> case S_IFREG:
>> - if (strbuf_read_file(&buf, read_from, st.st_size) != st.st_size)
>> - die_errno("cannot open or read '%s'", read_from);
>> + if (!DIFF_OPT_TST(&opt, ALLOW_TEXTCONV) ||
>> + !textconv_object(read_from, null_sha1, mode, &buf))
>> + if (strbuf_read_file(&buf, read_from, st.st_size) != st.st_size)
>> + die_errno("cannot open or read '%s'", read_from);
>
> This is just a style thing but it would probably be easier to read if you
> structured it like:
>
> if (! we are allowed to use textconv ||
> do textconv and we did get the converted data in the buffer)
> ; /* happy */
> else if (! successfully read the blob into buffer)
> die;
>
We changed the structure, we now have something like:
case S_IFREG:
if (DIFF_OPT_TST(&opt, ALLOW_TEXTCONV) &&
textconv_object(read_from, null_sha1, mode, &buf))
;
else if (strbuf_read_file(&buf, read_from, st.st_size) != st.st_size)
die_errno("cannot open or read '%s'", read_from);
break;
> By the way, can't textconv_object() ever fail? I see the function has its
> own die()
I don't really see which die you are talking about, there is no direct
die in textconv_object().
> but it looks a bit funny to see one branch of an "if" statement
> calls a function that lets the caller decide to die while the function
> called by the other branch unconditionally dies on failure at the API
> design level.
>
The function fill_textconv() called by textconv_object() can fail if
there is a problem during the textconv conversion. But
textconv_object() tests before if we have to and if we can peform a
conversion.
We did not add some die but only let the existing die.
> An alternative would be to encapsulate the whole of the above logic in one
> helper function perhaps.
>
>> @@ -2249,8 +2291,10 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
>> int cmd_is_annotate = !strcmp(argv[0], "annotate");
>>
>> git_config(git_blame_config, NULL);
>> + git_config(git_diff_ui_config, NULL);
>
> What configuration are we pulling into the system with this call? Would
> they ever affect the internal diff machinery in a negative way? I am
> especially wondering about "diff.renames" here.
>
Actually, we call git_diff_ui_config in order to get the drivers. But
we could call a more specific configuration.
Here are others solutions:
1) We could add:
switch (userdiff_config(var, value)) {
case 0: break;
case -1: return -1;
default: return 0;
}
to git_blame_config
2) We could call
git_config(git_diff_basic_config, NULL);
or git_config((config_fn_t)userdiff_config, NULL);
instead of git_config(git_diff_ui_config, NULL);
>> init_revisions(&revs, NULL);
>> revs.date_mode = blame_date_mode;
>> + DIFF_OPT_SET(&revs.diffopt, ALLOW_TEXTCONV);
>
> As an RFC patch, I would have preferred if we didn't have this line to
> force --textconv on by default, but instead you merely allowed the
> mechanism to be used by giving the option explicitly from the command
> line.
>
> Other than these points, the series looked quite sane to me.
>
Thanks a lot for your time and comments.
next prev parent reply other threads:[~2010-06-04 10:34 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-03 10:47 [RFC/PATCH 0/4] textconv support for blame Axel Bonnet
2010-06-03 10:47 ` [RFC/PATCH 1/4] textconv: make the API public Axel Bonnet
2010-06-03 10:47 ` [RFC/PATCH 2/4] textconv: make diff_options accessible from blame Axel Bonnet
2010-06-03 10:47 ` [RFC/PATCH 3/4] textconv: support for blame Axel Bonnet
2010-06-03 10:47 ` [RFC/PATCH 4/4] t/t8006: test textconv " Axel Bonnet
2010-06-03 15:44 ` Johannes Sixt
2010-06-04 8:55 ` Diane Gasselin
2010-06-04 9:45 ` Matthieu Moy
2010-06-04 8:49 ` Matthieu Moy
2010-06-04 6:00 ` [RFC/PATCH 3/4] textconv: " Junio C Hamano
2010-06-04 10:34 ` Diane Gasselin [this message]
2010-06-06 21:51 ` Jeff King
2010-06-04 5:48 ` [RFC/PATCH 2/4] textconv: make diff_options accessible from blame Junio C Hamano
2010-06-04 7:59 ` Matthieu Moy
2010-06-04 10:21 ` bonneta
2010-06-04 17:23 ` Matthieu Moy
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AANLkTinfYAFAX4Hcl9lZMspju_Yk5eGll2S-z9HPdkjh@mail.gmail.com \
--to=diane.gasselin@ensimag.imag.fr \
--cc=axel.bonnet@ensimag.imag.fr \
--cc=clement.poulain@ensimag.imag.fr \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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.
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 NNTP newsgroup(s).