git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Peter Backes <rtc@helen.PLASMA.Xg8.DE>
Cc: git@vger.kernel.org
Subject: Re: Git should preserve modification times at least on request
Date: Tue, 20 Feb 2018 11:46:38 +0100 (STD)	[thread overview]
Message-ID: <nycvar.QRO.7.76.6.1802201127140.31@ZVAVAG-6OXH6DA.rhebcr.pbec.zvpebfbsg.pbz> (raw)
In-Reply-To: <20180219220819.GA10466@helen.PLASMA.Xg8.DE>

Hi Peter,

On Mon, 19 Feb 2018, Peter Backes wrote:

> On Mon, Feb 19, 2018 at 10:58:12PM +0100, Johannes Schindelin wrote:
> > Since you already assessed that it shouldn't be hard to do, you
> > probably want to put your money where your mouth is and come up with a
> > patch, and then offer it up for discussion on this here mailing list.
> 
> Well, it would be good to discuss this a bit beforehand, since my time 
> is wasted if there's no chance to get it accepted. Perhaps there is 
> some counterargument I don't know about.

Oh, sorry. I understood your mail as if you had told the core Git
developers that they should implement the feature you desire. I did not
understand that you hinted at a discussion first, and that you would then
go and implement the feature you asked for.

> Is there some existing code that could be used? I think I read 
> somewhere that git once did preserve mtimes, but that this code was 
> removed because of the build tool issues. Perhaps that code could 
> simply be put back in, and surrounded by conditions.

I don't think that code was ever there. Maybe you heard about some file
mode being preserved overzealously (we stored the octal file mode
verbatim, but then decided to store only 644 or 755).

(This is to add to Theodore's reply, giving a bit more depth.)

As you can see from the code decoding a tree entry:

https://github.com/git-for-windows/git/blob/e1848984d/tree-walk.c#L25-L52

there is no mtime at all in the on-disk format of tree objects. There is
the hash, the mode, and the file name.

As your main use case would be stashing and unstashing (which uses tree
objects as storage format), this means you would have to find a different
way to store the information you desire.

If I were you, and if I had the time to implement this feature, I would go
about it by adding a note (using `git notes` from a script first, but only
for proof of concept, because I saw too many things go wrong with Unix
shell scripts in production) for the tree object, say, in
refs/notes/mtimes. I would probably invent a file format
(`<mtime><TAB><path><LF>`) to store the information, and for starters I
would only store the mtimes of the files that were stashed, then extend
the script into a full Git builtin with a subcommand that can generates
these notes, a subcommand to replay them, and a subcommand to inspect
them.

Then I would extend `git-stash.sh` to take an option (and later, to heed a
new config setting to do this automatically) to generate those mtime notes
for the newest stash's top-level tree object (storing only the times of
the files that were modified by the `stash` command), and to replay them
if such an mtime note is found for the stash that is being applied.

You will not be able to convince the core Git developers to make this the
default, I don't think. But if you make it an opt-in as I outlined above,
I believe your chances would be good to get that feature if you put in the
effort to implement it.

Oh, and if you implement the feature using notes, the same feature can be
used not only for stashing and unstashing. These notes are maintained in
regular Git refs, i.e. they can be shared. And since those notes would be
for tree objects, you could even apply the mtimes on a fresh clone, if
you have a use case for that.

Ciao,
Johannes

  parent reply	other threads:[~2018-02-20 10:46 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-19 21:22 Git should preserve modification times at least on request Peter Backes
2018-02-19 21:58 ` Johannes Schindelin
2018-02-19 22:08   ` Peter Backes
2018-02-20  1:22     ` Theodore Ts'o
2018-02-20 10:46     ` Johannes Schindelin [this message]
2018-02-20 11:53       ` Peter Backes
2018-02-20 21:05       ` Peter Backes
2018-02-20 22:32         ` Johannes Schindelin
2018-02-20 22:48           ` Peter Backes
2018-02-21 21:30             ` Phillip Wood
2018-02-19 22:37   ` Randall S. Becker
2018-02-19 23:22     ` Hilco Wijbenga
2018-02-20 16:42       ` Hilco Wijbenga
2018-02-20 21:16 ` Jeff King
2018-02-20 22:05   ` Peter Backes
2018-02-21  9:48     ` Jacob Keller
2018-02-20 23:40   ` Junio C Hamano
2018-02-21 21:03 ` Derek Fawcus
2018-02-21 21:33   ` Ævar Arnfjörð Bjarmason
2018-02-21 22:14     ` Peter Backes
2018-02-21 22:44       ` Ævar Arnfjörð Bjarmason
2018-02-21 23:12         ` Peter Backes
2018-02-21 23:58           ` Randall S. Becker
2018-02-22  2:05             ` 'Peter Backes'
2018-02-26 10:56               ` Andreas Krey
2018-02-26 11:04                 ` 'Peter Backes'
2018-02-22 23:24         ` Derek Fawcus
2018-02-23 12:28       ` Konstantin Khomoutov

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

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

  git send-email \
    --in-reply-to=nycvar.QRO.7.76.6.1802201127140.31@ZVAVAG-6OXH6DA.rhebcr.pbec.zvpebfbsg.pbz \
    --to=johannes.schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=rtc@helen.PLASMA.Xg8.DE \
    /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.
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 NNTP newsgroup(s).