Skip to contentSkip to conversation

Problems using perl's Git.pm module

DISCUSSION Josef Wolf 5 participants 19 messages Jun 15, 2016

lore
Share & tools
lore

Josef Wolf

author
#0 lore raw

Hello folks,

I am trying to use perl's Git.pm module, but for some reason, it keeps bailing out:

jw@raven:~/testrepos> git st
# On branch master
nothing to commit (working directory clean)

jw@raven:~/testrepos> ./test.pl
# On branch master
nothing to commit (working directory clean)
status failed w/ code 1 at ./test.pl line 9

jw@raven:~/testrepos> cat test.pl
#! /usr/bin/perl

use strict;
use warnings;
use Git;

  my $repo = Git->repository (Directory => '.');
  git_cmd_try { $repo->command_noisy('status') }
                       '%s failed w/ code %d';

print "Never reach this line\n";

jw@raven:~/testrepos>

Any ideas why the status command keeps bailing out on an entire clean repository?

#1 lore raw
Quoted 3 lines · Josef Wolf

jw@raven:~/testrepos> git st
# On branch master
nothing to commit (working directory clean)

I take it that you have "alias.st.cmd = status".

Observe what this gives you:

    $ git st; echo $?

If you are running pre-1.7.0 version of git, I think "git status" was a synonym to "git commit --dry-run" and exited with non-zero status to signal the caller that there is nothing to commit, which is...

Quoted 4 lines

jw@raven:~/testrepos> ./test.pl
# On branch master
nothing to commit (working directory clean)
status failed w/ code 1 at ./test.pl line 9

...consistent with what we see here.

author
#2 lore raw
Quoted 6 lines · Junio C Hamano
Quoted 3 lines · Josef Wolf

jw@raven:~/testrepos> git st
# On branch master
nothing to commit (working directory clean)

I take it that you have "alias.st.cmd = status".

Yes, I'm still strongly tied to svn ;-)

Quoted 3 lines

Observe what this gives you:

    $ git st; echo $?

1

Quoted 3 lines

If you are running pre-1.7.0 version of git, I think "git status" was a synonym to "git commit --dry-run" and exited with non-zero status to signal the caller that there is nothing to commit, which is...

It's 1.6.4.2, so I guess you're right.

Thanks!

#3 lore raw
In reply to Josef Wolf
Quoted 2 lines · Josef Wolf

I am trying to use perl's Git.pm module, but for some reason, it keeps bailing out:

Why are you using it? It's for internal use only.

Couldn't you use one of the Perl Git wrappers on the CPAN?

#4 lore raw
Quoted 6 lines · Ævar Arnfjörð Bjarmason
Quoted 2 lines · Josef Wolf

I am trying to use perl's Git.pm module, but for some reason, it keeps bailing out:

Why are you using it? It's for internal use only.

Where do you get that from? (Not sure whether it's true, just curious.)

Quoted 1 line

Couldn't you use one of the Perl Git wrappers on the CPAN?

This is still a reasonable suggestion, certainly.

#5 lore raw
Quoted 9 lines · Jonathan Nieder
Quoted 6 lines · Ævar Arnfjörð Bjarmason
Quoted 2 lines · Josef Wolf

I am trying to use perl's Git.pm module, but for some reason, it keeps bailing out:

Why are you using it? It's for internal use only.

Where do you get that from?  (Not sure whether it's true, just curious.)

It, like our internal C is subject to change at any time. It's not intended for external use.

Quoted 3 lines
Quoted 1 line

Couldn't you use one of the Perl Git wrappers on the CPAN?

This is still a reasonable suggestion, certainly.

Yes, it really is much better to use the CPAN modules that wrap Git. We might even want to use them ourselves someday.

author
#6 lore raw
In reply to Ævar Arnfjörð Bjarmason
Quoted 4 lines · Ævar Arnfjörð Bjarmason
Quoted 2 lines · Josef Wolf

I am trying to use perl's Git.pm module, but for some reason, it keeps bailing out:

Why are you using it?

1. It is always available whenever git is available, so I don't need to search/install additional packages just to hack some scripts. If you have to support multiple distros/OS'es, it starts getting a PITA to find out what/how to install those additional packages.

2. Since it is used by the core developers, I assumed that it would be more robust than some third-party wrappers.

3. Since it is bundled with git, I'd not expect any version mismatches. With a third-party wrapper, version mismatches are much more likely.

Quoted 1 line

Couldn't you use one of the Perl Git wrappers on the CPAN?

Which one would you suggest?

#7 lore raw
Quoted 5 lines · Josef Wolf
Quoted 1 line · Ævar Arnfjörð Bjarmason

Couldn't you use one of the Perl Git wrappers on the CPAN?

Which one would you suggest?

Judging from [1], Git::Wrapper might be worth trying.

That said, if you have more questions or any ideas for Git.pm, they would be welcome. That is when the lack of declared stable API can come in handy. ;-)

[1] https://git.wiki.kernel.org/index.php/Interfaces,_frontends,_and_tools#Perl

#8 lore raw
In reply to Ævar Arnfjörð Bjarmason
Quoted 5 lines · Ævar Arnfjörð Bjarmason
Quoted 2 lines · Josef Wolf

I am trying to use perl's Git.pm module, but for some reason, it keeps bailing out:

Why are you using it? It's for internal use only.

That is not a valid question nor answer, I am afraid.

It probably is showing that perl/Git.pm is underdocumented. We should make it possible if not trivial for people who want to write the next great git-svn.perl or whatever that uses the module to interact with the repository.

I don't understand why the Josef's scriptlet passes Directory to the initialization code. Is it working with a bare repository?

#9 lore raw
Quoted 9 lines · Junio C Hamano
Quoted 5 lines · Ævar Arnfjörð Bjarmason
Quoted 2 lines · Josef Wolf

I am trying to use perl's Git.pm module, but for some reason, it keeps bailing out:

Why are you using it? It's for internal use only.

That is not a valid question nor answer, I am afraid.

So you are saying that it is for more than internal use?

Yves

Signature · 1 line
perl -Mre=debug -e "/just|another|perl|hacker/"
#10 lore raw
Quoted 8 lines · demerphq
Quoted 5 lines · Junio C Hamano
Quoted 1 line · Ævar Arnfjörð Bjarmason

Why are you using it? It's for internal use only.

That is not a valid question nor answer, I am afraid.

So you are saying that it is for more than internal use?

I assume so. I had guessed the same thing (that it is meant to be generally useful), based on the following:

- it is installed to be usable with a simple "use Git" automatically

- "perldoc Git" tells me that this module gives Perl scripts an easy way to interface the Git version control system, not that it is an implementation artifact

- tools like "git svn" were not historically part of core git, and usage by them was not exactly internal use.

Hope that helps.
Jonathan

#11 lore raw
Quoted 8 lines · Jonathan Nieder
Quoted 7 lines · demerphq
Quoted 5 lines · Junio C Hamano
Quoted 1 line · Ævar Arnfjörð Bjarmason

Why are you using it? It's for internal use only.

That is not a valid question nor answer, I am afraid.

Quoted 7 lines
Quoted 1 line

So you are saying that it is for more than internal use?

I assume so.  I had guessed the same thing (that it is meant to be generally useful), based on the following:

 - it is installed to be usable with a simple "use Git" automatically

Well that is true. But im not sure that is a good reason.

Quoted 3 lines

 - "perldoc Git" tells me that this module gives Perl scripts an easy way to interface the Git version control system, not that it is an implementation artifact

Any perl module, or script, or podfile installed in a place that perldoc knows about is available to perldoc.

Quoted 2 lines

 - tools like "git svn" were not historically part of core git, and usage by them was not exactly internal use.

Well, the counter arguments are:

No back-compat layer for older gits. Tight binding to a particular git
- no availability of upgrades independent of upgrading git. No availability or review of the module on the standard venues for doing so for Perl modules. CPAN, CPANTESTERS, smoke reports, etc.

And well the line:

# Totally unstable API.
$VERSION = '0.01';

STRONGLY suggests that the module should not be used by code outside the Git package itself.

Cheers,
yves

Signature · 1 line
perl -Mre=debug -e "/just|another|perl|hacker/"
#12 lore raw

[RFC/PATCH] Git.pm: discourage casual use

Git's internal perl interface still does not have a stable API, and meanwhile CPAN has a number of modules to fulfill the need for a perl git interface. The line

	# Totally unstable API.
	$VERSION = '0.01';

in the source makes this clear enough, but users who just looked at git-svn.perl and then tried "perldoc Git" would not notice. Add a note to the manual to warn the reader.

---

Quoted 7 lines · demerphq

And well the line:

# Totally unstable API.
$VERSION = '0.01';

STRONGLY suggests that the module should not be used by code outside the Git package itself.

So how about something like this patch, to start?

perl/Git.pm +6 -2
index 6cb0dd1..7f6c500 100644
@@ -63,12 +63,16 @@ require Exporter;
 
 =head1 DESCRIPTION
 
-This module provides Perl scripts easy way to interface the Git version control
-system. The modules have an easy and well-tested way to call arbitrary Git
+This module provides an easy way to interact with the Git version control
+system for Git's internal perl scripts.
+The modules have an easy and well-tested way to call arbitrary Git
 commands; in the future, the interface will also provide specialized methods
 for doing easily operations which are not totally trivial to do over
 the generic command interface.
 
+Note: this module should not be used by code outside the Git package itself,
+since the API is not stable yet.
+
 While some commands can be executed outside of any context (e.g. 'version'
 or 'init'), most operations require a repository context, which in practice
 means getting an instance of the Git object using the repository() constructor.
#13 lore raw

Re: [RFC/PATCH] Git.pm: discourage casual use

Quoted 1 line · Jonathan Nieder

So how about something like this patch, to start?

Ok. We may probably want to reduce the repetition of "easy", though.

Quoted 23 lines
perl/Git.pm +6 -2
index 6cb0dd1..7f6c500 100644
@@ -63,12 +63,16 @@ require Exporter;
 
 =head1 DESCRIPTION
 
-This module provides Perl scripts easy way to interface the Git version control
-system. The modules have an easy and well-tested way to call arbitrary Git
+This module provides an easy way to interact with the Git version control
+system for Git's internal perl scripts.
+The modules have an easy and well-tested way to call arbitrary Git
 commands; in the future, the interface will also provide specialized methods
 for doing easily operations which are not totally trivial to do over
 the generic command interface.
 
+Note: this module should not be used by code outside the Git package itself,
+since the API is not stable yet.
+
 While some commands can be executed outside of any context (e.g. 'version'
 or 'init'), most operations require a repository context, which in practice
 means getting an instance of the Git object using the repository() constructor.
#14 lore raw

Re: [RFC/PATCH] Git.pm: discourage casual use

Quoted 5 lines · Junio C Hamano
Quoted 1 line · Jonathan Nieder

So how about something like this patch, to start?

Ok. We may probably want to reduce the repetition of "easy", though.

Yes.
---

perl/Git.pm +4 -4
index 69e92aa..4700dd7 100644
@@ -65,12 +65,12 @@ require Exporter;
 
 This module provides an easy way to interact with the Git version control
 system for Git's internal perl scripts.
-The modules have an easy and well-tested way to call arbitrary Git
-commands; in the future, the interface will also provide specialized methods
-for doing easily operations which are not totally trivial to do over
+The modules include a robust way to call arbitrary Git commands;
+in the future, the interface will also provide specialized methods
+to simplify operations which are not totally trivial to do over
 the generic command interface.
 
-Note: this module should not be used by code outside the Git package itself,
+The module should not be used by code outside the Git package itself,
 since the API is not stable yet.
 
 While some commands can be executed outside of any context (e.g. 'version'
author
#15 lore raw
In reply to demerphq
Quoted 4 lines · demerphq

Well, the counter arguments are:

No back-compat layer for older gits. Tight binding to a particular git
- no availability of upgrades independent of upgrading git.

I don't understand this one. Why do you need independent upgrades here? Since Git.pm comes with git core, the installed version of Git.pm should always match the installed version of git.

Quoted 3 lines

No
availability or review of the module on the standard venues for doing so for Perl modules. CPAN, CPANTESTERS, smoke reports, etc.

A module on CPAN has better tests for perl integration. A module in git-core has better tests for git integration.

You trade one for the other. The question is which is more critical. IMHO, git-integration is more critical.

#16 lore raw
Quoted 9 lines · Josef Wolf
Quoted 4 lines · demerphq

Well, the counter  arguments are:

No back-compat layer for older gits. Tight binding to a particular git
- no availability of upgrades independent of upgrading git.

I don't understand this one. Why do you need independent upgrades here? Since Git.pm comes with git core, the installed version of Git.pm should always match the installed version of git.

Because in my experience coding a tool against a particular version of Git.pm basically means that tool has to be on the same git version or higher than the version you coded against.

There is no easy/safe way to update Git,pm to provide a consistent interface to older gits.

Quoted 10 lines
Quoted 4 lines

No
availability or review of the module on the standard venues for doing so for Perl modules. CPAN, CPANTESTERS, smoke reports, etc.

A module on CPAN has better tests for perl integration. A module in git-core has better tests for git integration.

You trade one for the other. The question is which is more critical. IMHO, git-integration is more critical.

A CPAN module would be automatically tested by the CPANTESTERS community against whatever git people happened to have lying around, and those tests would necessarily occur on a myriad of systems, and when failures occurred they would be automatically registered in CPAN rt bug tracking system, and available in various summarized and detailed forms from multiple locations.

Those test results and integration efforts would be automatically fed back to the module author, be publicly available on several websites, including via CPAN itself, and if it should happen that the p5p group were to somehow break Git.pm somehow we would know about it, and be able to fix perl itself without Git.pm having to change. Admittedly this is unlikely given the nature of the code.

So really, by tightly binding the package to git all that you guarantee is that the version of Git.pm installed by git will work with the git you have installed. It does not say that any program written against that version of Git.pm will continue to work on a later version, or that people stuck on a older version of git will be able to use it.

cheers,
Yves

Signature · 1 line
perl -Mre=debug -e "/just|another|perl|hacker/"
#17 lore raw
In reply to demerphq
Quoted 4 lines · demerphq
Quoted 3 lines · Junio C Hamano
Quoted 1 line · Ævar Arnfjörð Bjarmason

On Thu, Dec 2, 2010 at 12:40, Josef Wolf <[email protected]> wrote:

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

I am trying to use perl's Git.pm module, but for some reason, it keeps bailing out:

Why are you using it? It's for internal use only.

That is not a valid question nor answer, I am afraid.

So you are saying that it is for more than internal use?

No.

Imagine you were adding a new function to git-svn.perl and wanted to know why your addition that looked somewhat similar to what Josef sent did not work as you expected.

We should be able to answer such a question, don't you think? People often seem to badmouth this list as git develper's list that is unfriendly to end users. I don't think that is true, but even if that were true (or especially if that were true), shouldn't we be try to be friendly at least to a potential developer who tries to learn and use Git.pm module?

#18 lore raw
Quoted 21 lines · Junio C Hamano
Quoted 4 lines · demerphq
Quoted 3 lines · Junio C Hamano
Quoted 1 line · Ævar Arnfjörð Bjarmason

On Thu, Dec 2, 2010 at 12:40, Josef Wolf <[email protected]> wrote:

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

I am trying to use perl's Git.pm module, but for some reason, it keeps bailing out:

Why are you using it? It's for internal use only.

That is not a valid question nor answer, I am afraid.

So you are saying that it is for more than internal use?

No.

Imagine you were adding a new function to git-svn.perl and wanted to know why your addition that looked somewhat similar to what Josef sent did not work as you expected.

Quoted 5 lines

We should be able to answer such a question, don't you think?  People often seem to badmouth this list as git develper's list that is unfriendly to end users.  I don't think that is true, but even if that were true (or especially if that were true), shouldn't we be try to be friendly at least to a potential developer who tries to learn and use Git.pm module?

Certainly. My question purely had to do with whether it is for internal use or not.

The reason I asked is that I don't think it is for external use, and wanted to make sure you agree.

cheers,
Yves

Signature · 1 line
perl -Mre=debug -e "/just|another|perl|hacker/"