Skip to content
This repository was archived by the owner on Dec 2, 2026. It is now read-only.
This repository was archived by the owner on Dec 2, 2026. It is now read-only.

Set working tree #93

Closed
contentascode/nodegit
#4

Description

@jcmoore

As far as I can tell, there is no way to set the work-tree for a repository (a command like "git --git-dir=first/directory/.git --work-tree=second/directory init" would do the trick, but it looks like the plugin does not have support for libgit2's git_repository_init_ext method -- which accepts a git_repository_init_options argument ... or the git_repository_set_workdir function may also work).

I'd like to request a feature that would let me accomplish work-tree assignment in some way.

Thanks

Activity

  1. nkallen commented on Sep 23, 2013

    @nkallen
    Contributor

    Can you copy and paste here the entry in the v0.18.json file for git_repository_init_ext and whatever other functions you need? I'd like to guide you through making this enhancement yourself.

  2. jcmoore commented on Sep 26, 2013

    @jcmoore
    Author

    Thanks for your help.

    {
    "cFunctionName": "git_repository_init_ext",
    "args": [
    {
    "name": "out",
    "isReturn": true,
    "cType": "git_repository **",
    "cppClassName": "GitRepo",
    "jsClassName": "Repository",
    "comment": "Pointer to the repo which will be created or reinitialized."
    },
    {
    "name": "repo_path",
    "cType": "const char *",
    "cppClassName": "String",
    "jsClassName": "String",
    "comment": "The path to the repository."
    },
    {
    "name": "opts",
    "cType": "git_repository_init_options *",
    "cppClassName": "RepositoryInitOptions",
    "jsClassName": "RepositoryInitOptions",
    "comment": "Pointer to git_repository_init_options struct."
    }
    ],
    "ignore": true,
    "isAsync": false,
    "isConstructorMethod": true,
    "isPrototypeMethod": false,
    "jsFunctionName": "initExt",
    "cppFunctionName": "InitExt",
    "return": {
    "cType": "int",
    "cppClassName": "Int32",
    "isErrorCode": true,
    "comment": "0 or an error code on failure.",
    "jsClassName": "Number"
    },
    "description": "

    Create a new Git repository in the given folder with extended controls.

    \n"
    },

  3. nkallen commented on Sep 26, 2013

    @nkallen
    Contributor

    OK this isn't a super-simple one.

    At a high level, the process is to remove the ignore: true attribute and set async to true. Then you'll need to add a definition for git_repository_init_options. To do this you need to make something analogous to diff_range, which is another struct, just like ..._init_options. You'll want to populate an entry for each of the fields in the struct. Here is how diff_range looks:

      {
        "filename": "diff_range.h",
        "dependencies": [],
        "jsClassName": "DiffRange",
        "cppClassName": "GitDiffRange",
        "cType": "git_diff_range",
        "freeFunctionName": "free",
        "fields": [
          {
            "jsFunctionName": "oldStart",
            "cppFunctionName": "OldStart",
            "name": "old_start",
            "cType": "int",
            "cppClassName": "Integer",
            "jsClassName": "Number"
          },

    In the above example, oldStart is a field. If you just follow the conventions you see elsewhere you may be able to do this by yourself!

    Finally, you'll want to make sure this compiles and works in your project. npm run-script gen && npm install && npm test. Test it out with npm link. When all is good, submit a pull request!

    Let me know if this is too confusing!

  4. nkallen commented on Sep 26, 2013

    @nkallen
    Contributor

    Oh, additionally, you'll need to add the file you'll create init_options.h as a dependency to repo.h (see the dependencies field). Next, add an initialize line in base.cc, as in:

      GitRepoInitOptions::Initialize(target);
    

    Finally, add 'src/submodule.cc', to binding.gyp.

  5. tbranyen commented on Jul 3, 2014

    @tbranyen
    Member

    I've added support for this issue, I've greatly reduced down the amount of work it takes to bind, so the diff is relatively small. Still missing a unit test.

  6. tbranyen commented on Oct 11, 2014

    @tbranyen
    Member

    We're still working on options, but we're super close thanks to @johnhaley81. This should be landed next week. #208

  7. johnhaley81 commented on Nov 21, 2014

    @johnhaley81
    Collaborator

    This is now in the latest version. Give it a shot and if doesn't work then feel free to reopen this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions