From: Ramsay Jones <ramsay@ramsayjones.plus.com>
To: Jeff King <peff@peff.net>
Cc: Lars Schneider <larsxschneider@gmail.com>,
git@vger.kernel.org, sschuberth@gmail.com,
sunshine@sunshineco.com, hvoigt@hvoigt.net, sbeller@google.com,
Johannes.Schindelin@gmx.de, gitster@pobox.com
Subject: Re: [PATCH v4 3/3] config: add '--show-origin' option to print the origin of a config value
Date: Tue, 16 Feb 2016 22:14:45 +0000 [thread overview]
Message-ID: <56C39F55.1090903@ramsayjones.plus.com> (raw)
In-Reply-To: <20160216173853.GA15026@sigill.intra.peff.net>
On 16/02/16 17:38, Jeff King wrote:
> On Tue, Feb 16, 2016 at 04:46:07PM +0000, Ramsay Jones wrote:
>
>>> OK, I am happy to add the extra code.
>>
>> Unless I've missed something (quite possible), this patch does not
>> need to change. (you have (both) convinced me that your current
>> solution is the best).
>>
>> The only change that I would suggest is the one-liner I already
>> suggested to the previous patch (plus the one-liner in the test,
>> of course. err ... so the two-liner!). Having said that, I didn't
>> try it out - I was just typing into my email client, so ...
>
> I think it's more than that one-liner. This patch shows "type:name"
> verbatim from what is passed into do_config_from_file, as does the error
> message. If they are going to have different output formats (e.g.,
> "<stdin>" versus "stdin"), there needs to be logic transforming them in
> at least one of the spots.
Ugh, yes you are right.
Hmm, I just hacked something up (see below) and, since its a bit
ugly, I'm now in two minds! (it could be improved, of course). ;-)
So, I'll leave it to yourself and Lars to decide.
ATB,
Ramsay Jones
-- >8 --
From: Ramsay Jones <ramsay@ramsayjones.plus.com>
Date: Tue, 16 Feb 2016 21:39:47 +0000
Subject: [PATCH] config: fixup '<stdin>' error messages
Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
---
config.c | 22 ++++++++++++++++++----
t/t1300-repo-config.sh | 2 +-
2 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/config.c b/config.c
index 0a35323..adc808c 100644
--- a/config.c
+++ b/config.c
@@ -417,6 +417,8 @@ static int git_parse_source(config_fn_t fn, void *data)
int comment = 0;
int baselen = 0;
struct strbuf *var = &cf->var;
+ const char *cftype = cf->type;
+ const char *cfname = cf->name;
/* U+FEFF Byte Order Mark in UTF8 */
const char *bomptr = utf8_bom;
@@ -471,10 +473,14 @@ static int git_parse_source(config_fn_t fn, void *data)
if (get_value(fn, data, var) < 0)
break;
}
+ if (!strcmp(cftype, "stdin")) {
+ cftype = "file";
+ cfname = "<stdin>";
+ }
if (cf->die_on_error)
- die(_("bad config line %d in %s %s"), cf->linenr, cf->type, cf->name);
+ die(_("bad config line %d in %s %s"), cf->linenr, cftype, cfname);
else
- return error(_("bad config line %d in %s %s"), cf->linenr, cf->type, cf->name);
+ return error(_("bad config line %d in %s %s"), cf->linenr, cftype, cfname);
}
static int parse_unit_factor(const char *end, uintmax_t *val)
@@ -589,9 +595,17 @@ static void die_bad_number(const char *name, const char *value)
if (!value)
value = "";
- if (cf && cf->type && cf->name)
+ if (cf && cf->type && cf->name) {
+ const char *cftype = cf->type;
+ const char *cfname = cf->name;
+
+ if (!strcmp(cftype, "stdin")) {
+ cftype = "file";
+ cfname = "<stdin>";
+ }
die(_("bad numeric config value '%s' for '%s' in %s %s: %s"),
- value, name, cf->type, cf->name, reason);
+ value, name, cftype, cfname, reason);
+ }
die(_("bad numeric config value '%s' for '%s': %s"), value, name, reason);
}
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index 4abbdf9..4497688 100755
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
@@ -707,7 +707,7 @@ test_expect_success 'invalid unit' '
'
test_expect_success 'invalid stdin config' '
- echo "fatal: bad config line 1 in stdin " >expect &&
+ echo "fatal: bad config line 1 in file <stdin>" >expect &&
echo "[broken" | test_must_fail git config --list --file - >output 2>&1 &&
test_cmp expect output
'
--
2.7.0
next prev parent reply other threads:[~2016-02-16 22:14 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-15 10:17 [PATCH v4 0/3] config: add '--sources' option to print the source of a config value larsxschneider
2016-02-15 10:17 ` [PATCH v4 1/3] t: do not hide Git's exit code in tests larsxschneider
2016-02-15 17:41 ` Jeff King
2016-02-16 9:36 ` Lars Schneider
2016-02-15 10:17 ` [PATCH v4 2/3] config: add 'type' to config_source struct that identifies config type larsxschneider
2016-02-15 17:42 ` Jeff King
2016-02-16 22:07 ` Ramsay Jones
2016-02-15 21:30 ` Ramsay Jones
2016-02-17 13:12 ` Johannes Schindelin
2016-02-18 8:46 ` Lars Schneider
2016-02-15 10:17 ` [PATCH v4 3/3] config: add '--show-origin' option to print the origin of a config value larsxschneider
2016-02-15 18:06 ` Jeff King
2016-02-15 20:58 ` Eric Sunshine
2016-02-15 21:03 ` Jeff King
2016-02-17 8:32 ` Lars Schneider
2016-02-17 16:39 ` Junio C Hamano
2016-02-15 21:36 ` Ramsay Jones
2016-02-15 21:40 ` Jeff King
2016-02-15 22:39 ` Ramsay Jones
2016-02-16 9:51 ` Lars Schneider
2016-02-16 16:46 ` Ramsay Jones
2016-02-16 17:38 ` Jeff King
2016-02-16 22:14 ` Ramsay Jones [this message]
2016-02-16 22:17 ` Jeff King
2016-02-15 21:41 ` Junio C Hamano
2016-02-16 9:48 ` Lars Schneider
2016-02-15 22:18 ` Junio C Hamano
2016-02-15 22:59 ` Jeff King
2016-02-15 23:56 ` Junio C Hamano
2016-02-16 9:52 ` Lars Schneider
2016-02-15 18:05 ` [PATCH v4 0/3] config: add '--sources' option to print the source " Jeff King
2016-02-16 9:40 ` Lars Schneider
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=56C39F55.1090903@ramsayjones.plus.com \
--to=ramsay@ramsayjones.plus.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=hvoigt@hvoigt.net \
--cc=larsxschneider@gmail.com \
--cc=peff@peff.net \
--cc=sbeller@google.com \
--cc=sschuberth@gmail.com \
--cc=sunshine@sunshineco.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.