mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-13 23:31:08 +02:00
Frank Terbeck: 26549: VCS_Info improvements: check for changes in git
This commit is contained in:
parent
b0066bc202
commit
76f05a9932
14 changed files with 86 additions and 15 deletions
17
ChangeLog
17
ChangeLog
|
@ -1,5 +1,20 @@
|
||||||
2009-02-11 Peter Stephenson <pws@csr.com>
|
2009-02-11 Peter Stephenson <pws@csr.com>
|
||||||
|
|
||||||
|
* Frank Terbeck: 26549: Doc/Zsh/contrib.yo,
|
||||||
|
Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr,
|
||||||
|
Functions/VCS_Info/Backends/VCS_INFO_get_data_cdv,
|
||||||
|
Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs,
|
||||||
|
Functions/VCS_Info/Backends/VCS_INFO_get_data_darcs,
|
||||||
|
Functions/VCS_Info/Backends/VCS_INFO_get_data_git,
|
||||||
|
Functions/VCS_Info/Backends/VCS_INFO_get_data_hg,
|
||||||
|
Functions/VCS_Info/Backends/VCS_INFO_get_data_mtn,
|
||||||
|
Functions/VCS_Info/Backends/VCS_INFO_get_data_p4,
|
||||||
|
Functions/VCS_Info/Backends/VCS_INFO_get_data_svk,
|
||||||
|
Functions/VCS_Info/Backends/VCS_INFO_get_data_svn,
|
||||||
|
Functions/VCS_Info/Backends/VCS_INFO_get_data_tla,
|
||||||
|
Functions/VCS_Info/VCS_INFO_formats: improvements to VCS_Info:
|
||||||
|
check for changes in git.
|
||||||
|
|
||||||
* Richard Hartmann: 26547: Doc/Zsh/options.yo: further extension
|
* Richard Hartmann: 26547: Doc/Zsh/options.yo: further extension
|
||||||
to option indexing: NOoptions without underscore.
|
to option indexing: NOoptions without underscore.
|
||||||
|
|
||||||
|
@ -11133,5 +11148,5 @@
|
||||||
|
|
||||||
*****************************************************
|
*****************************************************
|
||||||
* This is used by the shell to define $ZSH_PATCHLEVEL
|
* This is used by the shell to define $ZSH_PATCHLEVEL
|
||||||
* $Revision: 1.4559 $
|
* $Revision: 1.4560 $
|
||||||
*****************************************************
|
*****************************************************
|
||||||
|
|
|
@ -516,6 +516,27 @@ Say, tt(~/.zsh) is a directory under version control, in which you do
|
||||||
not want var(vcs_info) to be active, do:
|
not want var(vcs_info) to be active, do:
|
||||||
example(zstyle ':vcs_info:*' disable-patterns "$HOME/.zsh+LPAR()|/*+RPAR()")
|
example(zstyle ':vcs_info:*' disable-patterns "$HOME/.zsh+LPAR()|/*+RPAR()")
|
||||||
)
|
)
|
||||||
|
kindex(check-for-changes)
|
||||||
|
item(tt(check-for-changes))(
|
||||||
|
If enabled, this style (currently only used by the tt(git) backend) causes the
|
||||||
|
tt(%c) and tt(%u) format escapes to be filled with information. The strings
|
||||||
|
filled into these escapes can be controlled via the var(stagedstr) and
|
||||||
|
var(unstagedstr) styles.
|
||||||
|
|
||||||
|
Note, that the actions taken if this style is enabled are potentially expensive
|
||||||
|
(read: they take time, depending on how big the current repository is).
|
||||||
|
Therefore, it is disabled by default.
|
||||||
|
)
|
||||||
|
kindex(stagedstr)
|
||||||
|
item(tt(stagedstr))(
|
||||||
|
This string will be used in the tt(%c) escape if there are staged changes in
|
||||||
|
the repository.
|
||||||
|
)
|
||||||
|
kindex(unstagedstr)
|
||||||
|
item(tt(unstagedstr))(
|
||||||
|
This string will be used in the tt(%u) escape if there are unstaged changes in
|
||||||
|
the repository.
|
||||||
|
)
|
||||||
kindex(command)
|
kindex(command)
|
||||||
item(tt(command))(
|
item(tt(command))(
|
||||||
This style causes var(vcs_info) to use the supplied string as the command
|
This style causes var(vcs_info) to use the supplied string as the command
|
||||||
|
@ -576,7 +597,12 @@ sitem(tt(nvcsformats))("")
|
||||||
sitem(tt(max-exports))(2)
|
sitem(tt(max-exports))(2)
|
||||||
sitem(tt(enable))(ALL)
|
sitem(tt(enable))(ALL)
|
||||||
sitem(tt(disable))((empty list))
|
sitem(tt(disable))((empty list))
|
||||||
|
sitem(tt(disable-patterns))((empty list))
|
||||||
|
sitem(tt(check-for-changes))(false)
|
||||||
|
sitem(tt(stagedstr))((string: "S"))
|
||||||
|
sitem(tt(unstagedstr))((string: "U"))
|
||||||
sitem(tt(command))((empty string))
|
sitem(tt(command))((empty string))
|
||||||
|
sitem(tt(use-server))(false)
|
||||||
sitem(tt(use-simple))(false)
|
sitem(tt(use-simple))(false)
|
||||||
sitem(tt(use-prompt-escapes))(true)
|
sitem(tt(use-prompt-escapes))(true)
|
||||||
endsitem()
|
endsitem()
|
||||||
|
@ -589,6 +615,10 @@ sitem(tt(%s))(The vcs in use (git, hg, svn etc.))
|
||||||
sitem(tt(%b))(Information about the current branch.)
|
sitem(tt(%b))(Information about the current branch.)
|
||||||
sitem(tt(%a))(An identifier, that describes the action. Only makes sense in
|
sitem(tt(%a))(An identifier, that describes the action. Only makes sense in
|
||||||
actionformats.)
|
actionformats.)
|
||||||
|
sitem(tt(%c))(The string from the var(stagedstr) style if there are staged
|
||||||
|
changes in the repository.)
|
||||||
|
sitem(tt(%u))(The string from the var(unstagedstr) style if there are unstaged
|
||||||
|
changes in the repository.)
|
||||||
sitem(tt(%R))(base directory of the repository.)
|
sitem(tt(%R))(base directory of the repository.)
|
||||||
sitem(tt(%r))(repository name. If tt(%R) is var(/foo/bar/repoXY), tt(%r) is
|
sitem(tt(%r))(repository name. If tt(%R) is var(/foo/bar/repoXY), tt(%r) is
|
||||||
var(repoXY).)
|
var(repoXY).)
|
||||||
|
|
|
@ -22,5 +22,5 @@ fi
|
||||||
rrn=${bzrbase:t}
|
rrn=${bzrbase:t}
|
||||||
zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat bzrbr || bzrbr="%b:%r"
|
zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat bzrbr || bzrbr="%b:%r"
|
||||||
zformat -f bzrbr "${bzrbr}" "b:${bzrinfo[2]}" "r:${bzrinfo[1]}"
|
zformat -f bzrbr "${bzrbr}" "b:${bzrinfo[2]}" "r:${bzrinfo[1]}"
|
||||||
VCS_INFO_formats '' "${bzrbr}" "${bzrbase}"
|
VCS_INFO_formats '' "${bzrbr}" "${bzrbase}" '' ''
|
||||||
return 0
|
return 0
|
||||||
|
|
|
@ -7,5 +7,5 @@ local cdvbase
|
||||||
|
|
||||||
cdvbase=${vcs_comm[basedir]}
|
cdvbase=${vcs_comm[basedir]}
|
||||||
rrn=${cdvbase:t}
|
rrn=${cdvbase:t}
|
||||||
VCS_INFO_formats '' "${cdvbase:t}" "${cdvbase}"
|
VCS_INFO_formats '' "${cdvbase:t}" "${cdvbase}" '' ''
|
||||||
return 0
|
return 0
|
||||||
|
|
|
@ -14,5 +14,5 @@ cvsbranch=$(< ./CVS/Repository)
|
||||||
rrn=${cvsbase:t}
|
rrn=${cvsbase:t}
|
||||||
cvsbranch=${cvsbranch##${rrn}/}
|
cvsbranch=${cvsbranch##${rrn}/}
|
||||||
[[ -z ${cvsbranch} ]] && cvsbranch=${rrn}
|
[[ -z ${cvsbranch} ]] && cvsbranch=${rrn}
|
||||||
VCS_INFO_formats '' "${cvsbranch}" "${cvsbase}"
|
VCS_INFO_formats '' "${cvsbranch}" "${cvsbase}" '' ''
|
||||||
return 0
|
return 0
|
||||||
|
|
|
@ -7,5 +7,5 @@ local darcsbase
|
||||||
|
|
||||||
darcsbase=${vcs_comm[basedir]}
|
darcsbase=${vcs_comm[basedir]}
|
||||||
rrn=${darcsbase:t}
|
rrn=${darcsbase:t}
|
||||||
VCS_INFO_formats '' "${darcsbase:t}" "${darcsbase}"
|
VCS_INFO_formats '' "${darcsbase:t}" "${darcsbase}" '' ''
|
||||||
return 0
|
return 0
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
## Distributed under the same BSD-ish license as zsh itself.
|
## Distributed under the same BSD-ish license as zsh itself.
|
||||||
|
|
||||||
setopt localoptions extendedglob NO_shwordsplit
|
setopt localoptions extendedglob NO_shwordsplit
|
||||||
local gitdir gitbase gitbranch gitaction
|
local gitdir gitbase gitbranch gitaction gitunstaged gitstaged
|
||||||
|
|
||||||
VCS_INFO_git_getaction () {
|
VCS_INFO_git_getaction () {
|
||||||
local gitaction='' gitdir=$1
|
local gitaction='' gitdir=$1
|
||||||
|
@ -96,9 +96,17 @@ if [[ -z ${gitdir} ]] || [[ -z ${gitbranch} ]] ; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" "check-for-changes" ; then
|
||||||
|
# Default: off - these are potentially expensive on big repositories
|
||||||
|
${vcs_comm[cmd]} diff --no-ext-diff --ignore-submodules --quiet --exit-code ||
|
||||||
|
gitunstaged=1
|
||||||
|
${vcs_comm[cmd]} diff-index --cached --quiet --ignore-submodules HEAD ||
|
||||||
|
gitstaged=1
|
||||||
|
fi
|
||||||
|
|
||||||
VCS_INFO_adjust
|
VCS_INFO_adjust
|
||||||
gitaction="$(VCS_INFO_git_getaction ${gitdir})"
|
gitaction="$(VCS_INFO_git_getaction ${gitdir})"
|
||||||
gitbase=${PWD%/${$( ${vcs_comm[cmd]} rev-parse --show-prefix )%/##}}
|
gitbase=${PWD%/${$( ${vcs_comm[cmd]} rev-parse --show-prefix )%/##}}
|
||||||
rrn=${gitbase:t}
|
rrn=${gitbase:t}
|
||||||
VCS_INFO_formats "${gitaction}" "${gitbranch}" "${gitbase}"
|
VCS_INFO_formats "${gitaction}" "${gitbranch}" "${gitbase}" "${gitstaged}" "${gitunstaged}"
|
||||||
return 0
|
return 0
|
||||||
|
|
|
@ -8,5 +8,5 @@ local hgbranch hgbase
|
||||||
hgbase=${vcs_comm[basedir]}
|
hgbase=${vcs_comm[basedir]}
|
||||||
rrn=${hgbase:t}
|
rrn=${hgbase:t}
|
||||||
hgbranch=$(< ${hgbase}/.hg/branch)
|
hgbranch=$(< ${hgbase}/.hg/branch)
|
||||||
VCS_INFO_formats '' "${hgbranch}" "${hgbase}"
|
VCS_INFO_formats '' "${hgbranch}" "${hgbase}" '' ''
|
||||||
return 0
|
return 0
|
||||||
|
|
|
@ -8,5 +8,5 @@ local mtnbranch mtnbase
|
||||||
mtnbase=${vcs_comm[basedir]}
|
mtnbase=${vcs_comm[basedir]}
|
||||||
rrn=${mtnbase:t}
|
rrn=${mtnbase:t}
|
||||||
mtnbranch=${${(M)${(f)"$( ${vcs_comm[cmd]} status )"}:#(#s)Current branch:*}/*: /}
|
mtnbranch=${${(M)${(f)"$( ${vcs_comm[cmd]} status )"}:#(#s)Current branch:*}/*: /}
|
||||||
VCS_INFO_formats '' "${mtnbranch}" "${mtnbase}"
|
VCS_INFO_formats '' "${mtnbranch}" "${mtnbase}" '' ''
|
||||||
return 0
|
return 0
|
||||||
|
|
|
@ -21,4 +21,4 @@ p4branch="%b:%r"
|
||||||
zformat -f p4branch "${p4branch}" "b:${p4info[Client_name]}" \
|
zformat -f p4branch "${p4branch}" "b:${p4info[Client_name]}" \
|
||||||
"r:$change"
|
"r:$change"
|
||||||
|
|
||||||
VCS_INFO_formats '' "${p4branch}" "${p4base}"
|
VCS_INFO_formats '' "${p4branch}" "${p4base}" '' ''
|
||||||
|
|
|
@ -9,5 +9,5 @@ svkbase=${vcs_comm[basedir]}
|
||||||
rrn=${svkbase:t}
|
rrn=${svkbase:t}
|
||||||
zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat svkbranch || svkbranch="%b:%r"
|
zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat svkbranch || svkbranch="%b:%r"
|
||||||
zformat -f svkbranch "${svkbranch}" "b:${vcs_comm[branch]}" "r:${vcs_comm[revision]}"
|
zformat -f svkbranch "${svkbranch}" "b:${vcs_comm[branch]}" "r:${vcs_comm[revision]}"
|
||||||
VCS_INFO_formats '' "${svkbranch}" "${svkbase}"
|
VCS_INFO_formats '' "${svkbranch}" "${svkbase}" '' ''
|
||||||
return 0
|
return 0
|
||||||
|
|
|
@ -24,5 +24,5 @@ svnbase="$(VCS_INFO_realpath ${svnbase})"
|
||||||
rrn=${svnbase:t}
|
rrn=${svnbase:t}
|
||||||
zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat svnbranch || svnbranch="%b:%r"
|
zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat svnbranch || svnbranch="%b:%r"
|
||||||
zformat -f svnbranch "${svnbranch}" "b:${svninfo[URL]##*/}" "r:${svninfo[Revision]}"
|
zformat -f svnbranch "${svnbranch}" "b:${svninfo[URL]##*/}" "r:${svninfo[Revision]}"
|
||||||
VCS_INFO_formats '' "${svnbranch}" "${svnbase}"
|
VCS_INFO_formats '' "${svnbranch}" "${svnbase}" '' ''
|
||||||
return 0
|
return 0
|
||||||
|
|
|
@ -9,5 +9,5 @@ tlabase="$(VCS_INFO_realpath ${vcs_comm[basedir]})"
|
||||||
rrn=${tlabase:t}
|
rrn=${tlabase:t}
|
||||||
# tree-id gives us something like 'foo@example.com/demo--1.0--patch-4', so:
|
# tree-id gives us something like 'foo@example.com/demo--1.0--patch-4', so:
|
||||||
tlabranch=${${"$( ${vcs_comm[cmd]} tree-id )"}/*\//}
|
tlabranch=${${"$( ${vcs_comm[cmd]} tree-id )"}/*\//}
|
||||||
VCS_INFO_formats '' "${tlabranch}" "${tlabase}"
|
VCS_INFO_formats '' "${tlabranch}" "${tlabase}" '' ''
|
||||||
return 0
|
return 0
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
## Distributed under the same BSD-ish license as zsh itself.
|
## Distributed under the same BSD-ish license as zsh itself.
|
||||||
|
|
||||||
setopt localoptions noksharrays NO_shwordsplit
|
setopt localoptions noksharrays NO_shwordsplit
|
||||||
local action=$1 branch=$2 base=$3
|
local action=$1 branch=$2 base=$3 staged=$4 unstaged=$5
|
||||||
local msg
|
local msg
|
||||||
local -i i j
|
local -i i j
|
||||||
|
|
||||||
|
@ -15,9 +15,27 @@ else
|
||||||
(( ${#msgs} < 1 )) && msgs[1]=' (%s)-[%b]-'
|
(( ${#msgs} < 1 )) && msgs[1]=' (%s)-[%b]-'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -n ${staged} ]] ; then
|
||||||
|
zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" stagedstr staged
|
||||||
|
[[ -z ${staged} ]] && staged='S'
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n ${unstaged} ]] ; then
|
||||||
|
zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" unstagedstr unstaged
|
||||||
|
[[ -z ${unstaged} ]] && unstaged='U'
|
||||||
|
fi
|
||||||
|
|
||||||
(( ${#msgs} > maxexports )) && msgs[$(( maxexports + 1 )),-1]=()
|
(( ${#msgs} > maxexports )) && msgs[$(( maxexports + 1 )),-1]=()
|
||||||
for i in {1..${#msgs}} ; do
|
for i in {1..${#msgs}} ; do
|
||||||
zformat -f msg ${msgs[$i]} a:${action} b:${branch} s:${vcs} r:${base:t} R:${base} S:"$(VCS_INFO_reposub ${base})"
|
zformat -f msg ${msgs[$i]} \
|
||||||
|
a:${action} \
|
||||||
|
b:${branch} \
|
||||||
|
c:${staged} \
|
||||||
|
r:${base:t} \
|
||||||
|
s:${vcs} \
|
||||||
|
u:${unstaged} \
|
||||||
|
R:${base} \
|
||||||
|
S:"$(VCS_INFO_reposub ${base})"
|
||||||
msgs[$i]=${msg}
|
msgs[$i]=${msg}
|
||||||
done
|
done
|
||||||
return 0
|
return 0
|
||||||
|
|
Loading…
Reference in a new issue