kometenstaub / obsidian-version-history-diff

Get a diff view of your Obsidian Sync, File Recovery and Git version history
MIT License
111 stars 5 forks source link

Git diff in sub-vault #13

Open joellti opened 1 year ago

joellti commented 1 year ago

I got a vault which contains several sub-vaults. And I plan to enable git version control for that. Obsidian Git and this plugin were installed in root vault and working great. I was able to do backups and do diffs on any vault file. Now I want to do the same in the sub-vaults by installed the two plugins there. But I got mixed results there. First the diff by this plugin is failing with following error log.

plugin:obsidian-git:30828 git obsidian error: fatal: ambiguous argument 'path/to/note.md': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

plugin:obsidian-git:23818 Uncaught (in promise) Error: fatal: ambiguous argument 'path/to/note.md': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

    at Object.action (plugin:obsidian-git:23818:25)
    at PluginStore.exec (plugin:obsidian-git:23843:25)
    at eval (plugin:obsidian-git:21430:43)
    at new Promise (<anonymous>)
    at GitExecutorChain.handleTaskData (plugin:obsidian-git:21428:16)
    at GitExecutorChain.eval (plugin:obsidian-git:21412:44)
    at Generator.next (<anonymous>)
    at fulfilled (plugin:obsidian-git:20261:24)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
action @ plugin:obsidian-git:23818
exec @ plugin:obsidian-git:23843
eval @ plugin:obsidian-git:21430
handleTaskData @ plugin:obsidian-git:21428
eval @ plugin:obsidian-git:21412
fulfilled @ plugin:obsidian-git:20261
processTicksAndRejections @ node:internal/process/task_queues:96
await in processTicksAndRejections (async)
e.open @ app.js:1
openGitDiffModal @ plugin:obsidian-version-history-diff:452
eval @ plugin:obsidian-version-history-diff:452
TB @ app.js:1
e.executeCommand @ app.js:1
e.executeCommandById @ app.js:1
eval @ plugin:cmdr:7
e.handleEvent @ app.js:1

On the other hand, the diff command in Git plugin worked fine.

Please let me know if there is any workaround or fix to make it working.

Thx

kometenstaub commented 1 year ago

I have no plans to support sub-vaults/nested vaults. The issue here probably is that it doesn’t pass the absolute path because the sub-vault isn’t aware of the real root of the git repo. There may be a better way to pass the file path, but I don’t know how the Git plugin does it.

kometenstaub commented 1 year ago

@Vinzent03 Is there anything I'm doing wrong by calling your APIs/is there anything you could do from your end to make this work?

kometenstaub commented 1 year ago

https://github.com/kometenstaub/obsidian-version-history-diff/blob/4ac1234252840a17bf96990b34f10832013c4774/src/git_diff_view.ts#L35

https://github.com/kometenstaub/obsidian-version-history-diff/blob/4ac1234252840a17bf96990b34f10832013c4774/src/git_diff_view.ts#L167-L172

This is how I call the APIs.