Is it possible to modify the default git-merge-one-file
program to do everything in the index without touching the working tree, leaving it completely unmodified?
UPDATE AND DETAILS
So I understand now that a file-level merge (where the merge is acting on lines in the file rather than whole files) can't occur without using a worktree. (Unlike a merge acting on whole files.) So I'm gonna have to use a worktree.
Another detail: I'm okay with the solution working only in the cases where the merge can be done automatically without manual resolution. It's okay if it just shows an error message if the merge is not automatic. (And of course, leave everything clean.)
Another detail: I'm not using git-merge-one-file
directly, I'm using it inside this script: https://gist.github.com/cool-RR/6575042
I tried to follow @torek 's advice and use a temporary work tree (as you can see in the script), because that seems like the best direction so far. Problem is, I get these errors:
git checkout-index: my_file is not in the cache
error: my_file: cannot add to the index - missing --add option?
I googled these error messages but couldn't find anything helpful.
Any idea what to do?