Skip to contentSkip to conversation

git fast-import: how to prevent incremental commit with no changes

DISCUSSION Timo Teras 2 participants 3 messages Jun 15, 2016

lore
Share & tools
lore

Timo Teras

author
#0 lore raw

Hi,

I'm trying to script a setup that would periodically import a tarball to git with fast-import. But things do not always change, so I'd like fast-import to be able to not do the commit in case there is no change.

That is, I'm constructing the commit with "deleteall" + importing each object by mark after that. Now, in case nothing changed, fast-import will happily create an empty commit for me.

Would it be possible to add some flag that would make commit fail in case nothing changed?

Any suggestions how to do this?

Thanks,
Timo

#1 lore raw
Quoted 4 lines · Timo Teras

I'm trying to script a setup that would periodically import a tarball to git with fast-import. But things do not always change, so I'd like fast-import to be able to not do the commit in case there is no change.

Quoted 8 lines

That is, I'm constructing the commit with "deleteall" + importing each object by mark after that. Now, in case nothing changed, fast-import will happily create an empty commit for me.

Would it be possible to add some flag that would make commit fail in case nothing changed?

Any suggestions how to do this?

I am not sure if such a conditional logically belongs to what fast-import does. Would it be an option for your script to rewind the HEAD after the import is done and it finds that the tarball did not have anything interesting new?

author
#2 lore raw
Quoted 14 lines · On Tue, 06 May 2014 12:18:16 -0700 Junio C Hamano <[email protected]> wrote:
Quoted 12 lines · Timo Teras

I'm trying to script a setup that would periodically import a tarball to git with fast-import. But things do not always change, so I'd like fast-import to be able to not do the commit in case there is no change.

That is, I'm constructing the commit with "deleteall" + importing each object by mark after that. Now, in case nothing changed, fast-import will happily create an empty commit for me.

Would it be possible to add some flag that would make commit fail in case nothing changed?

Quoted 6 lines
Quoted 1 line

Any suggestions how to do this?

I am not sure if such a conditional logically belongs to what fast-import does. Would it be an option for your script to rewind the HEAD after the import is done and it finds that the tarball did not have anything interesting new?

Yes, this is what I ended up with for now. I wanted to avoid this mostly so that I would not need to run "git gc --prune=now" or similar after each import (or at least not "often").

Thanks.