git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 0/3] Some add-on patches on top of dj/runtime-prefix
@ 2018-04-20  8:03 Johannes Schindelin
  2018-04-20  8:03 ` [PATCH 1/3] gettext: avoid initialization if the locale dir is not present Johannes Schindelin
                   ` (3 more replies)
  0 siblings, 4 replies; 21+ messages in thread
From: Johannes Schindelin @ 2018-04-20  8:03 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Dan Jacques

We carried a slightly different version of the git_setup_gettext() patch
(which took care of releasing the buffer allocated by system_path()),
and we carry two more patches that touch the same area, so now that
dj/runtime-prefix hit `next`, it seems a good time to contribute those,
too.


Johannes Schindelin (2):
  gettext: avoid initialization if the locale dir is not present
  git_setup_gettext: plug memory leak

Philip Oakley (1):
  Avoid multiple PREFIX definitions

 Makefile   |  2 +-
 exec-cmd.c |  4 ++--
 gettext.c  | 10 +++++++++-
 sideband.c | 10 +++++-----
 4 files changed, 17 insertions(+), 9 deletions(-)


base-commit: 8a3641ab3abcf492e9443f88d82a7a22fa8b4816
Published-As: https://github.com/dscho/git/releases/tag/runtime-prefix-addons-v1
Fetch-It-Via: git fetch https://github.com/dscho/git runtime-prefix-addons-v1
-- 
2.17.0.windows.1.15.gaa56ade3205


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 1/3] gettext: avoid initialization if the locale dir is not present
  2018-04-20  8:03 [PATCH 0/3] Some add-on patches on top of dj/runtime-prefix Johannes Schindelin
@ 2018-04-20  8:03 ` Johannes Schindelin
  2018-04-20  9:59   ` Ævar Arnfjörð Bjarmason
  2018-04-20  8:03 ` [PATCH 2/3] git_setup_gettext: plug memory leak Johannes Schindelin
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 21+ messages in thread
From: Johannes Schindelin @ 2018-04-20  8:03 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Dan Jacques

The runtime of a simple `git.exe version` call on Windows is currently
dominated by the gettext setup, adding a whopping ~150ms to the ~210ms
total.

Given that this cost is added to each and every git.exe invocation goes
through common-main's invocation of git_setup_gettext(), and given that
scripts have to call git.exe dozens, if not hundreds, of times, this is
a substantial performance penalty.

This is particularly pointless when considering that Git for Windows
ships without localization (to keep the installer's size to a bearable
~34MB): all that time setting up gettext is for naught.

So let's be smart about it and skip setting up gettext if the locale
directory is not even present.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 gettext.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gettext.c b/gettext.c
index baba28343c3..701355d66e7 100644
--- a/gettext.c
+++ b/gettext.c
@@ -163,6 +163,9 @@ void git_setup_gettext(void)
 	if (!podir)
 		podir = system_path(GIT_LOCALE_PATH);
 
+	if (!is_directory(podir))
+		return;
+
 	bindtextdomain("git", podir);
 	setlocale(LC_MESSAGES, "");
 	setlocale(LC_TIME, "");
-- 
2.17.0.windows.1.15.gaa56ade3205



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 2/3] git_setup_gettext: plug memory leak
  2018-04-20  8:03 [PATCH 0/3] Some add-on patches on top of dj/runtime-prefix Johannes Schindelin
  2018-04-20  8:03 ` [PATCH 1/3] gettext: avoid initialization if the locale dir is not present Johannes Schindelin
@ 2018-04-20  8:03 ` Johannes Schindelin
  2018-04-20  8:04 ` [PATCH 3/3] Avoid multiple PREFIX definitions Johannes Schindelin
  2018-04-21 11:13 ` [PATCH v2 0/3] Some add-on patches on top of dj/runtime-prefix Johannes Schindelin
  3 siblings, 0 replies; 21+ messages in thread
From: Johannes Schindelin @ 2018-04-20  8:03 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Dan Jacques

The system_path() function returns a freshly-allocated string. We need
to release it.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 gettext.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/gettext.c b/gettext.c
index 701355d66e7..7272771c8e4 100644
--- a/gettext.c
+++ b/gettext.c
@@ -159,18 +159,23 @@ static void init_gettext_charset(const char *domain)
 void git_setup_gettext(void)
 {
 	const char *podir = getenv(GIT_TEXT_DOMAIN_DIR_ENVIRONMENT);
+	char *p = NULL;
 
 	if (!podir)
-		podir = system_path(GIT_LOCALE_PATH);
+		podir = p = system_path(GIT_LOCALE_PATH);
 
-	if (!is_directory(podir))
+	if (!is_directory(podir)) {
+		free(p);
 		return;
+	}
 
 	bindtextdomain("git", podir);
 	setlocale(LC_MESSAGES, "");
 	setlocale(LC_TIME, "");
 	init_gettext_charset("git");
 	textdomain("git");
+
+	free(p);
 }
 
 /* return the number of columns of string 's' in current locale */
-- 
2.17.0.windows.1.15.gaa56ade3205



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 3/3] Avoid multiple PREFIX definitions
  2018-04-20  8:03 [PATCH 0/3] Some add-on patches on top of dj/runtime-prefix Johannes Schindelin
  2018-04-20  8:03 ` [PATCH 1/3] gettext: avoid initialization if the locale dir is not present Johannes Schindelin
  2018-04-20  8:03 ` [PATCH 2/3] git_setup_gettext: plug memory leak Johannes Schindelin
@ 2018-04-20  8:04 ` Johannes Schindelin
  2018-04-22 15:32   ` Philip Oakley
  2018-04-21 11:13 ` [PATCH v2 0/3] Some add-on patches on top of dj/runtime-prefix Johannes Schindelin
  3 siblings, 1 reply; 21+ messages in thread
From: Johannes Schindelin @ 2018-04-20  8:04 UTC (permalink / raw)
  To: git; +Cc: Philip Oakley, Junio C Hamano, Dan Jacques

From: Philip Oakley <philipoakley@iee.org>

The short and sweet PREFIX can be confused when used in many places.

Rename both usages to better describe their purpose. EXEC_CMD_PREFIX is
used in full to disambiguate it from the nearby GIT_EXEC_PATH.

The PREFIX in sideband.c, while nominally independant of the exec_cmd
PREFIX, does reside within libgit[1], so the definitions would clash
when taken together with a PREFIX given on the command line for use by
exec_cmd.c.

Noticed when compiling Git for Windows using MSVC/Visual Studio [1] which
reports the conflict beteeen the command line definition and the
definition in sideband.c within the libgit project.

[1] the libgit functions are brought into a single sub-project
within the Visual Studio construction script provided in contrib,
and hence uses a single command for both exec_cmd.c and sideband.c.

Signed-off-by: Philip Oakley <philipoakley@iee.org>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 Makefile   |  2 +-
 exec-cmd.c |  4 ++--
 sideband.c | 10 +++++-----
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/Makefile b/Makefile
index 111e93d3bea..49cec672242 100644
--- a/Makefile
+++ b/Makefile
@@ -2271,7 +2271,7 @@ exec-cmd.sp exec-cmd.s exec-cmd.o: EXTRA_CPPFLAGS = \
 	'-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \
 	'-DGIT_LOCALE_PATH="$(localedir_relative_SQ)"' \
 	'-DBINDIR="$(bindir_relative_SQ)"' \
-	'-DPREFIX="$(prefix_SQ)"'
+	'-DFALLBACK_RUNTIME_PREFIX="$(prefix_SQ)"'
 
 builtin/init-db.sp builtin/init-db.s builtin/init-db.o: GIT-PREFIX
 builtin/init-db.sp builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \
diff --git a/exec-cmd.c b/exec-cmd.c
index 3b0a039083a..02d31ee8971 100644
--- a/exec-cmd.c
+++ b/exec-cmd.c
@@ -48,7 +48,7 @@ static const char *system_prefix(void)
 	    !(prefix = strip_path_suffix(executable_dirname, GIT_EXEC_PATH)) &&
 	    !(prefix = strip_path_suffix(executable_dirname, BINDIR)) &&
 	    !(prefix = strip_path_suffix(executable_dirname, "git"))) {
-		prefix = PREFIX;
+		prefix = FALLBACK_RUNTIME_PREFIX;
 		trace_printf("RUNTIME_PREFIX requested, "
 				"but prefix computation failed.  "
 				"Using static fallback '%s'.\n", prefix);
@@ -243,7 +243,7 @@ void git_resolve_executable_dir(const char *argv0)
  */
 static const char *system_prefix(void)
 {
-	return PREFIX;
+	return FALLBACK_RUNTIME_PREFIX;
 }
 
 /*
diff --git a/sideband.c b/sideband.c
index 6d7f943e438..325bf0e974a 100644
--- a/sideband.c
+++ b/sideband.c
@@ -13,7 +13,7 @@
  * the remote died unexpectedly.  A flush() concludes the stream.
  */
 
-#define PREFIX "remote: "
+#define DISPLAY_PREFIX "remote: "
 
 #define ANSI_SUFFIX "\033[K"
 #define DUMB_SUFFIX "        "
@@ -49,7 +49,7 @@ int recv_sideband(const char *me, int in_stream, int out)
 		switch (band) {
 		case 3:
 			strbuf_addf(&outbuf, "%s%s%s", outbuf.len ? "\n" : "",
-				    PREFIX, buf + 1);
+				    DISPLAY_PREFIX, buf + 1);
 			retval = SIDEBAND_REMOTE_ERROR;
 			break;
 		case 2:
@@ -67,7 +67,7 @@ int recv_sideband(const char *me, int in_stream, int out)
 				int linelen = brk - b;
 
 				if (!outbuf.len)
-					strbuf_addstr(&outbuf, PREFIX);
+					strbuf_addstr(&outbuf, DISPLAY_PREFIX);
 				if (linelen > 0) {
 					strbuf_addf(&outbuf, "%.*s%s%c",
 						    linelen, b, suffix, *brk);
@@ -81,8 +81,8 @@ int recv_sideband(const char *me, int in_stream, int out)
 			}
 
 			if (*b)
-				strbuf_addf(&outbuf, "%s%s",
-					    outbuf.len ? "" : PREFIX, b);
+				strbuf_addf(&outbuf, "%s%s", outbuf.len ?
+					    "" : DISPLAY_PREFIX, b);
 			break;
 		case 1:
 			write_or_die(out, buf + 1, len);
-- 
2.17.0.windows.1.15.gaa56ade3205

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [PATCH 1/3] gettext: avoid initialization if the locale dir is not present
  2018-04-20  8:03 ` [PATCH 1/3] gettext: avoid initialization if the locale dir is not present Johannes Schindelin
@ 2018-04-20  9:59   ` Ævar Arnfjörð Bjarmason
  2018-04-20 10:54     ` Martin Ågren
  0 siblings, 1 reply; 21+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2018-04-20  9:59 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git, Junio C Hamano, Dan Jacques


On Fri, Apr 20 2018, Johannes Schindelin wrote:

> The runtime of a simple `git.exe version` call on Windows is currently
> dominated by the gettext setup, adding a whopping ~150ms to the ~210ms
> total.
>
> Given that this cost is added to each and every git.exe invocation goes
> through common-main's invocation of git_setup_gettext(), and given that
> scripts have to call git.exe dozens, if not hundreds, of times, this is
> a substantial performance penalty.
>
> This is particularly pointless when considering that Git for Windows
> ships without localization (to keep the installer's size to a bearable
> ~34MB): all that time setting up gettext is for naught.
>
> So let's be smart about it and skip setting up gettext if the locale
> directory is not even present.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
>  gettext.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/gettext.c b/gettext.c
> index baba28343c3..701355d66e7 100644
> --- a/gettext.c
> +++ b/gettext.c
> @@ -163,6 +163,9 @@ void git_setup_gettext(void)
>  	if (!podir)
>  		podir = system_path(GIT_LOCALE_PATH);
>
> +	if (!is_directory(podir))
> +		return;
> +
>  	bindtextdomain("git", podir);
>  	setlocale(LC_MESSAGES, "");
>  	setlocale(LC_TIME, "");

I wish we could fix the root cause and just make gettext faster (or ship
with a small shimmy of our own), but leaving that aside, I don't see how
this patch makes sense.

If you don't ship git for windows with gettext or a podir, then compile
with NO_GETTEXT, then we won't even compile this function you're
patching here. See line 30 and beyond of gettext.h.

Are you instead compiling git for windows with gettext support with an
optional add-on package for i18n, so then this podir conditional would
pass?

In any case, if this is actually the desired behavior I think it's worth
clearly explaining the interaction with NO_GETTEXT in the commit
message, and if you *actually* don't want NO_GETTEXT I think it's useful
to guard this with something like MAYBE_GETTEXT on top, so this code
doesn't unintentionally hide installation errors on other
platforms. I.e. something like:

	int have_podir = is_directory(podir);
	if (!have_podir)
#ifdef MAYBE_GETTEXT
		return;
#else
		BUG("Broken installation, can't find '%s'!", podir);
#endif

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 1/3] gettext: avoid initialization if the locale dir is not present
  2018-04-20  9:59   ` Ævar Arnfjörð Bjarmason
@ 2018-04-20 10:54     ` Martin Ågren
  2018-04-20 11:18       ` Ævar Arnfjörð Bjarmason
  0 siblings, 1 reply; 21+ messages in thread
From: Martin Ågren @ 2018-04-20 10:54 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: Johannes Schindelin, Git Mailing List, Junio C Hamano,
	Dan Jacques

On 20 April 2018 at 11:59, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
>
> On Fri, Apr 20 2018, Johannes Schindelin wrote:
>
>> The runtime of a simple `git.exe version` call on Windows is currently
>> dominated by the gettext setup, adding a whopping ~150ms to the ~210ms
>> total.
>>
>> Given that this cost is added to each and every git.exe invocation goes
>> through common-main's invocation of git_setup_gettext(), and given that
>> scripts have to call git.exe dozens, if not hundreds, of times, this is
>> a substantial performance penalty.
>>
>> This is particularly pointless when considering that Git for Windows
>> ships without localization (to keep the installer's size to a bearable
>> ~34MB): all that time setting up gettext is for naught.
>>
>> So let's be smart about it and skip setting up gettext if the locale
>> directory is not even present.

> If you don't ship git for windows with gettext or a podir, then compile
> with NO_GETTEXT, then we won't even compile this function you're
> patching here. See line 30 and beyond of gettext.h.
>
> Are you instead compiling git for windows with gettext support with an
> optional add-on package for i18n, so then this podir conditional would
> pass?
>
> In any case, if this is actually the desired behavior I think it's worth
> clearly explaining the interaction with NO_GETTEXT in the commit
> message, and if you *actually* don't want NO_GETTEXT I think it's useful
> to guard this with something like MAYBE_GETTEXT on top, so this code
> doesn't unintentionally hide installation errors on other
> platforms. I.e. something like:
>
>         int have_podir = is_directory(podir);
>         if (!have_podir)
> #ifdef MAYBE_GETTEXT
>                 return;
> #else
>                 BUG("Broken installation, can't find '%s'!", podir);
> #endif

Is it fair to say that such a broken installation would function more or
less well before and after Dscho's patch, and that your approach would
render such an installation quite useless? Do we have some other similar
cases where we go BUG("I could not find a resource. I could manage
fairly well without it, but you seemed to want it when you installed
me.")? I wonder what other well-respected software do if they can't find
their translations.

I suppose the logic could be the other way round, i.e., with a flag
REALLY_REQUIRE_GETTEXT_AT_RUNTIME. But I also wonder if a user who does
not notice that the installation is broken without us screaming BUG in
their face, really minds the "brokenness" that much.

Disclaimer: I do not use translated Git, nor other non-English-language
software.

Martin

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 1/3] gettext: avoid initialization if the locale dir is not present
  2018-04-20 10:54     ` Martin Ågren
@ 2018-04-20 11:18       ` Ævar Arnfjörð Bjarmason
  2018-04-20 19:35         ` Johannes Schindelin
  0 siblings, 1 reply; 21+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2018-04-20 11:18 UTC (permalink / raw)
  To: Martin Ågren
  Cc: Johannes Schindelin, Git Mailing List, Junio C Hamano,
	Dan Jacques


On Fri, Apr 20 2018, Martin Ågren wrote:

> On 20 April 2018 at 11:59, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
>>
>> On Fri, Apr 20 2018, Johannes Schindelin wrote:
>>
>>> The runtime of a simple `git.exe version` call on Windows is currently
>>> dominated by the gettext setup, adding a whopping ~150ms to the ~210ms
>>> total.
>>>
>>> Given that this cost is added to each and every git.exe invocation goes
>>> through common-main's invocation of git_setup_gettext(), and given that
>>> scripts have to call git.exe dozens, if not hundreds, of times, this is
>>> a substantial performance penalty.
>>>
>>> This is particularly pointless when considering that Git for Windows
>>> ships without localization (to keep the installer's size to a bearable
>>> ~34MB): all that time setting up gettext is for naught.
>>>
>>> So let's be smart about it and skip setting up gettext if the locale
>>> directory is not even present.
>
>> If you don't ship git for windows with gettext or a podir, then compile
>> with NO_GETTEXT, then we won't even compile this function you're
>> patching here. See line 30 and beyond of gettext.h.
>>
>> Are you instead compiling git for windows with gettext support with an
>> optional add-on package for i18n, so then this podir conditional would
>> pass?
>>
>> In any case, if this is actually the desired behavior I think it's worth
>> clearly explaining the interaction with NO_GETTEXT in the commit
>> message, and if you *actually* don't want NO_GETTEXT I think it's useful
>> to guard this with something like MAYBE_GETTEXT on top, so this code
>> doesn't unintentionally hide installation errors on other
>> platforms. I.e. something like:
>>
>>         int have_podir = is_directory(podir);
>>         if (!have_podir)
>> #ifdef MAYBE_GETTEXT
>>                 return;
>> #else
>>                 BUG("Broken installation, can't find '%s'!", podir);
>> #endif
>
> Is it fair to say that such a broken installation would function more or
> less well before and after Dscho's patch, and that your approach would
> render such an installation quite useless?

Yes my thown out there for the purposes of discussion suggestion may
break things for Dscho, or not. I'm just saying that we should document
*what* the use-case is.

Because it's not just important to massage the code so it works now, but
to document what the use-case is, so someone down the line who things
"oh why are we doing that" has a clear answer.

> Do we have some other similar
> cases where we go BUG("I could not find a resource. I could manage
> fairly well without it, but you seemed to want it when you installed
> me.")? I wonder what other well-respected software do if they can't find
> their translations.

E.g. my recent 1aca69c019 ("perl Git::LoadCPAN: emit better errors under
NO_PERL_CPAN_FALLBACKS", 2018-03-03) does similar things, we *could*
carry on in certain cases instead of dying there (or not, depending on
the codepath).

But in general, I don't think there's any reasonable use-cases for git
needing to repair from a broken or semi-broken installation that aren't
so specific that they can be explicitly declared, e.g. in this
hypothetical MAYBE_GETTEXT case.

Otherwise if it's not conditional, e.g. my git on Debian that won't ever
need this is going to just subtly regress because the FS is broken or
whatever, and I don't think we should have such code in git running
unconditionally.

> I suppose the logic could be the other way round, i.e., with a flag
> REALLY_REQUIRE_GETTEXT_AT_RUNTIME. But I also wonder if a user who does
> not notice that the installation is broken without us screaming BUG in
> their face, really minds the "brokenness" that much.

Without the BUG(...) that user is going to spend time fiddling with his
i18n settings before finally realizing that his package is broken, much
better to just emit an error so it's obvious that things are broken,
rather than taking the fallback path.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 1/3] gettext: avoid initialization if the locale dir is not present
  2018-04-20 11:18       ` Ævar Arnfjörð Bjarmason
@ 2018-04-20 19:35         ` Johannes Schindelin
  2018-04-21  7:43           ` Ævar Arnfjörð Bjarmason
  0 siblings, 1 reply; 21+ messages in thread
From: Johannes Schindelin @ 2018-04-20 19:35 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: Martin Ågren, Git Mailing List, Junio C Hamano, Dan Jacques

[-- Attachment #1: Type: text/plain, Size: 8422 bytes --]

Hi Ævar,

On Fri, 20 Apr 2018, Ævar Arnfjörð Bjarmason wrote:

> On Fri, Apr 20 2018, Martin Ågren wrote:
> 
> > On 20 April 2018 at 11:59, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
> >>
> >> On Fri, Apr 20 2018, Johannes Schindelin wrote:
> >>
> >>> The runtime of a simple `git.exe version` call on Windows is currently
> >>> dominated by the gettext setup, adding a whopping ~150ms to the ~210ms
> >>> total.
> >>>
> >>> Given that this cost is added to each and every git.exe invocation goes
> >>> through common-main's invocation of git_setup_gettext(), and given that
> >>> scripts have to call git.exe dozens, if not hundreds, of times, this is
> >>> a substantial performance penalty.
> >>>
> >>> This is particularly pointless when considering that Git for Windows
> >>> ships without localization (to keep the installer's size to a bearable
> >>> ~34MB): all that time setting up gettext is for naught.
> >>>
> >>> So let's be smart about it and skip setting up gettext if the locale
> >>> directory is not even present.
> >
> >> If you don't ship git for windows with gettext or a podir, then compile
> >> with NO_GETTEXT, then we won't even compile this function you're
> >> patching here. See line 30 and beyond of gettext.h.
> >>
> >> Are you instead compiling git for windows with gettext support with an
> >> optional add-on package for i18n, so then this podir conditional would
> >> pass?
> >>
> >> In any case, if this is actually the desired behavior I think it's worth
> >> clearly explaining the interaction with NO_GETTEXT in the commit
> >> message, and if you *actually* don't want NO_GETTEXT I think it's useful
> >> to guard this with something like MAYBE_GETTEXT on top, so this code
> >> doesn't unintentionally hide installation errors on other
> >> platforms. I.e. something like:
> >>
> >>         int have_podir = is_directory(podir);
> >>         if (!have_podir)
> >> #ifdef MAYBE_GETTEXT
> >>                 return;
> >> #else
> >>                 BUG("Broken installation, can't find '%s'!", podir);
> >> #endif
> >
> > Is it fair to say that such a broken installation would function more or
> > less well before and after Dscho's patch, and that your approach would
> > render such an installation quite useless?
> 
> Yes my thown out there for the purposes of discussion suggestion may
> break things for Dscho, or not. I'm just saying that we should document
> *what* the use-case is.

I think you underestimate the scope of your willful breakage. It is not
just "break things for Dscho". It is breaking things for every single last
user of Git for Windows. If we ever do that, I will make sure to announce
that together with your name and your postal address on it.

> Because it's not just important to massage the code so it works now, but
> to document what the use-case is, so someone down the line who things
> "oh why are we doing that" has a clear answer.

Let's face it: if gettext would ever fail to work in case of a missing
podir, then it would fail for every installation using a locale for which
we just happen not to have any translation.

So we know that your patch would not only break things, but break things
totally without reason!

> > Do we have some other similar
> > cases where we go BUG("I could not find a resource. I could manage
> > fairly well without it, but you seemed to want it when you installed
> > me.")? I wonder what other well-respected software do if they can't find
> > their translations.
> 
> E.g. my recent 1aca69c019 ("perl Git::LoadCPAN: emit better errors under
> NO_PERL_CPAN_FALLBACKS", 2018-03-03) does similar things, we *could*
> carry on in certain cases instead of dying there (or not, depending on
> the codepath).
> 
> But in general, I don't think there's any reasonable use-cases for git
> needing to repair from a broken or semi-broken installation that aren't
> so specific that they can be explicitly declared, e.g. in this
> hypothetical MAYBE_GETTEXT case.

Ævar, you need to understand one thing, and you need to understand it
right now: the vast majority of Git users will not compile their Git. Not.
Ever. Really, I am not kidding. They use whatever built version they can
get most conveniently.

It is even more true on Windows, where it may be easier to build Git for
Windows now (what with all the work I put into the Git for Windows SDK),
but it is still an expensive endeavor.

And that is even assuming that every Git user is at liberty to build their
own software, which is completely untrue in a large chunk of our business.

So in order to give users who want localization what they want, without
burdening users who do not want localization, we use the exact same build
of Git for Windows for both, and the entire difference is that one comes
with the podir, and the other without.

Okay, I am lying, at the moment we do not even have anything end-user
facing that ships with the podir. But I distinctly want to leave the door
open for that.

And if you think that this is out of sheer laziness on my part, then I
hate to break it to you that this is for *very* good reasons: maintenance
cost.

It probably has not crossed your mind that the entire Git test suite fails
to pass if you run it on Git for Windows when built with NO_GETTEXT
defined?

Yep. It fails. With a honking

	BUG: your vsnprintf is broken (returned -1)

And if you build it without NO_GETTEXT, it passes without that error.
Crazy, huh?

So unless you acquire quite a bit more experience with maintaining Git on
a common platform, I would like to implore you to stop trying to break it.
Thank you very much.

> Otherwise if it's not conditional, e.g. my git on Debian that won't ever
> need this is going to just subtly regress because the FS is broken or
> whatever, and I don't think we should have such code in git running
> unconditionally.

I have not the faintest idea what the heck you are talking about.

If the podir exists, then it is used. No change from before.

If the podir does not exist (which is unlikely in your setup, but there
you go, it might happen), the *only* difference you might notice is that
things get slightly faster (but probably not even noticably so, on your
platform). That is literally the only difference you could possibly notice
with vs without my patch. Seriously.

> > I suppose the logic could be the other way round, i.e., with a flag
> > REALLY_REQUIRE_GETTEXT_AT_RUNTIME. But I also wonder if a user who does
> > not notice that the installation is broken without us screaming BUG in
> > their face, really minds the "brokenness" that much.
> 
> Without the BUG(...) that user is going to spend time fiddling with his

Don't exclude half of humanity, for your own sake.

> i18n settings before finally realizing that his package is broken, much
> better to just emit an error so it's obvious that things are broken,
> rather than taking the fallback path.

And then you will also add code to output BUG BUG BUG when the actual
*language* subdirectory is missing?

You would *need* to do that, and you know this as well as I do, because
even if your Git installation is "broken" and does not bring its l18n
stuff, *another package will have it*, and therefore podir *exists*! And
therefore your suggested change would not only break Git for Windows, it
would also totally not do what you want it to do!

And even then, I totally, utterly hate to break it to you: even on Ubuntu,
it is quite, quite common to have the git package installed *without* the
language-pack-de-base or whatever you need for your locale.

The reason is the same as for Git for Windows: we want to save on space,
so you do not get localization files that you are not even interested in,
instead you get a leaner download.

And in this case -- even on Ubuntu -- your patch does not make sense, but
simply breaks things for no reason other than some well-intended but
horribly broken idea that you should force the user to have a
/usr/share/locale/ even if they may never even want it, and even if things
work very well without it, thankyouverymuch.

In short: I totally disagree with your reasoning to break things that work
very well, with a BUG() that is prone to confuse and scare end users no
less.

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 1/3] gettext: avoid initialization if the locale dir is not present
  2018-04-20 19:35         ` Johannes Schindelin
@ 2018-04-21  7:43           ` Ævar Arnfjörð Bjarmason
  2018-04-21 10:17             ` Johannes Schindelin
  0 siblings, 1 reply; 21+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2018-04-21  7:43 UTC (permalink / raw)
  To: Johannes Schindelin
  Cc: Martin Ågren, Git Mailing List, Junio C Hamano, Dan Jacques


On Fri, Apr 20 2018, Johannes Schindelin wrote:

> Hi Ævar,
>
> On Fri, 20 Apr 2018, Ævar Arnfjörð Bjarmason wrote:
>
>> On Fri, Apr 20 2018, Martin Ågren wrote:
>>
>> > On 20 April 2018 at 11:59, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
>> >>
>> >> On Fri, Apr 20 2018, Johannes Schindelin wrote:
>> >>
>> >>> The runtime of a simple `git.exe version` call on Windows is currently
>> >>> dominated by the gettext setup, adding a whopping ~150ms to the ~210ms
>> >>> total.
>> >>>
>> >>> Given that this cost is added to each and every git.exe invocation goes
>> >>> through common-main's invocation of git_setup_gettext(), and given that
>> >>> scripts have to call git.exe dozens, if not hundreds, of times, this is
>> >>> a substantial performance penalty.
>> >>>
>> >>> This is particularly pointless when considering that Git for Windows
>> >>> ships without localization (to keep the installer's size to a bearable
>> >>> ~34MB): all that time setting up gettext is for naught.
>> >>>
>> >>> So let's be smart about it and skip setting up gettext if the locale
>> >>> directory is not even present.
>> >
>> >> If you don't ship git for windows with gettext or a podir, then compile
>> >> with NO_GETTEXT, then we won't even compile this function you're
>> >> patching here. See line 30 and beyond of gettext.h.
>> >>
>> >> Are you instead compiling git for windows with gettext support with an
>> >> optional add-on package for i18n, so then this podir conditional would
>> >> pass?
>> >>
>> >> In any case, if this is actually the desired behavior I think it's worth
>> >> clearly explaining the interaction with NO_GETTEXT in the commit
>> >> message, and if you *actually* don't want NO_GETTEXT I think it's useful
>> >> to guard this with something like MAYBE_GETTEXT on top, so this code
>> >> doesn't unintentionally hide installation errors on other
>> >> platforms. I.e. something like:
>> >>
>> >>         int have_podir = is_directory(podir);
>> >>         if (!have_podir)
>> >> #ifdef MAYBE_GETTEXT
>> >>                 return;
>> >> #else
>> >>                 BUG("Broken installation, can't find '%s'!", podir);
>> >> #endif
>> >
>> > Is it fair to say that such a broken installation would function more or
>> > less well before and after Dscho's patch, and that your approach would
>> > render such an installation quite useless?
>>
>> Yes my thown out there for the purposes of discussion suggestion may
>> break things for Dscho, or not. I'm just saying that we should document
>> *what* the use-case is.
>
> I think you underestimate the scope of your willful breakage. It is not
> just "break things for Dscho". It is breaking things for every single last
> user of Git for Windows. If we ever do that, I will make sure to announce
> that together with your name and your postal address on it.
>
>> Because it's not just important to massage the code so it works now, but
>> to document what the use-case is, so someone down the line who things
>> "oh why are we doing that" has a clear answer.
>
> Let's face it: if gettext would ever fail to work in case of a missing
> podir, then it would fail for every installation using a locale for which
> we just happen not to have any translation.
>
> So we know that your patch would not only break things, but break things
> totally without reason!
>
>> > Do we have some other similar
>> > cases where we go BUG("I could not find a resource. I could manage
>> > fairly well without it, but you seemed to want it when you installed
>> > me.")? I wonder what other well-respected software do if they can't find
>> > their translations.
>>
>> E.g. my recent 1aca69c019 ("perl Git::LoadCPAN: emit better errors under
>> NO_PERL_CPAN_FALLBACKS", 2018-03-03) does similar things, we *could*
>> carry on in certain cases instead of dying there (or not, depending on
>> the codepath).
>>
>> But in general, I don't think there's any reasonable use-cases for git
>> needing to repair from a broken or semi-broken installation that aren't
>> so specific that they can be explicitly declared, e.g. in this
>> hypothetical MAYBE_GETTEXT case.
>
> Ævar, you need to understand one thing, and you need to understand it
> right now: the vast majority of Git users will not compile their Git. Not.
> Ever. Really, I am not kidding. They use whatever built version they can
> get most conveniently.
>
> It is even more true on Windows, where it may be easier to build Git for
> Windows now (what with all the work I put into the Git for Windows SDK),
> but it is still an expensive endeavor.
>
> And that is even assuming that every Git user is at liberty to build their
> own software, which is completely untrue in a large chunk of our business.
>
> So in order to give users who want localization what they want, without
> burdening users who do not want localization, we use the exact same build
> of Git for Windows for both, and the entire difference is that one comes
> with the podir, and the other without.
>
> Okay, I am lying, at the moment we do not even have anything end-user
> facing that ships with the podir. But I distinctly want to leave the door
> open for that.
>
> And if you think that this is out of sheer laziness on my part, then I
> hate to break it to you that this is for *very* good reasons: maintenance
> cost.
>
> It probably has not crossed your mind that the entire Git test suite fails
> to pass if you run it on Git for Windows when built with NO_GETTEXT
> defined?
>
> Yep. It fails. With a honking
>
> 	BUG: your vsnprintf is broken (returned -1)
>
> And if you build it without NO_GETTEXT, it passes without that error.
> Crazy, huh?
>
> So unless you acquire quite a bit more experience with maintaining Git on
> a common platform, I would like to implore you to stop trying to break it.
> Thank you very much.
>
>> Otherwise if it's not conditional, e.g. my git on Debian that won't ever
>> need this is going to just subtly regress because the FS is broken or
>> whatever, and I don't think we should have such code in git running
>> unconditionally.
>
> I have not the faintest idea what the heck you are talking about.
>
> If the podir exists, then it is used. No change from before.
>
> If the podir does not exist (which is unlikely in your setup, but there
> you go, it might happen), the *only* difference you might notice is that
> things get slightly faster (but probably not even noticably so, on your
> platform). That is literally the only difference you could possibly notice
> with vs without my patch. Seriously.
>
>> > I suppose the logic could be the other way round, i.e., with a flag
>> > REALLY_REQUIRE_GETTEXT_AT_RUNTIME. But I also wonder if a user who does
>> > not notice that the installation is broken without us screaming BUG in
>> > their face, really minds the "brokenness" that much.
>>
>> Without the BUG(...) that user is going to spend time fiddling with his
>
> Don't exclude half of humanity, for your own sake.
>
>> i18n settings before finally realizing that his package is broken, much
>> better to just emit an error so it's obvious that things are broken,
>> rather than taking the fallback path.
>
> And then you will also add code to output BUG BUG BUG when the actual
> *language* subdirectory is missing?
>
> You would *need* to do that, and you know this as well as I do, because
> even if your Git installation is "broken" and does not bring its l18n
> stuff, *another package will have it*, and therefore podir *exists*! And
> therefore your suggested change would not only break Git for Windows, it
> would also totally not do what you want it to do!
>
> And even then, I totally, utterly hate to break it to you: even on Ubuntu,
> it is quite, quite common to have the git package installed *without* the
> language-pack-de-base or whatever you need for your locale.
>
> The reason is the same as for Git for Windows: we want to save on space,
> so you do not get localization files that you are not even interested in,
> instead you get a leaner download.
>
> And in this case -- even on Ubuntu -- your patch does not make sense, but
> simply breaks things for no reason other than some well-intended but
> horribly broken idea that you should force the user to have a
> /usr/share/locale/ even if they may never even want it, and even if things
> work very well without it, thankyouverymuch.
>
> In short: I totally disagree with your reasoning to break things that work
> very well, with a BUG() that is prone to confuse and scare end users no
> less.

You raise a lot of good points, although I wish you could phrase them
without the threats of doxxing.

The suggestion of doing that BUG(...) assertion was, to be clear, not
mentioned as a "we should definitely do this", but "why don't we do
this?".

I still stand by the observation that the "why don't we" isn't clear at
all from your patch's commit message and that should be fixed. It
doesn't mention any of the actual reasons for the change which have been
revealed in this follow-up thread.

I.e. that you're aiming to compile a version of git that has a
hot-swappable "locale" directory, and don't want to slow down those
users who don't have it with pointless gettext setup.

I know that the "vast majority of Git users will not compile their
Git". I'm not talking about that, but that there are certainly packagers
who know that they're building for an installation where
/usr/share/locale is expected never expected to just disappear.

Asserting this particular thing isn't going to be that useful, since
gettext has fallback behavior anyway. It just looks suspicious to me
that git at runtime has fallback behavior for stuff not existing that we
*know* we installed during 'make install'.

That's why I mentioned that we should consider doing something similar
to NO_PERL_CPAN_FALLBACKS. I.e. that there's a 1=1 mapping between what
the packager declared was going to happen, and what fallback behaviors
the runtime package is using.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 1/3] gettext: avoid initialization if the locale dir is not present
  2018-04-21  7:43           ` Ævar Arnfjörð Bjarmason
@ 2018-04-21 10:17             ` Johannes Schindelin
  0 siblings, 0 replies; 21+ messages in thread
From: Johannes Schindelin @ 2018-04-21 10:17 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: Martin Ågren, Git Mailing List, Junio C Hamano, Dan Jacques

[-- Attachment #1: Type: text/plain, Size: 363 bytes --]

Hi Ævar,

On Sat, 21 Apr 2018, Ævar Arnfjörð Bjarmason wrote:

> I still stand by the observation that the "why don't we" isn't clear at
> all from your patch's commit message and that should be fixed. It
> doesn't mention any of the actual reasons for the change which have been
> revealed in this follow-up thread.

Fair enough.

Will fix,
Dscho

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH v2 0/3] Some add-on patches on top of dj/runtime-prefix
  2018-04-20  8:03 [PATCH 0/3] Some add-on patches on top of dj/runtime-prefix Johannes Schindelin
                   ` (2 preceding siblings ...)
  2018-04-20  8:04 ` [PATCH 3/3] Avoid multiple PREFIX definitions Johannes Schindelin
@ 2018-04-21 11:13 ` Johannes Schindelin
  2018-04-21 11:14   ` [PATCH v2 1/3] gettext: avoid initialization if the locale dir is not present Johannes Schindelin
                     ` (3 more replies)
  3 siblings, 4 replies; 21+ messages in thread
From: Johannes Schindelin @ 2018-04-21 11:13 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Dan Jacques,
	Ævar Arnfjörð Bjarmason

We carried a slightly different version of the git_setup_gettext() patch
(which took care of releasing the buffer allocated by system_path()),
and we carry two more patches that touch the same area, so now that
dj/runtime-prefix hit `next`, it seems a good time to contribute those,
too.

Changes since v1:

- clarified in v1 why we cannot simply force users to recompile with NO_GETTEXT
  instead.


Johannes Schindelin (2):
  gettext: avoid initialization if the locale dir is not present
  git_setup_gettext: plug memory leak

Philip Oakley (1):
  Avoid multiple PREFIX definitions

 Makefile   |  2 +-
 exec-cmd.c |  4 ++--
 gettext.c  | 10 +++++++++-
 sideband.c | 10 +++++-----
 4 files changed, 17 insertions(+), 9 deletions(-)


base-commit: b46fe60e1d7235603a29499822493bd3791195da
Published-As: https://github.com/dscho/git/releases/tag/runtime-prefix-addons-v2
Fetch-It-Via: git fetch https://github.com/dscho/git runtime-prefix-addons-v2
-- 
2.17.0.windows.1.15.gaa56ade3205


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH v2 1/3] gettext: avoid initialization if the locale dir is not present
  2018-04-21 11:13 ` [PATCH v2 0/3] Some add-on patches on top of dj/runtime-prefix Johannes Schindelin
@ 2018-04-21 11:14   ` Johannes Schindelin
  2018-04-21 11:14   ` [PATCH v2 2/3] git_setup_gettext: plug memory leak Johannes Schindelin
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 21+ messages in thread
From: Johannes Schindelin @ 2018-04-21 11:14 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Dan Jacques,
	Ævar Arnfjörð Bjarmason

The runtime of a simple `git.exe version` call on Windows is currently
dominated by the gettext setup, adding a whopping ~150ms to the ~210ms
total.

Given that this cost is added to each and every git.exe invocation goes
through common-main's invocation of git_setup_gettext(), and given that
scripts have to call git.exe dozens, if not hundreds, of times, this is
a substantial performance penalty.

This is particularly pointless when considering that Git for Windows
ships without localization (to keep the installer's size to a bearable
~34MB): all that time setting up gettext is for naught.

To be clear, Git for Windows *needs* to be compiled with localization,
for the following reasons:

- to allow users to copy add-on localization in case they want it, and

- to fix the nasty error message

	BUG: your vsnprintf is broken (returned -1)

  by using libgettext's override of vsnprintf() that does not share the
  behavior of msvcrt.dll's version of vsnprintf().

So let's be smart about it and skip setting up gettext if the locale
directory is not even present.

Since localization might be missing for not-yet-supported locales, this
will not break anything.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 gettext.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gettext.c b/gettext.c
index baba28343c3..701355d66e7 100644
--- a/gettext.c
+++ b/gettext.c
@@ -163,6 +163,9 @@ void git_setup_gettext(void)
 	if (!podir)
 		podir = system_path(GIT_LOCALE_PATH);
 
+	if (!is_directory(podir))
+		return;
+
 	bindtextdomain("git", podir);
 	setlocale(LC_MESSAGES, "");
 	setlocale(LC_TIME, "");
-- 
2.17.0.windows.1.15.gaa56ade3205



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH v2 2/3] git_setup_gettext: plug memory leak
  2018-04-21 11:13 ` [PATCH v2 0/3] Some add-on patches on top of dj/runtime-prefix Johannes Schindelin
  2018-04-21 11:14   ` [PATCH v2 1/3] gettext: avoid initialization if the locale dir is not present Johannes Schindelin
@ 2018-04-21 11:14   ` Johannes Schindelin
  2018-04-21 11:18   ` [PATCH v2 3/3] Avoid multiple PREFIX definitions Johannes Schindelin
  2018-04-24  1:44   ` [PATCH v2 0/3] Some add-on patches on top of dj/runtime-prefix Junio C Hamano
  3 siblings, 0 replies; 21+ messages in thread
From: Johannes Schindelin @ 2018-04-21 11:14 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Dan Jacques,
	Ævar Arnfjörð Bjarmason

The system_path() function returns a freshly-allocated string. We need
to release it.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 gettext.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/gettext.c b/gettext.c
index 701355d66e7..7272771c8e4 100644
--- a/gettext.c
+++ b/gettext.c
@@ -159,18 +159,23 @@ static void init_gettext_charset(const char *domain)
 void git_setup_gettext(void)
 {
 	const char *podir = getenv(GIT_TEXT_DOMAIN_DIR_ENVIRONMENT);
+	char *p = NULL;
 
 	if (!podir)
-		podir = system_path(GIT_LOCALE_PATH);
+		podir = p = system_path(GIT_LOCALE_PATH);
 
-	if (!is_directory(podir))
+	if (!is_directory(podir)) {
+		free(p);
 		return;
+	}
 
 	bindtextdomain("git", podir);
 	setlocale(LC_MESSAGES, "");
 	setlocale(LC_TIME, "");
 	init_gettext_charset("git");
 	textdomain("git");
+
+	free(p);
 }
 
 /* return the number of columns of string 's' in current locale */
-- 
2.17.0.windows.1.15.gaa56ade3205



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH v2 3/3] Avoid multiple PREFIX definitions
  2018-04-21 11:13 ` [PATCH v2 0/3] Some add-on patches on top of dj/runtime-prefix Johannes Schindelin
  2018-04-21 11:14   ` [PATCH v2 1/3] gettext: avoid initialization if the locale dir is not present Johannes Schindelin
  2018-04-21 11:14   ` [PATCH v2 2/3] git_setup_gettext: plug memory leak Johannes Schindelin
@ 2018-04-21 11:18   ` Johannes Schindelin
  2018-04-24  1:44   ` [PATCH v2 0/3] Some add-on patches on top of dj/runtime-prefix Junio C Hamano
  3 siblings, 0 replies; 21+ messages in thread
From: Johannes Schindelin @ 2018-04-21 11:18 UTC (permalink / raw)
  To: git
  Cc: Philip Oakley, Junio C Hamano, Dan Jacques,
	Ævar Arnfjörð Bjarmason

From: Philip Oakley <philipoakley@iee.org>

The short and sweet PREFIX can be confused when used in many places.

Rename both usages to better describe their purpose. EXEC_CMD_PREFIX is
used in full to disambiguate it from the nearby GIT_EXEC_PATH.

The PREFIX in sideband.c, while nominally independant of the exec_cmd
PREFIX, does reside within libgit[1], so the definitions would clash
when taken together with a PREFIX given on the command line for use by
exec_cmd.c.

Noticed when compiling Git for Windows using MSVC/Visual Studio [1] which
reports the conflict beteeen the command line definition and the
definition in sideband.c within the libgit project.

[1] the libgit functions are brought into a single sub-project
within the Visual Studio construction script provided in contrib,
and hence uses a single command for both exec_cmd.c and sideband.c.

Signed-off-by: Philip Oakley <philipoakley@iee.org>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 Makefile   |  2 +-
 exec-cmd.c |  4 ++--
 sideband.c | 10 +++++-----
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/Makefile b/Makefile
index 111e93d3bea..49cec672242 100644
--- a/Makefile
+++ b/Makefile
@@ -2271,7 +2271,7 @@ exec-cmd.sp exec-cmd.s exec-cmd.o: EXTRA_CPPFLAGS = \
 	'-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \
 	'-DGIT_LOCALE_PATH="$(localedir_relative_SQ)"' \
 	'-DBINDIR="$(bindir_relative_SQ)"' \
-	'-DPREFIX="$(prefix_SQ)"'
+	'-DFALLBACK_RUNTIME_PREFIX="$(prefix_SQ)"'
 
 builtin/init-db.sp builtin/init-db.s builtin/init-db.o: GIT-PREFIX
 builtin/init-db.sp builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \
diff --git a/exec-cmd.c b/exec-cmd.c
index 3b0a039083a..02d31ee8971 100644
--- a/exec-cmd.c
+++ b/exec-cmd.c
@@ -48,7 +48,7 @@ static const char *system_prefix(void)
 	    !(prefix = strip_path_suffix(executable_dirname, GIT_EXEC_PATH)) &&
 	    !(prefix = strip_path_suffix(executable_dirname, BINDIR)) &&
 	    !(prefix = strip_path_suffix(executable_dirname, "git"))) {
-		prefix = PREFIX;
+		prefix = FALLBACK_RUNTIME_PREFIX;
 		trace_printf("RUNTIME_PREFIX requested, "
 				"but prefix computation failed.  "
 				"Using static fallback '%s'.\n", prefix);
@@ -243,7 +243,7 @@ void git_resolve_executable_dir(const char *argv0)
  */
 static const char *system_prefix(void)
 {
-	return PREFIX;
+	return FALLBACK_RUNTIME_PREFIX;
 }
 
 /*
diff --git a/sideband.c b/sideband.c
index 6d7f943e438..325bf0e974a 100644
--- a/sideband.c
+++ b/sideband.c
@@ -13,7 +13,7 @@
  * the remote died unexpectedly.  A flush() concludes the stream.
  */
 
-#define PREFIX "remote: "
+#define DISPLAY_PREFIX "remote: "
 
 #define ANSI_SUFFIX "\033[K"
 #define DUMB_SUFFIX "        "
@@ -49,7 +49,7 @@ int recv_sideband(const char *me, int in_stream, int out)
 		switch (band) {
 		case 3:
 			strbuf_addf(&outbuf, "%s%s%s", outbuf.len ? "\n" : "",
-				    PREFIX, buf + 1);
+				    DISPLAY_PREFIX, buf + 1);
 			retval = SIDEBAND_REMOTE_ERROR;
 			break;
 		case 2:
@@ -67,7 +67,7 @@ int recv_sideband(const char *me, int in_stream, int out)
 				int linelen = brk - b;
 
 				if (!outbuf.len)
-					strbuf_addstr(&outbuf, PREFIX);
+					strbuf_addstr(&outbuf, DISPLAY_PREFIX);
 				if (linelen > 0) {
 					strbuf_addf(&outbuf, "%.*s%s%c",
 						    linelen, b, suffix, *brk);
@@ -81,8 +81,8 @@ int recv_sideband(const char *me, int in_stream, int out)
 			}
 
 			if (*b)
-				strbuf_addf(&outbuf, "%s%s",
-					    outbuf.len ? "" : PREFIX, b);
+				strbuf_addf(&outbuf, "%s%s", outbuf.len ?
+					    "" : DISPLAY_PREFIX, b);
 			break;
 		case 1:
 			write_or_die(out, buf + 1, len);
-- 
2.17.0.windows.1.15.gaa56ade3205

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [PATCH 3/3] Avoid multiple PREFIX definitions
  2018-04-20  8:04 ` [PATCH 3/3] Avoid multiple PREFIX definitions Johannes Schindelin
@ 2018-04-22 15:32   ` Philip Oakley
  0 siblings, 0 replies; 21+ messages in thread
From: Philip Oakley @ 2018-04-22 15:32 UTC (permalink / raw)
  To: Johannes Schindelin, Git List; +Cc: Junio C Hamano, Dan Jacques

From: "Johannes Schindelin" <johannes.schindelin@gmx.de>
> From: Philip Oakley <philipoakley@iee.org>
>
> The short and sweet PREFIX can be confused when used in many places.
>
> Rename both usages to better describe their purpose. EXEC_CMD_PREFIX is
> used in full to disambiguate it from the nearby GIT_EXEC_PATH.

@dcsho; Thanks for keeping up with this and all your work. LGTM Philip.

>
> The PREFIX in sideband.c, while nominally independant of the exec_cmd
> PREFIX, does reside within libgit[1], so the definitions would clash
> when taken together with a PREFIX given on the command line for use by
> exec_cmd.c.
>
> Noticed when compiling Git for Windows using MSVC/Visual Studio [1] which
> reports the conflict beteeen the command line definition and the
> definition in sideband.c within the libgit project.
>
> [1] the libgit functions are brought into a single sub-project
> within the Visual Studio construction script provided in contrib,
> and hence uses a single command for both exec_cmd.c and sideband.c.
>
> Signed-off-by: Philip Oakley <philipoakley@iee.org>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
> Makefile   |  2 +-
> exec-cmd.c |  4 ++--
> sideband.c | 10 +++++-----
> 3 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 111e93d3bea..49cec672242 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -2271,7 +2271,7 @@ exec-cmd.sp exec-cmd.s exec-cmd.o: EXTRA_CPPFLAGS =
> \
>  '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \
>  '-DGIT_LOCALE_PATH="$(localedir_relative_SQ)"' \
>  '-DBINDIR="$(bindir_relative_SQ)"' \
> - '-DPREFIX="$(prefix_SQ)"'
> + '-DFALLBACK_RUNTIME_PREFIX="$(prefix_SQ)"'
>
> builtin/init-db.sp builtin/init-db.s builtin/init-db.o: GIT-PREFIX
> builtin/init-db.sp builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \
> diff --git a/exec-cmd.c b/exec-cmd.c
> index 3b0a039083a..02d31ee8971 100644
> --- a/exec-cmd.c
> +++ b/exec-cmd.c
> @@ -48,7 +48,7 @@ static const char *system_prefix(void)
>      !(prefix = strip_path_suffix(executable_dirname, GIT_EXEC_PATH)) &&
>      !(prefix = strip_path_suffix(executable_dirname, BINDIR)) &&
>      !(prefix = strip_path_suffix(executable_dirname, "git"))) {
> - prefix = PREFIX;
> + prefix = FALLBACK_RUNTIME_PREFIX;
>  trace_printf("RUNTIME_PREFIX requested, "
>  "but prefix computation failed.  "
>  "Using static fallback '%s'.\n", prefix);
> @@ -243,7 +243,7 @@ void git_resolve_executable_dir(const char *argv0)
>  */
> static const char *system_prefix(void)
> {
> - return PREFIX;
> + return FALLBACK_RUNTIME_PREFIX;
> }
>
> /*
> diff --git a/sideband.c b/sideband.c
> index 6d7f943e438..325bf0e974a 100644
> --- a/sideband.c
> +++ b/sideband.c
> @@ -13,7 +13,7 @@
>  * the remote died unexpectedly.  A flush() concludes the stream.
>  */
>
> -#define PREFIX "remote: "
> +#define DISPLAY_PREFIX "remote: "
>
> #define ANSI_SUFFIX "\033[K"
> #define DUMB_SUFFIX "        "
> @@ -49,7 +49,7 @@ int recv_sideband(const char *me, int in_stream, int
> out)
>  switch (band) {
>  case 3:
>  strbuf_addf(&outbuf, "%s%s%s", outbuf.len ? "\n" : "",
> -     PREFIX, buf + 1);
> +     DISPLAY_PREFIX, buf + 1);
>  retval = SIDEBAND_REMOTE_ERROR;
>  break;
>  case 2:
> @@ -67,7 +67,7 @@ int recv_sideband(const char *me, int in_stream, int
> out)
>  int linelen = brk - b;
>
>  if (!outbuf.len)
> - strbuf_addstr(&outbuf, PREFIX);
> + strbuf_addstr(&outbuf, DISPLAY_PREFIX);
>  if (linelen > 0) {
>  strbuf_addf(&outbuf, "%.*s%s%c",
>      linelen, b, suffix, *brk);
> @@ -81,8 +81,8 @@ int recv_sideband(const char *me, int in_stream, int
> out)
>  }
>
>  if (*b)
> - strbuf_addf(&outbuf, "%s%s",
> -     outbuf.len ? "" : PREFIX, b);
> + strbuf_addf(&outbuf, "%s%s", outbuf.len ?
> +     "" : DISPLAY_PREFIX, b);
>  break;
>  case 1:
>  write_or_die(out, buf + 1, len);
> -- 
> 2.17.0.windows.1.15.gaa56ade3205
>


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 0/3] Some add-on patches on top of dj/runtime-prefix
  2018-04-21 11:13 ` [PATCH v2 0/3] Some add-on patches on top of dj/runtime-prefix Johannes Schindelin
                     ` (2 preceding siblings ...)
  2018-04-21 11:18   ` [PATCH v2 3/3] Avoid multiple PREFIX definitions Johannes Schindelin
@ 2018-04-24  1:44   ` Junio C Hamano
  2018-04-24  1:50     ` Junio C Hamano
  3 siblings, 1 reply; 21+ messages in thread
From: Junio C Hamano @ 2018-04-24  1:44 UTC (permalink / raw)
  To: Johannes Schindelin
  Cc: git, Dan Jacques, Ævar Arnfjörð Bjarmason

Johannes Schindelin <johannes.schindelin@gmx.de> writes:

> We carried a slightly different version of the git_setup_gettext() patch
> (which took care of releasing the buffer allocated by system_path()),
> and we carry two more patches that touch the same area, so now that
> dj/runtime-prefix hit `next`, it seems a good time to contribute those,
> too.
>
> Changes since v1:
>
> - clarified in v1 why we cannot simply force users to recompile with NO_GETTEXT
>   instead.
>
>
> Johannes Schindelin (2):
>   gettext: avoid initialization if the locale dir is not present
>   git_setup_gettext: plug memory leak
>
> Philip Oakley (1):
>   Avoid multiple PREFIX definitions
>
>  Makefile   |  2 +-
>  exec-cmd.c |  4 ++--
>  gettext.c  | 10 +++++++++-
>  sideband.c | 10 +++++-----
>  4 files changed, 17 insertions(+), 9 deletions(-)
>
>
> base-commit: b46fe60e1d7235603a29499822493bd3791195da

Basing your work on the tip of 'next' is good for discussion, but
not readily usable for final application.  Let me see if I can
untangle the dependents to come up with a reasonable base.

The changes themselves looked reasonable.  Thanks.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 0/3] Some add-on patches on top of dj/runtime-prefix
  2018-04-24  1:44   ` [PATCH v2 0/3] Some add-on patches on top of dj/runtime-prefix Junio C Hamano
@ 2018-04-24  1:50     ` Junio C Hamano
  2018-04-24  2:41       ` Junio C Hamano
  0 siblings, 1 reply; 21+ messages in thread
From: Junio C Hamano @ 2018-04-24  1:50 UTC (permalink / raw)
  To: Johannes Schindelin
  Cc: git, Dan Jacques, Ævar Arnfjörð Bjarmason

Junio C Hamano <gitster@pobox.com> writes:

>> base-commit: b46fe60e1d7235603a29499822493bd3791195da
>
> Basing your work on the tip of 'next' is good for discussion, but
> not readily usable for final application.  Let me see if I can
> untangle the dependents to come up with a reasonable base.

I'll queue this on top of a merge of 'dj/runtime-prefix' into 'master'.
Merging the resulting topic into 'next' and applying these patches
directly on top of 'next' result in identical trees, of course ;-)


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 0/3] Some add-on patches on top of dj/runtime-prefix
  2018-04-24  1:50     ` Junio C Hamano
@ 2018-04-24  2:41       ` Junio C Hamano
  2018-04-24 14:48         ` Johannes Schindelin
  0 siblings, 1 reply; 21+ messages in thread
From: Junio C Hamano @ 2018-04-24  2:41 UTC (permalink / raw)
  To: Johannes Schindelin
  Cc: git, Dan Jacques, Ævar Arnfjörð Bjarmason

Junio C Hamano <gitster@pobox.com> writes:

> Junio C Hamano <gitster@pobox.com> writes:
>
>>> base-commit: b46fe60e1d7235603a29499822493bd3791195da
>>
>> Basing your work on the tip of 'next' is good for discussion, but
>> not readily usable for final application.  Let me see if I can
>> untangle the dependents to come up with a reasonable base.
>
> I'll queue this on top of a merge of 'dj/runtime-prefix' into 'master'.
> Merging the resulting topic into 'next' and applying these patches
> directly on top of 'next' result in identical trees, of course ;-)

Actually, these trivially rebase on top of dj/runtime-prefix, so
I'll queue them like so without taking it hostage to other things in
'master'.  We'd want to keep these mergeable to any integration
branch that dj/runtime-prefix would be merged to, so that is the
most logical organization, I would think, even though I do not
immediately see the reason why we would want to merge
dj/runtime-prefix to 'maint' and lower right now.

Thanks.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 0/3] Some add-on patches on top of dj/runtime-prefix
  2018-04-24  2:41       ` Junio C Hamano
@ 2018-04-24 14:48         ` Johannes Schindelin
  2018-04-25  1:28           ` Junio C Hamano
  0 siblings, 1 reply; 21+ messages in thread
From: Johannes Schindelin @ 2018-04-24 14:48 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Dan Jacques, Ævar Arnfjörð Bjarmason

Hi Junio,

On Tue, 24 Apr 2018, Junio C Hamano wrote:

> Junio C Hamano <gitster@pobox.com> writes:
> 
> > Junio C Hamano <gitster@pobox.com> writes:
> >
> >>> base-commit: b46fe60e1d7235603a29499822493bd3791195da
> >>
> >> Basing your work on the tip of 'next' is good for discussion, but
> >> not readily usable for final application.  Let me see if I can
> >> untangle the dependents to come up with a reasonable base.
> >
> > I'll queue this on top of a merge of 'dj/runtime-prefix' into 'master'.
> > Merging the resulting topic into 'next' and applying these patches
> > directly on top of 'next' result in identical trees, of course ;-)
> 
> Actually, these trivially rebase on top of dj/runtime-prefix, so
> I'll queue them like so without taking it hostage to other things in
> 'master'.  We'd want to keep these mergeable to any integration
> branch that dj/runtime-prefix would be merged to, so that is the
> most logical organization, I would think, even though I do not
> immediately see the reason why we would want to merge
> dj/runtime-prefix to 'maint' and lower right now.
> 
> Thanks.

Thank you, and sorry for the trouble. I am just too used to a Continuous
Integration setting with exactly one integration branch.

I will make an effort in the future to figure out the best base branch for
patches that do not apply cleanly on `master` but require more stuff from
`next`/`pu`.

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 0/3] Some add-on patches on top of dj/runtime-prefix
  2018-04-24 14:48         ` Johannes Schindelin
@ 2018-04-25  1:28           ` Junio C Hamano
  2018-04-25  7:46             ` Johannes Schindelin
  0 siblings, 1 reply; 21+ messages in thread
From: Junio C Hamano @ 2018-04-25  1:28 UTC (permalink / raw)
  To: Johannes Schindelin
  Cc: git, Dan Jacques, Ævar Arnfjörð Bjarmason

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> Thank you, and sorry for the trouble. I am just too used to a Continuous
> Integration setting with exactly one integration branch.

Fixing problems close to the source (i.e. picking an appropriately
aged base) and making sure everthing works near the tip ala CI style
are not opposing goals.  It just takes an extra step (i.e. trial
merge and testing the result) and discipline.  Until one gets used
to do it so much that one can do in one's sleep, that is ;-)

> I will make an effort in the future to figure out the best base branch for
> patches that do not apply cleanly on `master` but require more stuff from
> `next`/`pu`.

The easiest is to leave that to the maintainer most of the time, as
that is what maintainers do.

Thanks.

I really want to see that the runtime prefix stuff mature enough
during this cycle, so these follow-up patches are all very much
appreciated.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 0/3] Some add-on patches on top of dj/runtime-prefix
  2018-04-25  1:28           ` Junio C Hamano
@ 2018-04-25  7:46             ` Johannes Schindelin
  0 siblings, 0 replies; 21+ messages in thread
