<div dir="ltr">But the move is right before the "if <GIT>" clause.. when not make that clause into a "if <NOT GIT> mv else git mv"?<div><br></div><div style>Having this be a git mv when appropriate would make the git log more clear.</div>
<div style><br></div><div style>Von</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Apr 15, 2013 at 4:44 PM, Brian Mattern <span dir="ltr"><<a href="mailto:rephorm@rephorm.com" target="_blank">rephorm@rephorm.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">To answer my own question, you've already moved the file, so can't use<br>
git mv.<br>
<br>
Sorry for the overly-quick question :)<br>
<span class="HOEnZb"><font color="#888888"><br>
Brian<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On Mon, 15 Apr 2013, Brian Mattern wrote:<br>
<br>
> Is there a reason you don't use git mv?<br>
><br>
> Brian<br>
><br>
> On Mon, 15 Apr 2013, Laurent Navet wrote:<br>
><br>
> > Allow to move and rearrange branches in password tree<br>
> ><br>
> > Signed-off-by: Laurent Navet <<a href="mailto:laurent.navet@gmail.com">laurent.navet@gmail.com</a>><br>
> > ---<br>
> > src/password-store.sh | 43 ++++++++++++++++++++++++++++++++++++++++++-<br>
> > 1 file changed, 42 insertions(+), 1 deletion(-)<br>
> ><br>
> > diff --git a/src/password-store.sh b/src/password-store.sh<br>
> > index 99010e9..2cad6a4 100755<br>
> > --- a/src/password-store.sh<br>
> > +++ b/src/password-store.sh<br>
> > @@ -42,6 +42,8 @@ Usage:<br>
> > Insert new password. Optionally, the console can be enabled echo<br>
> > the password back. Or, optionally, it may be multiline. Prompt<br>
> > before overwriting existing password unless forced.<br>
> > + $program move [--force,-f] old-pass-name new-pass-name<br>
> > + Allow to move and rearrange branches<br>
> > $program edit pass-name<br>
> > Insert a new password or edit an existing password using ${EDITOR:-vi}.<br>
> > $program generate [--no-symbols,-n] [--clip,-c] [--force,-f] pass-name pass-length<br>
> > @@ -63,7 +65,7 @@ _EOF<br>
> > }<br>
> > is_command() {<br>
> > case "$1" in<br>
> > - init|ls|list|show|insert|edit|generate|remove|rm|delete|git|help|--help|version|--version) return 0 ;;<br>
> > + init|ls|list|show|insert|move|edit|generate|remove|rm|delete|git|help|--help|version|--version) return 0 ;;<br>
> > *) return 1 ;;<br>
> > esac<br>
> > }<br>
> > @@ -278,6 +280,45 @@ case "$command" in<br>
> > fi<br>
> > git_add_file "$passfile" "Added given password for $path to store."<br>
> > ;;<br>
> > + move)<br>
> > + force=0<br>
> > + opts="$($GETOPT -o f -l force -n "$program" -- "$@")"<br>
> > + err=$?<br>
> > + eval set -- "$opts"<br>
> > + while true; do case $1 in<br>
> > + -f|--force) force=1; shift ;;<br>
> > + --) shift; break ;;<br>
> > + esac done<br>
> > +<br>
> > + if [[ $# -ne 2 ]]; then<br>
> > + echo "Usage: $program $command [--force,-f] old-pass-name new-pass-name"<br>
> > + exit 1<br>
> > + fi<br>
> > +<br>
> > + oldpath="$1"<br>
> > + newpath="$2"<br>
> > + oldpassfile="$PREFIX/${oldpath%/}"<br>
> > + newpassfile="$PREFIX/${newpath%/}"<br>
> > +<br>
> > + if [[ ! -d $oldpassfile ]]; then<br>
> > + oldpassfile="$PREFIX/$oldpath.gpg"<br>
> > + if [[ ! -f $oldpassfile ]]; then<br>
> > + echo "$oldpath is not in the password store."<br>
> > + exit 1<br>
> > + else<br>
> > + newpassfile="$PREFIX/$newpath.gpg"<br>
> > + fi<br>
> > + fi<br>
> > +<br>
> > + [[ $force -eq 1 ]] || yesno "Are you sure you would like to move $oldpath to $newpath ?"<br>
> > +<br>
> > + mv -f -v $oldpassfile $newpassfile<br>
> > + if [[ -d $GIT_DIR && -e $newpassfile ]]; then<br>
> > + git rm -qr "$oldpassfile"<br>
> > + git_add_file "$newpassfile" "Moved $oldpassfile to $newpassfile."<br>
> > + git commit -m "Moved $oldpath to $newpath."<br>
> > + fi<br>
> > + ;;<br>
> > edit)<br>
> > if [[ $# -ne 1 ]]; then<br>
> > echo "Usage: $program $command pass-name"<br>
> > --<br>
> > 1.7.10.4<br>
> ><br>
> > _______________________________________________<br>
> > Password-Store mailing list<br>
> > <a href="mailto:Password-Store@lists.zx2c4.com">Password-Store@lists.zx2c4.com</a><br>
> > <a href="http://lists.zx2c4.com/listinfo.cgi/password-store-zx2c4.com" target="_blank">http://lists.zx2c4.com/listinfo.cgi/password-store-zx2c4.com</a><br>
> _______________________________________________<br>
> Password-Store mailing list<br>
> <a href="mailto:Password-Store@lists.zx2c4.com">Password-Store@lists.zx2c4.com</a><br>
> <a href="http://lists.zx2c4.com/listinfo.cgi/password-store-zx2c4.com" target="_blank">http://lists.zx2c4.com/listinfo.cgi/password-store-zx2c4.com</a><br>
_______________________________________________<br>
Password-Store mailing list<br>
<a href="mailto:Password-Store@lists.zx2c4.com">Password-Store@lists.zx2c4.com</a><br>
<a href="http://lists.zx2c4.com/listinfo.cgi/password-store-zx2c4.com" target="_blank">http://lists.zx2c4.com/listinfo.cgi/password-store-zx2c4.com</a><br>
</div></div></blockquote></div><br></div>