(Apologies if there is a proper place to report bugs; but I could not
find one.)
PROBLEM: "git add" adds sub-directories without checking to see if there
is already a git repository already there.
WHY BAD: This causes files to be in two repositories (leading to a mess
if you don't notice for a while...)
ONE SOLUTION: When adding files from a directory (except root of the
repository, of course) look for a .git subdirectory, and complain if
found. Allow --force to override this.
MORE SOPHISTICATED:
1. Offer to merge in all that history, followed by removing that old
.git subdirectory.
2. Look inside the .git subdirectory to see if the file being added is
actually under control there. If not, no need to complain.
EXAMPLE OF PROBLEM
The problem can arise when people are just dipping their toe into git,
and decide to try it on just one directory, then later expand its use to
the whole project.
mkdir test
cd test
mkdir settings
cd settings
git init
touch x
git add x
git commit -m "xx"
(time passes)
cd ..
git init
git add settings/
(should complain)
Thanks for taking the time to read this,
Darren
--
Darren Cook, Software Researcher/Developer
http://dcook.org/work/ (About me and my work)
http://dcook.org/blogs.html (My blogs and articles)
Hi Darren,
Darren Cook writes:
(Apologies if there is a proper place to report bugs; but I could not
find one.)
There is no bugtracker, so this is the right place to report it.
Thanks for reporting.
PROBLEM: "git add" adds sub-directories without checking to see if there
is already a git repository already there.
WHY BAD: This causes files to be in two repositories (leading to a mess
if you don't notice for a while...)
ONE SOLUTION: When adding files from a directory (except root of the
repository, of course) look for a .git subdirectory, and complain if
found. Allow --force to override this.
This is a good suggestion. It already has a way to handle gitlinks
(for submodules), so this seems like a very reasonable feature.
MORE SOPHISTICATED:
1. Offer to merge in all that history, followed by removing that old
.git subdirectory.
Hm, I don't like this one -- there are too many ways to "merge" the
history, and I can't see a sane default (or even a sane subset of
defaults).
2. Look inside the .git subdirectory to see if the file being added is
actually under control there. If not, no need to complain.
I don't like this one either. Tangling up two Git repositories like
this is not a good idea -- the user should use submodules or similar.
Next steps: Me (or someone else who has the time) will post a patch
fixing this shortly.
-- Ram
On Wed, Apr 06, 2011 at 08:18:54AM +0900, Darren Cook wrote:
PROBLEM: "git add" adds sub-directories without checking to see if there
is already a git repository already there.
Sort of...
EXAMPLE OF PROBLEM
The problem can arise when people are just dipping their toe into git,
and decide to try it on just one directory, then later expand its use to
the whole project.
mkdir test
cd test
mkdir settings
cd settings
git init
touch x
git add x
git commit -m "xx"
(time passes)
cd ..
git init
git add settings/
(should complain)
If you do "git add settings" (without the slash) it will add the
repository as a submodule. Which is not the behavior you asked for, but
is at least reasonable. So the real bug seems to me the fact that "git
add settings/" and "git add settings" behave differently.
-Peff
Ramkumar Ramachandra [off-list ref] writes:
Darren Cook writes:
quoted
PROBLEM: "git add" adds sub-directories without checking to see if there
is already a git repository already there.
WHY BAD: This causes files to be in two repositories (leading to a mess
if you don't notice for a while...)
ONE SOLUTION: When adding files from a directory (except root of the
repository, of course) look for a .git subdirectory, and complain if
found. Allow --force to override this.
This is a good suggestion. It already has a way to handle gitlinks
(for submodules), so this seems like a very reasonable feature.
I just hope that a suboptimal workflow that I use won't stop working.
Currently I have TODO file in gitweb/ subdirectory, which is stored in
gitweb/.git repository. Still it doesn't prevent me from "git add"-ing
e.g. 'gitweb/gitweb.perl' to git repository itself.
--
Jakub Narebski
Poland
ShadeHawk on #git
Hi Jakub,
Jakub Narebski writes:
Ramkumar Ramachandra [off-list ref] writes:
quoted
Darren Cook writes:
quoted
quoted
PROBLEM: "git add" adds sub-directories without checking to see if there
is already a git repository already there.
WHY BAD: This causes files to be in two repositories (leading to a mess
if you don't notice for a while...)
ONE SOLUTION: When adding files from a directory (except root of the
repository, of course) look for a .git subdirectory, and complain if
found. Allow --force to override this.
This is a good suggestion. It already has a way to handle gitlinks
(for submodules), so this seems like a very reasonable feature.
I just hope that a suboptimal workflow that I use won't stop working.
Currently I have TODO file in gitweb/ subdirectory, which is stored in
gitweb/.git repository. Still it doesn't prevent me from "git add"-ing
e.g. 'gitweb/gitweb.perl' to git repository itself.
It shouldn't. The idea is merely to make the porcelain show a
friendly warning, which can be overriden with a '--force'.
-- Ram