mirror of
https://github.com/tj/git-extras.git
synced 2026-09-13 00:46:26 -04:00
Merge pull request #131 from nickl-/develop
general fixes and improvements pt 3
This commit is contained in:
commit
7f324175de
38
bin/git-undo
38
bin/git-undo
|
|
@ -1,27 +1,19 @@
|
|||
#!/bin/sh
|
||||
|
||||
hard='no'
|
||||
digit=1
|
||||
back="^"
|
||||
|
||||
parseArgs () {
|
||||
for var in "$@"; do
|
||||
if [ "$var" = "--hard" -o "$var" = "-h" ]; then
|
||||
hard='yes';
|
||||
elif `echo $var | grep -q [^[:digit:]]`; then
|
||||
echo "You entered an invalid option. Valid options are [--hard|-h] [commitcount]." 1>&2
|
||||
exit 1;
|
||||
else
|
||||
digit=$var
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
parseArgs $@
|
||||
|
||||
if [ "$hard" = "yes" ]; then
|
||||
git reset --hard HEAD~$digit
|
||||
else
|
||||
git reset --soft HEAD~$digit
|
||||
git reset
|
||||
fi
|
||||
case "$1" in
|
||||
-h|--hard)
|
||||
test $2 -gt 1 > /dev/null 2>&1 && back="~$2"
|
||||
git reset --hard HEAD$back && exit 0;
|
||||
;;
|
||||
-s|--soft)
|
||||
test $2 -gt 1 > /dev/null 2>&1 && back="~$2"
|
||||
;;
|
||||
*)
|
||||
test $1 -gt 1 > /dev/null 2>&1 && back="~$1"
|
||||
;;
|
||||
esac
|
||||
|
||||
git reset --soft HEAD$back
|
||||
git reset
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
# bash completion support for git-extras.
|
||||
|
||||
_git_bug(){
|
||||
__git_extras_workflow "bug"
|
||||
}
|
||||
|
||||
_git_changelog(){
|
||||
__gitcomp "--list"
|
||||
}
|
||||
|
|
@ -28,6 +32,14 @@ _git_extras(){
|
|||
__gitcomp "--version update"
|
||||
}
|
||||
|
||||
__git_extras_workflow(){
|
||||
__gitcomp "$(__git_heads | grep ^$1/ | sed s/^$1\\///g) finish"
|
||||
}
|
||||
|
||||
_git_feature(){
|
||||
__git_extras_workflow "feature"
|
||||
}
|
||||
|
||||
_git_graft(){
|
||||
__gitcomp "$(__git_heads)"
|
||||
}
|
||||
|
|
@ -45,22 +57,14 @@ _git_ignore(){
|
|||
esac
|
||||
}
|
||||
|
||||
_git_squash(){
|
||||
__gitcomp "$(__git_heads)"
|
||||
}
|
||||
|
||||
__git_extras_workflow(){
|
||||
__gitcomp "$(__git_heads | grep ^$1/ | sed s/^$1\\///g) finish"
|
||||
}
|
||||
|
||||
_git_feature(){
|
||||
__git_extras_workflow "feature"
|
||||
}
|
||||
|
||||
_git_refactor(){
|
||||
__git_extras_workflow "refactor"
|
||||
}
|
||||
|
||||
_git_bug(){
|
||||
__git_extras_workflow "bug"
|
||||
_git_squash(){
|
||||
__gitcomp "$(__git_heads)"
|
||||
}
|
||||
|
||||
_git_undo(){
|
||||
__gitcomp "--hard --soft -h -s"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,16 +7,16 @@
|
|||
\fBgit\-undo\fR \- Remove latest commits
|
||||
.
|
||||
.SH "SYNOPSIS"
|
||||
\fBgit\-undo\fR [<commitcount>] [\-\-hard|\-h]
|
||||
\fBgit\-undo\fR [<commitcount>] [\-s, \-\-soft, \-h, \-\-hard]
|
||||
.
|
||||
.SH "DESCRIPTION"
|
||||
Removes the latest commits\.
|
||||
.
|
||||
.SH "OPTIONS"
|
||||
<commitcount>
|
||||
\-\-soft or \-s
|
||||
.
|
||||
.P
|
||||
Number of commits to remove\. Defaults to \fI1\fR, thus remove the latest commit\.
|
||||
This is the default, only rolls back the commit but changes remain un\-staged\.
|
||||
.
|
||||
.P
|
||||
\-\-hard or \-h
|
||||
|
|
@ -24,6 +24,12 @@ Number of commits to remove\. Defaults to \fI1\fR, thus remove the latest commit
|
|||
.P
|
||||
This option wipes your commit(s), so that your changes cannot be recovered\. Use with care\.
|
||||
.
|
||||
.P
|
||||
<commitcount>
|
||||
.
|
||||
.P
|
||||
Number of commits to remove\. Defaults to \fI1\fR, thus remove the latest commit\.
|
||||
.
|
||||
.SH "EXAMPLES"
|
||||
Removes the latest commit\.
|
||||
.
|
||||
|
|
@ -51,7 +57,7 @@ $ git undo 3
|
|||
.IP "" 0
|
||||
.
|
||||
.SH "AUTHOR"
|
||||
Written by Kenneth Reitz <\fIme@kennethreitz\.com\fR>
|
||||
Written by Kenneth Reitz <\fIme@kennethreitz\.com\fR> and Nick Lombard <\fIgithub@jigsoft\.co\.za\fR>
|
||||
.
|
||||
.SH "REPORTING BUGS"
|
||||
<\fIhttp://github\.com/visionmedia/git\-extras/issues\fR>
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@
|
|||
|
||||
<h2 id="SYNOPSIS">SYNOPSIS</h2>
|
||||
|
||||
<p><code>git-undo</code> [<commitcount>] [--hard|-h]</p>
|
||||
<p><code>git-undo</code> [<commitcount>] [-s, --soft, -h, --hard]</p>
|
||||
|
||||
<h2 id="DESCRIPTION">DESCRIPTION</h2>
|
||||
|
||||
|
|
@ -84,14 +84,18 @@
|
|||
|
||||
<h2 id="OPTIONS">OPTIONS</h2>
|
||||
|
||||
<p> <commitcount></p>
|
||||
<p> --soft or -s</p>
|
||||
|
||||
<p> Number of commits to remove. Defaults to <em>1</em>, thus remove the latest commit.</p>
|
||||
<p> This is the default, only rolls back the commit but changes remain un-staged.</p>
|
||||
|
||||
<p> --hard or -h</p>
|
||||
|
||||
<p> This option wipes your commit(s), so that your changes cannot be recovered. Use with care.</p>
|
||||
|
||||
<p> <commitcount></p>
|
||||
|
||||
<p> Number of commits to remove. Defaults to <em>1</em>, thus remove the latest commit.</p>
|
||||
|
||||
<h2 id="EXAMPLES">EXAMPLES</h2>
|
||||
|
||||
<p> Removes the latest commit.</p>
|
||||
|
|
@ -106,7 +110,7 @@
|
|||
|
||||
<h2 id="AUTHOR">AUTHOR</h2>
|
||||
|
||||
<p>Written by Kenneth Reitz <<a href="mailto:me@kennethreitz.com" data-bare-link="true">me@kennethreitz.com</a>></p>
|
||||
<p>Written by Kenneth Reitz <<a href="mailto:me@kennethreitz.com" data-bare-link="true">me@kennethreitz.com</a>> and Nick Lombard <<a href="mailto:github@jigsoft.co.za" data-bare-link="true">github@jigsoft.co.za</a>></p>
|
||||
|
||||
<h2 id="REPORTING-BUGS">REPORTING BUGS</h2>
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ git-undo(1) -- Remove latest commits
|
|||
|
||||
## SYNOPSIS
|
||||
|
||||
`git-undo` [<commitcount>] [--hard|-h]
|
||||
`git-undo` [<commitcount>] [-s, --soft, -h, --hard]
|
||||
|
||||
## DESCRIPTION
|
||||
|
||||
|
|
@ -11,14 +11,18 @@ git-undo(1) -- Remove latest commits
|
|||
|
||||
## OPTIONS
|
||||
|
||||
<commitcount>
|
||||
--soft or -s
|
||||
|
||||
Number of commits to remove. Defaults to *1*, thus remove the latest commit.
|
||||
This is the default, only rolls back the commit but changes remain un-staged.
|
||||
|
||||
--hard or -h
|
||||
|
||||
This option wipes your commit(s), so that your changes cannot be recovered. Use with care.
|
||||
|
||||
<commitcount>
|
||||
|
||||
Number of commits to remove. Defaults to *1*, thus remove the latest commit.
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
Removes the latest commit.
|
||||
|
|
@ -31,7 +35,7 @@ git-undo(1) -- Remove latest commits
|
|||
|
||||
## AUTHOR
|
||||
|
||||
Written by Kenneth Reitz <<me@kennethreitz.com>>
|
||||
Written by Kenneth Reitz <<me@kennethreitz.com>> and Nick Lombard <<github@jigsoft.co.za>>
|
||||
|
||||
## REPORTING BUGS
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue