git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: johnkw <johnkw@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: `git stash --include-untracked` touches .pack files
Date: Mon, 11 Aug 2025 11:10:25 +0200	[thread overview]
Message-ID: <aJmzgfucZIJf_iQA@pks.im> (raw)
In-Reply-To: <2ea19b6b-716b-4736-8dd3-8831056c39f9@gmail.com>

On Wed, Aug 06, 2025 at 09:27:05PM -0500, johnkw wrote:
> `git stash --include-untracked` causes the timestamp to be touched for some
> .pack files.  It's not always all .pack files, although I don't see a
> pattern regarding how some survive the operation with the timestamp intact. 
> For a given repo it seems consistent though on the .pack files impacted by
> the issue.
> 
> This breaks backup systems such as rsync, causing pointless churn.
> 
> The issue occurs with or without ".keep" files for the ".pack" files in
> question.
> 
> `git stash` without `--include-untracked` does not have this issue.
> 
> The issue occurs with no untracked files actually even in the repo for
> `--include-untracked` to take action on.

What you probably see here is Git freshening its objects: when Git is
asked to write objects into the object database that it already knows
about it will freshen the access time of each such object. If the object
is stored in a packfile, then the whole packfile is getting freshened.

This is overall an expected outcome, and Git relies on those freshened
access times to do garbage collection. So this isn't something that we
can change. One _could_ have a look at `save_untracked_files()` and
teach it to skip writing objects in case there is nothing to be done.
But honestly, I doubt that this would really solve the underlying issue
for you, as any other command that writes objects might also cause Git
to freshen the packfile.

Patrick

      reply	other threads:[~2025-08-11  9:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-07  2:27 `git stash --include-untracked` touches .pack files johnkw
2025-08-11  9:10 ` Patrick Steinhardt [this message]

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=aJmzgfucZIJf_iQA@pks.im \
    --to=ps@pks.im \
    --cc=git@vger.kernel.org \
    --cc=johnkw@gmail.com \
    /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).