Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BF: annexrepo: Avoid typechange when using temporary index
git-annex's pre-commit hook throws the following error if an unlocked file is given in a 'git commit PATH ...' call: Cannot make a partial commit with unlocked annexed files. You should `git annex add` the files you want to commit, and then run git commit. The motivation for this is explained in git-annex's adc5ca70a (pre-commit: Block partial commit of unlocked annexed file, since that left a typechange staged in index, 2014-11-10) In the typical case, we could fix this by running 'git annex add' before the 'git commit PATH' call. (And 'datalad save' already does this, so this is an issue only when directly calling AnnexRepo.commit().) *But* a complication is introduced when 'git annex add' adds the file to index as a regular file while the file in HEAD is an annex symbolic link (e.g., the common case would be the file size shrinking below the threshold specified via annex.largefiles). git-annex can't distinguish the typechange of the added file from that of an unlocked file, so 'git commit PATH' fails with the partial commit error [*]. To work around this, dataladgh-3009 taught AnnexRepo.commit() to stage the specified paths in a temporary index and then call 'git commit' without the pathspec. After the commit, we need to reset the main index to the state in HEAD to reflect changes that git-annex might have made in the pre-commit hook (e.g., changing the regular file to an annex symlink). dataladgh-3009 did this for the specified paths that had unstaged changes, but we need to do the same thing for paths with staged changes. Otherwise, calling 'datalad save PATH' with a path moved below the annex.largefiles cutoff will show a typechange after the save call. [*]: https://git-annex.branchable.com/bugs/cannot_commit___34__annex_add__34__ed_modified_file_which_switched_its_largefile_status_to_be_committed_to_git_now/
- Loading branch information