Added a comment: even git mv -f seems to work correctly

This commit is contained in:
Ilya_Shlyakhter 2019-11-24 17:25:32 +00:00 committed by admin
parent 20da59f62f
commit 1f035c0d66

View file

@ -0,0 +1,126 @@
[[!comment format=mdwn
username="Ilya_Shlyakhter"
avatar="http://cdn.libravatar.org/avatar/1647044369aa7747829c38b9dcc84df0"
subject="even git mv -f seems to work correctly"
date="2019-11-24T17:25:32Z"
content="""
Also, `git mv` seems to reuse the already-smudged object contents of the source file for the target file, so even with `git mv -f` only the checksum gets checked into git:
[[!format sh \"\"\"
+ cat ./test-git-mv
#!/bin/bash
set -eu -o pipefail -x
cat $0
TEST_DIR=/tmp/test_dir
mkdir -p $TEST_DIR
chmod -R u+w $TEST_DIR
rm -rf $TEST_DIR
mkdir -p $TEST_DIR
pushd $TEST_DIR
git init
git annex init
git --version
git annex version
rm .git/info/attributes
echo foo > foo
echo bar > bar
git annex add foo bar
git check-attr -a foo
git check-attr -a bar
echo 'bar filter=annex' > .gitattributes
git add .gitattributes
git check-attr -a foo
git check-attr -a bar
git annex unlock bar
git mv bar foo || true
git mv -f bar foo
git commit -m add
git log -p
+ TEST_DIR=/tmp/test_dir
+ mkdir -p /tmp/test_dir
+ chmod -R u+w /tmp/test_dir
+ rm -rf /tmp/test_dir
+ mkdir -p /tmp/test_dir
+ pushd /tmp/test_dir
/tmp/test_dir /tmp
+ git init
Initialized empty Git repository in /tmp/test_dir/.git/
+ git annex init
init (scanning for unlocked files...)
ok
(recording state in git...)
+ git --version
git version 2.20.1
+ git annex version
git-annex version: 7.20191024-g6dc2272
build flags: Assistant Webapp Pairing S3 WebDAV Inotify DBus DesktopNotify TorrentParser MagicMime Feeds Testsuite
dependency versions: aws-0.21.1 bloomfilter-2.0.1.0 cryptonite-0.25 DAV-1.3.3 feed-1.0.1.0 ghc-8.6.5 http-client-0.5.14 persistent-sqlite-2.9.3 torrent-10000.1.1 uuid-1.3.13 yesod-1.6.0
key/value backends: SHA256E SHA256 SHA512E SHA512 SHA224E SHA224 SHA384E SHA384 SHA3_256E SHA3_256 SHA3_512E SHA3_512 SHA3_224E SHA3_224 SHA3_384E SHA3_384 SKEIN256E SKEIN256 SKEIN512E SKEIN512 BLAKE2B256E BLAKE2B256 BLAKE2B512E BLAKE2B512 BLAKE2B160E BLAKE2B160 BLAKE2B224E BLAKE2B224 BLAKE2B384E BLAKE2B384 BLAKE2BP512E BLAKE2BP512 BLAKE2S256E BLAKE2S256 BLAKE2S160E BLAKE2S160 BLAKE2S224E BLAKE2S224 BLAKE2SP256E BLAKE2SP256 BLAKE2SP224E BLAKE2SP224 SHA1E SHA1 MD5E MD5 WORM URL
remote types: git gcrypt p2p S3 bup directory rsync web bittorrent webdav adb tahoe glacier ddar git-lfs hook external
operating system: linux x86_64
supported repository versions: 7
upgrade supported from repository versions: 0 1 2 3 4 5 6
local repository version: 7
+ rm .git/info/attributes
+ echo foo
+ echo bar
+ git annex add foo bar
add foo ok
add bar ok
(recording state in git...)
+ git check-attr -a foo
+ git check-attr -a bar
+ echo 'bar filter=annex'
+ git add .gitattributes
+ git check-attr -a foo
+ git check-attr -a bar
bar: filter: annex
+ git annex unlock bar
unlock bar ok
(recording state in git...)
+ git mv bar foo
fatal: destination exists, source=bar, destination=foo
+ true
+ git mv -f bar foo
+ git commit -m add
[master (root-commit) 8610c0d] add
2 files changed, 2 insertions(+)
create mode 100644 .gitattributes
create mode 100644 foo
+ git log -p
commit 8610c0d8f327140608e71dc229f167731552d284
Author: Ilya Shlyakhter <ilya_shl@alum.mit.edu>
Date: Sun Nov 24 12:24:28 2019 -0500
add
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..649f07e
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+bar filter=annex
diff --git a/foo b/foo
new file mode 100644
index 0000000..266ae50
--- /dev/null
+++ b/foo
@@ -0,0 +1 @@
+/annex/objects/MD5E-s4--c157a79031e1c40f85931829bc5fc552
\"\"\"]]
"""]]