obsidian-git: [Bug]: InternalError on iOS when Tasks is installed

Describe the bug

I get this error:

IMG_0555

And the backup is not completed. To solve the issue, I have to not install Tasks, and clone again the repository.

Relevant errors (if available)

InternalError: An internal error caused this command to fail. Please file a bug report at 
https://github.com/isomorphic-git/isomorphic-git/issues 
with this error message: SHA check failed! Expected 27eb43e79ec4b1236d2ba1b27e738f279420bd93, 
computed b77dOb17f624d487b84cc67d4510794aeb349819

Steps to reproduce

The steps I am doing:

  • Created a new vault.
  • Clone a repository from Github.
  • The repository has .obsidian.
  • Set depth to 1.

No issues so far. Then…

  • Edit a note.
  • Run Obsidian Git: Create backup
  • Backup is complete

No issues so far. Then…

Expected Behavior

No response

Addition context

Obsidian: 1.4.4 (98) << From TestFligth Also tested with the stable release from the AppStore.

iPhone 12 iOS: 16.4.1 Calendar: 1.5.10 Dataview: 0.5.55 Obsidian Git: 2.19.1

No other plugin installed on my phone.

Operating system

iOS

Installation Method

Other

Plugin version

2.19.1

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Comments: 42 (1 by maintainers)

Most upvoted comments

The error message

SHA check failed! Expected
27eb43e79ec4b1236d2ba1b27e738f279420bd93, computed 
b77dOb17f624d487b84cc67d4510794aeb349819

is a cryptic way to say that the .git/index file is broken. The file consists of 3 parts:

  1. fixed size header
  2. list of staging informations for each file
  3. hash which is computed over 1. and 2.

The error message says that the hash over the first two parts is not correct.

Isomorphic-git has the class GitIndexManager.js which maintances the .git/index file. The class ensures that the file has a proper format, the hash is always computed when the list in 2. changed and has a lock to ensure that concurrent writes that could corrupt the file can never occur. In isomorphic-git the .git/index is never directy accessed, only through the GitIndexManager class.

In the obsidian-git repository there is a file: myAdapter.ts which contains the following code that overwrites the .git/index:

    async saveAndClear(): Promise<void> {
        if (this.index !== undefined) {
            await this.adapter.writeBinary(
                this.plugin.gitManager.getVaultPath(this.gitDir + "/index"),
                this.index,
                {
                    ctime: this.indexctime,
                    mtime: this.indexmtime,
                }
            );
        }
        this.clearIndex();
    }

Why do you do this?

The issue in isomorohic-git: https://github.com/isomorphic-git/isomorphic-git/issues/1760

I’m also having this issue and I’ve tried with a clean new vault, with only two plugins (Excalidraw and Obsidian-Git).

Obsidian-Git version: 2.20.5 iPad iOS version: 16.5.1

Im not sure how to resolve this issue and I’m hoping there will be a solution soon, because this plugin is awesome 😃

At least make your vault sync properly again, people, you don’t have to stuck here. Good luck! (me 2 months ago)

So finally I re-cloned the repo and replaced the .git/ in my vault, and sync the vault back to iPad, re-set the auth information, and pushed with this rebuilt vault repo. Old unpushed commits are lost and combined as a new commit, but at least the vault on iOS is back working again.

@Vinzent03 As I said in the note above, the GitIndexManager.js has a lock, that ensures that concurrent writing to the index results in a valid index file. You delegate the writing to the saveAndClear function, which pushes the write outside the lock context and with this concurrent writes are possible. As far as I understand the implementation you pull before you commit. Both can update the index. If you look at the first image in this thread you see

  1. commit
  2. pull
  3. error

which has the wrong order. I think this is a race problem, but I have no evidence jet.

With your implementation you only save the reading of the index file, but the file has to be parsed each time. A better way to improve performance is to use the isomorphic git cache:

https://isomorphic-git.org/docs/en/cache

Create a global cache object, pass this to the function calls and flush the cache from time to time. You get better performance because you cache pared objects and you relay on the official api.