Commit Graph

280 Commits

Author SHA1 Message Date
Frank Lichtenheld
fe53bbc9be Git.pm: Always set Repository to absolute path if autodetecting
So far we only set it to absolute paths in some cases which lead
to problems like wc_chdir not working.

Signed-off-by: Frank Lichtenheld <flichtenheld@astaro.com>
Acked-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-05-09 08:25:55 -07:00
Frank Lichtenheld
da159c7759 Git.pm: Set GIT_WORK_TREE if we set GIT_DIR
Otherwise git will use the current directory as work tree which will
lead to unexpected results if we operate in sub directory of the
work tree.

Signed-off-by: Frank Lichtenheld <flichtenheld@astaro.com>
Acked-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-05-09 08:25:55 -07:00
Markus Heidelberg
89a56bfbd3 add --html-path to get the location of installed HTML docs
This can be used in GUIs to open installed HTML documentation in the
browser.

Signed-off-by: Markus Heidelberg <markus.heidelberg@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-04-04 23:57:59 -07:00
Junio C Hamano
e98c6a1686 Merge branch 'maint'
* maint:
  fast-import: Cleanup mode setting.
  Git.pm: call Error::Simple() properly
2009-01-13 23:12:51 -08:00
Junio C Hamano
4f8b8992ef Merge branch 'maint-1.6.0' into maint
* maint-1.6.0:
  fast-import: Cleanup mode setting.
  Git.pm: call Error::Simple() properly
2009-01-13 23:10:50 -08:00
Jay Soffian
8faea4f3b2 Git.pm: call Error::Simple() properly
The error message to Error::Simple() must be passed as a single argument.

Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-01-13 22:52:35 -08:00
Philippe Bruhat (BooK)
11b8a41c45 Git.pm: correctly handle directory name that evaluates to "false"
The repository constructor mistakenly rewrote a Directory parameter that
Perl happens to evaluate to false (e.g. "0") to ".".

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-01-01 06:34:58 -08:00
Richard Hartmann
f66bc5f928 Always show which directory is not a git repository
Unify all

  fatal: Not a git repository

error messages so they include path information.

Signed-off-by: Richard Hartmann <richih@net.in.tum.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-12-21 18:46:41 -08:00
Marten Svanfeldt (dev)
bcdd1b4456 Git.pm: Make _temp_cache use the repository directory
Update the usage of File::Temp->tempfile to place the temporary files
within the repository directory instead of just letting Perl decide what
directory to use, given there is a repository specified when requesting
the temporary file.

This is needed to be able to fix git-svn on msys as msysperl generates
paths with UNIX-style paths (/tmp/xxx) while the git tools expect natvie
path format (c:/..). The repository dir is stored in native format so by
using it as the base directory for temporary files we always get a
usable native full path.

Signed-off-by: Marten Svanfeldt <developer@svanfeldt.com>
Acked-by: Eric Wong <normalperson@yhbt.net>
2008-11-13 22:36:34 -08:00
Christian Jaeger
d8b24b930f Git.pm: do not break inheritance
Make it possible to write subclasses of Git.pm

Signed-off-by: Christian Jaeger <christian@jaeger.mine.nu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-10-19 14:46:33 -07:00
Marcus Griep
836ff95df6 Git.pm: Use File::Temp->tempfile instead of ->new
Perl 5.8.0 ships with File::Temp 0.13, which does not have the new()
interface introduced in 0.14, as pointed out by Tom G. Christensen.

This modifies Git.pm to use the more established tempfile() interface
and updates 'git svn' to match.

Signed-off-by: Marcus Griep <marcus@griep.us>
Acked-by: Eric Wong <normalperson@yhbt.net>
Tested-by: Tom G. Christensen <tgc@statsbiblioteket.dk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-09-10 11:45:22 -07:00
Marcus Griep
c14c8ceb13 Git.pm: Make File::Spec and File::Temp requirement lazy
This will ensure that the API at large is accessible to nearly
all Perl versions, while only the temp file caching API is tied to
the File::Temp and File::Spec modules being available.

Signed-off-by: Marcus Griep <marcus@griep.us>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-08-16 02:58:22 -07:00
Marcus Griep
e41352b24e Git.pm: Add faculties to allow temp files to be cached
This patch offers a generic interface to allow temp files to be
cached while using an instance of the 'Git' package. If many
temp files are created and destroyed during the execution of a
program, this caching mechanism can help reduce the amount of
files created and destroyed by the filesystem.

The temp_acquire method provides a weak guarantee that a temp
file will not be stolen by subsequent requests. If a file is
locked when another acquire request is made, a simple error is
thrown.

Signed-off-by: Marcus Griep <marcus@griep.us>
Acked-by: Eric Wong <normalperson@yhbt.net>
2008-08-12 20:46:54 -07:00
Brandon Casey
1fc2cbc1d8 perl/Makefile: handle paths with spaces in the NO_PERL_MAKEMAKER section
Use double quotes to protect against paths which may contain spaces.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-08-06 14:00:36 -07:00
Abhijit Menon-Sen
9751a32a6b Fix typo in perl/Git.pm
Signed-off-by: Abhijit Menon-Sen <ams@toroid.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-08-04 21:51:53 -07:00
Abhijit Menon-Sen
452d36b1f3 Fix hash slice syntax error
Signed-off-by: Abhijit Menon-Sen <ams@toroid.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-08-04 21:51:23 -07:00
Abhijit Menon-Sen
108c2aaf79 Git.pm: localise $? in command_close_bidi_pipe()
Git::DESTROY calls _close_cat_blob and _close_hash_and_insert_object,
which in turn call command_close_bidi_pipe, which calls waitpid, which
alters $?. If this happens during global destruction, it may alter the
program's exit status unexpectedly. Making $? local to the function
solves the problem.

(The problem was discovered due to a failure of test #8 in
t9106-git-svn-commit-diff-clobber.sh.)

Signed-off-by: Abhijit Menon-Sen <ams@toroid.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-08-04 21:51:17 -07:00
Todd Zullinger
5354a56fe7 Replace uses of "git-var" with "git var"
Signed-off-by: Todd Zullinger <tmz@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-30 11:42:01 -07:00
Brandon Casey
058fb41480 perl/Makefile: update NO_PERL_MAKEMAKER section
The perl modules must be copied to blib/lib so they are available for
testing.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-25 00:08:56 -07:00
Petr Baudis
31a92f6aa4 Git.pm: Add remote_refs() git-ls-remote frontend
This patch also converts the good ole' git-remote.perl to use it.
It is otherwise used in the repo.or.cz machinery and I guess other
scripts might find it useful too.

Unfortunately,

	git-ls-remote --heads .

is subtly different from

	git-ls-remote . refs/heads/

(since the second matches anywhere in the string, not just at the
beginning) so we have to provide interface for both.

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-08 22:46:01 -07:00
Lea Wiemann
32d8050a86 Git.pm: fix return value of config method
If config is called in array context, it is supposed to return all
values set for the given option key.  This works for all cases except
if there is no value set at all.  In that case, it wrongly returns
(undef) instead of ().  This fixes the return statement so that it
returns undef in scalar context but an empty array in array context.

Signed-off-by: Lea Wiemann <LeWiemann@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-06-01 22:28:27 -07:00
Lea Wiemann
58c8dd2173 Git.pm: fix documentation of hash_object
The documentation of hash_object incorrectly states that it accepts a
file handle -- in fact it doesn't, and there is even a TODO comment
for this.  This fixes the documentation.

Signed-off-by: Lea Wiemann <LeWiemann@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-06-01 22:21:05 -07:00
Junio C Hamano
d683a0e00c Git::cat_blob: allow using an empty blob to fix git-svn breakage
Recent "git-svn optimization" series introduced Git::cat_blob() subroutine
whose interface was broken in that it returned the size of the blob but
signalled an error by returning 0.  You can never use an empty blob with
such an interface.

This fixes the interface to return a negative value to signal an error.

Reported by Björn Steinbrink.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-27 23:35:55 -07:00
Adam Roben
7182530d8c Git.pm: Add hash_and_insert_object and cat_blob
These functions are more efficient ways of executing `git hash-object -w` and
`git cat-file blob` when you are dealing with many files/objects.

