threads / discuss / 36586

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

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

## tl;dr

3 messages between May 5, 2014 and May 7, 2014.

replies: 2people: 2as markdown or json

Timo Teras· May 5, 2014, 08:53 UTC · lore
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

Junio C Hamano· May 6, 2014, 19:18 UTC · re: Timo Teras · lore

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

Timo Teras <timo.teras@iki.fi> writes:
Show 12 quoted lines
> 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?

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?

Timo Teras· May 7, 2014, 05:01 UTC · re: Junio C Hamano · lore

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

On Tue, 06 May 2014 12:18:16 -0700 Junio C Hamano <gitster@pobox.com> wrote:

Show 20 quoted lines
> Timo Teras <timo.teras@iki.fi> writes:
> 
> > 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?
> 
> 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.

← back to recent threads