All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC 0/6] git-check-attr should work for relative paths
@ 2011-07-28 10:36 Michael Haggerty
  2011-07-28 10:37 ` [RFC 1/6] git-check-attr: test that no output is written to stderr Michael Haggerty
                   ` (6 more replies)
  0 siblings, 7 replies; 15+ messages in thread
From: Michael Haggerty @ 2011-07-28 10:36 UTC (permalink / raw)
  To: git; +Cc: gitster, Michael Haggerty

Currently, git-check-attr gets confused if it is passed certain types
of unnormalized paths or is invoked from a non-top-level directory.
For example, using the test repo created by t0003-attributes.sh,
inquiring about a path that starts with "./" causes git-check-attr to
emit a spurious warning:

    $ git check-attr test ./f
    [attr]notest !test
     not allowed: ./.gitattributes:1
    ./f: test: f
    $ git check-attr test ./a/i
    [attr]notest !test
     not allowed: ./.gitattributes:1
    ./a/i: test: a/i

In these cases it seems to find the right values, even including the
application of macros from the top-level .gitattributes file.  (My
guess is that it is loading the top-level .gitattributes file
twice--once as a top-level file, and once believing that it is in a
subdirectory.)

Invoking git-check-attr from a subdirectory using a relative path
gives incorrect answers; for example:

    $ (cd a; git check-attr test i )
    i: test: unspecified

(On the other hand, if invoked using the full path of a file, it
"works":

    $ (cd a; git check-attr test a/i )
    a/i: test: a/i

.)  I think that this behavior is confusing and inconsistent with
other git commands.  It is also inconsistent with the behavior of
.gitignore, which works from subdirectories.

The patches in this series add tests demonstrating the problem,
propose a possible solution, and add a couple of subcommands to
test-path-utils.

I am far from confident that the solution proposed in patch 4 is
correct; please see the notes in that email for discussion.

The changes to test-path-utils helped me figure out how the
corresponding functions work (comments? we don't need no stinkin'
comments) but they are not used anywhere.  Take 'em or leave 'em.

Michael Haggerty (6):
  git-check-attr: test that no output is written to stderr
  git-check-attr: Demonstrate problems with unnormalized paths
  git-check-attr: Demonstrate problems with relative paths
  git-check-attr: Normalize paths
  test-path-utils: Add subcommand "absolute_path"
  test-path-utils: Add subcommand "prefix_path"

 builtin/check-attr.c  |   20 ++++++++++++--------
 t/t0003-attributes.sh |   29 ++++++++++++++++++++++++++---
 test-path-utils.c     |   22 ++++++++++++++++++++++
 3 files changed, 60 insertions(+), 11 deletions(-)

-- 
1.7.6.8.gd2879

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

end of thread, other threads:[~2011-08-07  4:57 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-28 10:36 [RFC 0/6] git-check-attr should work for relative paths Michael Haggerty
2011-07-28 10:37 ` [RFC 1/6] git-check-attr: test that no output is written to stderr Michael Haggerty
2011-07-28 10:37 ` [RFC 2/6] git-check-attr: Demonstrate problems with unnormalized paths Michael Haggerty
2011-07-28 10:37 ` [RFC 3/6] git-check-attr: Demonstrate problems with relative paths Michael Haggerty
2011-07-28 10:37 ` [RFC 4/6] git-check-attr: Normalize paths Michael Haggerty
2011-08-02 17:24   ` Junio C Hamano
2011-08-04  3:32     ` Michael Haggerty
2011-08-04 17:05       ` Junio C Hamano
2011-08-05  6:24         ` Michael Haggerty
2011-08-05 15:02           ` Junio C Hamano
2011-08-07  4:32             ` Michael Haggerty
2011-07-28 10:37 ` [RFC 5/6] test-path-utils: Add subcommand "absolute_path" Michael Haggerty
2011-07-28 10:37 ` [RFC 6/6] test-path-utils: Add subcommand "prefix_path" Michael Haggerty
2011-08-02 22:02 ` [RFC 0/6] git-check-attr should work for relative paths Junio C Hamano
2011-08-04  3:35   ` Michael Haggerty

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.