Signed-off-by: Adam Roben <aroben@apple.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-23 12:06:58 -07:00
Adam Roben
d1a29af98e Git.pm: Add command_bidi_pipe and command_close_bidi_pipe
command_bidi_pipe hands back the stdin and stdout file handles from the
executed command. command_close_bidi_pipe closes these handles and terminates
the process.

Signed-off-by: Adam Roben <aroben@apple.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-23 12:06:51 -07:00
Frank Lichtenheld
44617928ae Git.pm: Don't require repository instance for ident
git var doesn't require to be called in a repository anymore,
so don't require it either.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-15 01:43:56 -07:00
Frank Lichtenheld
c2e357c2fe Git.pm: Don't require a repository instance for config
git config itself doesn't require to be called in a repository,
so don't add arbitrary restrictions.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-15 01:43:56 -07:00
Gerrit Pape
28072a5d30 Don't cache DESTDIR in perl/perl.mak.
DESTDIR is supposed to be overridden on 'make install' after doing
'make'.  Have the automatically generated perl/perl.mak not cache the
value of DESTDIR to support that for the perl/ subdirectory also.

Signed-off-by: Gerrit Pape <pape@smarden.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-11 00:38:46 -08:00
Junio C Hamano
b4c61ed6d3 Color support for "git-add -i"
This is mostly lifted from earlier series by Dan Zwell, but updated to
use "git config --get-color" and "git config --get-colorbool" to make it
simpler and more consistent with commands written in C.

A new configuration color.interactive variable is like color.diff and
color.status, and controls if "git-add -i" uses color.

A set of configuration variables, color.interactive.<slot>, are used to
define what color is used for the prompt, header, and help text.

For perl scripts, Git.pm provides $repo->get_color() method, which takes
the slot name and the default color, and returns the terminal escape
sequence to color the output text.  $repo->get_colorbool() method can be
used to check if color is set to be used for a given operation.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-05 17:57:11 -08:00
Jakub Narebski
346d203bc3 Add config_int() method to the Git perl module
Integer variables can have optional 'k', 'm' or 'g' suffix.
config_int() method will return simple decimal number, taking
care of those suffixes.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-30 13:52:36 -08:00
Ask Bjørn Hansen
6aaa65da20 When exec() fails include the failing command in the error message
git-svn occasionally fails with no details as to what went wrong - this should help debug those situations.

Signed-off-by: Ask Bjørn Hansen <ask@develooper.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-07 11:39:37 -08:00
martin f. krafft
191131e538 Install man3 manpages to $PREFIX/share/man/man3 even for site installs
MakeMaker supports three installation modes: perl, site, and vendor. The first
and third install manpages to $PREFIX/share/man, only site installs to
$PREFIX/man. For consistency with the rest of git, which does not make the
distinction and writes all manpages to $PREFIX/share/man, this change makes
sure that perl does too, even when it's installed in site mode.

Signed-off-by: martin f. krafft <madduck@madduck.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-08-23 01:02:49 -07:00
Alex Riesen
2f5b398061 Fix git-remote for ActiveState Perl
For reason unknown a package in ActiveState Perl 5.8.7 must implement
READLINE method differently for scalar and array context. The code
tested to work for more sane and recent version of perl (5.8.8 shipped
with Ubuntu), so maybe it was always a requirement.

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-08-22 15:28:58 -07:00
Junio C Hamano
a6080a0a44 War on whitespace
This uses "git-apply --whitespace=strip" to fix whitespace errors that have
crept in to our source files over time.  There are a few files that need
to have trailing whitespaces (most notably, test vectors).  The results
still passes the test, and build result in Documentation/ area is unchanged.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-06-07 00:04:01 -07:00
Petr Baudis
35c49eeae7 Git.pm: config_boolean() -> config_bool()
This patch renames config_boolean() to config_bool() for consistency with
the commandline interface and because it is shorter but still obvious. ;-)
It also changes the return value from some obscure string to real Perl
boolean, allowing for clean user code.

