{"thread":{"id":"25229","subject":"Commiting automatically","startedAt":"2010-09-24T20:43:12Z","lastAt":"2010-10-10T21:11:35Z","messageCount":5,"participants":["Maaartin","Ramkumar Ramachandra","Alex Riesen","Matthieu Moy"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"151546","messageId":"loom.20100924T224155-693@post.gmane.org","threadId":"25229","inReplyTo":null,"subject":"Commiting automatically","fromName":"Maaartin","fromEmail":"grajcar1@seznam.cz","sentAt":"2010-09-24T20:43:12Z","receivedAt":"2010-09-24T20:43:12Z","isPatch":false,"sender":{"key":"grajcar1@seznam.cz","avatar":null},"body":"I'm going to run periodically a process which uses the current working tree and \nI'd like to protocol what happens. As a part of the protocol I need the exact \nstate of the working tree and that's what is git good for, right? But it must \nneither disturb my normal workflow nor interfere with my ordinal commits. I \ncould probably use something like\n\nGIT_DIR=a_special_git_dir\ngit reset --soft a_special_branch\ngit add -A\ngit commit -m \"automatic\"\ngit push\n\nwhere the push would go to my ordinary external repository (used as a backup \nhere). I'm quite a beginner and unsure what problem should I expect here.\n\nEven if there were no problems, it's not very nice. It uses an additional \nrepository which is quite strange. Moreover, there's no way to find out how the \nsaved working tree snapshot is related to existing ordinal commits.\n\n\nPS: I don't want to post separate \"thank you\" messages, so let me thank to \neverybody now. I've already had three questions and got three times a very \nhelpful answer in a very short time, just fantastic.\n"},{"id":"151622","messageId":"20100925080117.GC17928@kytes","threadId":"25229","inReplyTo":"loom.20100924T224155-693@post.gmane.org","subject":"Re: Commiting automatically","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2010-09-25T08:01:19Z","receivedAt":"2010-09-25T08:01:19Z","isPatch":false,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Hi Maartin,\n\nMaaartin writes:\n> I'm going to run periodically a process which uses the current working tree and \n> I'd like to protocol what happens. As a part of the protocol I need the exact \n> state of the working tree and that's what is git good for, right? But it must \n> neither disturb my normal workflow nor interfere with my ordinal commits. I \n> could probably use something like\n> \n> GIT_DIR=a_special_git_dir\n> git reset --soft a_special_branch\n> git add -A\n> git commit -m \"automatic\"\n> git push\n\nInstead of doing it by hand, I'd recommend using something nicer like\nFlashbake to do this [1].\n\n> where the push would go to my ordinary external repository (used as a backup \n> here). I'm quite a beginner and unsure what problem should I expect here.\n\nI suppose you can create another branch without common ancestry and\nkeep committing there. I'd suggest using contrib/git-new-workdir to\nkeep a working copy of that branch and using flashbake to commit to it\nwithout interrupting your working branch.\n\n> Even if there were no problems, it's not very nice. It uses an additional \n> repository which is quite strange. Moreover, there's no way to find out how the \n> saved working tree snapshot is related to existing ordinal commits.\n\nThe additional repository is eliminated now. You can use the complete\nGit infrastructure to play with the commits in your working branch and\nyour flashbake branch.\n\n-- Ram\n\n[1] http://bitbucketlabs.net/flashbake/\n"},{"id":"151629","messageId":"AANLkTimpyTVe+OhYRhsV3H8TGahgsASOPAZRqwR=V6od@mail.gmail.com","threadId":"25229","inReplyTo":"loom.20100924T224155-693@post.gmane.org","subject":"Re: Commiting automatically","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2010-09-25T10:05:28Z","receivedAt":"2010-09-25T10:05:28Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On Fri, Sep 24, 2010 at 22:43, Maaartin <grajcar1@seznam.cz> wrote:\n> I'm going to run periodically a process which uses the current working tree and\n> I'd like to protocol what happens. As a part of the protocol I need the exact\n> state of the working tree and that's what is git good for, right? But it must\n> neither disturb my normal workflow nor interfere with my ordinal commits. I\n> could probably use something like\n...\n> Even if there were no problems, it's not very nice. It uses an additional\n> repository which is quite strange. Moreover, there's no way to find out how the\n> saved working tree snapshot is related to existing ordinal commits.\n\nTry using low-level git commands (the \"plumbing\").\nTake a look at GIT_INDEX_FILE environment variable and\n\"git write-tree\", \"git commit-tree\" and \"git update-ref\", in\naddition to \"git add\".\n\nI.e. (untested):\n\n  $ (\n  export GIT_INDEX_FILE=.git/myindex\n  git add . &&\n  tree=$(git write-tree) &&\n  commit=$(date |git commit-tree $tree -p protocol) &&\n  git update-ref -m autolog protocol $commit\n  )\n"},{"id":"153157","messageId":"loom.20101010T212207-709@post.gmane.org","threadId":"25229","inReplyTo":"AANLkTimpyTVe+OhYRhsV3H8TGahgsASOPAZRqwR=V6od@mail.gmail.com","subject":"Re: Commiting automatically","fromName":"Maaartin","fromEmail":"grajcar1@seznam.cz","sentAt":"2010-10-10T19:23:56Z","receivedAt":"2010-10-10T19:23:56Z","isPatch":false,"sender":{"key":"grajcar1@seznam.cz","avatar":null},"body":"On 10-09-25 12:05, Alex Riesen wrote:\n> On Fri, Sep 24, 2010 at 22:43, Maaartin <grajcar1@seznam.cz> wrote:\n>> I'm going to run periodically a process which uses the current working tree \nand\n>> I'd like to protocol what happens. As a part of the protocol I need the exact\n>> state of the working tree and that's what is git good for, right? But it must\n>> neither disturb my normal workflow nor interfere with my ordinal commits. I\n>> could probably use something like\n>\n> Try using low-level git commands (the \"plumbing\").\n> Take a look at GIT_INDEX_FILE environment variable and\n> \"git write-tree\", \"git commit-tree\" and \"git update-ref\", in\n> addition to \"git add\".\n> \n> I.e. (untested):\n> \n>   $ (\n>   export GIT_INDEX_FILE=.git/myindex\n>   git add . &&\n>   tree=$(git write-tree) &&\n>   commit=$(date |git commit-tree $tree -p protocol) &&\n>   git update-ref -m autolog protocol $commit\n>   )\n\nBased on this, I've created a simple script \"git-autocom\" which seems to work \nsomehow. In order to test it place both attachments in a new directory and run \n\"test-git-autocom\". The test creates a new working tree with a repository and \nsome commits and then invokes \"git-autocom\".\n\nA branch autocom gets created, but I'm quite unsure if it's correct. I see a \nproblem in case the script runs with the branch autocom checked out. Maybe a \ntag could be better or whatever.\n\nI see I can attach no files here in http://post.gmane.org\n\nSo I placed them in\nhttp://dl.dropbox.com/u/4971686/101010/git-autocom\nand\nhttp://dl.dropbox.com/u/4971686/101010/test-git-autocom\nand copied them here as well (I hope there's a better way).\n\n====== git-autocom\n#!/bin/sh\nmessage=\"autocom $(date)\"\nhead=$(git show-ref -s --head HEAD)\n\n# the first parent should be autocom\nparent1=\"-p $(git show-ref -s refs/heads/autocom)\"\n# needed for the very first use\ntest -f .git/refs/heads/autocom || parent1=\"\"\n# the second parent should be the current head\nparent2=\"-p $head\"\n# make sure not giving the same parent twice\ntest \"$parent1\" = \"$parent2\" && parent1=\"\"\n\n#temporary index\nexport GIT_INDEX_FILE=.git/autocom.tmp\n\ngit add -A &&\ntree=$(git write-tree) &&\ncommit=$(echo \"$message\" | git commit-tree $tree $parent1 $parent2) &&\ngit update-ref -m \"$message\" refs/heads/autocom $commit\n====== test-git-autocom\n#!/bin/sh\n\n/bin/rm -fR testtree 2>/dev/null\nmkdir testtree &&\ncd testtree && \ngit init && \necho a > a &&\ngit add -A && git commit -m \"a\" &&\necho b > b &&\ngit add -A && git commit -m \"b\" &&\necho c > c &&\n/bin/rm b &&\ngit add -A &&\n/bin/rm a &&\necho \"preparation OK\" &&\n../git-autocom &&\necho \"autocom OK\" &&\ngit log &&\ngit log autocom\n======\n"},{"id":"153178","messageId":"vpqzkulah2w.fsf@bauges.imag.fr","threadId":"25229","inReplyTo":"loom.20101010T212207-709@post.gmane.org","subject":"Re: Commiting automatically","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2010-10-10T21:11:35Z","receivedAt":"2010-10-10T21:11:35Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Maaartin <grajcar1@seznam.cz> writes:\n\n> # the first parent should be autocom\n> parent1=\"-p $(git show-ref -s refs/heads/autocom)\"\n> # needed for the very first use\n> test -f .git/refs/heads/autocom || parent1=\"\"\n\nDon't use the content of .git/refs/ directly. Git can pack them, and\nyou can have a branch autocom packed in .git/info/refs without having it in\n.git/refs/*\n\nperhaps\n\nparent1=$(git show-ref -s refs/heads/autocom)\nif [ \"$parent1\" != \"\" ]; then\n\tparent1=\"-p $parent1\"\nfi\n\n?\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"}]}