inotify-commit, was Re: git guidance

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

[long Cc: list culled, as they probably forgot about this thread]

On Fri, 7 Dec 2007, Björn Steinbrink wrote:

> That said, out of pure curiousness I came up with the attached script 
> which just uses inotifywait to watch a directory and issue git commands 
> on certain events. It is extremely stupid, but seems to work. And at 
> least it hasn't got the drawbacks of a real gitfs regarding the need to 
> have a "separate" non-versioned storage area for the working directory, 
> because it simply uses the existing working directory wherever that 
> might be stored. It doesn't use GIT_DIR/WORK_DIR yet, but hey, should be 
> easy to add...
> 
> Feel free to mess with that thing, hey, maybe you even like it and
> extend it to match your proposed workflow even more. I for sure won't
> use or even extend it, so you're likely on your own there.
> 
> Side-note: Writing that script probably took less time than writing this
> email and probably less time than was wasted on this topic. Makes me
> want to use today's preferred "Code talks, b...s... walks" statement,
> but I'll refrain from that... Just because I lack the credibility to say
> that, and the script attached is quite crappy ;-)

I could not agree more with the statement.

As it happens, I have a very delicate setup that we tested in a test 
environment as much as possible, but now we have to deploy it and I want 
to be able to rewind very quickly to a known-good state.

So I adjusted your script a little.  It now reads like this:

-- snip --
#!/bin/sh

# Originally by Bjoern Steinbrink, simplified by Johannes Schindelin

inotifywait -m -r --exclude ^\./\.git/.* \
        -e close_write -e move -e create -e delete . 2>/dev/null |
while read FILE_PATH EVENT FILE_NAME
do
        FILE_NAME="$FILE_PATH$FILE_NAME"
        FILE_NAME=${FILE_NAME#./}

        # git doesn't care about directories
        test -d "$FILE_NAME" && continue

        case "$EVENT" in
        *MOVED_TO*|*CREATE*)
                git add "$FILE_NAME"
                git commit -m "$FILE_NAME created"
                ;;
        *CLOSE_WRITE*|*MODIFY*)
                git add "$FILE_NAME"
                git commit -m "$FILE_NAME changed"
                ;;
        *DELETE*|*MOVED_FROM*)
                git rm --cached "$FILE_NAME"
                git commit -m "$FILE_NAME removed"
                ;;
        esac
done
-- snap --

Thanks for your original script!

Ciao,
Dscho

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]