1

My server-side bare git repo needs to periodically cherry-pick commits from a special branch onto master (executed from a hook).

Is there any way to avoid a checkout and do this directly in the bare repo?

Edit: Since the cherry-picking procedure is non-interactive, it is okay to completely error out if the cherry-pick isn't trivial to apply.

Irfy
  • 9,323
  • 1
  • 45
  • 67
  • 1
    No, cherry-pick needs an index and work tree in case it decides to do a merge. – torek May 31 '16 at 18:03
  • Can `cherry-pick` perhaps be broken into plumbing commands that can be performed in the trivial case? Any non-trivial cherry-pick would result in an error and that would be acceptable. – Irfy May 31 '16 at 19:01
  • If it's *entirely* trivial (as in, no patching required at all, all versions of all files are contained in the two "interesting" commits), it could be done that way. You will still need an index but a bare repository has one (or you could create a temporary one). Figuring out which hashes to use for which files is nontrivial though. – torek May 31 '16 at 19:47

1 Answers1

2

Current solution is for the hook to make a temporary shallow checkout, perform the cherry-pick there, push back to the bare repo, and (possibly) remove the temporary checkout.

I'll accept a different answer if there is a way to do this without a temporary checkout.

Irfy
  • 9,323
  • 1
  • 45
  • 67