aboutsummaryrefslogtreecommitdiff
path: root/perl/Git.pm
Commit message (Collapse)AuthorAge
* Git.pm: fix return value of config methodLea Wiemann2008-06-01
| | | | | | | | | | | 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>
* Git.pm: fix documentation of hash_objectLea Wiemann2008-06-01
| | | | | | | | | 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>
* Git::cat_blob: allow using an empty blob to fix git-svn breakageJunio C Hamano2008-05-27
| | | | | | | | | | | | | 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>
* Git.pm: Add hash_and_insert_object and cat_blobAdam Roben2008-05-23
| | | | | | | | 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>
* Git.pm: Add command_bidi_pipe and command_close_bidi_pipeAdam Roben2008-05-23
| | | | | | | | | 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>
* Git.pm: Don't require repository instance for identFrank Lichtenheld2008-03-15
| | | | | | | | 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>
* Git.pm: Don't require a repository instance for configFrank Lichtenheld2008-03-15
| | | | | | | | 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>
* Color support for "git-add -i"Junio C Hamano2007-12-05
| | | | | | | | | | | | | | | | | | | 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>
* Add config_int() method to the Git perl moduleJakub Narebski2007-11-30
| | | | | | | | | 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>
* When exec() fails include the failing command in the error messageAsk Bjørn Hansen2007-11-07
| | | | | | | 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>
* Fix git-remote for ActiveState PerlAlex Riesen2007-08-22
| | | | | | | | | | 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>
* Git.pm: config_boolean() -> config_bool()Petr Baudis2007-05-10
| | | | | | | | | 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>
* Add config_boolean() method to the Git perl moduleTheodore Ts'o2007-02-20
| | | | | Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Assorted typo fixesPavel Roskin2007-02-03
| | | | Signed-off-by: Junio C Hamano <junkio@cox.net>
* [PATCH] Rename git-repo-config to git-config.Tom Prince2007-01-28
| | | | | Signed-off-by: Tom Prince <tom.prince@ualberta.net> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Cleanup uninitialized value in chompAlex Riesen2007-01-22
| | | | | | | | 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>
* Force Activestate Perl to tie git command pipe handle to a handle classAlex Riesen2007-01-22
| | | | | | | | | 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>
* Insert ACTIVESTATE_STRING in Git.pmAlex Riesen2007-01-22
| | | | | | | | 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>
* use 'init' instead of 'init-db' for shipped docs and toolsNicolas Pitre2007-01-12
| | | | | | | | | 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>
* Git.pm: Kill Git.xs for nowPetr Baudis2006-09-23
| | | | | | | | | | | | | | | | | | 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>
* Revert "Make it possible to set up libgit directly (instead of from the ↵Junio C Hamano2006-09-02
| | | | | | environment)" This reverts commit 0270083ded143fd49841e3d3d0cac5eb06081d2a.
* Revert "Git.pm: Introduce fast get_object() method"Junio C Hamano2006-09-02
| | | | This reverts commit 3c479c37f8651d09e1d08b8d6ea9757164ee1235.
* Git.pm: Introduce fast get_object() methodPetr Baudis2006-07-09
| | | | | | | | | | | | | | | | | | 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>
* Make it possible to set up libgit directly (instead of from the environment)Petr Baudis2006-07-09
| | | | | | | | | | | | | | | 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>
* Git.pm: Introduce ident() and ident_person() methodsPetr Baudis2006-07-03
| | | | | | | 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>
* Git.pm: Add config() methodPetr Baudis2006-07-03
| | | | | | | 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>
* Git.pm: Remove PerlIO usage from Git.xsPetr Baudis2006-07-02
| | | | | | | | | 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>
* Git.pm: Fix Git->repository("/somewhere/totally/elsewhere")Petr Baudis2006-07-02
| | | | | Signed-off-by: Petr Baudis <pasky@suse.cz> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Git.pm: Swap hash_object() parametersPetr Baudis2006-07-02
| | | | | | | | | 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>
* Git.pm: Try to support ActiveState output pipePetr Baudis2006-07-02
| | | | | | | | | | | 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>
* Git.pm: Add support for subdirectories inside of working copiesPetr Baudis2006-07-02
| | | | | | | | | | | | | | | 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>
* Git.pm: Implement options for the command interfacePetr Baudis2006-07-02
| | | | | | | | | | 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>
* Git.pm: Enhance the command_pipe() mechanismPetr Baudis2006-07-02
| | | | | | | | | | 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>
* Git.pm: Handle failed commands' outputPetr Baudis2006-07-02
| | | | | | | | | | | | | | | | | | 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>
* Git.pm: Better error handlingPetr Baudis2006-07-02
| | | | | | | | | | | 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>
* Git.pm: Implement Git::version()Petr Baudis2006-07-02
| | | | | | | Git::version() returns the Git version string. Signed-off-by: Petr Baudis <pasky@suse.cz> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Git.pm: Call external commands using execv_git_cmd()Petr Baudis2006-07-02
| | | | | | | | | | | | 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>
* Git.pm: Implement Git::exec_path()Petr Baudis2006-07-02
| | | | | | | 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>
* Introduce Git.pm (v4)Petr Baudis2006-07-02
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>