From: Zak Wilcox Date: Fri, 1 Jun 2012 09:10:36 +0000 (+0100) Subject: Add a --no-check-device option to bup index (cf. tar). X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=1eafa883ab462f73d3edbb3ce10d71706935a29c;p=packages%2Fb%2Fbup.git Add a --no-check-device option to bup index (cf. tar). Ignore stat.st_dev when comparing files against existing index entries, like git does without #define USE_STDEV: http://www.kernel.org/pub/software/scm/git/docs/v1.7.10.1/technical/racy-git.txt See also: "info tar". Signed-off-by: Zak Wilcox [rlb@defaultvalue.org: change original --ignore-dev to --no-check-device to match tar. Adjust code to work with current master. Remove tests -- will be reintroduced shortly.] Signed-off-by: Rob Browning --- diff --git a/cmd/index-cmd.py b/cmd/index-cmd.py index 5a8913d..6f743c6 100755 --- a/cmd/index-cmd.py +++ b/cmd/index-cmd.py @@ -117,7 +117,8 @@ def update_index(top, excluded_paths): # in from_stat(). meta.ctime = meta.mtime = meta.atime = 0 meta_ofs = msw.store(meta) - rig.cur.from_stat(pst, meta_ofs, tstart) + rig.cur.from_stat(pst, meta_ofs, tstart, + check_device=opt.check_device) if not (rig.cur.flags & index.IX_HASHVALID): if hashgen: (rig.cur.gitmode, rig.cur.sha) = hashgen(path) @@ -179,6 +180,7 @@ clear clear the index Options: H,hash print the hash for each object next to its name l,long print more information about each file +no-check-device don't invalidate an entry if the containing device changes fake-valid mark all index entries as up-to-date even if they aren't fake-invalid mark all index entries as invalid f,indexfile= the name of the index file (normally BUP_DIR/bupindex) diff --git a/lib/bup/index.py b/lib/bup/index.py index 4fdb8e4..1f3c777 100644 --- a/lib/bup/index.py +++ b/lib/bup/index.py @@ -174,10 +174,12 @@ class Entry: log('pack error: %s (%r)\n' % (e, self)) raise - def from_stat(self, st, meta_ofs, tstart): - old = (self.dev, self.ino, self.nlink, self.ctime, self.mtime, + def from_stat(self, st, meta_ofs, tstart, check_device=True): + old = (self.dev if check_device else 0, + self.ino, self.nlink, self.ctime, self.mtime, self.uid, self.gid, self.size, self.flags & IX_EXISTS) - new = (st.st_dev, st.st_ino, st.st_nlink, st.st_ctime, st.st_mtime, + new = (st.st_dev if check_device else 0, + st.st_ino, st.st_nlink, st.st_ctime, st.st_mtime, st.st_uid, st.st_gid, st.st_size, IX_EXISTS) self.dev = st.st_dev self.ino = st.st_ino