Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions generate/input/descriptor.json
Original file line number Diff line number Diff line change
Expand Up @@ -3957,6 +3957,9 @@
"git_stash_apply_options_init": {
"ignore": true
},
"git_stash_save_options_init": {
"ignore": true
},
"git_stash_drop": {
"isAsync": true,
"return": {
Expand Down
112 changes: 112 additions & 0 deletions generate/input/libgit2-supplement.json
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,44 @@
},
"group": "status_list"
},
"git_stash_save_options_init": {
"file": "git2/stash.h",
"args": [
{
"name": "opts",
"type": "git_stash_save_options *"
},
{
"name": "version",
"type": "unsigned int"
}
],
"return": {
"type": "int"
},
"group": "stash"
},
"git_stash_save_with_opts": {
"file": "git2/stash.h",
"args": [
{
"name": "out",
"type": "git_oid *"
},
{
"name": "repo",
"type": "git_repository *"
},
{
"name": "opts",
"type": "git_stash_save_options *"
}
],
"return": {
"type": "int"
},
"group": "stash"
},
"git_tree_get_all_filepaths": {
"args": [
{
Expand Down Expand Up @@ -1240,6 +1278,13 @@
"git_revwalk_file_history_walk"
]
],
[
"stash",
[
"git_stash_save_options_init",
"git_stash_save_with_opts"
]
],
[
"status_list",
[
Expand Down Expand Up @@ -1854,6 +1899,73 @@
}
}
],
[
"git_stash_flags",
{
"type": "enum",
"fields": [
{
"type": "unsigned int",
"name": "GIT_STASH_DEFAULT",
"value": 0
},
{
"type": "unsigned int",
"name": "GIT_STASH_KEEP_INDEX",
"value": 1
},
{
"type": "unsigned int",
"name": "GIT_STASH_INCLUDE_UNTRACKED",
"value": 2
},
{
"type": "unsigned int",
"name": "GIT_STASH_INCLUDE_IGNORED",
"value": 4
},
{
"type": "unsigned int",
"name": "GIT_STASH_KEEP_ALL",
"value": 8
}
]
}
],
[
"git_stash_save_options",
{
"type": "struct",
"fields": [
{
"type": "unsigned int",
"name": "version"
},
{
"type": "const git_signature *",
"name": "stasher"
},
{
"type": "const char *",
"name": "message"
},
{
"type": "uint32_t",
"name": "flags"
},
{
"type": "git_strarray",
"name": "paths"
}
],
"used": {
"needs": [
"git_stash_save_with_opts",
"git_stash_save_options_init"
]
}
}
],
[
"git_status_options",
{
Expand Down
70 changes: 70 additions & 0 deletions test/tests/stash.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,74 @@ describe("Stash", function() {
assert.equal(fileContentB, content);
});
});

it("can partial stash the workdir and pop it", function() {
const repo = this.repository;

const fileName1 = "README.md";
const fileName2 = "install.js";
const fileName3 = "LICENSE";

const fileContentA = "Hi. It's me. I'm the dog. My name is the dog.";
const fileContentB = "Everyone likes me. I'm cute.";

let oldContentA;
let oldContentB;
let oldContentC;

const filePath1 = path.join(repo.workdir(), fileName1);
const filePath2 = path.join(repo.workdir(), fileName2);
const filePath3 = path.join(repo.workdir(), fileName3);

const options = {
flags: 0,
message: "stast test",
paths: [fileName1, fileName2]
};

return fse.readFile(filePath1, "utf-8")
.then((content) => {
oldContentA = content;
return fse.readFile(filePath2, "utf-8");
})
.then((content) => {
oldContentB = content;
return fse.readFile(filePath3, "utf-8");
})
.then((content) => {
oldContentC = content;
return fse.writeFile(filePath1, fileContentA);
})
.then(() => fse.writeFile(filePath2, fileContentB))
.then(() => repo.defaultSignature())
.then((signature) => {
options.stasher = signature;
return Stash.saveWithOpts(repo, options);
})
.then(() => fse.readFile(filePath1, "utf-8"))
.then((content) => {
assert.equal(oldContentA, content);
return fse.readFile(filePath2, "utf-8");
})
.then((content) => {
assert.equal(oldContentB, content);
return fse.readFile(filePath3, "utf-8");
})
.then((content) => {
assert.equal(oldContentC, content);
return Stash.pop(repo, 0);
})
.then(() => fse.readFile(filePath1, "utf-8"))
.then((content) => {
assert.equal(fileContentA, content);
return fse.readFile(filePath2, "utf-8");
})
.then((content) => {
assert.equal(fileContentB, content);
return fse.readFile(filePath3, "utf-8");
})
.then((content) => {
assert.equal(oldContentC, content);
});
});
});
2 changes: 1 addition & 1 deletion vendor/libgit2