pax_global_header00006660000000000000000000000064115304201340014503gustar00rootroot0000000000000052 comment=a59681d37caf78ab69733f4b96eccb25c238a16b git-sh-1.1/000077500000000000000000000000001153042013400125375ustar00rootroot00000000000000git-sh-1.1/.gitignore000066400000000000000000000000071153042013400145240ustar00rootroot00000000000000git-sh git-sh-1.1/CHANGES000066400000000000000000000004441153042013400135340ustar00rootroot00000000000000= 0.5 / unreleased * Addition of built-in aliases taken from the example gitshrc file. * Aliases defined in the [alias] section of ~/.gitconfig are available from the top-level of the shell with completion. These aliases override builtin aliases. * Addition of git-sh(1) manpage. git-sh-1.1/COPYING000066400000000000000000000355021153042013400135770ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. git-sh-1.1/Makefile000066400000000000000000000016171153042013400142040ustar00rootroot00000000000000SHELL = /bin/sh DESTDIR = PREFIX = $(DESTDIR)/usr/local execdir = $(PREFIX)/bin datadir = $(PREFIX)/share mandir = $(datadir)/man PROGRAM = git-sh SOURCES = git-sh.bash git-completion.bash \ git-sh-aliases.bash git-sh-config.bash RONN = ronn --date=2010-03-30 \ --organization='Ryan Tomayko' all: $(PROGRAM) $(PROGRAM): $(SOURCES) rm -f $@ cat $(SOURCES) > $@+ bash -n $@+ mv $@+ $@ chmod 0755 $@ git-sh.1.roff: git-sh.1.ronn $(RONN) $^ > $@ git-sh.1.html: git-sh.1.ronn $(RONN) -5 $^ > $@ doc: git-sh.1.roff git-sh.1.html run: all ./$(PROGRAM) install: $(PROGRAM) install -d "$(execdir)" install -m 0755 $(PROGRAM) "$(execdir)/$(PROGRAM)" install -d "$(mandir)/man1" install -m 0644 git-sh.1.roff "$(mandir)/man1/git-sh.1" clean: rm -f $(PROGRAM) rm -f git-sh.1.html pages: git-sh.1.html cp $^ pages/$^ .PHONY: run install site clean pages git-sh-1.1/README.markdown000066400000000000000000000072051153042013400152440ustar00rootroot00000000000000git-sh ====== A customized bash shell suitable for git work. The `git-sh` command starts an interactive bash shell tweaked for heavy git interaction: * All git commands available at top-level (`checkout master` = `git checkout master`) * All git aliases defined in the `[alias]` section of `~/.gitconfig` available at top-level. * Shawn O. Pearce's excellent bash completion strapped onto all core commands and git aliases. * Custom prompt with current branch, repository, and work tree dirty indicator. * Customizable via `/etc/gitshrc` and `~/.gitshrc` config files; for creating aliases, changing the prompt, etc. * Runs on top of normal bash (`~/.bashrc`) and readline (`~/.inputrc`) configurations. Installation ------------ Install the most recent available version under `/usr/local`: $ git clone git://github.com/rtomayko/git-sh.git $ cd git-sh $ make $ sudo make install Start a shell with `git-sh`: $ git-sh master!git-sh> help Use the `PREFIX` environment variable to specify a different install location. For example, under `~/bin`: $ make install PREFIX=~ Basic Usage ----------- Typical usage is to change into a git working copy and then start the shell: $ cd mygreatrepo $ git sh master!mygreatrepo> help Core git commands and git command aliases defined in `~/.gitconfig` can be used as top-level commands: master!mygreatrepo> checkout -b new new!mygreatrepo> log -p new!mygreatrepo> rebase -i HEAD~10 It's really just a normal bash shell, though, so all commands on `PATH` and any aliases defined in `~/.bashrc` are also available: new!mygreatrepo> ls -l new!mygreatrepo> vim somefile *IMPORTANT: `rm`, `mv`, and `diff` are aliased to their git counterparts. Use `command(1)` (e.g., `command rm`) or qualify the command (e.g. `/bin/rm`) to use system versions.* Prompt ------ The default prompt shows the current branch, a bang (`!`), and then the relative path to the current working directory from the root of the work tree. If the work tree includes modified files that have not yet been staged, a dirty status indicator (`*`) is also displayed. The git-sh prompt includes ANSI colors when the git `color.ui` option is set and enabled. To enable git-sh's prompt colors explicitly, set the `color.sh` config value to `auto`: $ git config --global color.sh auto Customize prompt colors by setting the `color.sh.branch`, `color.sh.workdir`, and `color.sh.dirty` git config values: $ git config --global color.sh.branch 'yellow reverse' $ git config --global color.sh.workdir 'blue bold' $ git config --global color.sh.dirty 'red' See [colors in git](http://scie.nti.st/2007/5/2/colors-in-git) for information. Customizing ----------- Most `git-sh` behavior can be configured by editing the user or system gitconfig files (`~/.gitconfig` and `/etc/gitconfig`) either by hand or using `git-config(1)`. The `[alias]` section is used to create basic command aliases. The `/etc/gitshrc` and `~/.gitshrc` files are sourced (in that order) immediately before the shell becomes interactive. The `~/.bashrc` file is sourced before either `/etc/gitshrc` or `~/.gitshrc`. Any bash customizations defined there and not explicitly overridden by `git-sh` are also available. Copying ------- Copyright (C) 2008 [Ryan Tomayko](http://tomayko.com/) Copyright (C) 2008 [Aristotle Pagaltzis](http://plasmasturm.org/) Copyright (C) 2006, 2007 [Shawn O. Pearce](mailto:spearce@spearce.org) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation. git-sh-1.1/git-completion.bash000066400000000000000000001405111153042013400163320ustar00rootroot00000000000000#!bash # # bash completion support for core Git. # # Copyright (C) 2006,2007 Shawn O. Pearce # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). # Distributed under the GNU General Public License, version 2.0. # # The contained completion routines provide support for completing: # # *) local and remote branch names # *) local and remote tag names # *) .git/remotes file names # *) git 'subcommands' # *) tree paths within 'ref:path/to/file' expressions # *) common --long-options # # To use these routines: # # 1) Copy this file to somewhere (e.g. ~/.git-completion.sh). # 2) Added the following line to your .bashrc: # source ~/.git-completion.sh # # 3) Consider changing your PS1 to also show the current branch: # PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ ' # # The argument to __git_ps1 will be displayed only if you # are currently in a git repository. The %s token will be # the name of the current branch. # # In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty # value, unstaged (*) and staged (+) changes will be shown next # to the branch name. You can configure this per-repository # with the bash.showDirtyState variable, which defaults to true # once GIT_PS1_SHOWDIRTYSTATE is enabled. # # You can also see if currently something is stashed, by setting # GIT_PS1_SHOWSTASHSTATE to a nonempty value. If something is stashed, # then a '$' will be shown next to the branch name. # # If you would like to see if there're untracked files, then you can # set GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're # untracked files, then a '%' will be shown next to the branch name. # # If you would like to see the difference between HEAD and its # upstream, set GIT_PS1_SHOWUPSTREAM="auto". A "<" indicates # you are behind, ">" indicates you are ahead, and "<>" # indicates you have diverged. You can further control # behaviour by setting GIT_PS1_SHOWUPSTREAM to a space-separated # list of values: # verbose show number of commits ahead/behind (+/-) upstream # legacy don't use the '--count' option available in recent # versions of git-rev-list # git always compare HEAD to @{upstream} # svn always compare HEAD to your SVN upstream # By default, __git_ps1 will compare HEAD to your SVN upstream # if it can find one, or @{upstream} otherwise. Once you have # set GIT_PS1_SHOWUPSTREAM, you can override it on a # per-repository basis by setting the bash.showUpstream config # variable. # # # To submit patches: # # *) Read Documentation/SubmittingPatches # *) Send all patches to the current maintainer: # # "Shawn O. Pearce" # # *) Always CC the Git mailing list: # # git@vger.kernel.org # case "$COMP_WORDBREAKS" in *:*) : great ;; *) COMP_WORDBREAKS="$COMP_WORDBREAKS:" esac # __gitdir accepts 0 or 1 arguments (i.e., location) # returns location of .git repo __gitdir () { if [ -z "${1-}" ]; then if [ -n "${__git_dir-}" ]; then echo "$__git_dir" elif [ -d .git ]; then echo .git else git rev-parse --git-dir 2>/dev/null fi elif [ -d "$1/.git" ]; then echo "$1/.git" else echo "$1" fi } # stores the divergence from upstream in $p # used by GIT_PS1_SHOWUPSTREAM __git_ps1_show_upstream () { local key value local svn_remote=() svn_url_pattern count n local upstream=git legacy="" verbose="" # get some config options from git-config while read key value; do case "$key" in bash.showupstream) GIT_PS1_SHOWUPSTREAM="$value" if [[ -z "${GIT_PS1_SHOWUPSTREAM}" ]]; then p="" return fi ;; svn-remote.*.url) svn_remote[ $((${#svn_remote[@]} + 1)) ]="$value" svn_url_pattern+="\\|$value" upstream=svn+git # default upstream is SVN if available, else git ;; esac done < <(git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev/null | tr '\0\n' '\n ') # parse configuration values for option in ${GIT_PS1_SHOWUPSTREAM}; do case "$option" in git|svn) upstream="$option" ;; verbose) verbose=1 ;; legacy) legacy=1 ;; esac done # Find our upstream case "$upstream" in git) upstream="@{upstream}" ;; svn*) # get the upstream from the "git-svn-id: ..." in a commit message # (git-svn uses essentially the same procedure internally) local svn_upstream=($(git log --first-parent -1 \ --grep="^git-svn-id: \(${svn_url_pattern:2}\)" 2>/dev/null)) if [[ 0 -ne ${#svn_upstream[@]} ]]; then svn_upstream=${svn_upstream[ ${#svn_upstream[@]} - 2 ]} svn_upstream=${svn_upstream%@*} for ((n=1; "$n" <= "${#svn_remote[@]}"; ++n)); do svn_upstream=${svn_upstream#${svn_remote[$n]}} done if [[ -z "$svn_upstream" ]]; then # default branch name for checkouts with no layout: upstream=${GIT_SVN_ID:-git-svn} else upstream=${svn_upstream#/} fi elif [[ "svn+git" = "$upstream" ]]; then upstream="@{upstream}" fi ;; esac # Find how many commits we are ahead/behind our upstream if [[ -z "$legacy" ]]; then count="$(git rev-list --count --left-right \ "$upstream"...HEAD 2>/dev/null)" else # produce equivalent output to --count for older versions of git local commits if commits="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null)" then local commit behind=0 ahead=0 for commit in $commits do case "$commit" in "<"*) let ++behind ;; *) let ++ahead ;; esac done count="$behind $ahead" else count="" fi fi # calculate the result if [[ -z "$verbose" ]]; then case "$count" in "") # no upstream p="" ;; "0 0") # equal to upstream p="=" ;; "0 "*) # ahead of upstream p=">" ;; *" 0") # behind upstream p="<" ;; *) # diverged from upstream p="<>" ;; esac else case "$count" in "") # no upstream p="" ;; "0 0") # equal to upstream p=" u=" ;; "0 "*) # ahead of upstream p=" u+${count#0 }" ;; *" 0") # behind upstream p=" u-${count% 0}" ;; *) # diverged from upstream p=" u+${count#* }-${count% *}" ;; esac fi } # __git_ps1 accepts 0 or 1 arguments (i.e., format string) # returns text to add to bash PS1 prompt (includes branch name) __git_ps1 () { local g="$(__gitdir)" if [ -n "$g" ]; then local r="" local b="" if [ -f "$g/rebase-merge/interactive" ]; then r="|REBASE-i" b="$(cat "$g/rebase-merge/head-name")" elif [ -d "$g/rebase-merge" ]; then r="|REBASE-m" b="$(cat "$g/rebase-merge/head-name")" else if [ -d "$g/rebase-apply" ]; then if [ -f "$g/rebase-apply/rebasing" ]; then r="|REBASE" elif [ -f "$g/rebase-apply/applying" ]; then r="|AM" else r="|AM/REBASE" fi elif [ -f "$g/MERGE_HEAD" ]; then r="|MERGING" elif [ -f "$g/BISECT_LOG" ]; then r="|BISECTING" fi b="$(git symbolic-ref HEAD 2>/dev/null)" || { b="$( case "${GIT_PS1_DESCRIBE_STYLE-}" in (contains) git describe --contains HEAD ;; (branch) git describe --contains --all HEAD ;; (describe) git describe HEAD ;; (* | default) git describe --exact-match HEAD ;; esac 2>/dev/null)" || b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)..." || b="unknown" b="($b)" } fi local w="" local i="" local s="" local u="" local c="" local p="" if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then c="BARE:" else b="GIT_DIR!" fi elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then git diff --no-ext-diff --quiet --exit-code || w="*" if git rev-parse --quiet --verify HEAD >/dev/null; then git diff-index --cached --quiet HEAD -- || i="+" else i="#" fi fi fi if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ]; then git rev-parse --verify refs/stash >/dev/null 2>&1 && s="$" fi if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ]; then if [ -n "$(git ls-files --others --exclude-standard)" ]; then u="%" fi fi if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then __git_ps1_show_upstream fi fi local f="$w$i$s$u" printf "${1:- (%s)}" "$c${b##refs/heads/}${f:+ $f}$r$p" fi } # __gitcomp_1 requires 2 arguments __gitcomp_1 () { local c IFS=' '$'\t'$'\n' for c in $1; do case "$c$2" in --*=*) printf %s$'\n' "$c$2" ;; *.) printf %s$'\n' "$c$2" ;; *) printf %s$'\n' "$c$2 " ;; esac done } # __gitcomp accepts 1, 2, 3, or 4 arguments # generates completion reply with compgen __gitcomp () { local cur="${COMP_WORDS[COMP_CWORD]}" if [ $# -gt 2 ]; then cur="$3" fi case "$cur" in --*=) COMPREPLY=() ;; *) local IFS=$'\n' COMPREPLY=($(compgen -P "${2-}" \ -W "$(__gitcomp_1 "${1-}" "${4-}")" \ -- "$cur")) ;; esac } # __git_heads accepts 0 or 1 arguments (to pass to __gitdir) __git_heads () { local cmd i is_hash=y dir="$(__gitdir "${1-}")" if [ -d "$dir" ]; then git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ refs/heads return fi for i in $(git ls-remote "${1-}" 2>/dev/null); do case "$is_hash,$i" in y,*) is_hash=n ;; n,*^{}) is_hash=y ;; n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;; n,*) is_hash=y; echo "$i" ;; esac done } # __git_tags accepts 0 or 1 arguments (to pass to __gitdir) __git_tags () { local cmd i is_hash=y dir="$(__gitdir "${1-}")" if [ -d "$dir" ]; then git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ refs/tags return fi for i in $(git ls-remote "${1-}" 2>/dev/null); do case "$is_hash,$i" in y,*) is_hash=n ;; n,*^{}) is_hash=y ;; n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;; n,*) is_hash=y; echo "$i" ;; esac done } # __git_refs accepts 0 or 1 arguments (to pass to __gitdir) __git_refs () { local i is_hash=y dir="$(__gitdir "${1-}")" local cur="${COMP_WORDS[COMP_CWORD]}" format refs if [ -d "$dir" ]; then case "$cur" in refs|refs/*) format="refname" refs="${cur%/*}" ;; *) for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do if [ -e "$dir/$i" ]; then echo $i; fi done format="refname:short" refs="refs/tags refs/heads refs/remotes" ;; esac git --git-dir="$dir" for-each-ref --format="%($format)" \ $refs return fi for i in $(git ls-remote "$dir" 2>/dev/null); do case "$is_hash,$i" in y,*) is_hash=n ;; n,*^{}) is_hash=y ;; n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;; n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;; n,refs/remotes/*) is_hash=y; echo "${i#refs/remotes/}" ;; n,*) is_hash=y; echo "$i" ;; esac done } # __git_refs2 requires 1 argument (to pass to __git_refs) __git_refs2 () { local i for i in $(__git_refs "$1"); do echo "$i:$i" done } # __git_refs_remotes requires 1 argument (to pass to ls-remote) __git_refs_remotes () { local cmd i is_hash=y for i in $(git ls-remote "$1" 2>/dev/null); do case "$is_hash,$i" in n,refs/heads/*) is_hash=y echo "$i:refs/remotes/$1/${i#refs/heads/}" ;; y,*) is_hash=n ;; n,*^{}) is_hash=y ;; n,refs/tags/*) is_hash=y;; n,*) is_hash=y; ;; esac done } __git_remotes () { local i ngoff IFS=$'\n' d="$(__gitdir)" shopt -q nullglob || ngoff=1 shopt -s nullglob for i in "$d/remotes"/*; do echo ${i#$d/remotes/} done [ "$ngoff" ] && shopt -u nullglob for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do i="${i#remote.}" echo "${i/.url*/}" done } __git_list_merge_strategies () { git merge -s help 2>&1 | sed -n -e '/[Aa]vailable strategies are: /,/^$/{ s/\.$// s/.*:// s/^[ ]*// s/[ ]*$// p }' } __git_merge_strategies= # 'git merge -s help' (and thus detection of the merge strategy # list) fails, unfortunately, if run outside of any git working # tree. __git_merge_strategies is set to the empty string in # that case, and the detection will be repeated the next time it # is needed. __git_compute_merge_strategies () { : ${__git_merge_strategies:=$(__git_list_merge_strategies)} } __git_complete_file () { local pfx ls ref cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in ?*:*) ref="${cur%%:*}" cur="${cur#*:}" case "$cur" in ?*/*) pfx="${cur%/*}" cur="${cur##*/}" ls="$ref:$pfx" pfx="$pfx/" ;; *) ls="$ref" ;; esac case "$COMP_WORDBREAKS" in *:*) : great ;; *) pfx="$ref:$pfx" ;; esac local IFS=$'\n' COMPREPLY=($(compgen -P "$pfx" \ -W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \ | sed '/^100... blob /{ s,^.* ,, s,$, , } /^120000 blob /{ s,^.* ,, s,$, , } /^040000 tree /{ s,^.* ,, s,$,/, } s/^.* //')" \ -- "$cur")) ;; *) __gitcomp "$(__git_refs)" ;; esac } __git_complete_revlist () { local pfx cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in *...*) pfx="${cur%...*}..." cur="${cur#*...}" __gitcomp "$(__git_refs)" "$pfx" "$cur" ;; *..*) pfx="${cur%..*}.." cur="${cur#*..}" __gitcomp "$(__git_refs)" "$pfx" "$cur" ;; *) __gitcomp "$(__git_refs)" ;; esac } __git_complete_remote_or_refspec () { local cmd="${COMP_WORDS[0]}" local cur="${COMP_WORDS[COMP_CWORD]}" local i c=1 remote="" pfx="" lhs=1 no_complete_refspec=0 # git-sh hack: adjust args upward when completing git * if [ "$cmd" = "git" ] then cmd="${COMP_WORDS[1]}" c=2 fi while [ $c -lt $COMP_CWORD ]; do i="${COMP_WORDS[c]}" case "$i" in --mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;; --all) case "$cmd" in push) no_complete_refspec=1 ;; fetch) COMPREPLY=() return ;; *) ;; esac ;; -*) ;; *) remote="$i"; break ;; esac c=$((++c)) done if [ -z "$remote" ]; then __gitcomp "$(__git_remotes)" return fi if [ $no_complete_refspec = 1 ]; then COMPREPLY=() return fi [ "$remote" = "." ] && remote= case "$cur" in *:*) case "$COMP_WORDBREAKS" in *:*) : great ;; *) pfx="${cur%%:*}:" ;; esac cur="${cur#*:}" lhs=0 ;; +*) pfx="+" cur="${cur#+}" ;; esac case "$cmd" in fetch) if [ $lhs = 1 ]; then __gitcomp "$(__git_refs2 "$remote")" "$pfx" "$cur" else __gitcomp "$(__git_refs)" "$pfx" "$cur" fi ;; pull) if [ $lhs = 1 ]; then __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur" else __gitcomp "$(__git_refs)" "$pfx" "$cur" fi ;; push) if [ $lhs = 1 ]; then __gitcomp "$(__git_refs)" "$pfx" "$cur" else __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur" fi ;; esac } __git_complete_strategy () { __git_compute_merge_strategies case "${COMP_WORDS[COMP_CWORD-1]}" in -s|--strategy) __gitcomp "$__git_merge_strategies" return 0 esac local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --strategy=*) __gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}" return 0 ;; esac return 1 } __git_list_all_commands () { local i IFS=" "$'\n' for i in $(git help -a|egrep '^ [a-zA-Z0-9]') do case $i in *--*) : helper pattern;; *) echo $i;; esac done } __git_all_commands= __git_compute_all_commands () { : ${__git_all_commands:=$(__git_list_all_commands)} } __git_list_porcelain_commands () { local i IFS=" "$'\n' __git_compute_all_commands for i in "help" $__git_all_commands do case $i in *--*) : helper pattern;; applymbox) : ask gittus;; applypatch) : ask gittus;; archimport) : import;; cat-file) : plumbing;; check-attr) : plumbing;; check-ref-format) : plumbing;; checkout-index) : plumbing;; commit-tree) : plumbing;; count-objects) : infrequent;; cvsexportcommit) : export;; cvsimport) : import;; cvsserver) : daemon;; daemon) : daemon;; diff-files) : plumbing;; diff-index) : plumbing;; diff-tree) : plumbing;; fast-import) : import;; fast-export) : export;; fsck-objects) : plumbing;; fetch-pack) : plumbing;; fmt-merge-msg) : plumbing;; for-each-ref) : plumbing;; hash-object) : plumbing;; http-*) : transport;; index-pack) : plumbing;; init-db) : deprecated;; local-fetch) : plumbing;; lost-found) : infrequent;; ls-files) : plumbing;; ls-remote) : plumbing;; ls-tree) : plumbing;; mailinfo) : plumbing;; mailsplit) : plumbing;; merge-*) : plumbing;; mktree) : plumbing;; mktag) : plumbing;; pack-objects) : plumbing;; pack-redundant) : plumbing;; pack-refs) : plumbing;; parse-remote) : plumbing;; patch-id) : plumbing;; peek-remote) : plumbing;; prune) : plumbing;; prune-packed) : plumbing;; quiltimport) : import;; read-tree) : plumbing;; receive-pack) : plumbing;; reflog) : plumbing;; remote-*) : transport;; repo-config) : deprecated;; rerere) : plumbing;; rev-list) : plumbing;; rev-parse) : plumbing;; runstatus) : plumbing;; sh-setup) : internal;; shell) : daemon;; show-ref) : plumbing;; send-pack) : plumbing;; show-index) : plumbing;; ssh-*) : transport;; stripspace) : plumbing;; symbolic-ref) : plumbing;; tar-tree) : deprecated;; unpack-file) : plumbing;; unpack-objects) : plumbing;; update-index) : plumbing;; update-ref) : plumbing;; update-server-info) : daemon;; upload-archive) : plumbing;; upload-pack) : plumbing;; write-tree) : plumbing;; var) : infrequent;; verify-pack) : infrequent;; verify-tag) : plumbing;; *) echo $i;; esac done } __git_porcelain_commands= __git_compute_porcelain_commands () { __git_compute_all_commands : ${__git_porcelain_commands:=$(__git_list_porcelain_commands)} } __git_aliases () { local i IFS=$'\n' for i in $(git --git-dir="$(__gitdir)" config --get-regexp "alias\..*" 2>/dev/null); do case "$i" in alias.*) i="${i#alias.}" echo "${i/ */}" ;; esac done } # __git_aliased_command requires 1 argument __git_aliased_command () { local word cmdline=$(git --git-dir="$(__gitdir)" \ config --get "alias.$1") for word in $cmdline; do case "$word" in \!gitk|gitk) echo "gitk" return ;; \!*) : shell command alias ;; -*) : option ;; *=*) : setting env ;; git) : git itself ;; *) echo "$word" return esac done } # __git_find_on_cmdline requires 1 argument __git_find_on_cmdline () { local word subcommand c=1 while [ $c -lt $COMP_CWORD ]; do word="${COMP_WORDS[c]}" for subcommand in $1; do if [ "$subcommand" = "$word" ]; then echo "$subcommand" return fi done c=$((++c)) done } __git_has_doubledash () { local c=1 while [ $c -lt $COMP_CWORD ]; do if [ "--" = "${COMP_WORDS[c]}" ]; then return 0 fi c=$((++c)) done return 1 } __git_whitespacelist="nowarn warn error error-all fix" _git_am () { local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)" if [ -d "$dir"/rebase-apply ]; then __gitcomp "--skip --continue --resolved --abort" return fi case "$cur" in --whitespace=*) __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}" return ;; --*) __gitcomp " --3way --committer-date-is-author-date --ignore-date --ignore-whitespace --ignore-space-change --interactive --keep --no-utf8 --signoff --utf8 --whitespace= --scissors " return esac COMPREPLY=() } _git_apply () { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --whitespace=*) __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}" return ;; --*) __gitcomp " --stat --numstat --summary --check --index --cached --index-info --reverse --reject --unidiff-zero --apply --no-add --exclude= --ignore-whitespace --ignore-space-change --whitespace= --inaccurate-eof --verbose " return esac COMPREPLY=() } _git_add () { __git_has_doubledash && return local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --*) __gitcomp " --interactive --refresh --patch --update --dry-run --ignore-errors --intent-to-add " return esac COMPREPLY=() } _git_archive () { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --format=*) __gitcomp "$(git archive --list)" "" "${cur##--format=}" return ;; --remote=*) __gitcomp "$(__git_remotes)" "" "${cur##--remote=}" return ;; --*) __gitcomp " --format= --list --verbose --prefix= --remote= --exec= " return ;; esac __git_complete_file } _git_bisect () { __git_has_doubledash && return local subcommands="start bad good skip reset visualize replay log run" local subcommand="$(__git_find_on_cmdline "$subcommands")" if [ -z "$subcommand" ]; then __gitcomp "$subcommands" return fi case "$subcommand" in bad|good|reset|skip) __gitcomp "$(__git_refs)" ;; *) COMPREPLY=() ;; esac } _git_branch () { local i c=1 only_local_ref="n" has_r="n" while [ $c -lt $COMP_CWORD ]; do i="${COMP_WORDS[c]}" case "$i" in -d|-m) only_local_ref="y" ;; -r) has_r="y" ;; esac c=$((++c)) done case "${COMP_WORDS[COMP_CWORD]}" in --*) __gitcomp " --color --no-color --verbose --abbrev= --no-abbrev --track --no-track --contains --merged --no-merged --set-upstream " ;; *) if [ $only_local_ref = "y" -a $has_r = "n" ]; then __gitcomp "$(__git_heads)" else __gitcomp "$(__git_refs)" fi ;; esac } _git_bundle () { local cmd="${COMP_WORDS[1]}" case "${COMP_WORDS[COMP_CWORD-1]}" in bundle) __gitcomp "create list-heads verify unbundle" ;; create) __git_complete_revlist ;; list-heads|verify|unbundle|*) # looking for a file ;; esac } _git_checkout () { __git_has_doubledash && return local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --conflict=*) __gitcomp "diff3 merge" "" "${cur##--conflict=}" ;; --*) __gitcomp " --quiet --ours --theirs --track --no-track --merge --conflict= --orphan --patch " ;; *) __gitcomp "$(__git_refs)" ;; esac } _git_cherry () { __gitcomp "$(__git_refs)" } _git_cherry_pick () { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --*) __gitcomp "--edit --no-commit" ;; *) __gitcomp "$(__git_refs)" ;; esac } _git_clean () { __git_has_doubledash && return local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --*) __gitcomp "--dry-run --quiet" return ;; esac COMPREPLY=() } _git_clone () { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --*) __gitcomp " --local --no-hardlinks --shared --reference --quiet --no-checkout --bare --mirror --origin --upload-pack --template= --depth " return ;; esac COMPREPLY=() } _git_commit () { __git_has_doubledash && return local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --cleanup=*) __gitcomp "default strip verbatim whitespace " "" "${cur##--cleanup=}" return ;; --reuse-message=*) __gitcomp "$(__git_refs)" "" "${cur##--reuse-message=}" return ;; --reedit-message=*) __gitcomp "$(__git_refs)" "" "${cur##--reedit-message=}" return ;; --untracked-files=*) __gitcomp "all no normal" "" "${cur##--untracked-files=}" return ;; --*) __gitcomp " --all --author= --signoff --verify --no-verify --edit --amend --include --only --interactive --dry-run --reuse-message= --reedit-message= --reset-author --file= --message= --template= --cleanup= --untracked-files --untracked-files= --verbose --quiet " return esac COMPREPLY=() } _git_describe () { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --*) __gitcomp " --all --tags --contains --abbrev= --candidates= --exact-match --debug --long --match --always " return esac __gitcomp "$(__git_refs)" } __git_diff_common_options="--stat --numstat --shortstat --summary --patch-with-stat --name-only --name-status --color --no-color --color-words --no-renames --check --full-index --binary --abbrev --diff-filter= --find-copies-harder --text --ignore-space-at-eol --ignore-space-change --ignore-all-space --exit-code --quiet --ext-diff --no-ext-diff --no-prefix --src-prefix= --dst-prefix= --inter-hunk-context= --patience --raw --dirstat --dirstat= --dirstat-by-file --dirstat-by-file= --cumulative " _git_diff () { __git_has_doubledash && return local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --*) __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex --base --ours --theirs $__git_diff_common_options " return ;; esac __git_complete_file } __git_mergetools_common="diffuse ecmerge emerge kdiff3 meld opendiff tkdiff vimdiff gvimdiff xxdiff araxis p4merge " _git_difftool () { __git_has_doubledash && return local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --tool=*) __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}" return ;; --*) __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex --base --ours --theirs --no-renames --diff-filter= --find-copies-harder --relative --ignore-submodules --tool=" return ;; esac __git_complete_file } __git_fetch_options=" --quiet --verbose --append --upload-pack --force --keep --depth= --tags --no-tags --all --prune --dry-run " _git_fetch () { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --*) __gitcomp "$__git_fetch_options" return ;; esac __git_complete_remote_or_refspec } _git_format_patch () { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --thread=*) __gitcomp " deep shallow " "" "${cur##--thread=}" return ;; --*) __gitcomp " --stdout --attach --no-attach --thread --thread= --output-directory --numbered --start-number --numbered-files --keep-subject --signoff --signature --no-signature --in-reply-to= --cc= --full-index --binary --not --all --cover-letter --no-prefix --src-prefix= --dst-prefix= --inline --suffix= --ignore-if-in-upstream --subject-prefix= " return ;; esac __git_complete_revlist } _git_fsck () { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --*) __gitcomp " --tags --root --unreachable --cache --no-reflogs --full --strict --verbose --lost-found " return ;; esac COMPREPLY=() } _git_gc () { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --*) __gitcomp "--prune --aggressive" return ;; esac COMPREPLY=() } _git_gitk () { _gitk } _git_grep () { __git_has_doubledash && return local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --*) __gitcomp " --cached --text --ignore-case --word-regexp --invert-match --full-name --extended-regexp --basic-regexp --fixed-strings --files-with-matches --name-only --files-without-match --max-depth --count --and --or --not --all-match " return ;; esac __gitcomp "$(__git_refs)" } _git_help () { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --*) __gitcomp "--all --info --man --web" return ;; esac __git_compute_all_commands __gitcomp "$__git_all_commands attributes cli core-tutorial cvs-migration diffcore gitk glossary hooks ignore modules repository-layout tutorial tutorial-2 workflows " } _git_init () { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --shared=*) __gitcomp " false true umask group all world everybody " "" "${cur##--shared=}" return ;; --*) __gitcomp "--quiet --bare --template= --shared --shared=" return ;; esac COMPREPLY=() } _git_ls_files () { __git_has_doubledash && return local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --*) __gitcomp "--cached --deleted --modified --others --ignored --stage --directory --no-empty-directory --unmerged --killed --exclude= --exclude-from= --exclude-per-directory= --exclude-standard --error-unmatch --with-tree= --full-name --abbrev --ignored --exclude-per-directory " return ;; esac COMPREPLY=() } _git_ls_remote () { __gitcomp "$(__git_remotes)" } _git_ls_tree () { __git_complete_file } # Options that go well for log, shortlog and gitk __git_log_common_options=" --not --all --branches --tags --remotes --first-parent --merges --no-merges --max-count= --max-age= --since= --after= --min-age= --until= --before= " # Options that go well for log and gitk (not shortlog) __git_log_gitk_options=" --dense --sparse --full-history --simplify-merges --simplify-by-decoration --left-right " # Options that go well for log and shortlog (not gitk) __git_log_shortlog_options=" --author= --committer= --grep= --all-match " __git_log_pretty_formats="oneline short medium full fuller email raw format:" __git_log_date_formats="relative iso8601 rfc2822 short local default raw" _git_log () { __git_has_doubledash && return local cur="${COMP_WORDS[COMP_CWORD]}" local g="$(git rev-parse --git-dir 2>/dev/null)" local merge="" if [ -f "$g/MERGE_HEAD" ]; then merge="--merge" fi case "$cur" in --pretty=*) __gitcomp "$__git_log_pretty_formats " "" "${cur##--pretty=}" return ;; --format=*) __gitcomp "$__git_log_pretty_formats " "" "${cur##--format=}" return ;; --date=*) __gitcomp "$__git_log_date_formats" "" "${cur##--date=}" return ;; --decorate=*) __gitcomp "long short" "" "${cur##--decorate=}" return ;; --*) __gitcomp " $__git_log_common_options $__git_log_shortlog_options $__git_log_gitk_options --root --topo-order --date-order --reverse --follow --full-diff --abbrev-commit --abbrev= --relative-date --date= --pretty= --format= --oneline --cherry-pick --graph --decorate --decorate= --walk-reflogs --parents --children $merge $__git_diff_common_options --pickaxe-all --pickaxe-regex " return ;; esac __git_complete_revlist } __git_merge_options=" --no-commit --no-stat --log --no-log --squash --strategy --commit --stat --no-squash --ff --no-ff --ff-only " _git_merge () { __git_complete_strategy && return local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --*) __gitcomp "$__git_merge_options" return esac __gitcomp "$(__git_refs)" } _git_mergetool () { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --tool=*) __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}" return ;; --*) __gitcomp "--tool=" return ;; esac COMPREPLY=() } _git_merge_base () { __gitcomp "$(__git_refs)" } _git_mv () { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --*) __gitcomp "--dry-run" return ;; esac COMPREPLY=() } _git_name_rev () { __gitcomp "--tags --all --stdin" } _git_notes () { local subcommands="edit show" if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then __gitcomp "$subcommands" return fi case "${COMP_WORDS[COMP_CWORD-1]}" in -m|-F) COMPREPLY=() ;; *) __gitcomp "$(__git_refs)" ;; esac } _git_pull () { __git_complete_strategy && return local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --*) __gitcomp " --rebase --no-rebase $__git_merge_options $__git_fetch_options " return ;; esac __git_complete_remote_or_refspec } _git_push () { local cur="${COMP_WORDS[COMP_CWORD]}" case "${COMP_WORDS[COMP_CWORD-1]}" in --repo) __gitcomp "$(__git_remotes)" return esac case "$cur" in --repo=*) __gitcomp "$(__git_remotes)" "" "${cur##--repo=}" return ;; --*) __gitcomp " --all --mirror --tags --dry-run --force --verbose --receive-pack= --repo= " return ;; esac __git_complete_remote_or_refspec } _git_rebase () { local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)" if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then __gitcomp "--continue --skip --abort" return fi __git_complete_strategy && return case "$cur" in --whitespace=*) __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}" return ;; --*) __gitcomp " --onto --merge --strategy --interactive --preserve-merges --stat --no-stat --committer-date-is-author-date --ignore-date --ignore-whitespace --whitespace= --autosquash " return esac __gitcomp "$(__git_refs)" } __git_send_email_confirm_options="always never auto cc compose" __git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all" _git_send_email () { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --confirm=*) __gitcomp " $__git_send_email_confirm_options " "" "${cur##--confirm=}" return ;; --suppress-cc=*) __gitcomp " $__git_send_email_suppresscc_options " "" "${cur##--suppress-cc=}" return ;; --smtp-encryption=*) __gitcomp "ssl tls" "" "${cur##--smtp-encryption=}" return ;; --*) __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to --compose --confirm= --dry-run --envelope-sender --from --identity --in-reply-to --no-chain-reply-to --no-signed-off-by-cc --no-suppress-from --no-thread --quiet --signed-off-by-cc --smtp-pass --smtp-server --smtp-server-port --smtp-encryption= --smtp-user --subject --suppress-cc= --suppress-from --thread --to --validate --no-validate" return ;; esac COMPREPLY=() } _git_stage () { _git_add } __git_config_get_set_variables () { local prevword word config_file= c=$COMP_CWORD while [ $c -gt 1 ]; do word="${COMP_WORDS[c]}" case "$word" in --global|--system|--file=*) config_file="$word" break ;; -f|--file) config_file="$word $prevword" break ;; esac prevword=$word c=$((--c)) done git --git-dir="$(__gitdir)" config $config_file --list 2>/dev/null | while read line do case "$line" in *.*=*) echo "${line/=*/}" ;; esac done } _git_config () { local cur="${COMP_WORDS[COMP_CWORD]}" local prv="${COMP_WORDS[COMP_CWORD-1]}" case "$prv" in branch.*.remote) __gitcomp "$(__git_remotes)" return ;; branch.*.merge) __gitcomp "$(__git_refs)" return ;; remote.*.fetch) local remote="${prv#remote.}" remote="${remote%.fetch}" __gitcomp "$(__git_refs_remotes "$remote")" return ;; remote.*.push) local remote="${prv#remote.}" remote="${remote%.push}" __gitcomp "$(git --git-dir="$(__gitdir)" \ for-each-ref --format='%(refname):%(refname)' \ refs/heads)" return ;; pull.twohead|pull.octopus) __git_compute_merge_strategies __gitcomp "$__git_merge_strategies" return ;; color.branch|color.diff|color.interactive|\ color.showbranch|color.status|color.ui) __gitcomp "always never auto" return ;; color.pager) __gitcomp "false true" return ;; color.*.*) __gitcomp " normal black red green yellow blue magenta cyan white bold dim ul blink reverse " return ;; help.format) __gitcomp "man info web html" return ;; log.date) __gitcomp "$__git_log_date_formats" return ;; sendemail.aliasesfiletype) __gitcomp "mutt mailrc pine elm gnus" return ;; sendemail.confirm) __gitcomp "$__git_send_email_confirm_options" return ;; sendemail.suppresscc) __gitcomp "$__git_send_email_suppresscc_options" return ;; --get|--get-all|--unset|--unset-all) __gitcomp "$(__git_config_get_set_variables)" return ;; *.*) COMPREPLY=() return ;; esac case "$cur" in --*) __gitcomp " --global --system --file= --list --replace-all --get --get-all --get-regexp --add --unset --unset-all --remove-section --rename-section " return ;; branch.*.*) local pfx="${cur%.*}." cur="${cur##*.}" __gitcomp "remote merge mergeoptions rebase" "$pfx" "$cur" return ;; branch.*) local pfx="${cur%.*}." cur="${cur#*.}" __gitcomp "$(__git_heads)" "$pfx" "$cur" "." return ;; guitool.*.*) local pfx="${cur%.*}." cur="${cur##*.}" __gitcomp " argprompt cmd confirm needsfile noconsole norescan prompt revprompt revunmerged title " "$pfx" "$cur" return ;; difftool.*.*) local pfx="${cur%.*}." cur="${cur##*.}" __gitcomp "cmd path" "$pfx" "$cur" return ;; man.*.*) local pfx="${cur%.*}." cur="${cur##*.}" __gitcomp "cmd path" "$pfx" "$cur" return ;; mergetool.*.*) local pfx="${cur%.*}." cur="${cur##*.}" __gitcomp "cmd path trustExitCode" "$pfx" "$cur" return ;; pager.*) local pfx="${cur%.*}." cur="${cur#*.}" __git_compute_all_commands __gitcomp "$__git_all_commands" "$pfx" "$cur" return ;; remote.*.*) local pfx="${cur%.*}." cur="${cur##*.}" __gitcomp " url proxy fetch push mirror skipDefaultUpdate receivepack uploadpack tagopt pushurl " "$pfx" "$cur" return ;; remote.*) local pfx="${cur%.*}." cur="${cur#*.}" __gitcomp "$(__git_remotes)" "$pfx" "$cur" "." return ;; url.*.*) local pfx="${cur%.*}." cur="${cur##*.}" __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur" return ;; esac __gitcomp " add.ignore-errors alias. apply.ignorewhitespace apply.whitespace branch.autosetupmerge branch.autosetuprebase clean.requireForce color.branch color.branch.current color.branch.local color.branch.plain color.branch.remote color.diff color.diff.commit color.diff.frag color.diff.meta color.diff.new color.diff.old color.diff.plain color.diff.whitespace color.grep color.grep.external color.grep.match color.interactive color.interactive.header color.interactive.help color.interactive.prompt color.pager color.showbranch color.status color.status.added color.status.changed color.status.header color.status.nobranch color.status.untracked color.status.updated color.ui commit.template core.autocrlf core.bare core.compression core.createObject core.deltaBaseCacheLimit core.editor core.excludesfile core.fileMode core.fsyncobjectfiles core.gitProxy core.ignoreCygwinFSTricks core.ignoreStat core.logAllRefUpdates core.loosecompression core.packedGitLimit core.packedGitWindowSize core.pager core.preferSymlinkRefs core.preloadindex core.quotepath core.repositoryFormatVersion core.safecrlf core.sharedRepository core.symlinks core.trustctime core.warnAmbiguousRefs core.whitespace core.worktree diff.autorefreshindex diff.external diff.mnemonicprefix diff.renameLimit diff.renameLimit. diff.renames diff.suppressBlankEmpty diff.tool diff.wordRegex difftool. difftool.prompt fetch.unpackLimit format.attach format.cc format.headers format.numbered format.pretty format.signature format.signoff format.subjectprefix format.suffix format.thread gc.aggressiveWindow gc.auto gc.autopacklimit gc.packrefs gc.pruneexpire gc.reflogexpire gc.reflogexpireunreachable gc.rerereresolved gc.rerereunresolved gitcvs.allbinary gitcvs.commitmsgannotation gitcvs.dbTableNamePrefix gitcvs.dbdriver gitcvs.dbname gitcvs.dbpass gitcvs.dbuser gitcvs.enabled gitcvs.logfile gitcvs.usecrlfattr guitool. gui.blamehistoryctx gui.commitmsgwidth gui.copyblamethreshold gui.diffcontext gui.encoding gui.fastcopyblame gui.matchtrackingbranch gui.newbranchtemplate gui.pruneduringfetch gui.spellingdictionary gui.trustmtime help.autocorrect help.browser help.format http.lowSpeedLimit http.lowSpeedTime http.maxRequests http.noEPSV http.proxy http.sslCAInfo http.sslCAPath http.sslCert http.sslKey http.sslVerify i18n.commitEncoding i18n.logOutputEncoding imap.folder imap.host imap.pass imap.port imap.preformattedHTML imap.sslverify imap.tunnel imap.user instaweb.browser instaweb.httpd instaweb.local instaweb.modulepath instaweb.port interactive.singlekey log.date log.showroot mailmap.file man. man.viewer merge.conflictstyle merge.log merge.renameLimit merge.stat merge.tool merge.verbosity mergetool. mergetool.keepBackup mergetool.prompt pack.compression pack.deltaCacheLimit pack.deltaCacheSize pack.depth pack.indexVersion pack.packSizeLimit pack.threads pack.window pack.windowMemory pager. pull.octopus pull.twohead push.default rebase.stat receive.denyCurrentBranch receive.denyDeletes receive.denyNonFastForwards receive.fsckObjects receive.unpackLimit repack.usedeltabaseoffset rerere.autoupdate rerere.enabled sendemail.aliasesfile sendemail.aliasesfiletype sendemail.bcc sendemail.cc sendemail.cccmd sendemail.chainreplyto sendemail.confirm sendemail.envelopesender sendemail.multiedit sendemail.signedoffbycc sendemail.smtpencryption sendemail.smtppass sendemail.smtpserver sendemail.smtpserverport sendemail.smtpuser sendemail.suppresscc sendemail.suppressfrom sendemail.thread sendemail.to sendemail.validate showbranch.default status.relativePaths status.showUntrackedFiles tar.umask transfer.unpackLimit url. user.email user.name user.signingkey web.browser branch. remote. " } _git_remote () { local subcommands="add rename rm show prune update set-head" local subcommand="$(__git_find_on_cmdline "$subcommands")" if [ -z "$subcommand" ]; then __gitcomp "$subcommands" return fi case "$subcommand" in rename|rm|show|prune) __gitcomp "$(__git_remotes)" ;; update) local i c='' IFS=$'\n' for i in $(git --git-dir="$(__gitdir)" config --get-regexp "remotes\..*" 2>/dev/null); do i="${i#remotes.}" c="$c ${i/ */}" done __gitcomp "$c" ;; *) COMPREPLY=() ;; esac } _git_replace () { __gitcomp "$(__git_refs)" } _git_reset () { __git_has_doubledash && return local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --*) __gitcomp "--merge --mixed --hard --soft --patch" return ;; esac __gitcomp "$(__git_refs)" } _git_revert () { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --*) __gitcomp "--edit --mainline --no-edit --no-commit --signoff" return ;; esac __gitcomp "$(__git_refs)" } _git_rm () { __git_has_doubledash && return local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --*) __gitcomp "--cached --dry-run --ignore-unmatch --quiet" return ;; esac COMPREPLY=() } _git_shortlog () { __git_has_doubledash && return local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --*) __gitcomp " $__git_log_common_options $__git_log_shortlog_options --numbered --summary " return ;; esac __git_complete_revlist } _git_show () { __git_has_doubledash && return local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --pretty=*) __gitcomp "$__git_log_pretty_formats " "" "${cur##--pretty=}" return ;; --format=*) __gitcomp "$__git_log_pretty_formats " "" "${cur##--format=}" return ;; --*) __gitcomp "--pretty= --format= --abbrev-commit --oneline $__git_diff_common_options " return ;; esac __git_complete_file } _git_show_branch () { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --*) __gitcomp " --all --remotes --topo-order --current --more= --list --independent --merge-base --no-name --color --no-color --sha1-name --sparse --topics --reflog " return ;; esac __git_complete_revlist } _git_stash () { local cur="${COMP_WORDS[COMP_CWORD]}" local save_opts='--keep-index --no-keep-index --quiet --patch' local subcommands='save list show apply clear drop pop create branch' local subcommand="$(__git_find_on_cmdline "$subcommands")" if [ -z "$subcommand" ]; then case "$cur" in --*) __gitcomp "$save_opts" ;; *) if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then __gitcomp "$subcommands" else COMPREPLY=() fi ;; esac else case "$subcommand,$cur" in save,--*) __gitcomp "$save_opts" ;; apply,--*|pop,--*) __gitcomp "--index --quiet" ;; show,--*|drop,--*|branch,--*) COMPREPLY=() ;; show,*|apply,*|drop,*|pop,*|branch,*) __gitcomp "$(git --git-dir="$(__gitdir)" stash list \ | sed -n -e 's/:.*//p')" ;; *) COMPREPLY=() ;; esac fi } _git_submodule () { __git_has_doubledash && return local subcommands="add status init update summary foreach sync" if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --*) __gitcomp "--quiet --cached" ;; *) __gitcomp "$subcommands" ;; esac return fi } _git_svn () { local subcommands=" init fetch clone rebase dcommit log find-rev set-tree commit-diff info create-ignore propget proplist show-ignore show-externals branch tag blame migrate mkdirs reset gc " local subcommand="$(__git_find_on_cmdline "$subcommands")" if [ -z "$subcommand" ]; then __gitcomp "$subcommands" else local remote_opts="--username= --config-dir= --no-auth-cache" local fc_opts=" --follow-parent --authors-file= --repack= --no-metadata --use-svm-props --use-svnsync-props --log-window-size= --no-checkout --quiet --repack-flags --use-log-author --localtime --ignore-paths= $remote_opts " local init_opts=" --template= --shared= --trunk= --tags= --branches= --stdlayout --minimize-url --no-metadata --use-svm-props --use-svnsync-props --rewrite-root= --prefix= --use-log-author --add-author-from $remote_opts " local cmt_opts=" --edit --rmdir --find-copies-harder --copy-similarity= " local cur="${COMP_WORDS[COMP_CWORD]}" case "$subcommand,$cur" in fetch,--*) __gitcomp "--revision= --fetch-all $fc_opts" ;; clone,--*) __gitcomp "--revision= $fc_opts $init_opts" ;; init,--*) __gitcomp "$init_opts" ;; dcommit,--*) __gitcomp " --merge --strategy= --verbose --dry-run --fetch-all --no-rebase --commit-url --revision $cmt_opts $fc_opts " ;; set-tree,--*) __gitcomp "--stdin $cmt_opts $fc_opts" ;; create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\ show-externals,--*|mkdirs,--*) __gitcomp "--revision=" ;; log,--*) __gitcomp " --limit= --revision= --verbose --incremental --oneline --show-commit --non-recursive --authors-file= --color " ;; rebase,--*) __gitcomp " --merge --verbose --strategy= --local --fetch-all --dry-run $fc_opts " ;; commit-diff,--*) __gitcomp "--message= --file= --revision= $cmt_opts" ;; info,--*) __gitcomp "--url" ;; branch,--*) __gitcomp "--dry-run --message --tag" ;; tag,--*) __gitcomp "--dry-run --message" ;; blame,--*) __gitcomp "--git-format" ;; migrate,--*) __gitcomp " --config-dir= --ignore-paths= --minimize --no-auth-cache --username= " ;; reset,--*) __gitcomp "--revision= --parent" ;; *) COMPREPLY=() ;; esac fi } _git_tag () { local i c=1 f=0 while [ $c -lt $COMP_CWORD ]; do i="${COMP_WORDS[c]}" case "$i" in -d|-v) __gitcomp "$(__git_tags)" return ;; -f) f=1 ;; esac c=$((++c)) done case "${COMP_WORDS[COMP_CWORD-1]}" in -m|-F) COMPREPLY=() ;; -*|tag) if [ $f = 1 ]; then __gitcomp "$(__git_tags)" else COMPREPLY=() fi ;; *) __gitcomp "$(__git_refs)" ;; esac } _git_whatchanged () { _git_log } _git () { local i c=1 command __git_dir while [ $c -lt $COMP_CWORD ]; do i="${COMP_WORDS[c]}" case "$i" in --git-dir=*) __git_dir="${i#--git-dir=}" ;; --bare) __git_dir="." ;; --version|-p|--paginate) ;; --help) command="help"; break ;; *) command="$i"; break ;; esac c=$((++c)) done if [ -z "$command" ]; then case "${COMP_WORDS[COMP_CWORD]}" in --*) __gitcomp " --paginate --no-pager --git-dir= --bare --version --exec-path --html-path --work-tree= --help " ;; *) __git_compute_porcelain_commands __gitcomp "$__git_porcelain_commands $(__git_aliases)" ;; esac return fi local completion_func="_git_${command//-/_}" declare -F $completion_func >/dev/null && $completion_func && return local expansion=$(__git_aliased_command "$command") if [ -n "$expansion" ]; then completion_func="_git_${expansion//-/_}" declare -F $completion_func >/dev/null && $completion_func fi } _gitk () { __git_has_doubledash && return local cur="${COMP_WORDS[COMP_CWORD]}" local g="$(__gitdir)" local merge="" if [ -f "$g/MERGE_HEAD" ]; then merge="--merge" fi case "$cur" in --*) __gitcomp " $__git_log_common_options $__git_log_gitk_options $merge " return ;; esac __git_complete_revlist } complete -o bashdefault -o default -o nospace -F _git git 2>/dev/null \ || complete -o default -o nospace -F _git git complete -o bashdefault -o default -o nospace -F _gitk gitk 2>/dev/null \ || complete -o default -o nospace -F _gitk gitk # The following are necessary only for Cygwin, and only are needed # when the user has tab-completed the executable name and consequently # included the '.exe' suffix. # if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then complete -o bashdefault -o default -o nospace -F _git git.exe 2>/dev/null \ || complete -o default -o nospace -F _git git.exe fi git-sh-1.1/git-sh-aliases.bash000066400000000000000000000027661153042013400162230ustar00rootroot00000000000000#!/bin/bash # These are the standard set of aliases enabled by default in all # git-sh sessions. Aliases defined in the gitconfig [alias] section override # these. gitalias a='git add' gitalias b='git branch' gitalias c='git checkout' gitalias d='git diff' gitalias f='git fetch --prune' gitalias k='git cherry-pick' gitalias l='git log --pretty=oneline --abbrev-commit' gitalias n='git commit --verbose --amend' gitalias r='git remote' gitalias s='git commit --dry-run --short' gitalias t='git diff --cached' # git add and the staging area gitalias a='git add' gitalias aa='git add --update' # mnemonic: "add all" gitalias stage='git add' gitalias ap='git add --patch' gitalias p='git diff --cached' # mnemonic: "patch" gitalias ps='git diff --cached --stat' # mnemonic: "patch stat" gitalias unstage='git reset HEAD' # commits and history gitalias ci='git commit --verbose' gitalias ca='git commit --verbose --all' gitalias amend='git commit --verbose --amend' gitalias n='git commit --verbose --amend' gitalias k='git cherry-pick' gitalias re='git rebase --interactive' gitalias pop='git reset --soft HEAD^' gitalias peek='git log -p --max-count=1' # git fetch gitalias f='git fetch' gitalias pm='git pull' # mnemonic: pull merge gitalias pr='git pull --rebase' # mnemonic: pull rebase # git diff gitalias d='git diff' gitalias ds='git diff --stat' # mnemonic: "diff stat" # git reset gitalias hard='git reset --hard' gitalias soft='git reset --soft' gitalias scrap='git checkout HEAD' git-sh-1.1/git-sh-config.bash000066400000000000000000000004341153042013400160350ustar00rootroot00000000000000 # CONFIG ============================================================== # load gitconfig [alias] section as top-level aliases. _git_import_aliases # source the system-wide rc file [ -r /etc/gitshrc ] && . /etc/gitshrc # source the user's rc file [ -r ~/.gitshrc ] && . ~/.gitshrc git-sh-1.1/git-sh.1.roff000066400000000000000000000130261153042013400147510ustar00rootroot00000000000000.\" generated with Ronn/v0.4.1 .\" http://github.com/rtomayko/ronn/ . .TH "GIT\-SH" "1" "March 2010" "Ryan Tomayko" "" . .SH "NAME" \fBgit\-sh\fR \-\- a git shell . .SH "SYNOPSIS" \fBgit\-sh\fR . .SH "DESCRIPTION" \fBgit\-sh\fR starts an interactive \fBbash(1)\fR session modified for git\-heavy workflows. Typical usage is to change into the directory of a git work tree or bare repository and run the \fBgit\-sh\fR command to start an interactive shell session. . .P Top\-level command aliases are created for all core \fBgit(1)\fR subcommands, git\-sh builtin aliases (see \fIBUILTIN ALIASES\fR), and git command aliases defined in \fB~/.gitconfig\fR. . .SH "BUILTIN ALIASES" \fBgit\-sh\fR loads a set of standard aliases in addition to all core git commands. The builtin aliases are overridden by aliases defined in the user or system gitconfig files. . .TP \fBa\fR git add . .TP \fBb\fR git branch . .TP \fBc\fR git checkout . .TP \fBd\fR git diff . .TP \fBf\fR git fetch \-\-prune . .TP \fBk\fR git cherry\-pick . .TP \fBl\fR git log \-\-pretty=oneline \-\-abbrev\-commit . .TP \fBn\fR git commit \-\-verbose \-\-amend . .TP \fBr\fR git remote . .TP \fBs\fR git commit \-\-dry\-run \-\-short . .TP \fBt\fR git diff \-\-cached . .SS "The Staging Area" . .TP \fBa\fR git add . .TP \fBaa\fR git add \-\-update (mnemonic: "add all") . .TP \fBstage\fR git add . .TP \fBap\fR git add \-\-patch . .TP \fBp\fR git diff \-\-cached (mnemonic: "patch") . .TP \fBps\fR git diff \-\-cached \-\-stat (mnemonic: "patch stat") . .TP \fBunstage\fR git reset HEAD . .SS "Commits and Commit History" . .TP \fBci\fR git commit \-\-verbose . .TP \fBca\fR git commit \-\-verbose \-\-all . .TP \fBamend\fR git commit \-\-verbose \-\-amend . .TP \fBn\fR git commit \-\-verbose \-\-amend . .TP \fBk\fR git cherry\-pick . .TP \fBre\fR git rebase \-\-interactive . .TP \fBpop\fR git reset \-\-soft HEAD^ . .TP \fBpeek\fR git log \-p \-\-max\-count=1 . .SS "Fetching and Pulling" . .TP \fBf\fR git fetch . .TP \fBpm\fR git pull (mnemonic: "pull merge") . .TP \fBpr\fR git pull \-\-rebase (mnemonic: "pull rebase") . .SS "Miscellaneous Commands" . .TP \fBd\fR git diff . .TP \fBds\fR git diff \-\-stat (mnemonic: "diff stat") . .TP \fBhard\fR git reset \-\-hard . .TP \fBsoft\fR git reset \-\-soft . .TP \fBscrap\fR git checkout HEAD . .SH "CUSTOM ALIASES" Anything defined in the \fB[alias]\fR section of the repository, user, or system git config files are also available as top\-level shell commands. Assuming a \fB~/.gitconfig\fR that looked like this: . .IP "" 4 . .nf [alias] ci = commit \-\-verbose ca = commit \-a d = diff s = status thanks = !git\-thanks . .fi . .IP "" 0 . .P ... you might then have the following shell session: . .IP "" 4 . .nf master!something> echo "stuff" >somefile master!something*> s M somefile master!something*> d diff \-\-git a/somefile b/somefile \-\- a/somefile ++ b/somefile @@ \-0,0 +1 @@ + stuff master!something*> ca \-m "add stuff" master!something> thanks HEAD . .fi . .IP "" 0 . .SS "PROMPT" The default prompt shows the current branch, a bang (\fB!\fR), and then the relative path to the current working directory from the root of the work tree. If the work tree includes modified files that have not yet been staged, a dirty status indicator (\fB*\fR) is also displayed. . .P The git\-sh prompt includes ANSI colors when the git \fBcolor.ui\fR option is set and enabled. To enable git\-sh's prompt colors explicitly, set the \fBcolor.sh\fR config value to \fBauto\fR: . .IP "" 4 . .nf $ git config \-\-global color.sh auto . .fi . .IP "" 0 . .P Customize prompt colors by setting the \fBcolor.sh.branch\fR, \fBcolor.sh.workdir\fR, and \fBcolor.sh.dirty\fR git config values: . .IP "" 4 . .nf $ git config \-\-global color.sh.branch 'yellow reverse' $ git config \-\-global color.sh.workdir 'blue bold' $ git config \-\-global color.sh.dirty 'red' . .fi . .IP "" 0 . .P See \fIcolors in git\fR for information. . .SH "COMPLETION" Bash completion support is automatically enabled for all git built\-in commands and also for aliases defined in the user \fB~/.gitconfig\fR file. The auto\-completion logic is smart enough to know an alias \fBd\fR that expands to \fBgit\-diff\fR should use the same completion configuration as the \fBgit\-diff\fR command. . .P The completion code is a slightly modified version of the git bash completion script shipped with the core git distribution. The script is built into the\fBgit\-sh\fR executable at compile time and need not be obtained or installed separately. . .SH "CUSTOMIZING" Most \fBgit\-sh\fR behavior can be configured by editing the user or system gitconfig files (\fB~/.gitconfig\fR and \fB/etc/gitconfig\fR) either by hand or using \fBgit\-config(1)\fR. The \fB[alias]\fR section is used to create basic command aliases. . .P The \fB/etc/gitshrc\fR and \fB~/.gitshrc\fR files are sourced (in that order) immediately before the shell becomes interactive. . .P The \fB~/.bashrc\fR file is sourced before either \fB/etc/gitshrc\fR or \fB~/.gitshrc\fR. Any bash customizations defined there and not explicitly overridden by \fBgit\-sh\fR are also available. . .SH "ENVIRONMENT" . .TP \fBPS1\fR Set to the dynamic git\-sh prompt. This can be customized in the \fB~/.gitshrc\fR or \fB/etc/gitshrc\fR files. . .TP \fBGIT_DIR\fR Explicitly set the path to the git repository instead of assuming the nearest \fB.git\fR path. . .TP \fBGIT_WORK_TREE\fR Explicitly set the path to the root of the work tree instead of assuming the nearest parent directory with a \fB.git\fR repository. . .SH "SEE ALSO" bash(1), git(1), git\-config(1),\fIhttp://github.com/rtomayko/git\-sh\fR git-sh-1.1/git-sh.1.ronn000066400000000000000000000121111153042013400147630ustar00rootroot00000000000000git-sh(1) -- a git shell ======================== ## SYNOPSIS `git-sh` ## DESCRIPTION `git-sh` starts an interactive `bash(1)` session modified for git-heavy workflows. Typical usage is to change into the directory of a git work tree or bare repository and run the `git-sh` command to start an interactive shell session. Top-level command aliases are created for all core `git(1)` subcommands, git-sh builtin aliases (see *BUILTIN ALIASES*), and git command aliases defined in `~/.gitconfig`. ## BUILTIN ALIASES **git-sh** loads a set of standard aliases in addition to all core git commands. The builtin aliases are overridden by aliases defined in the user or system gitconfig files. * `a`: git add * `b`: git branch * `c`: git checkout * `d`: git diff * `f`: git fetch --prune * `k`: git cherry-pick * `l`: git log --pretty=oneline --abbrev-commit * `n`: git commit --verbose --amend * `r`: git remote * `s`: git commit --dry-run --short * `t`: git diff --cached ### The Staging Area * `a`: git add * `aa`: git add --update (mnemonic: "add all") * `stage`: git add * `ap`: git add --patch * `p`: git diff --cached (mnemonic: "patch") * `ps`: git diff --cached --stat (mnemonic: "patch stat") * `unstage`: git reset HEAD ### Commits and Commit History * `ci`: git commit --verbose * `ca`: git commit --verbose --all * `amend`: git commit --verbose --amend * `n`: git commit --verbose --amend * `k`: git cherry-pick * `re`: git rebase --interactive * `pop`: git reset --soft HEAD^ * `peek`: git log -p --max-count=1 ### Fetching and Pulling * `f`: git fetch * `pm`: git pull (mnemonic: "pull merge") * `pr`: git pull --rebase (mnemonic: "pull rebase") ### Miscellaneous Commands * `d`: git diff * `ds`: git diff --stat (mnemonic: "diff stat") * `hard`: git reset --hard * `soft`: git reset --soft * `scrap`: git checkout HEAD ## CUSTOM ALIASES Anything defined in the `[alias]` section of the repository, user, or system git config files are also available as top-level shell commands. Assuming a `~/.gitconfig` that looked like this: [alias] ci = commit --verbose ca = commit -a d = diff s = status thanks = !git-thanks ... you might then have the following shell session: master!something> echo "stuff" >somefile master!something*> s M somefile master!something*> d diff --git a/somefile b/somefile -- a/somefile ++ b/somefile @@ -0,0 +1 @@ + stuff master!something*> ca -m "add stuff" master!something> thanks HEAD ### PROMPT The default prompt shows the current branch, a bang (`!`), and then the relative path to the current working directory from the root of the work tree. If the work tree includes modified files that have not yet been staged, a dirty status indicator (`*`) is also displayed. The git-sh prompt includes ANSI colors when the git `color.ui` option is set and enabled. To enable git-sh's prompt colors explicitly, set the `color.sh` config value to `auto`: $ git config --global color.sh auto Customize prompt colors by setting the `color.sh.branch`, `color.sh.workdir`, and `color.sh.dirty` git config values: $ git config --global color.sh.branch 'yellow reverse' $ git config --global color.sh.workdir 'blue bold' $ git config --global color.sh.dirty 'red' See [colors in git](http://scie.nti.st/2007/5/2/colors-in-git) for information. ## COMPLETION Bash completion support is automatically enabled for all git built-in commands and also for aliases defined in the user `~/.gitconfig` file. The auto-completion logic is smart enough to know an alias `d` that expands to `git-diff` should use the same completion configuration as the `git-diff` command. The completion code is a slightly modified version of the git bash completion script shipped with the core git distribution. The script is built into the `git-sh` executable at compile time and need not be obtained or installed separately. ## CUSTOMIZING Most `git-sh` behavior can be configured by editing the user or system gitconfig files (`~/.gitconfig` and `/etc/gitconfig`) either by hand or using `git-config(1)`. The `[alias]` section is used to create basic command aliases. The `/etc/gitshrc` and `~/.gitshrc` files are sourced (in that order) immediately before the shell becomes interactive. The `~/.bashrc` file is sourced before either `/etc/gitshrc` or `~/.gitshrc`. Any bash customizations defined there and not explicitly overridden by `git-sh` are also available. ## ENVIRONMENT * `PS1`: Set to the dynamic git-sh prompt. This can be customized in the `~/.gitshrc` or `/etc/gitshrc` files. * `GIT_DIR`: Explicitly set the path to the git repository instead of assuming the nearest `.git` path. * `GIT_WORK_TREE`: Explicitly set the path to the root of the work tree instead of assuming the nearest parent directory with a `.git` repository. ## SEE ALSO bash(1), git(1), git-config(1), git-sh-1.1/git-sh.bash000066400000000000000000000165501153042013400146000ustar00rootroot00000000000000#!/usr/bin/env bash # # A customized bash environment suitable for git work. # # Copyright (C) 2008 Ryan Tomayko # Copyright (C) 2008 Aristotle Pagaltzis # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Distributed under the GNU General Public License, version 2.0. # use to install the sh alias [[ $1 = '--configure' && $# = 1 ]] && { set -e git config --global alias.sh '!git-sh' echo "alias 'sh' added to ~/.gitconfig" exit 0 } # we expect to be sourced into an interactive shell. when executed as a # command, kick off a new shell and source us. [ "$0" = 'bash' ] || exec /usr/bin/env bash --rcfile "$0" "$@" # source the user's .bashrc file [ -r ~/.bashrc ] && { pushd ~ > /dev/null . .bashrc popd > /dev/null } # ALIASES + COMPLETION ========================================================= # gitcomp # # Complete command named like standard git command named # . must be a valid git command with completion. # # Examples: # gitcomplete ci commit # gitcomplete c checkout gitcomplete() { local alias="$1" command="$2" complete -o default -o nospace -F _git_${command//-/_} $alias } # gitalias =' [...]' # # Define a new shell alias (as with the alias builtin) named # and enable command completion based on . must be # a standard non-abbreviated git command name that has completion support. # # Examples: # gitalias c=checkout # gitalias ci='commit -v' # gitalias r='rebase --interactive HEAD~10' gitalias() { local alias="${1%%=*}" command="${1#*=}" local prog="${command##git }" prog="${prog%% *}" alias $alias="$command" gitcomplete "$alias" "$prog" } # create aliases and configure bash completion for most porcelain commands _git_cmd_cfg=( 'add alias' 'am alias stdcmpl' 'annotate alias' 'apply alias stdcmpl' 'archive alias' 'bisect alias stdcmpl' 'blame alias' 'branch alias stdcmpl' 'bundle alias stdcmpl' 'cat-file alias' 'checkout alias stdcmpl' 'cherry alias stdcmpl' 'cherry-pick alias stdcmpl' 'clean alias' 'clone alias' 'commit alias stdcmpl' 'config alias stdcmpl' 'describe alias stdcmpl' 'diff alias stdcmpl' 'difftool alias' 'fetch alias stdcmpl' 'format-patch alias stdcmpl' 'fsck alias' 'gc alias stdcmpl' 'gui alias' 'hash-object alias' 'init alias' 'instaweb alias' 'log alias logcmpl' 'lost-found alias' 'ls-files alias' 'ls-remote alias stdcmpl' 'ls-tree alias stdcmpl' 'merge alias stdcmpl' 'merge-base alias stdcmpl' 'mergetool alias' 'mv alias' 'name-rev stdcmpl' 'patch-id alias' 'peek-remote alias' 'prune alias' 'pull alias stdcmpl' 'push alias stdcmpl' 'quiltimport alias' 'rebase alias stdcmpl' 'reflog alias' 'remote alias stdcmpl' 'repack alias' 'repo-config alias' 'request-pull alias' 'reset alias stdcmpl' 'rev-list alias' 'rev-parse alias' 'revert alias' 'rm alias' 'send-email alias' 'send-pack alias' 'shortlog alias stdcmpl' 'show alias stdcmpl' 'show-branch alias logcmpl' 'stash alias stdcmpl' 'status alias' 'stripspace alias' 'submodule alias stdcmpl' 'svn alias stdcmpl' 'symbolic-ref alias' 'tag alias stdcmpl' 'tar-tree alias' 'var alias' 'whatchanged alias logcmpl' ) for cfg in "${_git_cmd_cfg[@]}" ; do read cmd opts <<< $cfg for opt in $opts ; do case $opt in alias) alias $cmd="git $cmd" ;; stdcmpl) complete -o default -o nospace -F _git_${cmd//-/_} $cmd ;; logcmpl) complete -o default -o nospace -F _git_log $cmd ;; esac done done # Create aliases for everything defined in the gitconfig [alias] section. _git_import_aliases () { eval "$( git config --get-regexp 'alias\..*' | sed 's/^alias\.//' | while read key command do if expr -- "$command" : '!' >/dev/null then echo "alias $key='git $key'" else echo "gitalias $key=\"git $command\"" fi done )" } # PROMPT ======================================================================= PS1='`_git_headname`!`_git_workdir``_git_dirty`> ' ANSI_RESET="\001$(git config --get-color "" "reset")\002" # detect whether the tree is in a dirty state. returns _git_dirty() { if git status 2>/dev/null | fgrep -q '(working directory clean)'; then return 0 fi local dirty_marker="`git config gitsh.dirty || echo ' *'`" _git_apply_color "$dirty_marker" "color.sh.dirty" "red" } # detect the current branch; use 7-sha when not on branch _git_headname() { local br=`git symbolic-ref -q HEAD 2>/dev/null` [ -n "$br" ] && br=${br#refs/heads/} || br=`git rev-parse --short HEAD 2>/dev/null` _git_apply_color "$br" "color.sh.branch" "yellow reverse" } # detect working directory relative to working tree root _git_workdir() { subdir=`git rev-parse --show-prefix 2>/dev/null` subdir="${subdir%/}" workdir="${PWD%/$subdir}" _git_apply_color "${workdir/*\/}${subdir:+/$subdir}" "color.sh.workdir" "blue bold" } # determine whether color should be enabled. this checks git's color.ui # option and then color.sh. _git_color_enabled() { [ `git config --get-colorbool color.sh true` = "true" ] } # apply a color to the first argument _git_apply_color() { local output="$1" color="$2" default="$3" if _git_color_enabled ; then color=`_git_color "$color" "$default"` echo -ne "${color}${output}${ANSI_RESET}" else echo -ne "$output" fi } # retrieve an ANSI color escape sequence from git config _git_color() { local color color=`git config --get-color "$1" "$2" 2>/dev/null` [ -n "$color" ] && echo -ne "\001$color\002" } # HELP ======================================================================== _help_display() { local name value # show git's inbuilt help, after some tweaking... git --help | grep -v "See 'git help" # show aliases defined in ~/.gitconfig echo "Command aliases:" git config --get-regexp 'alias\..*' | sed 's/^alias\.//' | sort | while read name value do printf " %-10s %-65s\n" "$name" "$value" done printf "\nSee 'help COMMAND' for more information on a specific command.\n" } help() { local _git_pager=$(git config core.pager) if [ $# = 1 ]; then git help $1 else (_help_display | ${_git_pager:-${PAGER:-less}}) fi } complete -o default -o nospace -F _git help # vim: tw=80 noexpandtab