git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] GIT_ONE_FILESYSTEM: flip the default to stop at filesystem boundaries

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 4, 2010, 22:39 UTC
Message-ID
<7vvdc6yh8h.fsf@alter.siamese.dyndns.org>
In-Reply-To
<7v4ojr85ee.fsf_-_@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 30 quoted lines
>    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;
Previous: Matthieu Moy
Message 20 of 20 in “Add support for GIT_ONE_FILESYSTEM”
  1. 0/3 Add support for GIT_ONE_FILESYSTEMLars R. Damerow, Mar 17, 2010
  2. 1/3 config.c: remove static keyword from git_env_bool()Lars R. Damerow, Mar 17, 2010
  3. 2/3 truncate cwd string before printing error messageLars R. Damerow, Mar 17, 2010
  4. 3/3 Add support for GIT_ONE_FILESYSTEMLars R. Damerow, Mar 17, 2010
  5. Jeff KingMar 28, 2010
  6. Jeff KingMar 28, 2010
  7. Junio C HamanoMar 28, 2010
  8. Lars DamerowMar 28, 2010
  9. Jeff KingMar 30, 2010
  10. Linus TorvaldsMar 30, 2010
  11. Thomas RastMar 30, 2010
  12. Jeff KingMar 30, 2010
  13. Jeff KingMar 30, 2010
  14. Junio C HamanoMar 30, 2010
  15. Linus TorvaldsMar 30, 2010
  16. Erik Faye-LundMar 31, 2010
  17. GIT_ONE_FILESYSTEM: flip the default to stop at filesystem boundariesJunio C Hamano, Apr 4, 2010
  18. Rename ONE_FILESYSTEM to DISCOVERY_ACROSS_FILESYSTEMJunio C Hamano, Apr 4, 2010
  19. Matthieu MoyApr 4, 2010
  20. Junio C HamanoApr 4, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.