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

Re: [PATCH 2/2] checkout: fix attribute handling in checkout all

From
Steffen Prohaska <prohaska@zib.de>
Date
Aug 13, 2007, 06:46 UTC
Message-ID
<8D126F5A-5998-4CB2-89BE-1CAEF5AE621F@zib.de>
In-Reply-To
<7vfy2ogdvl.fsf@assigned-by-dhcp.cox.net>
On Aug 13, 2007, at 8:14 AM, Junio C Hamano wrote:
Show 16 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
>
>> Steffen Prohaska <prohaska@zib.de> writes:
>> ...
>>> This works only together with the commit
>>>
>>> 'attr: fix attribute handling if .gitattributes is involved'
>>
>> While I think it is _one_ good approach to make things two-pass,
>> I do not know if this is enough.  A logic similar to this should
>> be made available to the codepath that switches branches,
>> shouldn't it?
>
> Ok, let's step back a bit and I'll suggest an alternative
> approach to your 1/2.  This would hopefully solve 2/2 without
> any code change your patch 2/2 has.
That would be great.
Show 42 quoted lines
> I think this approach is very much in line with how the git
> plumbing works, but you would need to know how the world is
> designed to work in order to appreciate it fully.  Let's have a
> few paragraphs to give the readers some background.
>
> The work tree side of git is primarily about the index, and what
> is on the work tree is more or less secondary.  At the lower
> level, often we deliberately treat not having a working tree
> file as equivalent to having an unmodified work tree file.  We
> can apply the same principle to this "missing .gitattributes
> file" case.
>
> People who only know modern git may not be aware of this, but
> you can apply patches and perform a merge in a work tree that
> does not have any file checked out, as long as your index is
> fully populated.  For example, you can do something like this:
>
>     $ git clone -n git://.../git.git v.git
>     $ cd v.git
>     $ git update-ref --no-deref HEAD $(git rev-parse v1.5.3-rc4^0)
>     $ git read-tree HEAD
>     $ git apply --index patch.txt
>
> You will have the files that are patched in the resulting work
> tree, so that you can inspect the result.  If you like the
> result, you can even make a commit in such a sparsely populated
> tree:
>
>     $ git commit
>
> Of course, "git commit -a" and "git add -u" Porcelain options
> are more recent inventions, and they would not work with such a
> sparsely populated work tree.  But the above demonstration shows
> that at the plumbing level the index is the king and the work
> tree is secondary, and this is very much as designed.  The merge
> operation has similar characteristics:
>
>     $ git merge master
>
> ... will check out the paths that need file-level 3-way merge,
> so that you can inspect the result, but what you will have is a
> sparsely populated work tree, and this is as designed.
Ah, merge ...
Show 14 quoted lines
> Currently, the attr_stack code reads only from the work tree
> and work tree alone.  We could change it to:
>
>  - If the directory on the work tree has .gitattributes, use it
>    (this is what the current code does);
>
>  - Otherwise if the index has .gitattributes at the
>    corresponding path, use that instead.
>
> This essentially treats not having .gitattributes files checked
> out as equivalent to having these files checked out unmodified,
> which is very much in line with how the world is designed to
> work.
>

We may have conflicts in the .gitattributes file during a merge. .gitattributes may be present in different stages, and with conflict markers in the work tree.

Could we drop reading the file in the work tree completely? .gitattributes would be a property of the index alone. To control attributes you first need to add them to the index, before adding the file that has attributes set in .gitattributes.

If we have .gitattributes in different stages, the right one should be chosen to checkout corresponding files in the same stage.

	Steffen
Previous: Junio C HamanoNext: Johannes Schindelin
Message 15 of 20 in “attr: fix attribute handling if .gitattributes is involved”
  1. 1/2 attr: fix attribute handling if .gitattributes is involvedSteffen Prohaska, Aug 12, 2007
  2. 2/2 checkout: fix attribute handling in checkout allSteffen Prohaska, Aug 12, 2007
  3. Junio C HamanoAug 12, 2007
  4. Steffen ProhaskaAug 12, 2007
  5. Junio C HamanoAug 13, 2007
  6. Marius Storm-OlsenAug 13, 2007
  7. Steffen ProhaskaAug 13, 2007
  8. Marius Storm-OlsenAug 13, 2007
  9. Steffen ProhaskaAug 13, 2007
  10. Marius Storm-OlsenAug 13, 2007
  11. Steffen ProhaskaAug 13, 2007
  12. Dmitry KakurinAug 13, 2007
  13. 1/2 attr.c: refactoringJunio C Hamano, Aug 14, 2007
  14. 2/2 attr.c: read .gitattributes from index as well.Junio C Hamano, Aug 14, 2007
  15. Steffen ProhaskaAug 13, 2007
  16. Johannes SchindelinAug 13, 2007
  17. David KastrupAug 13, 2007
  18. git-update-ref bug? (was: [PATCH 2/2] checkout: fix attribute handling in checkout all)David Kastrup, Aug 13, 2007
  19. Junio C HamanoAug 13, 2007
  20. Brian DowningAug 13, 2007

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.