Git development
 help / color / mirror / Atom feed
From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: Daniel Lublin <daniel@lublin.se>
Cc: git@vger.kernel.org, Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: Re: git stash push --patch offers skip-worktree hunks
Date: Wed, 27 Jan 2021 13:21:55 +0000	[thread overview]
Message-ID: <YBFo8xJu57fC1PO/@camp.crustytoothpaste.net> (raw)
In-Reply-To: <rur7en$16bk$1@ciao.gmane.io>

[-- Attachment #1: Type: text/plain, Size: 2129 bytes --]

On 2021-01-27 at 08:15:19, Daniel Lublin wrote:
> Hi,
> 
> I'm using this to hide some locally modified files from accidental commit:
> 
>   git update-index --skip-worktree ...

This isn't the intended purpose of this functionality, and as you've
seen it doesn't work properly for that case.  From gitfaq(7):

How do I ignore changes to a tracked file?

  Git doesn't provide a way to do this.  The reason is that if Git needs
  to overwrite this file, such as during a checkout, it doesn't know
  whether the changes to the file are precious and should be kept, or
  whether they are irrelevant and can safely be destroyed.  Therefore,
  it has to take the safe route and always preserve them.

  It's tempting to try to use certain features of `git update-index`,
  namely the assume-unchanged and skip-worktree bits, but these don't
  work properly for this purpose and shouldn't be used this way.

  If your goal is to modify a configuration file, it can often be
  helpful to have a file checked into the repository which is a template
  or set of defaults which can then be copied alongside and modified as
  appropriate.  This second, modified file is usually ignored to prevent
  accidentally committing it.

There is a lot of misinformation on Stack Overflow, which is why I wrote
that FAQ entry.  Unfortunately, I can only downvote a wrong answer once.

The skip-worktree bit is designed to prevent the file from being checked
out as part of sparse checkout.

> Doing `git stash push` does not result in the above modifications being
> stashed. But, doing `git stash push --patch` asks me about hunks in the
> files which were flagged to skip-worktree. Instinctively, this feels wrong.
> The docs also say:
> 
>   Interactively select hunks from the diff between HEAD and the working tree
>   to be stashed.
> 
> What do you think?

It looks like there is a test for the case without --push in t3903, and
it looks like Dscho (CC'd) last touched it, so maybe he's familiar with
what might be going on here.
-- 
brian m. carlson (he/him or they/them)
Houston, Texas, US

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 263 bytes --]

      reply	other threads:[~2021-01-27 13:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-27  8:15 git stash push --patch offers skip-worktree hunks Daniel Lublin
2021-01-27 13:21 ` brian m. carlson [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=YBFo8xJu57fC1PO/@camp.crustytoothpaste.net \
    --to=sandals@crustytoothpaste.net \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=daniel@lublin.se \
    --cc=git@vger.kernel.org \
    /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