Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config level for worktrees #816

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

vermiculus
Copy link

@vermiculus vermiculus commented Mar 3, 2022

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

See also libgit2/libgit2#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
  • add unit tests around worktree-level config
    • no unit tests current exist for checking different levels of config
  • determine if documentation needs updating
    • no special documentation exists mentioning the ConfigLevel enum
  • determine if any libgit2/git2-rs glue code needs updating

@vermiculus vermiculus marked this pull request as draft March 3, 2022 12:39
@vermiculus vermiculus changed the title WIP: Add config level for worktrees Add config level for worktrees Mar 3, 2022
@vermiculus
Copy link
Author

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 vermiculus force-pushed the sallred/worktree-config branch 3 times, most recently from 575e518 to b17a4cc Compare February 24, 2024 17:40
@vermiculus
Copy link
Author

vermiculus commented Feb 24, 2024

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.

@ehuss
Copy link
Contributor

ehuss commented Feb 24, 2024

For the ssh memory credential issue, the build.rs will need to be updated to accommodate libgit2/libgit2#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

@vermiculus vermiculus force-pushed the sallred/worktree-config branch from b17a4cc to df398cd Compare February 24, 2024 22:15
@vermiculus
Copy link
Author

vermiculus commented Feb 24, 2024

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

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

To fix a segfault at [1], adjust to upstream development[2,3] that
changed the shape of this struct.

This new field is added in the same style as `custom_headers`.

[1]: libgit2.git:39669956fb510fb7b13289f6ce959884969dbebd:src/libgit2/remote.c:2987
[2]: libgit2.git:ecc6f2fb8399d84e5b2bf043376dfc51f43f3e90
[3]: libgit2.git:39669956fb510fb7b13289f6ce959884969dbebd
Adjust to upstream development[1] that changed the name of this
compiler flag.

[1]: libgit2.git:3fccf7468ba7a9a9f764984435db83f4588ec905
Use the new support in libgit2 for the worktree-config extension.[1]

[1]: https://git-scm.com/docs/git-worktree/2.35.1#_configuration_file
@vermiculus vermiculus force-pushed the sallred/worktree-config branch from df398cd to 73ade96 Compare February 24, 2024 22:23
@ehuss
Copy link
Contributor

ehuss commented Feb 25, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants