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

Support stashing #24

Open
modocache opened this issue Feb 1, 2015 · 3 comments
Open

Support stashing #24

modocache opened this issue Feb 1, 2015 · 3 comments

Comments

@modocache
Copy link
Owner

I want to be able to stash uncommitted changes:

let repository = openRepository(NSURL(fileURLWithPath: "/Users/modocache/Desktop/MyRepo")!)
let index = repository.flatMap { $0.index }
let commit = index.flatMap { $0.stash(message: "Saving some work for another day") }

I'd also like to be able to apply stashed changes somehow. Not sure what that API should look like yet, but suggestions welcome!

@modocache
Copy link
Owner Author

We can create a stash thanks to b305354 and 699f411. It turns out a stash creates a commit object.

The next part of this issue would involve applying a stash. Perhaps "applying a stash" would simply mean merging the commit that was created? Is there a way to get a list of stashes, like git stash list? Ideally, we would be able to list all stashes, find the one we want, then apply it.

@PiersonBro
Copy link

Hi @modocache!

There are two things related to stashing that I think I can help shed some light on.

With regards to applying a stash, I don't know the specifics, but I'm pretty sure that it's far more complicated than a simple merge. Fortunately it appears that libgit2 will get git_stash_apply and git_stash_pop soon.

With regards to getting a list of stashes libgit2 already has this built in, with git_stash_foreach.

Hopefully this helps,
Ezekiel

@modocache
Copy link
Owner Author

Awesome, thanks for the heads up, @PiersonBro! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants