On Mon, May 23, 2016 at 9:31 PM, Eric Sunshine <sunshine@xxxxxxxxxxxxxx> wrote: > On Mon, May 23, 2016 at 10:48 AM, Pranit Bauva <pranit.bauva@xxxxxxxxx> wrote: >> Reimplement the `write_terms` shell function in C and add a `write-terms` >> subcommand to `git bisect--helper` to call it from git-bisect.sh . Also >> remove the subcommand `--check-term-format` as it can now be called from >> inside the function write_terms() C implementation. >> [...] >> Signed-off-by: Pranit Bauva <pranit.bauva@xxxxxxxxx> >> --- >> diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c >> @@ -56,18 +58,38 @@ static int check_term_format(const char *term, const char *orig_term) >> +static int write_terms(const char *bad, const char *good) >> +{ >> + FILE *fp; >> + int res; >> + >> + if (!strcmp(bad, good)) >> + return error(_("please use two different terms")); >> + >> + if (check_term_format(bad, "bad") || check_term_format(good, "good")) >> + return -1; >> + >> + fp = fopen(git_path_bisect_write_terms(), "w"); >> + if (!fp) >> + return error(_("could not open the file to write terms")); > > By adding two pieces of information, you could make this error message > much more helpful for anyone trying to debug the failure. > Specifically: > > (1) the pathname for which open() failed > (2) the actual system-level error > > For (2), you could use strerror(errno) or, better yet, error_errno() > which recently graduated to 'master'. Yes it would definitely be better to make the error message more helpful. I will dig more into this. >> + res = fprintf(fp, "%s\n%s\n", bad, good); >> + fclose(fp); >> + return (res < 0) ? -1 : 0; >> +} -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html