summaryrefslogtreecommitdiff
path: root/contrib
AgeCommit message (Collapse)AuthorFilesLines
2013-08-13git-remote-mediawiki: ignore generated git-mwLibravatar Matthieu Moy1-0/+1
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-02Merge branch 'rj/cygwin-clarify-use-of-cheating-lstat'Libravatar Junio C Hamano1-1/+0
Cygwin port added a "not quite correct but a lot faster and good enough for many lstat() calls that are only used to see if the working tree entity matches the index entry" lstat() emulation some time ago, and it started biting us in places. This removes it and uses the standard lstat() that comes with Cygwin. Recent topic that uses lstat on packed-refs file is broken when this cheating lstat is used, and this is a simplest fix that is also the cleanest direction to go in the long run. * rj/cygwin-clarify-use-of-cheating-lstat: cygwin: Remove the Win32 l/stat() implementation
2013-08-01Merge branch 'ob/typofixes'Libravatar Junio C Hamano3-4/+4
* ob/typofixes: many small typofixes
2013-08-01Merge branch 'ms/subtree-install-fix'Libravatar Junio C Hamano1-0/+1
* ms/subtree-install-fix: contrib/subtree: Fix make install target
2013-08-01Merge branch 'lf/echo-n-is-not-portable'Libravatar Junio C Hamano2-5/+5
* lf/echo-n-is-not-portable: Avoid using `echo -n` anywhere
2013-08-01Merge branch 'ma/hg-to-git'Libravatar Junio C Hamano1-1/+1
* ma/hg-to-git: hg-to-git: --allow-empty-message in git commit
2013-07-30Merge branch 'bc/completion-for-bash-3.0'Libravatar Junio C Hamano1-1/+1
* bc/completion-for-bash-3.0: git-completion.bash: replace zsh notation that breaks bash 3.X
2013-07-30contrib/subtree: Fix make install targetLibravatar Michal Sojka1-0/+1
If the libexec directory doesn't exist, git-subtree gets installed as $prefix/share/libexec/git-core file. This patch creates the directory before installing git-subtree file into it. Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-07-29many small typofixesLibravatar Ondřej Bílka3-4/+4
Signed-off-by: Ondřej Bílka <neleai@seznam.cz> Reviewed-by: Marc Branchaud <marcnarc@xiplink.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-07-29Avoid using `echo -n` anywhereLibravatar Lukas Fleischer2-5/+5
`echo -n` is non-portable. The POSIX specification says: Conforming applications that wish to do prompting without <newline> characters or that could possibly be expecting to echo a -n, should use the printf utility derived from the Ninth Edition system. Since all of the affected shell scripts use a POSIX shell shebang, replace `echo -n` invocations with printf. Signed-off-by: Lukas Fleischer <git@cryptocrack.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-07-24Merge branch 'mh/multimail'Libravatar Junio C Hamano7-4/+3411
An enhanced "post-receive" hook to send e-mail messages. * mh/multimail: post-receive-email: deprecate script in favor of git-multimail git-multimail: an improved replacement for post-receive-email
2013-07-24Merge branch 'es/contacts'Libravatar Junio C Hamano2-0/+282
A helper to read from a set of format-patch output files or a range of commits and find those who may have insights to the code that the changes touch by running a series of "git blame" commands. * es/contacts: contrib: contacts: add documentation contrib: contacts: add mailmap support contrib: contacts: interpret committish akin to format-patch contrib: contacts: add ability to parse from committish contrib: add git-contacts helper
2013-07-24git-completion.bash: replace zsh notation that breaks bash 3.XLibravatar Brandon Casey1-1/+1
50c5885e (git-completion.bash: replace zsh notation that breaks bash 3.X, 2013-01-18) fixed a zsh-ism introduced earlier to append to an array, which older versions of bash (3.0) did not grok. This was again broken by 734b2f05 (completion: synchronize zsh wrapper, 2013-05-08). Cherry-pick the fix again to let those with older bash use the completion script. Signed-off-by: Brandon Casey <drafnel@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-07-23hg-to-git: --allow-empty-message in git commitLibravatar Maurício C Antunes1-1/+1
Do not fail to import mercurial commits with empty commit messages. Signed-off-by: Maurício C Antunes <mauricio.antunes@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-07-22post-receive-email: deprecate script in favor of git-multimailLibravatar Michael Haggerty1-4/+13
Add a notice to the top of post-receive-email explaining that the script is no longer under active development and pointing the user to git-multimail. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-07-22Merge branch 'es/check-mailmap'Libravatar Junio C Hamano1-0/+1
A new command to allow scripts to query the mailmap information. * es/check-mailmap: t4203: test check-mailmap command invocation builtin: add git-check-mailmap command
2013-07-21contrib: contacts: add documentationLibravatar Eric Sunshine1-0/+94
Assuming that git-contacts may some day be promoted to a core git command, the documentation is written and formatted as if it already belongs in Documentation/ even though it presently resides in contrib/contacts. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-07-21contrib: contacts: add mailmap supportLibravatar Eric Sunshine1-0/+18
The purpose of git-contacts is to determine a list of people who might have some interest in a patch or set of changes. It can be used as git-send-email's --cc-cmd argument or the computed list might be used to ask for comments on a proposed change. As such, it is important to report up-to-date email addresses in the computed list rather than potentially outdated ones recorded with commits. Apply git's mailmap functionality to the retrieved contacts in order to achieve this goal. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-07-21contrib: contacts: interpret committish akin to format-patchLibravatar Eric Sunshine1-1/+18
As a convenience, accept the same style <since> committish as accepted by git-format-patch. For example: % git contacts origin will consider commits in the current branch built atop 'origin', just as "git format-patch origin" will format commits built atop 'origin'. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-07-21contrib: contacts: add ability to parse from committishLibravatar Eric Sunshine1-6/+32
For example: % git contacts R1..R2 Committishes and patch files can be mentioned in the same invocation: % git contacts R1..R2 extra/*.patch Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-07-21contrib: add git-contacts helperLibravatar Eric Sunshine1-0/+127
This script lists people that might be interested in a patch by going back through the history for each patch hunk, and finding people that reviewed, acknowledged, signed, authored, or were Cc:'d on the code the patch is modifying. It does this by running git-blame incrementally on each hunk and then parsing the commit message. After gathering all participants, it determines each person's relevance by considering how many commits mentioned that person compared with the total number of commits under consideration. The final output consists only of participants who pass a minimum threshold of participation. Several conditions controlling a person's significance are currently hard-coded, such as minimum participation level, blame date-limiting, and -C level for detecting moved and copied lines. In the future, these conditions may become configurable. For example: % git contacts 0001-remote-hg-trivial-cleanups.patch Felipe Contreras <felipe.contreras@gmail.com> Jeff King <peff@peff.net> Max Horn <max@quendi.de> Junio C Hamano <gitster@pobox.com> Thus, it can be invoked as git-send-email's --cc-cmd option, among other possible uses. This is a Perl rewrite of Felipe Contreras' git-related patch series[1] written in Ruby. [1]: http://thread.gmane.org/gmane.comp.version-control.git/226065/ Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-07-18Merge branch 'bp/mediawiki-preview'Libravatar Junio C Hamano6-82/+526
Add a command to allow previewing the contents locally before pushing it out, when working with a MediaWiki remote. I personally do not think this belongs to Git. If you are working on a set of AsciiDoc source files, you sure do want to locally format to preview what you will be pushing out, and if you are working on a set of C or Java source files, you do want to test it before pushing it out, too. That kind of thing belongs to your build script, not to your SCM. But I'll let it pass, as this is only a contrib/ thing. * bp/mediawiki-preview: git-remote-mediawiki: add preview subcommand into git mw git-remote-mediawiki: add git-mw command git-remote-mediawiki: factoring code between git-remote-mediawiki and Git::Mediawiki git-remote-mediawiki: update tests to run with the new bin-wrapper git-remote-mediawiki: add a git bin-wrapper for developement wrap-for-bin: make bin-wrappers chainable git-remote-mediawiki: introduction of Git::Mediawiki.pm
2013-07-18cygwin: Remove the Win32 l/stat() implementationLibravatar Ramsay Jones1-1/+0
Commit adbc0b6b ("cygwin: Use native Win32 API for stat", 30-09-2008) added a Win32 specific implementation of the stat functions. In order to handle absolute paths, cygwin mount points and symbolic links, this implementation may fall back on the standard cygwin l/stat() functions. Also, the choice of cygwin or Win32 functions is made lazily (by the first call(s) to l/stat) based on the state of some config variables. Unfortunately, this "schizophrenic stat" implementation has been the source of many problems ever since. For example, see commits 7faee6b8, 79748439, 452993c2, 085479e7, b8a97333, 924aaf3e, 05bab3ea and 0117c2f0. In order to avoid further problems, such as the issue raised by the new reference handling API, remove the Win32 l/stat() implementation. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-07-15git-multimail: an improved replacement for post-receive-emailLibravatar Michael Haggerty6-0/+3398
Add git-multimail, a tool for generating notification emails for pushes to a Git repository. It is largely plug-in compatible with post-receive-email, and is proposed to eventually replace that script. The advantages of git-multimail relative to post-receive-email are described in README.migrate-from-post-receive-email. git-multimail is organized in a directory contrib/hooks/multimail. The directory contains: * git_multimail.py -- a Python module that can generate notification emails for pushes to a Git repository. The file can be used directly as a post-receive script (configured via git config settings), or it can be imported as a Python module and configured via arbitrary Python code. * README -- user-level documentation for configuring and using git-multimail. * post-receive -- an example of building a post-receive script that imports git_multimail.py as a Python module, with an example of how to change the email templates. * README.migrate-from-post-receive-email -- documentation targeted at current users of post-receive-email, explaining the differences and how to migrate a post-receive-email configuration to git-multimail. * migrate-mailhook-config -- a script that can migrate a user's post-receive-email configuration options to the equivalent git-multimail options. * README.Git -- a short explanation of the relationship between git-multimail and the rest of the Git project, plus the exact date and revision when this version was taken from the upstream project. All but the last file are taken verbatim from the upstream git-multimail project. git-multimail is originally derived from post-receive-email and also incorporates suggestions from the mailing list as well as patches by the people listed below. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Contributions-by: Matthieu Moy <Matthieu.Moy@imag.fr> Contributions-by: Ramkumar Ramachandra <artagnon@gmail.com> Contributions-by: Chris Hiestand <chrishiestand@gmail.com> Contributions-by: Michiel Holtkamp <git@elfstone.nl> Contributions-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-07-13builtin: add git-check-mailmap commandLibravatar Eric Sunshine1-0/+1
Introduce command check-mailmap, similar to check-attr and check-ignore, which allows direct testing of .mailmap configuration. As plumbing accessible to scripts and other porcelain, check-mailmap publishes the stable, well-tested .mailmap functionality employed by built-in Git commands. Consequently, script authors need not re-implement .mailmap functionality manually, thus avoiding potential quirks and behavioral differences. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-07-11Merge branch 'jk/bash-completion'Libravatar Junio C Hamano1-1/+3
* jk/bash-completion: completion: learn about --man-path completion: handle unstuck form of base git options
2013-07-08git-remote-mediawiki: add preview subcommand into git mwLibravatar Benoit Person2-2/+311
In the current state, a user of git-remote-mediawiki can edit the markup text locally, but has to push to the remote wiki to see how the page is rendererd. Add a new 'git mw preview' command that allows rendering the markup text on the remote wiki without actually pushing any change on the wiki. This uses Mediawiki's API to render the markup and inserts it in an actual HTML page from the wiki so that CSS can be rendered properly. Most links should work when the page exists on the remote. Signed-off-by: Benoit Person <benoit.person@ensimag.fr> Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-07-08git-remote-mediawiki: add git-mw commandLibravatar Benoit Person2-3/+64
For now, git-remote-mediawiki is only a remote-helper. This patch adds a new toolset script in which we will be able to build new tools for git-remote-mediawiki. This toolset uses a subcommand-mechanism to launch the proper action. For now only the 'help' subcommand is implemented. It also provides some generic code for the verbose and help command line options. Signed-off-by: Benoit Person <benoit.person@ensimag.fr> Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-07-08git-remote-mediawiki: factoring code between git-remote-mediawiki and ↵Libravatar Benoit Person2-73/+89
Git::Mediawiki For now, Git::Mediawiki contains nothing. This first patch moves some of git-remote-mediawiki.perl's factorisable code into Git::Mediawiki. In the same time, it removes the side effects of that code and renames the fucntions and constants moved to expose a better API. Signed-off-by: Benoit Person <benoit.person@ensimag.fr> Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-07-08git-remote-mediawiki: update tests to run with the new bin-wrapperLibravatar Benoit Person1-6/+2
Until now, if git-remote-mediawiki was not installed, the test suite copied it to the toplevel directory. This solution pollutes the directory with untracked files. Plus, we would need to copy the new git-mw.perl file to test it too. Signed-off-by: Benoit Person <benoit.person@ensimag.fr> Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-07-08git-remote-mediawiki: add a git bin-wrapper for developementLibravatar Benoit Person2-0/+20
The introduction of the Git::Mediawiki package makes it impossible to test, without installation, git-remote-mediawiki and git-mw. Using a git bin-wrapper enables us to define proper $GITPERLLIB to force the use of the developement version of the Git::Mediawiki package, bypassing its installed version if any. An alternate solution was to 'install' all the files required at each build but it pollutes the toplevel with untracked files. Signed-off-by: Benoit Person <benoit.person@ensimag.fr> Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-07-08git-remote-mediawiki: introduction of Git::Mediawiki.pmLibravatar Benoit Person2-3/+45
We would want to allow the user to preview what he has edited locally before pushing it out (and thus creating a non-removable revision in the mediawiki's history). This patch introduces a new perl package in which we will be able to share code between that new tool and the remote helper: git-remote-mediawiki.perl. A perl package offers the best way to handle such case: Each script can select what should be imported in its namespace. The package namespacing limits the use of side effects in the shared code. An alternate solution is to concatenate a "toolset" file with each *.perl when 'make'-ing the project. In that scheme, everything is imported in the script's namespace. Plus, files should be renamed in order to chain to Git's toplevel makefile. Hence, this solution is not acceptable. Signed-off-by: Benoit Person <benoit.person@ensimag.fr> Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-07-03Merge branch 'dm/unbash-subtree' into maintLibravatar Junio C Hamano1-1/+1
* dm/unbash-subtree: contrib/git-subtree: Use /bin/sh interpreter instead of /bin/bash
2013-07-03git-remote-mediawiki: un-brace file handles in binmode callsLibravatar Matthieu Moy1-2/+2
Commit e83d36b66fc turned "print STDOUT" into "print {*STDOUT}", as suggested by perlcritic. Unfortunately, it also changed two "binmode STDOUT" calls the same way, which does not work and yield a "Not a GLOB reference" error. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-07-01Merge branch 'ed/color-prompt'Libravatar Junio C Hamano1-70/+41
Code clean-up for in-prompt status script (in contrib/). * ed/color-prompt: git-prompt.sh: add missing information in comments git-prompt.sh: do not print duplicate clean color code t9903: remove redundant tests git-prompt.sh: refactor colored prompt code t9903: add tests for git-prompt pcmode
2013-06-30completion: learn about --man-pathLibravatar John Keeping1-0/+1
Signed-off-by: John Keeping <john@keeping.me.uk> Acked-by: SZEDER Gábor <szeder@ira.uka.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-06-30completion: handle unstuck form of base git optionsLibravatar John Keeping1-1/+2
git-completion.bash's parsing of the command name relies on everything preceding it starting with '-' unless it is the "-c" option. This allows users to use the stuck form of "--work-tree=<path>" and "--namespace=<path>" but not the unstuck forms "--work-tree <path>" and "--namespace <path>". Fix this. Similarly, the completion only handles the stuck form "--git-dir=<path>" and not "--git-dir <path>", so fix this as well. Signed-off-by: John Keeping <john@keeping.me.uk> Acked-by: SZEDER Gábor <szeder@ira.uka.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-06-27Merge branch 'fc/show-branch-in-rebase-am' into maintLibravatar Junio C Hamano1-0/+2
* fc/show-branch-in-rebase-am: prompt: fix for simple rebase
2013-06-27Merge branch 'tg/maint-zsh-svn-remote-prompt' into maintLibravatar Junio C Hamano1-3/+4
* tg/maint-zsh-svn-remote-prompt: prompt: fix show upstream with svn and zsh
2013-06-27Merge branch 'jk/subtree-do-not-push-if-split-fails' into maintLibravatar Junio C Hamano1-1/+2
* jk/subtree-do-not-push-if-split-fails: contrib/subtree: don't delete remote branches if split fails
2013-06-26git-prompt.sh: add missing information in commentsLibravatar Eduardo R. D'Avila1-11/+15
Mention that the command below is needed for prompt in ZSH with PS1: setopt PROMPT_SUBST Rephrase some parts that mention only the "current branch name" being displayed in the prompt. Replace it by stating that the "repository status" is displayed. Make it clear that colored prompt is only available in PROMPT_COMMAND/precmd mode. With-suggestions-by: SZEDER Gábor <szeder@ira.uka.de> Signed-off-by: Eduardo R. D'Avila <erdavila@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-06-26git-prompt.sh: do not print duplicate clean color codeLibravatar Eduardo R. D'Avila1-1/+1
Do not print a duplicate clean color code when there is no other indicators other than the current branch in colored prompt. Acked-by: SZEDER Gábor <szeder@ira.uka.de> Signed-off-by: Eduardo R. D'Avila <erdavila@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-06-26git-prompt.sh: refactor colored prompt codeLibravatar Eduardo R. D'Avila1-59/+26
__git_ps1_colorize_gitstring() sets color codes and builds the prompt gitstring. It has duplicated code to handle color codes for bash and zsh shells. __git_ps1() also has duplicated logic to build the prompt gitstring. Remove duplication of logic to build gitstring in __git_ps1_colorize_gitstring() and __git_ps1(). Leave in __git_ps1_colorize_gitstring() only logic to set color codes. Signed-off-by: Eduardo R. D'Avila <erdavila@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-06-24bash prompt: mention that PROMPT_COMMAND mode is fasterLibravatar SZEDER Gábor1-5/+5
__git_ps1() is usually added to the prompt inside a command substitution, imposing the overhead of fork()ing a subshell. Using __git_ps1() for $PROMPT_COMMAND is slightly faster, because it avoids that command substitution. Mention this in the comments about setting up the git prompt. The whole series speeds up the bash prompt on Windows/MSysGit considerably. Here are some timing results in three scenarios, each repeated 10 times: At the top of the work tree, before: $ time for i in {0..9} ; do prompt="$(__git_ps1)" ; done real 0m1.716s user 0m0.301s sys 0m0.772s After: real 0m0.687s user 0m0.075s sys 0m0.396s After, from $PROMPT_COMMAND: $ time for i in {0..9} ; do __git_ps1 '\h:\w' '$ ' ; done real 0m0.546s user 0m0.075s sys 0m0.181s At the top of the work tree, detached head, before: real 0m2.574s user 0m0.376s sys 0m1.207s After: real 0m1.139s user 0m0.151s sys 0m0.500s After, from $PROMPT_COMMAND: real 0m1.030s user 0m0.245s sys 0m0.336s In a subdirectory, during rebase, stash status indicator enabled, before: real 0m3.557s user 0m0.495s sys 0m1.767s After: real 0m0.717s user 0m0.120s sys 0m0.300s After, from $PROMPT_COMMAND: real 0m0.577s user 0m0.047s sys 0m0.258s On Linux the speedup ratio is comparable to Windows, but overall it was about an order of magnitude faster to begin with. The last case from above, repeated 100 times, before: $ time for i in {0..99} ; do prompt="$(__git_ps1)" ; done real 0m2.806s user 0m0.180s sys 0m0.264s After: real 0m0.857s user 0m0.020s sys 0m0.028s Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
2013-06-24bash prompt: avoid command substitution when finalizing gitstringLibravatar SZEDER Gábor1-1/+5
Before setting $PS1, __git_ps1() uses a command substitution to redirect the output from a printf into a variable. Spare the overhead of fork()ing a subshell by using 'printf -v <var>' to directly assign the output to that variable. zsh's printf doesn't support the '-v <var>' option, so stick with the command substitution when under zsh. Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
2013-06-24bash prompt: avoid command substitution when checking for untracked filesLibravatar SZEDER Gábor1-1/+1
When enabled, the bash prompt can indicate the presence of untracked files with a '%' sign. __git_ps1() checks for untracked files by running the '$(git ls-files --others --exclude-standard)' command substitution, and displays the indicator when there is no output. Avoid this command substitution by additionally passing '--error-unmatch *', and checking the command's return value. Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
2013-06-24bash prompt: use bash builtins to check stash stateLibravatar SZEDER Gábor1-2/+3
When the environment variable $GIT_PS1_SHOWSTASHSTATE is set __git_ps1() checks the presence of stashes by running 'git rev-parse --verify refs/stash'. This command not only checks that the 'refs/stash' ref exists but also, well, verifies that it's a valid ref. However, we don't need to be that thorough for the bash prompt. We can omit that verification and only check whether 'refs/stash' exists or not. Since 'git pack-refs' never packs 'refs/stash', it's a matter of checking the existence of a ref file. Perform this check using only bash builtins to spare the overhead of fork()+exec()ing a git process. Also run 'git pack-refs --all' in the corresponding test to document that the prompt script depends on 'git pack-refs' not packing 'refs/stash' and to catch possible breakages should this behavior ever change. Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
2013-06-24bash prompt: use bash builtins to check for unborn branch for dirty stateLibravatar SZEDER Gábor1-1/+1
When the dirty work tree and index status indicator is enabled, __git_ps1() checks for changes in the index by running 'git diff-index --cached --quiet HEAD --' and looking at its exit code. However, that makes sense only when HEAD points to a valid commit: on an unborn branch the failure of said command would be caused by the invalid HEAD, not by changes in the index. Therefore, __git_ps1() first checks for a valid HEAD by running 'git rev-parse --quiet --verify HEAD'. Since the previous patch we implicitly check HEAD's validity by running 'git rev-parse ... --short HEAD', making the dirty status indicator's 'git rev-parse' check redundant. It's sufficient to check for non-emptyness of the variable holding the abbreviated commit object name, thereby sparing the overhead of fork()+exec()ing a git process. Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
2013-06-24bash prompt: combine 'git rev-parse' for detached headLibravatar SZEDER Gábor1-4/+12
When describing a detached HEAD according to the $GIT_PS1_DESCRIBE environment variable fails, __git_ps1() now runs the '$(git rev-parse --short HEAD)' command substitution to get the abbreviated detached HEAD commit object name. This imposes the overhead of fork()ing a subshell and fork()+exec()ing a git process. Avoid this overhead by combining this command substitution with the "main" 'git rev-parse' execution for getting the path to the .git directory & co. This means that we'll look for the abbreviated commit object name even when it's not necessary, because we're on a branch or the detached HEAD can be described. It doesn't matter, however, because once 'git rev-parse' is up and running to fulfill all those other queries, the additional overhead of looking for the abbreviated commit object name is not measurable because it's lost in the noise. There is a caveat, however, when we are on an unborn branch, because in that case HEAD doesn't point to a valid commit, hence the query for the abbreviated commit object name fails. Therefore, '--short HEAD' must be the last options to 'git rev-parse' in order to get all the other necessary information for the prompt even on an unborn branch. Furthermore, in that case, and in that case only, 'git rev-parse' doesn't output the last line containing the abbreviated commit object name, obviously, so we have to take care to only parse it if 'git rev-parse' exited without any error. Although there are tests already excercising __git_ps1() on unborn branches, they all do so implicitly. Add a test that checks this explicitly. Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
2013-06-24bash prompt: combine 'git rev-parse' executions in the main code pathLibravatar SZEDER Gábor1-5/+13
There are a couple of '$(git rev-parse --<opt>)' command substitutions in __git_ps1() and three of them are executed in the main code path: - the first to get the path to the .git directory ('--git-dir'), - the second to check whether we're inside the .git directory ('--is-inside-git-dir'), - and the last, depending on the results of the second, either * to check whether it's a bare repo ('--is-bare-repository'), or * to check whether inside a work tree ('--is-inside-work-tree'). Naturally, this imposes the overhead of fork()ing three subshells and fork()+exec()ing three git commands. Combine these four 'git rev-parse' queries into a single one and use bash parameter expansions to parse the combined output, i.e. to separate the path to the .git directory from the true/false of '--is-inside-git-dir', etc. This way we can eliminate two of the three subshells and git commands. Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>