All of lore.kernel.org
 help / color / mirror / Atom feed
* git stash push --patch offers skip-worktree hunks
@ 2021-01-27  8:15 Daniel Lublin
  2021-01-27 13:21 ` brian m. carlson
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Lublin @ 2021-01-27  8:15 UTC (permalink / raw)
  To: git

Hi,

I'm using this to hide some locally modified files from accidental commit:

  git update-index --skip-worktree ...

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?

regards,

-- 
Daniel
lublin.se


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: git stash push --patch offers skip-worktree hunks
  2021-01-27  8:15 git stash push --patch offers skip-worktree hunks Daniel Lublin
@ 2021-01-27 13:21 ` brian m. carlson
  0 siblings, 0 replies; 2+ messages in thread
From: brian m. carlson @ 2021-01-27 13:21 UTC (permalink / raw)
  To: Daniel Lublin; +Cc: git, Johannes Schindelin

[-- 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 --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-27 13:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-27  8:15 git stash push --patch offers skip-worktree hunks Daniel Lublin
2021-01-27 13:21 ` brian m. carlson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.