git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Don't delete untracked submodule's .git dirs by default
@ 2009-06-30  2:10 Jason Holden
  2009-06-30  2:10 ` [PATCH 1/2] Add option to not delete a .git directory in remove_dir_recursively() Jason Holden
  0 siblings, 1 reply; 10+ messages in thread
From: Jason Holden @ 2009-06-30  2:10 UTC (permalink / raw)
  To: git; +Cc: Jason Holden

Git-clean is not safe when there is a submodule tracked in a local branch that
is not tracked in the mainline branch. Running git-clean from the mainline
branch when we have unpushed changes in a submodule tracked only in a local
branch can lose local changes to that submodule permanentely.

I have accidentally lost changes in this way when working with very 
large projects where a git-clean is more reliable than a makefile's 
"make clean". 

By changing the default behavior of git-clean to not delete the .git
directories allows the history of the submodules to be recovered.

# Example of issue:
#
# Clone mainline project
git clone git://github.com/thoughtbot/paperclip.git           
cd paperclip/

# Add a submodule not tracked by mainline
git checkout -b test_submodule_clean
git submodule add git://github.com/technoweenie/attachment_fu.git attachement_fu
git commit -m "add submodule"

# Make a modification to the submodule.  Note that we haven't pushed the change
cd attachement_fu/
git checkout -b mod_readme_in_submodule
vi README 
git add README
git commit -m "Small change in submodule"

# Go back to mainline's master branch and do a clean
cd ..
git checkout master
git clean -f -d

# Our change to the submodule, that was never pushed, is now gone forever 
# because all the history stored in the submodule's .git direct is deleted.
# There is no recovering from this.
# This breaks the "git must be safe" rule, as we've lost potentially a lot of
# changes to any submodule projects that didn't get pushed yet. Solve
# this issue by not deleting any .git directories we come across during a
# git-clean, unless the "-m" option is passed to git-clean.

This is my first email submittal using git, so apologies in advance for any
formatting issues

Jason Holden (2):
  Add option to not delete a .git directory in remove_dir_recursively()
  Don't clean any untracked submodule's .git dir by default in
    git-clean

 Documentation/git-clean.txt |    6 +++++-
 builtin-clean.c             |   15 +++++++++++++--
 builtin-clone.c             |    4 ++--
 dir.c                       |   17 +++++++++++++++--
 dir.h                       |    2 +-
 refs.c                      |    2 +-
 transport.c                 |    4 ++--
 7 files changed, 39 insertions(+), 11 deletions(-)

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

end of thread, other threads:[~2009-07-01  2:13 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-30  2:10 [PATCH 0/2] Don't delete untracked submodule's .git dirs by default Jason Holden
2009-06-30  2:10 ` [PATCH 1/2] Add option to not delete a .git directory in remove_dir_recursively() Jason Holden
2009-06-30  2:10   ` [PATCH 2/2] Don't clean any untracked submodule's .git dir by default in git-clean Jason Holden
2009-06-30  6:07     ` Paolo Bonzini
2009-06-30  6:40     ` Johannes Sixt
2009-06-30  7:34       ` Junio C Hamano
2009-06-30 23:05         ` Junio C Hamano
2009-07-01  1:44           ` Jason Holden
2009-07-01  2:13             ` Junio C Hamano
2009-06-30  6:48   ` [PATCH 1/2] Add option to not delete a .git directory in remove_dir_recursively() Johannes Sixt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).