Created
September 10, 2009 22:48
-
-
Save web-zen/184891 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Get the current commit edits are based on | |
-1) Obtain <ID> corresponding to tip of apporiate branch 'git rev-parse <branch>'. | |
#To obtain index file to record the edits to. | |
0) Read the commit: 'GIT_INDEX_FILE=foo.index git read-tree <ID>'. Save the <ID> (obtained in step -1). | |
#Add | |
#add file to git db from temp file or piped into hash-object -w --stdin | |
1) Add the new contents to database 'git hash-object -w <temporary file containing end result of edit>'. This gives SHA-1. | |
#stage the file | |
2) Insert the file into index: 'GIT_INDEX_FILLE=foo.index git update-index --add --cacheinfo 100644 <ID-from-step-1> <path>' | |
(if there are multiple files to commit at once, repeat 1) and 2) for each. | |
#Commit | |
3) Turn the index into tree: 'GIT_INDEX_FILE=foo.index git write-tree'. Out comes SHA-1. | |
4) Create commit: 'git commit-tree <ID-from-step-3> -p <id-from-step--1> <commit.msg' | |
(that is, commit message is passed in stdin!). You get yet another sha-1. | |
GIT_{COMMITTER,AUTHOR}_{NAME,EMAIL} | |
> Invoke commit-tree with environment variable GIT_AUTHOR_NAME set to "Smith". How to do it is language-dependent. | |
<Ilari> In C it is via execve/execle. | |
<Ilari> (and execpe) | |
5) Then update the branch: 'git update-ref refs/heads/branchname <id-from-step-4> <id-from-step--1>'. If this succeeds, you are done. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment