[Vm-dev] Script needed; git mavens can you help?
Tobias Pape
Das.Linux at gmx.de
Mon Jun 20 21:09:46 UTC 2016
On 20.06.2016, at 22:40, Eliot Miranda <eliot.miranda at gmail.com> wrote:
> Hi git mavens,
>
> I've used a script called svnrevert in the svn version that reverts any changed file in its argument(s), which may be directories, /and/ sets the modification date to the date at which the file was last checked in. I'd like the same functionality in git. Her'es the subversion version:
without the modification-date requirement
git checkout -- ....
does what you want (given you have NOT staged/git-added it before).
I'm curious, what's important about the last commit date?
Best regards
-Tobias
>
> #!/bin/bash
> # Revert file(s) or all modified files in a directory
> # and touch them back to the checkin date
> for f in "$@"
> do
> if [ -d "$f" ]; then
> $0 `svn st "$f" | grep "^M" | sed 's/^M *//'`
> else
> if svn revert "$f"; then
> changed="`svn info \"$f\" | grep 'Last Changed Date:' | sed 's/ *(.*//'`"
> touch -t "`date -j -f 'Last Changed Date: %Y-%m-%d %H:%M:%S %z' \"$changed\" '+%Y%m%d%H%M.%S'`" "$f"
> fi
> fi
> done
>
> _,,,^..^,,,_
> best, Eliot
More information about the Vm-dev
mailing list