Signed-off-by: Petr Baudis <pasky@suse.cz>
2007-05-10 14:13:29 -07:00
Bryan Larsen
5318f69812 Allow PERL_PATH="/usr/bin/env perl"
There is a mechanism PERL_PATH in the Makefile to specify path to
Perl binary, but sometimes it is convenient to let 'env' figure
out where Perl comes from, with PERL_PATH="/usr/bin/env perl".

Allowing this would make things easier to MacPorts, where we wish
to work with the MacPorts perl if it is installed, but fall back
to the system perl if it isn't.

Signed-off-by: Bryan Larsen <bryan@larsen.st>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-05-03 22:36:32 -07:00
Eric Wong
4a40cbd949 perl: install private Error.pm if the site version is older than our own
bdash (on IRC) had a problem with Git.pm (via git-svn) when his
site installation of Error.pm was older than the version we
package.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-04-21 13:06:24 -07:00
Johannes Schindelin
6cd7895fee Do not output "GEN " when generating perl.mak
This fixes the same issue as 8bef6204, which became an issue again
after 31d0399c.

Besides, it is not really helpful to print just "GEN " (_without_
"perl.mak").

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-14 01:33:49 -07:00
Alex Riesen
31d0399c3c More build output cleaning up
- print output file name for .c files
- suppress output of the names of subdirectories when make changes into them
- use GEN prefix for makefile generation in perl/

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-06 17:16:37 -08:00
Shawn O. Pearce
2314c94770 Make 'make' quiet by default
Per Junio's suggestion we are setting 'make' to be quiet by default,
with `make V=1` available to force GNU make back to its default
behavior of showing each command it is running.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-06 00:48:13 -08:00
Shawn O. Pearce
74f2b2a8d0 Make 'make' quieter while building git
I find it difficult to see compiler warnings amongst the massive
spewing produced by GNU make as it works through our productions.
This is especially true if CFLAGS winds up being rather long, due
to a large number of -W options being enabled and due to a number
of -D options being configured/required by my platform.

By defining QUIET_MAKE (e.g. make QUIET_MAKE=YesPlease) during
compilation users will get a less verbose output, such as:

    ...
    CC builtin-grep.c
builtin-grep.c:187: warning: 'external_grep' defined but not used
    CC builtin-init-db.c
    CC builtin-log.c
    CC builtin-ls-files.c
    CC builtin-ls-tree.c
    ...

The verbose (normal make) output is still the default.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-06 00:48:13 -08:00
Theodore Ts'o
7b9a13ece8 Add config_boolean() method to the Git perl module
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-02-20 23:58:37 -08:00
Pavel Roskin
3dff5379bf Assorted typo fixes
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-02-03 21:49:54 -08:00
Tom Prince
e0d10e1c63 [PATCH] Rename git-repo-config to git-config.
Signed-off-by: Tom Prince <tom.prince@ualberta.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-28 16:16:53 -08:00
Alex Riesen
67e4baf826 Cleanup uninitialized value in chomp
which happens if you use ActiveState Perl and a
pipe workaround specially for it.

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-22 09:44:26 -08:00
Alex Riesen
bed118d6bb Force Activestate Perl to tie git command pipe handle to a handle class
Otherwise it tries to tie it to a scalar and complains about missing
method. Dunno why, may be ActiveState brokenness again.

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Acked-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-22 09:44:26 -08:00
Alex Riesen
d3b1785f3f Insert ACTIVESTATE_STRING in Git.pm
Also add "git" to the pipe parameters, otherwise it does not work at all, as
no git commands are usable out of git context.

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-22 09:44:25 -08:00
Johannes Schindelin
8bef62049b Fix spurious compile error
From time to time, I would get this error:

[...]
sed: -e expression #8, char 41: Unterminated `s' command
make: *** [git-add--interactive] Error 1

Turns out that the function WriteMakefile() called in Makefile.PL
outputs the message "Writing perl.mak for Git" to stdout! Thus,
the output of "make -C perl -s --no-print-directory instlibdir"
would be prefixed by that message whenever Makefile.PL was newer
than perl.mak.

This is fixed by redirecting stdout to stderr in Makefile.PL.

Signed-off-by: Johannes E. Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-16 13:43:50 -08:00
Nicolas Pitre
5c94f87e6b use 'init' instead of 'init-db' for shipped docs and tools
While 'init-db' still is and probably will always remain a valid git
command for obvious backward compatibility reasons, it would be a good
idea to move shipped tools and docs to using 'init' instead.

Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-12 13:36:16 -08:00
Junio C Hamano
2cdf87ebd9 Fix perl/ build.
An earlier commit f848718a broke the build in perl/ directory by
allowing the Makefile.PL to overwrite the now-tracked Makefile.
Fix this by forcing Makefile.PL to produce its output in
perl.mak as the broken commit originally intended.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-12-08 14:07:45 -08:00
Alex Riesen
f848718a69 Make perl/ build procedure ActiveState friendly.
On Cygwin + ActivateState Perl, Makefile generated with
MakeMaker is not usable because of line-endings and
back-slashes.

This teaches perl/Makefile to write a handcrafted equivalent
perl.mak file with 'make NO_PERL_MAKEMAKER=NoThanks'.

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-12-04 13:39:32 -08:00
Petr Baudis
18b0fc1ce1 Git.pm: Kill Git.xs for now
This patch removes Git.xs from the repository for the time being. This
should hopefully enable Git.pm to finally make its way to master.

Git.xs is not going away forever. When the Git libification makes some
progress, it will hopefully return (but most likely as an optional
component, due to the portability woes) since the performance boosts are
really important for applications like Gitweb or Cogito. It needs to go
away now since it is not really reliable in case you use it for several
repositories in the scope of a single process, and that is not possible
to fix without some either very ugly or very intrusive core changes.

Rest in peace. (While you can.)

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-09-23 14:02:40 -07:00
Junio C Hamano
81a71734bb Revert "Make it possible to set up libgit directly (instead of from the environment)"
This reverts commit 0270083ded.
2006-09-02 22:58:48 -07:00
Junio C Hamano
9594b326dc Revert "Git.pm: Introduce fast get_object() method"
This reverts commit 3c479c37f8.
2006-09-02 22:58:32 -07:00
Eric Wong
4c5cf8c44c pass DESTDIR to the generated perl/Makefile
Makes life for binary packagers easier, as the Perl modules will
be installed inside DESTDIR.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-08-13 10:25:00 -07:00
Petr Baudis
96bc4de85c Eliminate Scalar::Util usage from private-Error.pm
We used just the blessed() routine so steal it from Scalar/Util.pm.
Unfortunately, Scalar::Util is not bundled with older Perl versions.

This is a newer much saner blessed() version by Randal L. Schwarz.

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-25 21:13:30 -07:00
Petr Baudis
3c479c37f8 Git.pm: Introduce fast get_object() method
Direct .xs routine. Note that it does not work 100% correctly when
you juggle multiple repository objects, but it is not that bad either.
The trouble is that we might reuse packs information for another
Git project; that is not an issue since Git depends on uniqueness
of SHA1 ids so if we have found the object somewhere else, it is
nevertheless going to be the same object. It merely makes object
existence detection through this method unreliable; it is duly noted
in the documentation.

At least that's how I see it, I hope I didn't overlook any other
potential problem. I tested it for memory leaks and it appears to be
doing ok.

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-09 01:20:01 -07:00
Petr Baudis
0270083ded Make it possible to set up libgit directly (instead of from the environment)
This introduces a setup_git() function which is essentialy a (public)
backend for setup_git_env() which lets anyone specify custom sources
for the various paths instead of environment variables. Since the repositories
may get switched on the fly, this also updates code that caches paths to
invalidate them properly; I hope neither of those is a sweet spot.

It is used by Git.xs' xs__call_gate() to set up per-repository data
for libgit's consumption. No code actually takes advantage of it yet
but get_object() will in the next patches.

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-09 01:20:01 -07:00
Petr Baudis
c7a30e5684 Git.pm: Introduce ident() and ident_person() methods
These methods can retrieve/parse the author/committer ident.

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-03 18:35:23 -07:00
Petr Baudis
dc2613de86 Git.pm: Add config() method
This accessor will retrieve value(s) of the given configuration variable.

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-03 18:35:19 -07:00
Petr Baudis
65a4e98a22 Git.pm: Don't #define around die
Back in the old days, we called Git's die() from the .xs code, but we had to
hijack Perl's die() for that. Now we don't call Git's die() so no need to do
the hijacking and it silences a compiler warning.

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-02 17:14:45 -07:00
Johannes Schindelin
d78f099d89 Git.xs: older perl do not know const char *
Both of these casts _should_ be safe, since you do not want to muck around
with the version or the path anyway.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-02 17:14:44 -07:00
Petr Baudis
e2a3871094 Git.pm: Avoid ppport.h
This makes us not include ppport.h which seems not to give us anything
real anyway; it is useful for checking for portability warts but since
Devel::PPPort is a portability wart itself, we shouldn't require it
for build. You can check for portability problems by calling make check
in perl/.

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-02 17:14:44 -07:00
Petr Baudis
e6634ac984 Git.pm: Remove PerlIO usage from Git.xs
PerlIO_*() is not portable before 5.7.3, according to ppport.h, and it's
more clear what is going on when we do it in the Perl part of the Git module
anyway.

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-02 17:14:44 -07:00
Pavel Roskin
1d8c9dc47d Fix probing for already installed Error.pm
The syntax for 'require' was wrong, and it was always failing, which
resulted in installing our own version of Error.pm anyways.

Now we used to ship our own Error.pm in the same directory, so after
fixing the syntax, 'require' always succeeds, but it does not test if
the platform has Error.pm module installed anymore.  So rename the
source we ship to private-Error.pm, and install that as Error.pm when
the platform does not have one already.

Signed-off-by: Pavel Roskin <proski@gnu.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-02 17:14:44 -07:00
Junio C Hamano
893973a6f2 Perly git: work around buggy make implementations.
FC4 uses gnumake 3.80 whose annoying "Entering directory..."
messages are not silenced with -s alone.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-02 17:14:43 -07:00
Petr Baudis
71efe0ca3c Git.pm: Fix Git->repository("/somewhere/totally/elsewhere")
Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-02 17:14:42 -07:00
Petr Baudis
24c4b71436 Git.pm: Swap hash_object() parameters
I'm about to introduce get_object() and it will be better for consistency
if the object type always goes first. And writing 'blob' there explicitly
is not much bother.

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-02 17:14:42 -07:00
Petr Baudis
a6065b548f Git.pm: Try to support ActiveState output pipe
The code is stolen from git-annotate and completely untested since
I don't have access to any Microsoft operating system now. Someone
ActiveState-savvy should look at it anyway and try to implement
the input pipe as well, if it is possible at all; also, the implementation
seems to be horribly whitespace-unsafe.

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-02 17:14:42 -07:00
Petr Baudis
d595a473ee Git.pm: assorted build related fixes.
- We passed our own *.a archives as LIBS to the submake that runs
   in perl/; separate LIBS and EXTLIBS and pass the latter which
   tells what the system libraries are used.

 - The quoting of preprocesor symbol definitions passed down to
   perl/ submake was loose and we lost double quotes around
   include directives.  Use *_SQ to quote them properly.

 - The installation location of perl/ submake is not
   architecture neutral anymore, so use SITEARCH instead of
   SITELIB.

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-02 17:14:42 -07:00
Petr Baudis
d5c7721d58 Git.pm: Add support for subdirectories inside of working copies
This patch adds support for subdirectories inside of working copies;
you can specify them in the constructor either as the Directory
option (it will just get autodetected using rev-parse) or explicitly
using the WorkingSubdir option. This makes Git->repository() do the
exact same path setup and repository lookup as the Git porcelain
does.

This patch also introduces repo_path(), wc_path() and wc_subdir()
accessor methods and wc_chdir() mutator.

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-02 17:14:41 -07:00
Petr Baudis
d43ba46807 Git.pm: Implement options for the command interface
This gives the user a way to easily pass options to the command routines.
Currently only the STDERR option is implemented and can be used to adjust
what shall be done with error output of the called command (most usefully,
it can be used to silence it).

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-02 17:14:41 -07:00
Petr Baudis
d79850e1fd Git.pm: Enhance the command_pipe() mechanism
Rename command_pipe() to command_output_pipe(), outsource
the functionality to _command_common_pipe().

