git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Lars R. Damerow" <lars@pixar.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Jeff King <peff@peff.net>,
	Erik Faye-Lund <kusmabite@googlemail.com>,
	git@vger.kernel.org
Subject: Re: [PATCH] GIT_ONE_FILESYSTEM: flip the default to stop at filesystem boundaries
Date: Sun, 04 Apr 2010 15:39:58 -0700	[thread overview]
Message-ID: <7vvdc6yh8h.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <7v4ojr85ee.fsf_-_@alter.siamese.dyndns.org> (Junio C. Hamano's message of "Sun\, 04 Apr 2010 11\:00\:09 -0700")

Junio C Hamano <gitster@pobox.com> writes:

>    I wonder if "git add" and friends should also notice it and warn.  If
>    you have more than one values of ce->ce_dev in the index, it means that
>    the working tree spans more than one filesystem and from a subdirectory
>    with an entry that has a ce->ce_dev different from the value for a path
>    at the top of the work tree, you will not be able to discover the top
>    of the tree without GIT_ONE_FILESYSTEM set to true.  A likely scenario
>    for this to happen would be:
>
>     (1) You have a tarball of some sort; you extract it $there;
>
> 	$ mkdir $there && cd $there
>         $ tar xf /var/tmp/tarball.tar
>
>     (2) You notice the filesystem lacks enough free space, and move some
>         part (say "images/") to a separate filesystem, and bind-mount;
>
>         $ mv images $another/. && rm -fr images && mkdir images
>         $ mount --bind $another/images images
>
>     (3) You add everything to start the project;
>
>         $ git init && git add .
>
>         Up to this point it would work (you are at the top of the working
>         tree).  And this is the point we _could_ notice and warn that you
>         will have trouble in step (4).
>
>     (4) Go down to a subdirectory and start futzing;
>
> 	$ cd images && gimp naughty.jpg && git add -u

And this adds such a check.

 read-cache.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/read-cache.c b/read-cache.c
index f1f789b..486bb2a 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1550,6 +1550,7 @@ int write_index(struct index_state *istate, int newfd)
 	struct cache_entry **cache = istate->cache;
 	int entries = istate->cache_nr;
 	struct stat st;
+	int more_than_one_dev;
 
 	for (i = removed = extended = 0; i < entries; i++) {
 		if (cache[i]->ce_flags & CE_REMOVE)
@@ -1572,6 +1573,7 @@ int write_index(struct index_state *istate, int newfd)
 	if (ce_write(&c, newfd, &hdr, sizeof(hdr)) < 0)
 		return -1;
 
+	more_than_one_dev = 0;
 	for (i = 0; i < entries; i++) {
 		struct cache_entry *ce = cache[i];
 		if (ce->ce_flags & CE_REMOVE)
@@ -1580,8 +1582,15 @@ int write_index(struct index_state *istate, int newfd)
 			ce_smudge_racily_clean_entry(ce);
 		if (ce_write_entry(&c, newfd, ce) < 0)
 			return -1;
+		if (i && ce->ce_dev != cache[0]->ce_dev)
+			more_than_one_dev = 1;
 	}
 
+	if (more_than_one_dev &&
+	    !git_env_bool("GIT_DISCOVERY_ACROSS_FILESYSTEM", 0))
+		warning("working tree spans across filesystems but "
+			"GIT_DISCOVERY_ACROSS_FILESYSTEM is not set.");
+
 	/* Write extension data here */
 	if (istate->cache_tree) {
 		struct strbuf sb = STRBUF_INIT;

      parent reply	other threads:[~2010-04-04 22:40 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-17 19:55 [PATCH v3 0/3] Add support for GIT_ONE_FILESYSTEM Lars R. Damerow
2010-03-17 19:55 ` [PATCH 1/3] config.c: remove static keyword from git_env_bool() Lars R. Damerow
2010-03-17 19:55 ` [PATCH 2/3] truncate cwd string before printing error message Lars R. Damerow
2010-03-17 19:55 ` [PATCH 3/3] Add support for GIT_ONE_FILESYSTEM Lars R. Damerow
2010-03-28  9:22   ` Jeff King
2010-03-28 12:05     ` Jeff King
2010-03-28 16:44     ` Junio C Hamano
2010-03-28 17:32       ` Lars Damerow
2010-03-30 15:58         ` Jeff King
2010-03-30 22:43       ` Linus Torvalds
2010-03-30 22:59         ` Thomas Rast
2010-03-30 23:04           ` Jeff King
2010-03-30 23:02         ` Jeff King
2010-03-30 23:10           ` Junio C Hamano
2010-03-30 23:12           ` Linus Torvalds
2010-03-31  0:54             ` Erik Faye-Lund
2010-04-04 18:00               ` [PATCH] GIT_ONE_FILESYSTEM: flip the default to stop at filesystem boundaries Junio C Hamano
2010-04-04 22:30                 ` [PATCH] Rename ONE_FILESYSTEM to DISCOVERY_ACROSS_FILESYSTEM Junio C Hamano
2010-04-04 22:37                   ` Matthieu Moy
2010-04-04 22:39                 ` Junio C Hamano [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vvdc6yh8h.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=kusmabite@googlemail.com \
    --cc=lars@pixar.com \
    --cc=peff@peff.net \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).