Git development
 help / color / mirror / Atom feed
* How do I qualify paths in the .gitignore file w.r.t. the repo root  directory?
@ 2009-02-24  6:47 Brent Goodrick
  2009-02-24  7:06 ` Junio C Hamano
  0 siblings, 1 reply; 15+ messages in thread
From: Brent Goodrick @ 2009-02-24  6:47 UTC (permalink / raw)
  To: git

Say I have these files and directories [2]:

  /home/smart_tator/misc_files/.gitignore
  /home/smart_tator/misc_files/foo/
  /home/smart_tator/misc_files/bar/
  /home/smart_tator/misc_files/bar/baz/foo/
  /home/smart_tator/misc_files/bar/baz/real/

then I do:

  cd /home/smart_tator/misc_files/; git init

and say I have this line in that .gitignore file:

  foo/

And then I naively execute:

  git add bar/

then the bar/baz/real/ is added, but these are dutifully ignored:

  /home/smart_tator/misc_files/foo/
  /home/smart_tator/misc_files/bar/baz/foo/

But consider in my real repo, I have thousands of files, versus the
Tinker Toy example shown above. And consider that I don't know about
that bar/baz/foo/ exists ahead of time, because I'm not the only
developer checking in content to the repo that might contain precious
"foo/"'s to keep. I can't move my top level foo/, as I have tools that
rely upon that foo/ being in its place.

That means that we can't solve this problem efficiently/effectively
with the negation operator in the .gitignore file:

  foo/
  !bar/baz/foo/

because sooner or later someone is going to get surprised as to why
their foo/ isn't being added in some other subdirectory, and they will
"fix it" by committing a change where they have removed the foo/ from
the .gitignore file, thus causing the top level foo/ to show up as
candidates for addition in git status output.

Is there some way to express that the foo/ that is to be ignored is
always the one in /home/smart_tator/misc_files/ directory, but all
other foo/ subdirectories in any other directory under consideration
should still continue to participate in adds and merges, all without
having to "over-express" the exceptions with negation operators?

Maybe the imaginary .gitignore syntax I am thinking of would be one of
the following (most of these are just silly/fun):

  </>foo/  # <-- Huh?
  <top>foo/  # <-- What the ...?
  //foo/  # <-- Smells like Perforce or Windows UNC paths
  /foo/ # <-- No! Matches UNIX root filesystem directory paths!
  >foo/  # <-- You can't have a > character in DOS or Unix paths, can you?
  $root/foo/  # <-- I like this syntax the best [1]

Thanks,
bg

[1] Maybe there are other "variables" besides $root that might be
    useful to be added in the future, like $HOME.
[2] By "repo root directory", I mean whatever "$GIT_DIR/.." resolves to.

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

end of thread, other threads:[~2009-02-26 17:07 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-24  6:47 How do I qualify paths in the .gitignore file w.r.t. the repo root directory? Brent Goodrick
2009-02-24  7:06 ` Junio C Hamano
2009-02-24  9:07   ` Sitaram Chamarty
2009-02-24 17:33     ` Junio C Hamano
2009-02-24 18:31       ` Sitaram Chamarty
2009-02-25  3:31       ` Sitaram Chamarty
2009-02-25  8:36         ` Junio C Hamano
2009-02-25 11:17           ` Sitaram Chamarty
2009-02-25 21:25             ` Junio C Hamano
2009-02-26  0:45               ` Björn Steinbrink
2009-02-26  1:23               ` Sitaram Chamarty
2009-02-26  3:48                 ` Sitaram Chamarty
2009-02-26 17:04                   ` Junio C Hamano
2009-02-25  1:14   ` Brent Goodrick
2009-02-25  4:01     ` Sitaram Chamarty

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox