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

Re: Bug with .gitignore and branch switching

From
Stefan Beller <sbeller@google.com>
Date
Mar 17, 2017, 21:58 UTC
Message-ID
<CAGZ79kZQsauBfoTjyqm+-+LjyyEc2Ykj5exUY5KdErEzFH0GMA@mail.gmail.com>
In-Reply-To
<xmqqmvcj61j2.fsf@gitster.mtv.corp.google.com>
On Fri, Mar 17, 2017 at 2:23 PM, Junio C Hamano <gitster@pobox.com> wrote:
> We've discussed the lack of "untracked but precious" class a few
> times on the list in the past, but I do not recall the topic came up
> in the recent past.  It perhaps is because nobody found that class
> useful enough so far.

My gut reaction on reading the bug report was that the root cause is git-checkout doing the wrong thing by default. (cf. Git-Merge-2017, "What’s Wrong With Git?", I am not sure if the video is yet available)

One argument in that talk was that Git promises to do "work on multiple branches in parallel (context-switched, single threaded)", and git-checkout is the apparent command to switch to another context (branch). However by putting away only tracked content, we miss doing a proper context switch for untracked and ignored files.

That partial switch has advantages in the typical use case, e.g.
* compiled objects in the worktree may not need to be recompiled.
* no need to do work for the untracked files (e.g. move to a special
  location).

Both these reasons argue for performance, instead of "correctness" in the sense of "easy-to-understand commands for top level principles".

And in that talk the presenter concluded that git-stash was only invented to circumvent these "correctness" problems, such that if git-checkout were to also (de)populate the untracked and ignored files on branch switch we would not need git-stash, because git-checkout did it for you already. And by the omission of git-stash and an apparent easier-to-understand git-checkout the whole git suite would become easier for users.

I further conclude that when git-checkout were to behave "correct" as outlined above, then this class of bug reports would not occur.

Just food for thought.

Thanks, Stefan

Previous: Duy NguyenNext: Nevada Sanchez
Message 6 of 8 in “Bug with .gitignore and branch switching”
  1. Nevada SanchezMar 17, 2017
  2. Junio C HamanoMar 17, 2017
  3. Jonathan NiederMar 17, 2017
  4. Junio C HamanoMar 17, 2017
  5. Duy NguyenMar 18, 2017
  6. Stefan BellerMar 17, 2017
  7. Nevada SanchezMar 18, 2017
  8. Jonathan NiederMar 17, 2017

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.