Bug#842477: [PATCH] git-sh-setup: Restore sourcability from outside scripts
On Sun, 30 Oct 2016, Ævar Arnfjörð Bjarmason wrote: > This did break in v2.10.0, and it's taken a couple of months to notice > this, so clearly it's not very widely used, which says something about > the cost-benefit of maintaining this for external users. For the record, in case this affects the calculation, it was noticed that guilt was broken a just couple of days after the first git 2.10.x upload to Debian, which was last weekend. https://bugs.debian.org/842477 http://repo.or.cz/guilt.git/blob/v0.36:/guilt#l28 (I have no further opinion; I trust that Junio has all the information needed to decide one way or the other.) Anders
Bug#842477: [PATCH] git-sh-setup: Restore sourcability from outside scripts
Ævar Arnfjörð Bjarmasonwrites: (commenting out of order) > It's probably worthwhile to split off git-sh-setup into git-sh-setup & > git-sh-setup-internal along with a documentation fix. A lot of what > it's doing (e.g. git_broken_path_fix(), and adding a die() function) > is probably only needed internally by git itself. The > git-sh-setup-internal should be the thing sourcing "git-sh-i18n", I > don't see how anyone out-of-tree could make use of that. Surely nobody > needs to re-emit the exact message we shipped with our *.po files. My reading of d323c6b641 ("i18n: git-sh-setup.sh: mark strings for translation", 2016-06-17) is abit different. It needs to dot-source the i18n stuff because the shell library functions it contains need the localization support in the messages they emit. IOW, I do not think i18n belongs to -internal at all. > I don't see why we shouldn't have some stable shellscript function API > if that's needed either. > > I just wanted to point out that currently git-sh-setup isn't > documented as such. So at least a follow-up patch to the documentation > seems in order. > > This did break in v2.10.0, and it's taken a couple of months to notice > this, so clearly it's not very widely used, which says something about > the cost-benefit of maintaining this for external users. I am not sure if "stable API" in sh-setup is a good thing for the ecosystem in the longer term. As more and more in-tree scripted Porcelain commands migrate to C, many helper functions in sh-setup will lose their in-tree users. For example, get_author_ident_from_commit used to have three in-tree customers (git-commit.sh, git-am.sh and git-rebase--interactive.sh), but the first two is long gone and the third one may soon lose its need to call it. Once a helper function in setup-sh loses all in-tree users, we may no longer _break_ that helper, but that is simply because we feel no need to touch it. The in-tree Porcelain commands that migrated to C however will enhance the counterpart they use in C to be more featureful or fix longstanding bugs in the C version they use, while sh-setup version bitrot and making old practice obsolete for "modern" use of Git of the day. Keeping such a stale version that we do not use, or even we attempt to update it without having a good vehicle to test the change ourselves (because we no longer have any in-tree users) will be disservice to third-party scripts---the only thing they are getting by using the stale one, instead of reinventing their own that they may be responsible to keep up to date, is that they share the same staleness as everybody else that use the sh-setup version as a third-party. I am not arguing that we should remove what loses all in-tree users immediately. At least not yet. But I wanted to point out that it may not be a good use of our brain cycles to keep the API "stable" by keeping what in-tree users do not use anymore, especially if it does not help third-party users in the long run.
Bug#842477: [PATCH] git-sh-setup: Restore sourcability from outside scripts
Anders Kaseorgwrites: > v2.10.0-rc0~45^2~2 “i18n: git-sh-setup.sh: mark strings for > translation” broke outside scripts such as guilt that source > git-sh-setup as described in the documentation: > > $ . "$(git --exec-path)/git-sh-setup" > sh: 6: .: git-sh-i18n: not found > > This also affects contrib/convert-grafts-to-replace-refs.sh and > contrib/rerere-train.sh in tree. Fix this by using git --exec-path to > find git-sh-i18n. > > While we’re here, move the sourcing of git-sh-i18n below the shell > portability fixes. > > Signed-off-by: Anders Kaseorg > --- Looks good. Our in-tree scripts rely on the fact that $PATH is adjusted to have $GIT_EXEC_PATH early (either by getting invoked indirectly by "git" potty, or the requirement to do so for people and scripts that still run our in-tree scripts with dashed e.g. "git-rebase" form) by the time they run. But when sh-setup dot-sources git-sh-i18n for its own use, it should be explicit to name which one of the many copies that may appear in directories on user's $PATH (one among which is the one in $GIT_EXEC_PATH) it wants to use. And this patch does the right thing by not relying on the $PATH, but instead naming the exact path using $(git --exec-path)/ prefix, to the included file. In other words, I think this patch is a pure bugfix, even if there is no third-party script that includes it. We may want to have the above as the rationale to apply this patch in the proposed log message, though. > Is this a supported use of git-sh-setup? Although the documentation is > clear that the end user should not invoke it directly, it seems to imply > that scripts may do this, and in practice it has worked until v2.10.0. It is correct for the documentation to say that this is not a "command" end users would want to run; they cannot invoke it as a standalone command as it is written as a dot-sourced shell library. Even though it is intended solely for internal use, so far we have not removed things from there, which would have signalled people that third-party scripts can also dot-source it. We may want to reserve the right to break them in the future, but because this is a pure bugfix, "can third-party rely on the interface not changing?" is not a question we need to answer in this thread---there is no reason to leave this broken. Thanks. > git-sh-setup.sh | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/git-sh-setup.sh b/git-sh-setup.sh > index a8a4576..240c7eb 100644 > --- a/git-sh-setup.sh > +++ b/git-sh-setup.sh > @@ -2,9 +2,6 @@ > # to set up some variables pointing at the normal git directories and > # a few helper shell functions. > > -# Source git-sh-i18n for gettext support. > -. git-sh-i18n > - > # Having this variable in your environment would break scripts because > # you would cause "cd" to be taken to unexpected places. If you > # like CDPATH, define it for your interactive shell sessions without > @@ -46,6 +43,9 @@ git_broken_path_fix () { > > # @@BROKEN_PATH_FIX@@ > > +# Source git-sh-i18n for gettext support. > +. "$(git --exec-path)/git-sh-i18n" > + > die () { > die_with_status 1 "$@" > }
Bug#842477: [PATCH] git-sh-setup: Restore sourcability from outside scripts
,On Sun, Oct 30, 2016 at 10:12 PM, Jeff Kingwrote: > On Sun, Oct 30, 2016 at 08:09:21PM -, Philip Oakley wrote: > >> > It is documented (Documentation/git-sh-setup.txt), and this is not the >> > internal Documentation/technical section of the documentation, so my >> > default assumption would be that everything shown there is intended as >> > public. I only bring this up as a question because it was apparently >> > allowed to break. If I’m wrong and it isn’t public, other patches are >> > needed (to the documentation and to its users in contrib). >> > >> But the Documenation does say :: >> >> - This is not a command the end user would want to run. Ever. >> >> - This documentation is meant for people who are studying the Porcelain-ish >> scripts and/or are writing new ones. >> -- > > Historically speaking, porcelain-ish scripts were carried both in and > out of git.git. These days what we consider porcelain is usually carried > in-tree, but I don't think it's unreasonable for people building their > own scripts to want to make use of git-sh-setup. And we've generally > tried to retain backwards compatibility in the functions it provides, > even to out-of-tree scripts. > > So I think it is worth applying the fix at the start of this thread to > keep that working. > > As for a documentation change for "do not use this for out-of-tree > scripts", I am mildly negative, as I don't think that matches historical > practice. I don't see why we shouldn't have some stable shellscript function API if that's needed either. I just wanted to point out that currently git-sh-setup isn't documented as such. So at least a follow-up patch to the documentation seems in order. This did break in v2.10.0, and it's taken a couple of months to notice this, so clearly it's not very widely used, which says something about the cost-benefit of maintaining this for external users. It's probably worthwhile to split off git-sh-setup into git-sh-setup & git-sh-setup-internal along with a documentation fix. A lot of what it's doing (e.g. git_broken_path_fix(), and adding a die() function) is probably only needed internally by git itself. The git-sh-setup-internal should be the thing sourcing "git-sh-i18n", I don't see how anyone out-of-tree could make use of that. Surely nobody needs to re-emit the exact message we shipped with our *.po files.
Bug#842477: [PATCH] git-sh-setup: Restore sourcability from outside scripts
On Sun, Oct 30, 2016 at 08:09:21PM -, Philip Oakley wrote: > > It is documented (Documentation/git-sh-setup.txt), and this is not the > > internal Documentation/technical section of the documentation, so my > > default assumption would be that everything shown there is intended as > > public. I only bring this up as a question because it was apparently > > allowed to break. If I’m wrong and it isn’t public, other patches are > > needed (to the documentation and to its users in contrib). > > > But the Documenation does say :: > > - This is not a command the end user would want to run. Ever. > > - This documentation is meant for people who are studying the Porcelain-ish > scripts and/or are writing new ones. > -- Historically speaking, porcelain-ish scripts were carried both in and out of git.git. These days what we consider porcelain is usually carried in-tree, but I don't think it's unreasonable for people building their own scripts to want to make use of git-sh-setup. And we've generally tried to retain backwards compatibility in the functions it provides, even to out-of-tree scripts. So I think it is worth applying the fix at the start of this thread to keep that working. As for a documentation change for "do not use this for out-of-tree scripts", I am mildly negative, as I don't think that matches historical practice. -Peff
Bug#842477: [PATCH] git-sh-setup: Restore sourcability from outside scripts
From: "Anders Kaseorg"On Sun, 30 Oct 2016, Ævar Arnfjörð Bjarmason wrote: This seems like a reasonable fix for this issue. However as far as I can tell git-sh-setup was never meant to be used by outside scripts that didn't ship as part of git itself. If that's the case any change in the API which AFAICT is now considered internal might break them, so should some part of that be made public & documented as such? It is documented (Documentation/git-sh-setup.txt), and this is not the internal Documentation/technical section of the documentation, so my default assumption would be that everything shown there is intended as public. I only bring this up as a question because it was apparently allowed to break. If I’m wrong and it isn’t public, other patches are needed (to the documentation and to its users in contrib). But the Documenation does say :: - This is not a command the end user would want to run. Ever. - This documentation is meant for people who are studying the Porcelain-ish scripts and/or are writing new ones. -- So there is a cautionary word or two there... The question would then become: what (if anything) was missing in the documentation?... maybe the inclusion of Ævar's "[Not] to be used by outside scripts that didn't ship as part of git itself."? Or a comment that it may change in newer versions. Though the code fix may still be reasonable.. Philip
Bug#842477: [PATCH] git-sh-setup: Restore sourcability from outside scripts
On Sun, 30 Oct 2016, Ævar Arnfjörð Bjarmason wrote: > This seems like a reasonable fix for this issue. However as far as I > can tell git-sh-setup was never meant to be used by outside scripts > that didn't ship as part of git itself. > > If that's the case any change in the API which AFAICT is now > considered internal might break them, so should some part of that be > made public & documented as such? It is documented (Documentation/git-sh-setup.txt), and this is not the internal Documentation/technical section of the documentation, so my default assumption would be that everything shown there is intended as public. I only bring this up as a question because it was apparently allowed to break. If I’m wrong and it isn’t public, other patches are needed (to the documentation and to its users in contrib). Anders
Bug#842477: [PATCH] git-sh-setup: Restore sourcability from outside scripts
On Sun, Oct 30, 2016 at 3:10 AM, Anders Kaseorgwrote: > v2.10.0-rc0~45^2~2 “i18n: git-sh-setup.sh: mark strings for > translation” broke outside scripts such as guilt that source > git-sh-setup as described in the documentation: > > $ . "$(git --exec-path)/git-sh-setup" > sh: 6: .: git-sh-i18n: not found This seems like a reasonable fix for this issue. However as far as I can tell git-sh-setup was never meant to be used by outside scripts that didn't ship as part of git itself. If that's the case any change in the API which AFAICT is now considered internal might break them, so should some part of that be made public & documented as such?
Bug#842477: [PATCH] git-sh-setup: Restore sourcability from outside scripts
v2.10.0-rc0~45^2~2 “i18n: git-sh-setup.sh: mark strings for translation” broke outside scripts such as guilt that source git-sh-setup as described in the documentation: $ . "$(git --exec-path)/git-sh-setup" sh: 6: .: git-sh-i18n: not found This also affects contrib/convert-grafts-to-replace-refs.sh and contrib/rerere-train.sh in tree. Fix this by using git --exec-path to find git-sh-i18n. While we’re here, move the sourcing of git-sh-i18n below the shell portability fixes. Signed-off-by: Anders Kaseorg--- Is this a supported use of git-sh-setup? Although the documentation is clear that the end user should not invoke it directly, it seems to imply that scripts may do this, and in practice it has worked until v2.10.0. git-sh-setup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/git-sh-setup.sh b/git-sh-setup.sh index a8a4576..240c7eb 100644 --- a/git-sh-setup.sh +++ b/git-sh-setup.sh @@ -2,9 +2,6 @@ # to set up some variables pointing at the normal git directories and # a few helper shell functions. -# Source git-sh-i18n for gettext support. -. git-sh-i18n - # Having this variable in your environment would break scripts because # you would cause "cd" to be taken to unexpected places. If you # like CDPATH, define it for your interactive shell sessions without @@ -46,6 +43,9 @@ git_broken_path_fix () { # @@BROKEN_PATH_FIX@@ +# Source git-sh-i18n for gettext support. +. "$(git --exec-path)/git-sh-i18n" + die () { die_with_status 1 "$@" } -- 2.10.1