diff options
| author | David Catmull <dtcatmull@verisk.com> | 2017-07-21 17:07:10 -0600 |
|---|---|---|
| committer | David Catmull <dtcatmull@verisk.com> | 2017-11-30 07:59:45 -0700 |
| commit | 4ccacdc8ec7524065b0d78a10c9deccd04bcbda7 (patch) | |
| tree | 53971495b91c9e8b128a03acb18043340b5c090c /src | |
| parent | 661cf4d4974d6381f1482f169f9292262192140d (diff) | |
| download | libgit2-4ccacdc8ec7524065b0d78a10c9deccd04bcbda7.tar.gz | |
status: Add a baseline field to git_status_options for comparing to trees other than HEAD
Diffstat (limited to 'src')
| -rw-r--r-- | src/status.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/status.c b/src/status.c index 03682bc72..f547bd466 100644 --- a/src/status.c +++ b/src/status.c @@ -280,12 +280,16 @@ int git_status_list_new( if ((error = git_repository__ensure_not_bare(repo, "status")) < 0 || (error = git_repository_index(&index, repo)) < 0) return error; - - /* if there is no HEAD, that's okay - we'll make an empty iterator */ - if ((error = git_repository_head_tree(&head, repo)) < 0) { - if (error != GIT_ENOTFOUND && error != GIT_EUNBORNBRANCH) - goto done; - giterr_clear(); + + if (opts != NULL && opts->baseline != NULL) { + head = opts->baseline; + } else { + /* if there is no HEAD, that's okay - we'll make an empty iterator */ + if ((error = git_repository_head_tree(&head, repo)) < 0) { + if (error != GIT_ENOTFOUND && error != GIT_EUNBORNBRANCH) + goto done; + giterr_clear(); + } } /* refresh index from disk unless prevented */ @@ -377,7 +381,8 @@ done: *out = status; - git_tree_free(head); + if (opts == NULL || opts->baseline != head) + git_tree_free(head); git_index_free(index); return error; |
