Skip to content

How to specify filter with git fetch? #1425

@thkoch2001

Description

@thkoch2001

I started to document my workflow as promissed in #1417. However I also wanted to document how one could use josh-proxy to fetch a workspace branch into an existing monorepo clone.

Is this possible? I understand that the josh proxy parses the HTTP request line to find the requested filter after the colon. However in an existing clone I'd like to just use the origin remote and somehow still get the filter through to the josh proxy.

After the fetch I'd then use git worktree on the FETCH_HEAD.

It seems, filters can only be specified as part of a clone url, since the code searches for the filter in a "FilteredRefRegex" struct. So this issue is probably a feature request to also support specifying filters through a server-option, e.g.:

git fetch --server-option=josh-filter=... origin

For reference, a full example workflow:

URL=https://code.tvl.fyi/depot.git
git clone --bare $URL monorepo 
# --depth=1 leads to divergence from the monorepo
# --filter=blob:non is not supported by gerrit and gives: "warning: filtering not recognized by server, ignoring"
cd monorepo

# initial setup of the monorepo clone
ln -s ~/bin/gerrit-commit-msg-hook hooks/commit-msg
git config set --local url.$URL.insteadOf josh
git config set --local remote.origin.pushurl ssh://[email protected]:29418/depot
git config set --local remote.origin.push canon:refs/for/canon # since tvl uses gerrit

# create a git worktree
git fetch josh:/web/planet-mars.git
git worktree add -b planet-mars ../planet-mars FETCH_HEAD
cd ../planet-mars

cargo update # do some edits...
git commit #...

josh-filter ":/web/planet-mars" refs/heads/canon --update refs/heads/planet-mars --reverse
git log -1 --stat canon
git push

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions