From 23cb5bf3b3b9699bf00fa38c4c08f32f8c60b529 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 22 Dec 2011 11:21:26 -0800 Subject: i18n of multi-line advice messages Advice messages are by definition meant for human end-users, and prime candidates for i18n/l10n. They tend to also be more verbose to be helpful, and need to be longer than just one line. Although we do not have parameterized multi-line advice messages yet, once we do, we cannot emit such a message like this: advise(_("Please rename %s to something else"), gostak); advise(_("so that we can avoid distimming %s unnecessarily."), doshes); because some translations may need to have the replacement of 'gostak' on the second line (or 'doshes' on the first line). Some languages may even need to use three lines in order to fit the same message within a reasonable width. Instead, it has to be a single advise() construct, like this: advise(_("Please rename %s to something else\n" "so that we can avoid distimming %s unnecessarily."), gostak, doshes); Update the advise() function and its existing callers to - take a format string that can be multi-line and translatable as a whole; - use the string and the parameters to form a localized message; and - show each line in the result with the localization of the "hint: ". Signed-off-by: Junio C Hamano --- advice.c | 23 ++++++++++++++++------- builtin/revert.c | 9 ++++----- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/advice.c b/advice.c index e02e632df3..65a07859f2 100644 --- a/advice.c +++ b/advice.c @@ -21,11 +21,21 @@ static struct { void advise(const char *advice, ...) { + struct strbuf buf = STRBUF_INIT; va_list params; + const char *cp, *np; va_start(params, advice); - vreportf("hint: ", advice, params); + strbuf_addf(&buf, advice, params); va_end(params); + + for (cp = buf.buf; *cp; cp = np) { + np = strchrnul(cp, '\n'); + fprintf(stderr, _("hint: %.*s\n"), (int)(np - cp), cp); + if (*np) + np++; + } + strbuf_release(&buf); } int git_default_advice_config(const char *var, const char *value) @@ -46,16 +56,15 @@ int git_default_advice_config(const char *var, const char *value) int error_resolve_conflict(const char *me) { error("'%s' is not possible because you have unmerged files.", me); - if (advice_resolve_conflict) { + if (advice_resolve_conflict) /* * Message used both when 'git commit' fails and when * other commands doing a merge do. */ - advise("Fix them up in the work tree,"); - advise("and then use 'git add/rm ' as"); - advise("appropriate to mark resolution and make a commit,"); - advise("or use 'git commit -a'."); - } + advise(_("Fix them up in the work tree,\n" + "and then use 'git add/rm ' as\n" + "appropriate to mark resolution and make a commit,\n" + "or use 'git commit -a'.")); return -1; } diff --git a/builtin/revert.c b/builtin/revert.c index 1ea525c10e..3ad14a1f98 100644 --- a/builtin/revert.c +++ b/builtin/revert.c @@ -332,11 +332,10 @@ static void print_advice(int show_hint) return; } - if (show_hint) { - advise("after resolving the conflicts, mark the corrected paths"); - advise("with 'git add ' or 'git rm '"); - advise("and commit the result with 'git commit'"); - } + if (show_hint) + advise(_("after resolving the conflicts, mark the corrected paths\n" + "with 'git add ' or 'git rm '\n" + "and commit the result with 'git commit'")); } static void write_message(struct strbuf *msgbuf, const char *filename) -- cgit v1.2.3 From 18ab83e8568878edc3f6680ebdf439ccaa5bf5db Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Sat, 7 Jan 2012 11:47:38 +0100 Subject: gitweb: Fix actionless dispatch for non-existent objects When gitweb URL does not provide action explicitly, e.g. http://git.example.org/repo.git/branch dispatch() tries to guess action (view to be used) based on remaining parameters. Among others it is based on the type of requested object, which gave problems when asking for non-existent branch or file (for example misspelt name). Now undefined $action from dispatch() should not result in problems. Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- gitweb/gitweb.perl | 4 +++- t/t9500-gitweb-standalone-no-errors.sh | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 874023a33e..6cf38853b5 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -1122,8 +1122,10 @@ sub dispatch { if (!defined $action) { if (defined $hash) { $action = git_get_type($hash); + $action or die_error(404, "Object does not exist"); } elsif (defined $hash_base && defined $file_name) { $action = git_get_type("$hash_base:$file_name"); + $action or die_error(404, "File or directory does not exist"); } elsif (defined $project) { $action = 'summary'; } else { @@ -2364,7 +2366,7 @@ sub get_feed_info { return unless (defined $project); # some views should link to OPML, or to generic project feed, # or don't have specific feed yet (so they should use generic) - return if ($action =~ /^(?:tags|heads|forks|tag|search)$/x); + return if (!$action || $action =~ /^(?:tags|heads|forks|tag|search)$/x); my $branch; # branches refs uses 'refs/heads/' prefix (fullname) to differentiate diff --git a/t/t9500-gitweb-standalone-no-errors.sh b/t/t9500-gitweb-standalone-no-errors.sh index 53297156a3..94365bb006 100755 --- a/t/t9500-gitweb-standalone-no-errors.sh +++ b/t/t9500-gitweb-standalone-no-errors.sh @@ -403,6 +403,14 @@ test_expect_success \ 'path_info: project/branch:dir/' \ 'gitweb_run "" "/.git/master:foo/"' +test_expect_success \ + 'path_info: project/branch (non-existent)' \ + 'gitweb_run "" "/.git/non-existent"' + +test_expect_success \ + 'path_info: project/branch:filename (non-existent branch)' \ + 'gitweb_run "" "/.git/non-existent:non-existent"' + test_expect_success \ 'path_info: project/branch:file (non-existent)' \ 'gitweb_run "" "/.git/master:non-existent"' -- cgit v1.2.3 From aae5239be2b41477e8dc515f4fa372be2025e70a Mon Sep 17 00:00:00 2001 From: Kirill Smelkov Date: Sun, 4 Sep 2011 00:41:21 +0400 Subject: t/Makefile: Use $(sort ...) explicitly where needed Starting from GNU Make 3.82 $(wildcard ...) no longer sorts the result (from NEWS): * WARNING: Backward-incompatibility! Wildcards were not documented as returning sorted values, but the results have been sorted up until this release.. If your makefiles require sorted results from wildcard expansions, use the $(sort ...) function to request it explicitly. http://repo.or.cz/w/make.git/commitdiff/2a59dc32aaf0681dec569f32a9d7ab88a379d34f I usually watch test progress visually, and if tests are sorted, even with make -j4 they go more or less incrementally by their t number. On the other side, without sorting, tests are executed in seemingly random order even for -j1. Let's please maintain sane tests order for perceived prettyness. Another note is that in GNU Make sort also works as uniq, so after sort being removed, we might expect e.g. $(wildcard *.sh a.*) to produce duplicates for e.g. "a.sh". From this point of view, adding sort could be seen as hardening t/Makefile from accidentally introduced dups. It turned out that prevous releases of GNU Make did not perform full sort in $(wildcard), only sorting results for each pattern, that's why explicit sort-as-uniq is relevant even for older makes. Signed-off-by: Kirill Smelkov Signed-off-by: Junio C Hamano --- t/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/t/Makefile b/t/Makefile index 9046ec9816..66ceefefcc 100644 --- a/t/Makefile +++ b/t/Makefile @@ -17,9 +17,9 @@ DEFAULT_TEST_TARGET ?= test # Shell quote; SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) -T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh) -TSVN = $(wildcard t91[0-9][0-9]-*.sh) -TGITWEB = $(wildcard t95[0-9][0-9]-*.sh) +T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)) +TSVN = $(sort $(wildcard t91[0-9][0-9]-*.sh)) +TGITWEB = $(sort $(wildcard t95[0-9][0-9]-*.sh)) all: $(DEFAULT_TEST_TARGET) -- cgit v1.2.3