From: Johannes Schindelin @ 2018-04-25  7:46 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Dan Jacques, Ævar Arnfjörð Bjarmason

Hi Junio,

On Wed, 25 Apr 2018, Junio C Hamano wrote:

> I really want to see that the runtime prefix stuff mature enough during
> this cycle, so these follow-up patches are all very much appreciated.

FWIW I merged these patches (including my touch-ups) into Git for Windows'
`master` branch early.

(I should actually not say that I merged it, because that would have
merged way too much, as Git for Windows' `master` is still based on
v2.17.0. So I cherry-picked instead.)

That should help mature those patches in one big hurry. If they're not yet
perfect, that is.

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2018-04-25  7:46 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-20  8:03 [PATCH 0/3] Some add-on patches on top of dj/runtime-prefix Johannes Schindelin
2018-04-20  8:03 ` [PATCH 1/3] gettext: avoid initialization if the locale dir is not present Johannes Schindelin
2018-04-20  9:59   ` Ævar Arnfjörð Bjarmason
2018-04-20 10:54     ` Martin Ågren
2018-04-20 11:18       ` Ævar Arnfjörð Bjarmason
2018-04-20 19:35         ` Johannes Schindelin
2018-04-21  7:43           ` Ævar Arnfjörð Bjarmason
2018-04-21 10:17             ` Johannes Schindelin
2018-04-20  8:03 ` [PATCH 2/3] git_setup_gettext: plug memory leak Johannes Schindelin
2018-04-20  8:04 ` [PATCH 3/3] Avoid multiple PREFIX definitions Johannes Schindelin
2018-04-22 15:32   ` Philip Oakley
2018-04-21 11:13 ` [PATCH v2 0/3] Some add-on patches on top of dj/runtime-prefix Johannes Schindelin
2018-04-21 11:14   ` [PATCH v2 1/3] gettext: avoid initialization if the locale dir is not present Johannes Schindelin
2018-04-21 11:14   ` [PATCH v2 2/3] git_setup_gettext: plug memory leak Johannes Schindelin
2018-04-21 11:18   ` [PATCH v2 3/3] Avoid multiple PREFIX definitions Johannes Schindelin
2018-04-24  1:44   ` [PATCH v2 0/3] Some add-on patches on top of dj/runtime-prefix Junio C Hamano
2018-04-24  1:50     ` Junio C Hamano
2018-04-24  2:41       ` Junio C Hamano
2018-04-24 14:48         ` Johannes Schindelin
2018-04-25  1:28           ` Junio C Hamano
2018-04-25  7:46             ` Johannes Schindelin

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).