git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Philip Oakley" <philipoakley@iee.org>
To: "Angelo Borsotti" <angelo.borsotti@gmail.com>,
	"Junio C Hamano" <gitster@pobox.com>
Cc: "Johannes Sixt" <j.sixt@viscovery.net>, "git" <git@vger.kernel.org>
Subject: Re: erratic behavior commit --allow-empty
Date: Wed, 3 Oct 2012 08:29:37 +0100	[thread overview]
Message-ID: <90464C79DA97415C9D66846A77ECAA4A@PhilipOakley> (raw)
In-Reply-To: CAB9Jk9D-eJ8goYx7LWqGcWcLgRDS8+qLZVUsvvJ+QOtryP9-zg@mail.gmail.com

From: "Angelo Borsotti" <angelo.borsotti@gmail.com>
> Hi Junio,
>
>> It does create one; it just is the same one you already happen to 
>> have,
>> when you record the same state on top of the same history as the
>> same person at the same time.
>>
>
> No, it does not create one:

Angelo
This is a semantics problem. It is like the confusion as to whether zero 
is a natural number that can be used in counting.

In this case we have created two commits. However they are, by design 
and definition, identical to each other for this case of identical 
content and identical administration fields. They cannot be 
distinguished.

So when the file system is asked to 'write' the second commit, it (the 
file system in conjunction with the git code) does a no-op, and reports 
'done'.

It is a common (systems) engineering problem. Software engineering 
usually allows an empty subroutine to exist, while physical engineering 
wouldn't. Git cannot have two unique but identical commits (a 
contradiction in terms).

Normally git will create a new (different & unique) commit for each and 
every commit, but in this special case a second identical commit was 
'created', but the uniqueness requirement means it _is_ the same as the 
first commit.

> as you can see from the trace of the execution
> of my script, the sha of the commit is the same as that of the other,
> which means
> that in the .git/objects there is only one such commit object, and not 
> two with
> the same sha. The meaning of the word "create" is to bring into being 
> something
> that did not exist before. There is no "creation" if the object 
> already exists.
>
>>
>> And how would it help what to insert a sleep for 1 second (or 1 year
>> for that matter)?  As you said, it reads from the system clock, and
>> there are millions of systems in the world that have Git installed.
>> You may record the same state on top of the same history as the same
>> person on two different machines 5 minutes in wallclock time in
>> between doing so.  These two machines may end up creating the same
>> commit because one of them had a clock skewed by 5 minutes.
>
> I understood that the command does not create a new commit if all its 
> data, i.e.
> tree, committer, ... and date are the same, representing the date with 
> 1 second
> precision. Sleeping for 1 second guarantees that there is no commit in 
> the repo
> that has the same time as the time after the sleep, i.e. that the
> command creates
> a (new) commit.
>
>>
>> What problem are you really trying to solve?  You mentioned
>> importing from the foreign SCM,
>
> I quoted a piece of the man page of git commit, that states that
> --allow-empty bypasses
> the safety check that prevents to make a new commit. That piece
> incidentally states
> that it is "primarily" used by foreign SCM interface scripts. But of
> course it can be used
> in any script that needs to build a commit on top of another.
>
>>
>> You also did not seem to have read what I wrote, or deliberately
>> ignored it (in which case I am wasting even more time writing this,
>> so I'll stop).
>
> I did not deliberately ignore what you wrote. I might have missed some
> point though.
>
>> This does not have anything to do with "--allow-empty"; removing
>> "the option" would not help anything, either.
>
> I am reporting a problem with --allow-empty, so why you say that this
> does not have
> anything to do with it?
> Removing the option removes a behavior that is not predictable.
> Often it is better to remove a feature that turns out to be
> inconsistent than to leave it
> in the software. Of course a much better avenue is to make it 
> consistent.
>
>> Run the following on a fast-enough machine.
>>
> I did, and obtained most of the times "I was quick enough" and
> sometimes "I was not quick enough", which is the same kind of behavior
> of my script.
>
> The problem I am trying to solve is to push to a remote server the
> source files only,
> while keeping in the local repo both sources and binaries. To do it, I
> keep an orphan
> branch, say "sources". When I make a commit on the master branch, I 
> make also a
> commit on the sources one after having un-staged (git rm --cached) the 
> binaries.
> The script that does this must cope also with the particular case in
> which in the commit
> on the master branch there are no sources. Basically the script does:
>
> # this is the commit on the master branch
> git init
> echo "aaa" >f1
> git add f1
> git commit -m A
>
> # this is the piece of the script that builds the sources branch
> git checkout --orphan sources
> # git rm --cached ...   remove binaries, if any"
> git commit -m A --allow-empty
> git rev-list --all --pretty=oneline
>
> When there are binaries in the commit A, they are removed, and the
> tree for the second
> git commit is then different, and the commit is actually created.
> When there are no binaries (as in the script above, in which the
> removal is commented out),
> the second git commit would not create any new commit, and I would not
> have an orphan
> branch. Thence the --allow-empty to force it to create a new commit.
> Unfortunately, it creates a new commit only if the system clock
> changes the seconds of
> the system time between the two git commits.
> If you insert a "sleep 1" before the second git commit, the commit is
> really created.
>
> I spent many hours to spot this time-dependent error ....
>
> -Angelo
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
>
> -----
> No virus found in this message.
> Checked by AVG - www.avg.com
> Version: 2012.0.2221 / Virus Database: 2441/5305 - Release Date: 
> 10/02/12
> 

  parent reply	other threads:[~2012-10-03  7:29 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-02  7:51 erratic behavior commit --allow-empty Angelo Borsotti
2012-10-02  8:26 ` Johannes Sixt
2012-10-02  8:49   ` Angelo Borsotti
2012-10-02 17:27   ` Junio C Hamano
2012-10-02 19:34     ` Angelo Borsotti
2012-10-02 19:56       ` Junio C Hamano
2012-10-02 21:56         ` Angelo Borsotti
2012-10-03  2:10           ` PJ Weisberg
2012-10-03  5:37           ` Johannes Sixt
2012-10-03  6:22             ` Angelo Borsotti
2012-10-03  6:27               ` Johannes Sixt
     [not found]                 ` <CAB9Jk9AgtNQfWDr31CWbXf2ag=11du-aruu-0+nOZ3KaaG9=og@mail.gmail.com>
2012-10-03  7:12                   ` Johannes Sixt
2012-10-03  7:35                     ` Angelo Borsotti
2012-10-03 20:49                     ` Junio C Hamano
2012-10-03  7:29           ` Philip Oakley [this message]
2012-10-03  7:45             ` Angelo Borsotti
2012-10-03  8:04               ` Matthieu Moy
2012-10-03  8:24                 ` Angelo Borsotti
2012-10-03 11:07                   ` Matthieu Moy
2012-10-03 11:52                     ` Angelo Borsotti
     [not found]                       ` <CABURp0oHez6j8+FPG8Zm52TGVyC1XwWhE55TBDrXRGFrW6kWww@mail.gmail.com>
2012-10-03 13:35                         ` Angelo Borsotti
2012-10-03 14:15                           ` Phil Hord
2012-10-03 13:57                       ` Matthieu Moy
2012-10-03 14:46                         ` Angelo Borsotti
2012-10-03 14:52                           ` Matthieu Moy
2012-10-03 22:32                       ` Philip Oakley
2012-10-04  7:07                         ` Angelo Borsotti
2012-10-04 13:24                           ` Phil Hord
2012-10-04 19:00                             ` Angelo Borsotti
2012-10-04 21:17                           ` Philip Oakley
2012-10-04 22:09                             ` Angelo Borsotti
2012-10-04 22:42                               ` Philip Oakley
2012-10-04 23:10                                 ` Angelo Borsotti
2012-10-03 12:25                   ` Tomas Carnecky
2012-10-03 13:08                     ` Angelo Borsotti
2012-10-03 10:12               ` Andreas Schwab
2012-10-03 11:37                 ` Angelo Borsotti
2012-10-03 13:44                   ` Andreas Schwab
2012-10-03 14:37                     ` Angelo Borsotti
2012-10-03 16:44                       ` Andreas Schwab
2012-10-03 17:37                         ` Angelo Borsotti
2012-10-03 19:03                           ` Andreas Schwab
2012-10-03 19:11                             ` Angelo Borsotti
2012-10-03 20:30                               ` Andreas Schwab
2012-10-03 12:59       ` Phil Hord
2012-10-03 14:25         ` Angelo Borsotti
2012-10-03 16:06           ` PJ Weisberg
2012-10-03 17:34             ` Angelo Borsotti
2012-10-03 19:05               ` Andreas Schwab
2012-10-03 19:43               ` PJ Weisberg
2012-10-05  8:15               ` Lars Noschinski
2013-01-12 18:30   ` Jan Engelhardt
2013-01-16 12:26     ` Joachim Schmitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=90464C79DA97415C9D66846A77ECAA4A@PhilipOakley \
    --to=philipoakley@iee.org \
    --cc=angelo.borsotti@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j.sixt@viscovery.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).