Git format-patch / bundle for human readable sneakernet "pull / push"

I have two rooms in which I maintain some source code using git, "dev", where most of the development takes place, and the "deployment" of the room in which we actually use the software. Inevitably, some changes occur in the deployment room. I would like both rooms to share the same story in git.

Limitations:

  • For security reasons, the two rooms are not connected to the network.
  • Only text files (human-readable) can leave the deployment room.

Moving changes to the deployment room is done using git bundle and tracking the last commit we moved to the deployment room. Moving changes from a room is more difficult due to the limited text only.

Purpose: Moving back and forth between my two unconnected rooms, as if git pull , ie , identical SHA1 hashes in both rooms happened.

Still:

  • I tried git format-patch push the changes from the deployment back to dev, but this does not record merges and therefore requires creating a different set of patches for each adjacent set of changes along with some record on how to reproduce the exact merge that happened between them. There is some discussion on how to make diff for merge commands , but this does not seem to reflect the actual pedigree, but only the changes. It seems that the fixes may not be rich enough to provide the necessary information.

  • Some script text bindings can be used to convert the package to an unencrypted and readable (ish) format (and then back after loading), but I have not found any evidence that such a script exists.

  • Perhaps it would be possible to write a script to move the story from some common ancestor to the newest commit, and either a) make a patch, or b) recreate the merging of some well-known links.

Fallback: I could always crush the commits leaving the deployment room into one raw patch and break the history, but then further downloads from dev-> deploy would break the existing working copies. Not ideal.

Update: I believe that git fast-export can do what I need, although in most examples it works on entire repositories and not on partial histories like git bundle . I have a working example of toys in which I can export a partial story to an obsolete clone, but I need to manually edit the output with quick export to add from <sha1> to the first commit. Without this modification, the import creates different sha1s and then complains about Not updating refs/heads/master (new tip <hash> does not contain <master hash>) .

Update2: My git fast-export solution works, but it has a bandwidth problem as it works by providing completely new files, and not different from previous files. This is unacceptable since I really have to read all these extra lines.

+4
source share
1 answer

I did not find the perfect solution, but now we are working. The main disadvantage is that there is initially one SHA1 within the deployment room, which then transfers to another SHA1 after merging with the Dev room. The good news is that git pretty easily recognizes them, since the same commits can merge go through them.

  • There are 3 checkpoints that we must track:
    • dev/master , which has the latest development in the dev room.
    • deploy/master , which has the latest development in the deployment room.
    • dev_deploy_common , which is the last one to pass two stories.

.

  • When we move the code from dev for deployment (using the kit), we take the commit as part of the dev_deploy_common branch within the deployment location ( git pull to dev_deploy_common ), and then from a deploy/master do a git merge dev_deploy_common and then resolve and resolve conflicts.

  • When we translate the code from deployment to dev (which should be a text file), we take a few extra steps:

  • First, we reformat deploy/master to dev_deploy_common so that all of our patches are contiguous. This is usually easy, since we have already dealt with any conflicts during the mergers that occurred when deploying the package from dev for deployment.

  • Secondly, we create a set of patches using

     git format-patch -M25 -C25 --find-copies-harder -k --ignore-if-in-upstream 

    The options -M25 -C25 --find-copies-harder simply reduce the size of the output text. The -k option saves fixed objects. --ignore-if-in-upstream limits our commits to only new ones, since dev_deploy_common .

    The result of this is a set of patches patchset.txt . This file can be viewed manually and then moved to the dev room.

  • In the dev room, we import the patchset using the following command:

     git am -k -3 --keep-cr --committer-date-is-author-date patchset.txt 

    Unfortunately, despite the fact that we use all the commands, we can save the patch in the same way, some of the attributes change, especially the committer. As a result, the β€œsame” fix will have different SHA1 in dev and expand the rooms. This difference will persist until we move the package back to the deployment room.

  • When you move a package from dev for deployment, the merge operation (usually) recognizes identical fixes and smoothly replaces the commit with what is in the dev history. See step 1.

+4
source

Source: https://habr.com/ru/post/1496876/


All Articles