Skip to content

Reimplement git subtree as a built-in #1410

Open
@dscho

Description

@dscho

The git subtree command is currently implemented as a shell script and it lives inside contrib/subtree/. There was previously an attempt to move it out of contrib/, but there was the concern of adding yet another scripted command (with all the problems that brings with it).

Using the OPT_SUBCOMMAND infrastructure, this project is about reimplementing the individual subcommands one by one.

In contrast to earlier projects that converted shell scripts to pure C versions, we want to be mindful to avoid too-literal translations. For example, instead of using the --grep= argument of the revision walking machinery, we will want to implement a precise search through the commit messages via strstr() and avoid spawning a new process. And instead of near-duplicating the logic of find_latest_squash and find_existing_splits, there are probably better ways to do this in C, ways that avoid code duplication.

However, just like previous conversions, this project could start by renaming git-subtree.sh to git-subtree--helper.sh while moving it to the top-level, moving the test script to t/ and implementing a builtin/subtree.c that simply shells out to the helper. That way, subcommands can be converted incrementally (and even independently).

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