Print path, 'has changed (not restoring)' Timestamps = (sha1, s.st_mtime, s.st_atime) Print 'WARNING: Tree contains a non-blob.' """ Generates (sha1,path) pairs for all blobs (files) listed by git ls-tree. Return check_output( + list(args), stderr=subprocess.STDOUT) # check_output was added in Python 2.7, so it's not always availableĮrr = subprocess.CalledProcessError(retcode, cmd) Python Timestamp Save/Restore Script #!/usr/bin/env python This is kinda ugly, but it was interesting to write. That would have to be treated specially.Īnd yes, I tested this on a toy repo, and it appears to work properly! (Though I didn't try hard to break it.)Īlternatively, you can fix the symptoms directly by saving and restoring file timestamps. If you're in detached HEAD mode, things will go badly.I did this deliberately, because when you use -no-ff, git will actually force itself to use the default (recursive) strategy, but to write that in the reflog would be a lie. Obviously you'll actually have to check out and merge (possibly in a clone, to save your build system) in that case. This only works on merges that could have been a fast-forward.If you're obsessive, you could make sure that commit-tree succeeded - but that should be pretty much guaranteed. The commit's SHA1 is printed to stdout, so assuming the commit succeeded, you capture that, then merge that commit (that'll be a fast-forward). The commit message is supplied on stdin, and the rest of the arguments name the parents the new commit should have. The first argument is the tree to use that's the tree HEAD, the branch whose contents you want to keep. The interesting bit is that newcommit= line it uses commit-tree to directly create the merge commit. Git update-ref -m "merge $currentbranch: Merge made by simulated no-ff" "refs/heads/$branch" $newcommitĮcho "error: merging $currentbranch into $branch would not be a fast-forward" # move the branch to point to the new commit Newcommit=$(echo "Merge branch '$currentbranch'" | git commit-tree $(git log -n 1 -pretty=%T HEAD) -p $branch -p HEAD) # find the branch name associated with HEADĬurrentbranch=$(git symbolic-ref HEAD | sed make the commit If ! git rev-parse -verify -quiet -heads "$branch" > /dev/null thenĮcho "error: branch $branch does not exist" Interesting! I don't think there's a built-in way to do this, but you should be able to fudge it using the plumbing: #!/bin/bash
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |