]> arthur.barton.de Git - bup.git/commit
index: make --fake-valid match the man page
authorJohannes Berg <johannes@sipsolutions.net>
Mon, 17 Feb 2020 20:02:11 +0000 (21:02 +0100)
committerRob Browning <rlb@defaultvalue.org>
Sun, 1 Mar 2020 22:54:49 +0000 (16:54 -0600)
commita79de5af5c6fcdf730a94ae8d1b839dfbbc2dc59
treed0f3d5c8d3f95ed7a35a97ec8c30bf3f7584aa83
parentfb74d94974aeea5a2c78d3e32afe2aaaaf0d6f61
index: make --fake-valid match the man page

The index command currently clobbers the hash of a file when
marking it as valid, but the man page states:

    --fake-valid
        mark specified paths as up-to-date even if they aren't.
        This can be useful for testing, or to avoid unnecessarily
        backing up files that you know are boring.

The latter part ("avoid unnecessarily backing up [...]") cannot be
implemented with --fake-valid as is, because of the clobbering of
the hash: the fake invented hash will not exist in the repository,
and thus save checks and saves the file.

Fix this by clobbering the hash only if it's the invalid EMPTY_SHA.

Add a test for this to test-save-smaller, just because that's where
we discovered it.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
cmd/index-cmd.py
t/test-save-smaller