{"thread":{"id":"36586","subject":"git fast-import: how to prevent incremental commit with no changes","startedAt":"2014-05-05T08:53:20Z","lastAt":"2014-05-07T05:01:37Z","messageCount":3,"participants":["Timo Teras","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"240764","messageId":"20140505115320.395edd2e@vostro","threadId":"36586","inReplyTo":null,"subject":"git fast-import: how to prevent incremental commit with no changes","fromName":"Timo Teras","fromEmail":"timo.teras@iki.fi","sentAt":"2014-05-05T08:53:20Z","receivedAt":"2014-05-05T08:53:20Z","isPatch":false,"sender":{"key":"timo.teras@iki.fi","avatar":null},"body":"Hi,\n\nI'm trying to script a setup that would periodically import a tarball\nto git with fast-import. But things do not always change, so I'd like\nfast-import to be able to not do the commit in case there is no change.\n\nThat is, I'm constructing the commit with \"deleteall\" + importing each\nobject by mark after that. Now, in case nothing changed, fast-import\nwill happily create an empty commit for me.\n\nWould it be possible to add some flag that would make commit fail in\ncase nothing changed?\n\nAny suggestions how to do this?\n\nThanks,\nTimo\n"},{"id":"240818","messageId":"xmqqwqdyemx3.fsf@gitster.dls.corp.google.com","threadId":"36586","inReplyTo":"20140505115320.395edd2e@vostro","subject":"Re: git fast-import: how to prevent incremental commit with no changes","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-05-06T19:18:16Z","receivedAt":"2014-05-06T19:18:16Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Timo Teras <timo.teras@iki.fi> writes:\n\n> I'm trying to script a setup that would periodically import a tarball\n> to git with fast-import. But things do not always change, so I'd like\n> fast-import to be able to not do the commit in case there is no change.\n>\n> That is, I'm constructing the commit with \"deleteall\" + importing each\n> object by mark after that. Now, in case nothing changed, fast-import\n> will happily create an empty commit for me.\n>\n> Would it be possible to add some flag that would make commit fail in\n> case nothing changed?\n>\n> Any suggestions how to do this?\n\nI am not sure if such a conditional logically belongs to what\nfast-import does.  Would it be an option for your script to rewind\nthe HEAD after the import is done and it finds that the tarball did\nnot have anything interesting new?\n"},{"id":"240869","messageId":"20140507080137.64c94037@vostro","threadId":"36586","inReplyTo":"xmqqwqdyemx3.fsf@gitster.dls.corp.google.com","subject":"Re: git fast-import: how to prevent incremental commit with no changes","fromName":"Timo Teras","fromEmail":"timo.teras@iki.fi","sentAt":"2014-05-07T05:01:37Z","receivedAt":"2014-05-07T05:01:37Z","isPatch":false,"sender":{"key":"timo.teras@iki.fi","avatar":null},"body":"On Tue, 06 May 2014 12:18:16 -0700\nJunio C Hamano <gitster@pobox.com> wrote:\n\n> Timo Teras <timo.teras@iki.fi> writes:\n> \n> > I'm trying to script a setup that would periodically import a\n> > tarball to git with fast-import. But things do not always change,\n> > so I'd like fast-import to be able to not do the commit in case\n> > there is no change.\n> >\n> > That is, I'm constructing the commit with \"deleteall\" + importing\n> > each object by mark after that. Now, in case nothing changed,\n> > fast-import will happily create an empty commit for me.\n> >\n> > Would it be possible to add some flag that would make commit fail in\n> > case nothing changed?\n> >\n> > Any suggestions how to do this?\n> \n> I am not sure if such a conditional logically belongs to what\n> fast-import does.  Would it be an option for your script to rewind\n> the HEAD after the import is done and it finds that the tarball did\n> not have anything interesting new?\n\nYes, this is what I ended up with for now. I wanted to avoid this mostly\nso that I would not need to run \"git gc --prune=now\" or similar after\neach import (or at least not \"often\").\n\nThanks.\n"}]}