Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Make index methods async#971

Merged
johnhaley81 merged 6 commits intomasternodegit/nodegit:masterfrom
async-indexnodegit/nodegit:async-indexCopy head branch name to clipboard
Apr 11, 2016
Merged

Make index methods async#971
johnhaley81 merged 6 commits intomasternodegit/nodegit:masterfrom
async-indexnodegit/nodegit:async-indexCopy head branch name to clipboard

Conversation

@johnhaley81
Copy link
Collaborator

Anytime the index reads/writes to the disk it should be non-blocking. Additionally this will give us thread safety protection since async methods are piped through the LockManager

@johnhaley81
Copy link
Collaborator Author

Also updated the examples to both use the async methods and remove the double reading of the index. repo.openIndex forces a read of the index so it doesn't make sense to do another one right after the first one happens. I think that was a holdover from an ancient version of libgit2.

@joshaber
Copy link
Collaborator

💖

@johnhaley81
Copy link
Collaborator Author

This should be gtg now. @tbranyen, @srajko, and @joshaber if you wouldn't mind 👀 on this that would be most appreciated :)

@tbranyen
Copy link
Member

tbranyen commented Apr 8, 2016

We need to start using async/await internally. ^_^

@johnhaley81
Copy link
Collaborator Author

#874 😄

"isErrorCode": true
}
},
"git_index_conflict_remove": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to be pedantic about keeping things sorted alphabetically, this one belongs a few entries down

John Haley added 6 commits April 8, 2016 16:06
Anytime the index reads/writes to the disk it should be non-blocking. Additionally this will give us thread safety protection since async methods are piped through the `LockManager`
So this test was never valid ¯\_(ツ)_/¯

You can't call `Index#addByPath` with an absolute path which was what was happening. Since the method was sync the result was considered the actual result of the call and not the error code so this error was never caught. Now that the function is async, that result is correctly interpretted and the test failed correctly.

Changing this test to use the relative path fixes the test.
Writing an index to disk is now async and no longer returns it's result code. Instead of checking for `0` we can just handle the error callback/rejected promise case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.