git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 1/2] update-index: optionally leave skip-worktree entries alone

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 30, 2019, 01:13 UTC
Message-ID
<xmqq5zk7593d.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<86dbb11f159375da281acd6266df019106abeadb.1572261615.git.gitgitgadget@gmail.com>

"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com> writes:

Show 10 quoted lines
> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>
> While `git update-index` mostly ignores paths referring to index entries
> whose skip-worktree bit is set, in b4d1690df11 (Teach Git to respect
> skip-worktree bit (reading part), 2009-08-20), for reasons that are not
> entirely obvious, the `--remove` option was made special: it _does_
> remove index entries even if their skip-worktree bit is set.
>
> Seeing as this behavior has been in place for a decade now, it does not
> make sense to change it.

If this were end-user facing Porcelain behaviour, even it is a decade old, the story would have been different, but given that it is in an obscure corner in a plumbing command, I agree that it does not make sense to even transition the default over releases.

> +test_expect_success '--ignore-skip-worktree-entries leaves worktree alone' '
> +	test_commit geroff-me &&
> +	git update-index --skip-worktree geroff-me.t &&
> +	rm geroff-me.t &&

I do not see a need to swear with a sample file name. It may make sense to use words that relate to what the test is checking (e.g. skip-me or something like that), but otherwise meaningless filenames used in other tests (like 1, 2, etc) would be more in line with the existing tests.

> +
> +	: ignoring the worktree &&
> +	git update-index --remove --ignore-skip-worktree-entries geroff-me.t &&
> +	git diff-index --cached --exit-code HEAD &&

HEAD has it, working tree does not, and the one in the index should have been kept thanks to the new option added by this patch. Makes sense.

> +	: not ignoring the worktree, a deletion is staged &&
> +	git update-index --remove geroff-me.t &&
> +	test_must_fail git diff-index --cached --exit-code HEAD

Testing the other side of the coin (i.e. adding the new feature did not accidentally stop the command from removing by default) is good; "should have no difference" was a good test for the other side, but in contrast, "should have some difference" is a very loose test when the difference we want to see is that the particular path gets removed and no other changes.

Show 5 quoted lines
> +'
> +
>  #TODO test_expect_failure 'git-apply adds file' false
>  #TODO test_expect_failure 'git-apply updates file' false
>  #TODO test_expect_failure 'git-apply removes file' false
Previous: Johannes Schindelin via GitGitGadgetNext: Johannes Schindelin
Message 17 of 23 in “Fix git stash with skip-worktree entries”
  1. 0/2 Fix git stash with skip-worktree entriesJohannes Schindelin via GitGitGadget, Sep 26, 2019
  2. 1/2 update-index: optionally leave skip-worktree entries aloneJohannes Schindelin via GitGitGadget, Sep 26, 2019
  3. Junio C HamanoOct 28, 2019
  4. Johannes SchindelinOct 28, 2019
  5. Junio C HamanoOct 29, 2019
  6. 2/2 stash: handle staged changes in skip-worktree files correctlyJohannes Schindelin via GitGitGadget, Sep 26, 2019
  7. Junio C HamanoOct 28, 2019
  8. Johannes SchindelinOct 27, 2019
  9. Junio C HamanoOct 28, 2019
  10. Johannes SchindelinOct 28, 2019
  11. Junio C HamanoOct 29, 2019
  12. Johannes SchindelinOct 29, 2019
  13. 0/2 Fix git stash with skip-worktree entriesJohannes Schindelin via GitGitGadget, Oct 28, 2019
  14. 2/2 stash: handle staged changes in skip-worktree files correctlyJohannes Schindelin via GitGitGadget, Oct 28, 2019
  15. Junio C HamanoOct 30, 2019
  16. 1/2 update-index: optionally leave skip-worktree entries aloneJohannes Schindelin via GitGitGadget, Oct 28, 2019
  17. Junio C HamanoOct 30, 2019
  18. Johannes SchindelinOct 30, 2019
  19. Junio C HamanoNov 2, 2019
  20. Johannes SchindelinNov 2, 2019
  21. 0/2 Fix git stash with skip-worktree entriesJohannes Schindelin via GitGitGadget, Oct 30, 2019
  22. 1/2 update-index: optionally leave skip-worktree entries aloneJohannes Schindelin via GitGitGadget, Oct 30, 2019
  23. 2/2 stash: handle staged changes in skip-worktree files correctlyJohannes Schindelin via GitGitGadget, Oct 30, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.