kubernetes / git-sync

A sidecar app which clones a git repo and keeps it in sync with the upstream.
Apache License 2.0
2.14k stars 409 forks source link

Simplify inner loop #844

Closed thockin closed 7 months ago

thockin commented 7 months ago
$ rm -rf /tmp/gs; mkdir -p /tmp/gs/repo; mkdir -p /tmp/gs/wt; cd /tmp/gs/repo

$ REPO=https://github.com/kubernetes/git-sync

$ REF=HEAD

$ git init
Initialized empty Git repository in /tmp/gs/repo/.git/

$ git fetch --depth 1 $REPO $REF
remote: Enumerating objects: 937, done.
remote: Counting objects: 100% (937/937), done.
remote: Compressing objects: 100% (691/691), done.
remote: Total 937 (delta 285), reused 498 (delta 192), pack-reused 0
Receiving objects: 100% (937/937), 1.76 MiB | 7.67 MiB/s, done.
Resolving deltas: 100% (285/285), done.
From https://github.com/kubernetes/git-sync
 * branch            HEAD       -> FETCH_HEAD

$ git rev-parse FETCH_HEAD
9e1d0c5936270c6296d4ac13a948209f3e9715f9

$ # if this is different, add a new worktree

$ git worktree add /tmp/gs/wt/9e1d0c5936270c6296d4ac13a948209f3e9715f9 9e1d0c5936270c6296d4ac13a948209f3e9715f9
Preparing worktree (detached HEAD 9e1d0c5)
HEAD is now at 9e1d0c5 Document the change in default target