Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git diff in sub-vault #13

Open
joellti opened this issue Sep 20, 2022 · 5 comments
Open

Git diff in sub-vault #13

joellti opened this issue Sep 20, 2022 · 5 comments
Labels
question Further information is requested

Comments

@joellti
Copy link

joellti commented Sep 20, 2022

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
Copy link
Owner

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
Copy link
Owner

@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 kometenstaub added the question Further information is requested label Feb 25, 2023
@kometenstaub
Copy link
Owner

const gitVersions = await gitManager.log(this.file.path);

this.rightContent = await this.app.plugins.plugins[
'obsidian-git'
].gitManager.show(
clickedEl.v.hash,
clickedEl.v.fileName
);

This is how I call the APIs.

@lyukov
Copy link

lyukov commented Oct 31, 2024

I found following workaround:
Add "../" before clickedEl.v.fileName when calculating diff:

 this.rightContent = await this.app.plugins.plugins[ 
 	'obsidian-git' 
 ].gitManager.show( 
 	clickedEl.v.hash, 
 	"../" + clickedEl.v.fileName 
 ); 

@Vinzent03
Copy link

I've done some changes in this regard some time ago, and it should be solvable on your end by transforming a vault relative path to a repo relative path (which the showmethod needs) by calling plugin.gitManager.getRelativeRepoPath(pathRelativeToVault)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants