|
72 | 72 |
|
73 | 73 | Checks if commit `id` (which is a [`GitHash`](@ref) in string form)
|
74 | 74 | is in the repository.
|
| 75 | +
|
| 76 | +# Example |
| 77 | +
|
| 78 | +```julia |
| 79 | +julia> repo = LibGit2.GitRepo(repo_path); |
| 80 | +
|
| 81 | +julia> LibGit2.add!(repo, test_file); |
| 82 | +
|
| 83 | +julia> commit_oid = LibGit2.commit(repo, "add test_file"); |
| 84 | +
|
| 85 | +julia> LibGit2.iscommit(string(commit_oid), repo) |
| 86 | +true |
| 87 | +``` |
75 | 88 | """
|
76 | 89 | function iscommit(id::AbstractString, repo::GitRepo)
|
77 | 90 | res = true
|
@@ -573,6 +586,21 @@ set by `mode`:
|
573 | 586 | 3. `Consts.RESET_HARD` - move HEAD to `id`, reset the index to `id`, and discard all working changes.
|
574 | 587 |
|
575 | 588 | Equivalent to `git reset [--soft | --mixed | --hard] <id>`.
|
| 589 | +
|
| 590 | +# Example |
| 591 | +
|
| 592 | +```julia |
| 593 | +repo = LibGit2.GitRepo(repo_path) |
| 594 | +head_oid = LibGit2.head_oid(repo) |
| 595 | +open(joinpath(repo_path, "file1"), "w") do f |
| 596 | + write(f, "111\n") |
| 597 | +end |
| 598 | +LibGit2.add!(repo, "file1") |
| 599 | +mode = LibGit2.Consts.RESET_HARD |
| 600 | +# will discard the changes to file1 |
| 601 | +# and unstage it |
| 602 | +new_head = LibGit2.reset!(repo, head_oid, mode) |
| 603 | +``` |
576 | 604 | """
|
577 | 605 | reset!(repo::GitRepo, id::GitHash, mode::Cint = Consts.RESET_MIXED) =
|
578 | 606 | reset!(repo, GitObject(repo, id), mode)
|
|
0 commit comments