Git development
 help / color / mirror / Atom feed
From: "Dirk Süsserott" <newsletter@dirk.my1.cc>
To: Git Mailing List <git@vger.kernel.org>
Subject: How to make git diff-* ignore some patterns?
Date: Sat, 21 Nov 2009 17:40:14 +0100	[thread overview]
Message-ID: <4B0817EE.1040000@dirk.my1.cc> (raw)

Hi list,

is there a way to tell "git diff-index" to ignore some special patterns, 
such that /^-- Dump completed on .*$/ is NOT recognized as a difference 
and "git diff-index" returns 0 if that's the only difference?

     -- Dirk

<Background>
I have a mySQL database which I backup daily using mysqldump (cronjob).
The result is a text file (*.sql) with all the "create" and "insert"
statements and some metadata.
I used to use tar and gzip to backup these files and got a huge
collection of backups in the last tree years (500+ MB).
Then I switched to Git and recorded only the diffs between day X and day
X-1. My repository shrunk to 16 MB for the very same data, which was great!

My database doesn't change every day, but I backup it anway and store 
the backup files with Git and a cronjob. It does:

---------------
mysqldump ... -r <backupfile> # that's the output file ;-)
git add <backupfile>
if ! git diff-index --quiet HEAD --; then
     git commit -m "Backup of <database> at <timestamp>"
fi
---------------

This way, a new commit is only done when the backupfile has changed. So 
far, so perfect.
A few days ago my web hoster (where the database actually resides) 
changed the mySQL version.
mysqldump now writes "-- Dump completed on <timestamp>" to the file and 
Git correctly recognizes this as a change and my script creates a new 
commit. Every day, even if only that line has changed.

I'd like to skip these commits if only the "Dump completed" line has 
changed.
</Background>

             reply	other threads:[~2009-11-21 16:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-21 16:40 Dirk Süsserott [this message]
2009-11-21 17:31 ` How to make git diff-* ignore some patterns? Michael J Gruber
2009-11-21 18:07 ` Björn Steinbrink
2009-11-22 15:51   ` Dirk Süsserott

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B0817EE.1040000@dirk.my1.cc \
    --to=newsletter@dirk.my1.cc \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox