git2-rs icon indicating copy to clipboard operation
git2-rs copied to clipboard

Add config level for worktrees

Open vermiculus opened this issue 3 years ago • 6 comments

This uses the new support in libgit2 for the worktree-config extension.

See also https://github.com/libgit2/libgit2/pull/6202.


I suspect there is more work to be done on this PR, but I wanted to create it for tracking purposes. Tasks I can tell are coming:

  • [ ] once the upstream PR is merged, update the libgit2 submodule
  • [x] add unit tests around worktree-level config
    • no unit tests current exist for checking different levels of config
  • [x] determine if documentation needs updating
    • no special documentation exists mentioning the ConfigLevel enum
  • [x] determine if any libgit2/git2-rs glue code needs updating

vermiculus avatar Mar 03 '22 11:03 vermiculus

Putting this back on the radar. libgit2/libgit2#6202 is passing tests and out for review; I'm hoping it will be merged in the near future.

vermiculus avatar Feb 22 '24 15:02 vermiculus

Erm, what's going on with https://github.com/rust-lang/git2-rs/actions/runs/8032181003/job/21941280831?pr=816#step:4:398? I don't see any ... FAILED lines in the output above. I get similar output locally, but I also have apparent trouble building libgit2-sys:

warning: running: "cc" "--version"
warning: exit status: 0
warning: running: "xcrun" "--show-sdk-platform-version" "--sdk" "macosx"
warning: xcrun: error: unable to lookup item 'PlatformVersion' from command line tools installation
warning: xcrun: error: unable to lookup item 'PlatformVersion' in SDK '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk'
warning: exit status: 1
warning: running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-2" "-fno-omit-frame-pointer" "--target=arm64-apple-darwin" "-mmacosx-version-min=11.0" "-I" "$HOME/git/github.com/rust-lang/git2-rs/target/debug/build/libgit2-sys-5efb512b56edc92d/out/include" "-I" "libgit2/src/libgit2" "-I" "libgit2/src/util" "-I" "libgit2/deps/http-parser" "-I" "libgit2/deps/xdiff" "-I" "libgit2/deps/pcre" "-I" "$HOME/git/github.com/rust-lang/git2-rs/target/debug/build/libssh2-sys-5d8671b59c7f1f67/out/include" "-fvisibility=hidden" "-DGIT_REGEX_BUILTIN=1" "-DHAVE_STDINT_H=1" "-DHAVE_MEMMOVE=1" "-DNO_RECURSE=1" "-DNEWLINE=10" "-DPOSIX_MALLOC_THRESHOLD=10" "-DLINK_SIZE=2" "-DPARENS_NEST_LIMIT=250" "-DMATCH_LIMIT=10000000" "-DMATCH_LIMIT_RECURSION=MATCH_LIMIT" "-DMAX_NAME_SIZE=32" "-DMAX_NAME_COUNT=10000" "-DSHA1DC_NO_STANDARD_INCLUDES=1" "-DSHA1DC_CUSTOM_INCLUDE_SHA1_C=\"common.h\"" "-DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=\"common.h\"" "-o" "$HOME/git/github.com/rust-lang/git2-rs/target/debug/build/libgit2-sys-5efb512b56edc92d/out/build/9646caca89e97167-annotated_commit.o" "-c" "libgit2/src/libgit2/annotated_commit.c"
warning: running: "xcrun" "--show-sdk-platform-version" "--sdk" "macosx"
warning: xcrun: error: unable to lookup item 'PlatformVersion' from command line tools installation
warning: xcrun: error: unable to lookup item 'PlatformVersion' in SDK '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk'
warning: exit status: 1

and a failure to pass

test cred::test::ssh_key_from_memory ... FAILED

since libgit2-sys fails to build with the proper features: cred = Err(Error { code: -1, klass: 3, message: "this version of libgit2 was not built with ssh memory credentials." }).

I didn't expect to see the same behavior in CI.

@ehuss any wisdom here? I figured it was a result of my dev environment.

vermiculus avatar Feb 24 '24 18:02 vermiculus

For the ssh memory credential issue, the build.rs will need to be updated to accommodate https://github.com/libgit2/libgit2/pull/6617. In particular, it looks like GIT_SSH_MEMORY_CREDENTIALS was renamed to GIT_SSH_LIBSSH2_MEMORY_CREDENTIALS.

The test is also seg-faulting. Here's a backtrace:

* thread #36, name = 'remote::tests::push', stop reason = EXC_BAD_ACCESS (code=1, address=0x8)
    frame #0: 0x000000010024a1e4 git2-6f482251d0c12a64`git_remote_upload(remote=0x0000000121e047a0, refspecs=0x0000000171271ce0, opts=0x0000000171271de0) at remote.c:2987:31
   2984
   2985		if (opts && opts->remote_push_options.count > 0)
   2986			for (i = 0; i < opts->remote_push_options.count; ++i) {
-> 2987				char *optstr = git__strdup(opts->remote_push_options.strings[i]);
   2988				GIT_ERROR_CHECK_ALLOC(optstr);
   2989
   2990				if ((error = git_vector_insert(&push->remote_push_options, optstr)) < 0)
Target 0: (git2-6f482251d0c12a64) stopped.
(lldb) bt
* thread #36, name = 'remote::tests::push', stop reason = EXC_BAD_ACCESS (code=1, address=0x8)
  * frame #0: 0x000000010024a1e4 git2-6f482251d0c12a64`git_remote_upload(remote=0x0000000121e047a0, refspecs=0x0000000171271ce0, opts=0x0000000171271de0) at remote.c:2987:31
    frame #1: 0x000000010024a4b4 git2-6f482251d0c12a64`git_remote_push(remote=0x0000000121e047a0, refspecs=0x0000000171271ce0, opts=0x0000000171271de0) at remote.c:3025:15
    frame #2: 0x000000010009ca74 git2-6f482251d0c12a64`git2::remote::Remote::push::h68a78a039f76ea65(self=0x00000001712721d8, refspecs=&[&str] @ 0x0000000171271f20, opts=Option<&mut git2::remote::PushOptions> @ 0x0000000171271f30) at remote.rs:355:13
    frame #3: 0x00000001000468d8 git2-6f482251d0c12a64`git2::remote::tests::push::h32879140cc745f01 at remote.rs:979:13
    frame #4: 0x0000000100105884 git2-6f482251d0c12a64`git2::remote::tests::push::_$u7b$$u7b$closure$u7d$$u7d$::h87f24d99dd0e3fbb((null)=0x000000017127279e) at remote.rs:956:14

ehuss avatar Feb 24 '24 19:02 ehuss

@ehuss Thanks for the info; the segfault has now been fixed in b49d8b7e3fa7cd64a437ff3d340a15115eccfbd8.

If it's not too much trouble, how did you get that backtrace? RUST_BACKTRACE=1 cargo test offered no such insight.

vermiculus avatar Feb 24 '24 22:02 vermiculus

If it's not too much trouble, how did you get that backtrace? RUST_BACKTRACE=1 cargo test offered no such insight.

I used lldb on the test executable.

ehuss avatar Feb 25 '24 01:02 ehuss