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

3 messages from 2014-05-05 to 2014-05-07. Participants: Timo Teras, Junio C Hamano.
Thread: https://gitlist.dev/t/36586

## Timo Teras, 2014-05-05 08:53

Subject: git fast-import: how to prevent incremental commit with no changes
Message-ID: <20140505115320.395edd2e@vostro>
URL: https://gitlist.dev/e/20140505115320.395edd2e%40vostro

```
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, 2014-05-06 19:18

Subject: Re: git fast-import: how to prevent incremental commit with no changes
Message-ID: <xmqqwqdyemx3.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqqwqdyemx3.fsf%40gitster.dls.corp.google.com
In-Reply-To: <20140505115320.395edd2e@vostro>

```
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?

```

## Timo Teras, 2014-05-07 05:01

Subject: Re: git fast-import: how to prevent incremental commit with no changes
Message-ID: <20140507080137.64c94037@vostro>
URL: https://gitlist.dev/e/20140507080137.64c94037%40vostro
In-Reply-To: <xmqqwqdyemx3.fsf@gitster.dls.corp.google.com>

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

> 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.

```