Add command_input_pipe().

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-02 17:14:41 -07:00
Petr Baudis
8b9150e3e3 Git.pm: Handle failed commands' output
Currently if an external command returns error exit code, a generic exception
is thrown and there is no chance for the caller to retrieve the command's
output.

This patch introduces a Git::Error::Command exception class which is thrown
in this case and contains both the error code and the captured command output.
You can use the new git_cmd_try statement to fatally catch the exception
while producing a user-friendly message.

It also adds command_close_pipe() for easier checking of exit status of
a command we have just a pipe handle of. It has partial forward dependency
on the next patch, but basically only in the area of documentation.

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-02 17:14:41 -07:00
Petr Baudis
97b16c0674 Git.pm: Better error handling
So far, errors just killed the whole program and in case of an error
inside of libgit it would be totally uncatchable. This patch makes
Git.pm throw standard Perl exceptions instead. In the future we might
subclass Error to Git::Error or something but for now Error::Simple
is more than enough.

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-02 17:14:40 -07:00
Petr Baudis
5c4082fd68 Add Error.pm to the distribution
I have been thinking about how to do the error reporting the best
way and after scraping various overcomplicated concepts, I have
decided that by far the most elegant way is to throw Error exceptions;
the closest sane alternative is to catch the dies in Git.pm by
enclosing the calls in eval{}s and that's really _quite_ ugly.

The only "small" trouble is that Error.pm turns out sadly not to be
part of the standard distribution, and installation from CPAN is
a bother, especially if you can't install it system-wide. But since
it is very small, I've decided to just bundle it.

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-02 17:14:40 -07:00
Petr Baudis
63df97ae7b Git.pm: Implement Git::version()
Git::version() returns the Git version string.

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-02 17:14:40 -07:00
Petr Baudis
8062f81c2d Git.pm: Call external commands using execv_git_cmd()
Instead of explicitly using the git wrapper to call external commands,
use the execv_git_cmd() function which will directly call whatever
needs to be called. GitBin option becomes useless so drop it.

This actually means the exec_path() thing I planned to use worthless
internally, but Jakub wants it in anyway and I don't mind, so...

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-02 17:14:40 -07:00
Petr Baudis
eca1f6fdb8 Git.pm: Implement Git::exec_path()
This patch implements Git::exec_path() (as a direct XS call).

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-02 17:14:40 -07:00
Petr Baudis
b1edc53d06 Introduce Git.pm (v4)
This patch introduces a very basic and barebone Git.pm module
with a sketch of how the generic interface would look like;
most functions are missing, but this should give some good base.
I will continue expanding it.

Most desirable now is more careful error reporting, generic_in() for feeding
input to Git commands and the repository() constructor doing some poking
with git-rev-parse to get the git directory and subdirectory prefix.
Those three are basically the prerequisities for converting git-mv.
I will send them as follow-ups to this patch.

Currently Git.pm just wraps up exec()s of Git commands, but even that
is not trivial to get right and various Git perl scripts do it in
various inconsistent ways. In addition to Git.pm, there is now also
Git.xs which provides barebone Git.xs for directly interfacing with
libgit.a, and as an example providing the hash_object() function using
libgit.

This adds the Git module, integrates it to the build system and as
an example converts the git-fmt-merge-msg.perl script to it (the result
is not very impressive since its advantage is not quite apparent in this
one, but I just picked up the simplest Git user around).

Compared to v3, only very minor things were fixed in this patch (some
whitespaces, a missing export, tiny bug in git-fmt-merge-msg.perl);
at first I wanted to post them as a separate patch but since this
is still only in pu, I decided that it will be cleaner to just resend
the patch.

My current working state is available all the time at

	http://pasky.or.cz/~xpasky/git-perl/Git.pm

and an irregularily updated API documentation is at

	http://pasky.or.cz/~xpasky/git-perl/Git.html

Many thanks to Jakub Narebski, Junio and others for their feedback.

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-02 17:14:40 -07:00