diff options
author | Josh Triplett <josh@joshtriplett.org> | 2020-05-23 16:07:54 -0700 |
---|---|---|
committer | Josh Triplett <josh@joshtriplett.org> | 2020-05-23 16:07:54 -0700 |
commit | 5278a0061100e2527e83f4cb159b40fc58bc786c (patch) | |
tree | c910273e15e7e27604846e8da4edc217b33d1dd9 /src/pack-objects.c | |
parent | 0bc091ddb231b201ce22294cd529d37ae40b25cc (diff) | |
download | libgit2-5278a0061100e2527e83f4cb159b40fc58bc786c.tar.gz |
git_packbuilder_write: Allow setting path to NULL to use the default path
If given a NULL path, write to the object path of the repository.
Add tests for the new behavior.
Diffstat (limited to 'src/pack-objects.c')
-rw-r--r-- | src/pack-objects.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/pack-objects.c b/src/pack-objects.c index 55a99e40d..2c8885856 100644 --- a/src/pack-objects.c +++ b/src/pack-objects.c @@ -1385,6 +1385,7 @@ int git_packbuilder_write( void *progress_cb_payload) { int error = -1; + git_buf object_path = GIT_BUF_INIT; git_indexer_options opts = GIT_INDEXER_OPTIONS_INIT; git_indexer *indexer = NULL; git_indexer_progress stats; @@ -1393,6 +1394,14 @@ int git_packbuilder_write( PREPARE_PACK; + if (path == NULL) { + if ((error = git_repository_item_path(&object_path, pb->repo, GIT_REPOSITORY_ITEM_OBJECTS)) < 0) + goto cleanup; + if ((error = git_buf_joinpath(&object_path, git_buf_cstr(&object_path), "pack")) < 0) + goto cleanup; + path = git_buf_cstr(&object_path); + } + opts.progress_cb = progress_cb; opts.progress_cb_payload = progress_cb_payload; @@ -1415,6 +1424,7 @@ int git_packbuilder_write( cleanup: git_indexer_free(indexer); + git_buf_dispose(&object_path); return error; } |