[pass] [PATCH] Add move option

Von Welch von at vwelch.com
Mon Apr 15 22:52:48 CEST 2013


But the move is right before the "if <GIT>" clause.. when not make that
clause into a "if <NOT GIT> mv else git mv"?

Having this be a git mv when appropriate would make the git log more clear.

Von


On Mon, Apr 15, 2013 at 4:44 PM, Brian Mattern <rephorm at rephorm.com> wrote:

> To answer my own question, you've already moved the file, so can't use
> git mv.
>
> Sorry for the overly-quick question :)
>
> Brian
>
> On Mon, 15 Apr 2013, Brian Mattern wrote:
>
> > Is there a reason you don't use git mv?
> >
> > Brian
> >
> > On Mon, 15 Apr 2013, Laurent Navet wrote:
> >
> > > Allow to move and rearrange branches in password tree
> > >
> > > Signed-off-by: Laurent Navet <laurent.navet at gmail.com>
> > > ---
> > >  src/password-store.sh |   43
> ++++++++++++++++++++++++++++++++++++++++++-
> > >  1 file changed, 42 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/src/password-store.sh b/src/password-store.sh
> > > index 99010e9..2cad6a4 100755
> > > --- a/src/password-store.sh
> > > +++ b/src/password-store.sh
> > > @@ -42,6 +42,8 @@ Usage:
> > >          Insert new password. Optionally, the console can be enabled
> echo
> > >          the password back. Or, optionally, it may be multiline. Prompt
> > >          before overwriting existing password unless forced.
> > > +    $program move [--force,-f] old-pass-name new-pass-name
> > > +        Allow to move and rearrange branches
> > >      $program edit pass-name
> > >          Insert a new password or edit an existing password using
> ${EDITOR:-vi}.
> > >      $program generate [--no-symbols,-n] [--clip,-c] [--force,-f]
> pass-name pass-length
> > > @@ -63,7 +65,7 @@ _EOF
> > >  }
> > >  is_command() {
> > >     case "$1" in
> > > -
> init|ls|list|show|insert|edit|generate|remove|rm|delete|git|help|--help|version|--version)
> return 0 ;;
> > > +
> init|ls|list|show|insert|move|edit|generate|remove|rm|delete|git|help|--help|version|--version)
> return 0 ;;
> > >             *) return 1 ;;
> > >     esac
> > >  }
> > > @@ -278,6 +280,45 @@ case "$command" in
> > >             fi
> > >             git_add_file "$passfile" "Added given password for $path
> to store."
> > >             ;;
> > > +        move)
> > > +                force=0
> > > +                opts="$($GETOPT -o f -l force -n "$program" -- "$@")"
> > > +                err=$?
> > > +                eval set -- "$opts"
> > > +                while true; do case $1 in
> > > +                        -f|--force) force=1; shift ;;
> > > +                        --) shift; break ;;
> > > +                esac done
> > > +
> > > +                if [[ $# -ne 2 ]]; then
> > > +                        echo "Usage: $program $command [--force,-f]
> old-pass-name new-pass-name"
> > > +                        exit 1
> > > +                fi
> > > +
> > > +                oldpath="$1"
> > > +                newpath="$2"
> > > +                oldpassfile="$PREFIX/${oldpath%/}"
> > > +                newpassfile="$PREFIX/${newpath%/}"
> > > +
> > > +                if [[ ! -d $oldpassfile ]]; then
> > > +                        oldpassfile="$PREFIX/$oldpath.gpg"
> > > +                        if [[ ! -f $oldpassfile ]]; then
> > > +                                echo "$oldpath is not in the password
> store."
> > > +                                exit 1
> > > +                        else
> > > +                                newpassfile="$PREFIX/$newpath.gpg"
> > > +                        fi
> > > +                fi
> > > +
> > > +                [[ $force -eq 1 ]] || yesno "Are you sure you would
> like to move $oldpath to $newpath ?"
> > > +
> > > +                mv -f -v $oldpassfile $newpassfile
> > > +                if [[ -d $GIT_DIR &&  -e $newpassfile ]]; then
> > > +                        git rm -qr "$oldpassfile"
> > > +                        git_add_file "$newpassfile" "Moved
> $oldpassfile to $newpassfile."
> > > +                        git commit -m "Moved $oldpath to $newpath."
> > > +                fi
> > > +                ;;
> > >     edit)
> > >             if [[ $# -ne 1 ]]; then
> > >                     echo "Usage: $program $command pass-name"
> > > --
> > > 1.7.10.4
> > >
> > > _______________________________________________
> > > Password-Store mailing list
> > > Password-Store at lists.zx2c4.com
> > > http://lists.zx2c4.com/listinfo.cgi/password-store-zx2c4.com
> > _______________________________________________
> > Password-Store mailing list
> > Password-Store at lists.zx2c4.com
> > http://lists.zx2c4.com/listinfo.cgi/password-store-zx2c4.com
> _______________________________________________
> Password-Store mailing list
> Password-Store at lists.zx2c4.com
> http://lists.zx2c4.com/listinfo.cgi/password-store-zx2c4.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20130415/ced7d6cd/attachment.html>


More information about the Password-Store mailing list