All of lore.kernel.org
 help / color / mirror / Atom feed
* Implement core.symlinks to support filesystems without symlinks
@ 2007-02-27 21:41 Johannes Sixt
  2007-02-27 21:41 ` [PATCH] Add a flag core.symlinks analogous to core.filemode Johannes Sixt
  2007-02-27 23:13 ` Implement core.symlinks to support filesystems without symlinks Robin Rosenberg
  0 siblings, 2 replies; 18+ messages in thread
From: Johannes Sixt @ 2007-02-27 21:41 UTC (permalink / raw)
  To: git


Here is a small patch series that adds a configuration variable core.symlinks.
From the manual:

core.symlinks::
	If false, symbolic links are checked out as small plain files that
	contain the link text. gitlink:git-update-index[1] and
	gitlink:git-add[1] will not change the recorded type to regular
	file. Useful on filesystems like FAT that do not support
	symbolic links. True by default.


The implementation was surprisingly simple:

 Documentation/config.txt           |    7 +++++++
 Documentation/git-update-index.txt |    5 +++++
 builtin-apply.c                    |    2 +-
 builtin-update-index.c             |    6 +++---
 cache.h                            |    7 ++++++-
 config.c                           |    5 +++++
 diff-lib.c                         |    3 +++
 entry.c                            |    5 +++++
 environment.c                      |    1 +
 read-cache.c                       |   12 +++++++-----
 10 files changed, 43 insertions(+), 10 deletions(-)


-- Hannes

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

* [PATCH] Add a flag core.symlinks analogous to core.filemode.
  2007-02-27 21:41 Implement core.symlinks to support filesystems without symlinks Johannes Sixt
@ 2007-02-27 21:41 ` Johannes Sixt
  2007-02-27 21:41   ` [PATCH] Do not change the file type if the filesystem does not support symlinks Johannes Sixt
  2007-02-27 23:13 ` Implement core.symlinks to support filesystems without symlinks Robin Rosenberg
  1 sibling, 1 reply; 18+ messages in thread
From: Johannes Sixt @ 2007-02-27 21:41 UTC (permalink / raw)
  To: git; +Cc: Johannes Sixt

The new flag core.symlinks (which is true by default) can be set to false
to indicate that the filesystem does not support symbolic links. In this
case, symbolic links that exist in the trees are checked out as small plain
files and checking in modifications of these files preserve the symlink
property in the database (as long as an entry exists in the index).

This commit as the first of a series starts by adding and initializing
the global flag variable.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
---
 cache.h       |    1 +
 config.c      |    5 +++++
 environment.c |    1 +
 3 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/cache.h b/cache.h
index 04f8e63..6cbb9d8 100644
--- a/cache.h
+++ b/cache.h
@@ -202,6 +202,7 @@ extern int delete_ref(const char *, unsigned char *sha1);
 /* Environment bits from configuration mechanism */
 extern int use_legacy_headers;
 extern int trust_executable_bit;
+extern int trust_symlink_fmt;
 extern int assume_unchanged;
 extern int prefer_symlink_refs;
 extern int log_all_ref_updates;
diff --git a/config.c b/config.c
index c938aa0..749bec3 100644
--- a/config.c
+++ b/config.c
@@ -269,6 +269,11 @@ int git_default_config(const char *var, const char *value)
 		return 0;
 	}
 
+	if (!strcmp(var, "core.symlinks")) {
+		trust_symlink_fmt = git_config_bool(var, value);
+		return 0;
+	}
+
 	if (!strcmp(var, "core.bare")) {
 		is_bare_repository_cfg = git_config_bool(var, value);
 		return 0;
diff --git a/environment.c b/environment.c
index 54c22f8..1e8292a 100644
--- a/environment.c
+++ b/environment.c
@@ -13,6 +13,7 @@ char git_default_email[MAX_GITNAME];
 char git_default_name[MAX_GITNAME];
 int use_legacy_headers = 1;
 int trust_executable_bit = 1;
+int trust_symlink_fmt = 1;
 int assume_unchanged;
 int prefer_symlink_refs;
 int is_bare_repository_cfg = -1; /* unspecified */
-- 
1.5.0.19.gddff

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

* [PATCH] Do not change the file type if the filesystem does not support symlinks.
  2007-02-27 21:41 ` [PATCH] Add a flag core.symlinks analogous to core.filemode Johannes Sixt
@ 2007-02-27 21:41   ` Johannes Sixt
  2007-02-27 21:41     ` [PATCH] Create a symbolic link as a regular file on filesystems without symlinks Johannes Sixt
  2007-02-27 22:54     ` [PATCH] Do not change the file type if the filesystem does not support symlinks Johannes Schindelin
  0 siblings, 2 replies; 18+ messages in thread
From: Johannes Sixt @ 2007-02-27 21:41 UTC (permalink / raw)
  To: git; +Cc: Johannes Sixt

Upon git add and git update-index, if core.symlinks = false, do not change
an entry from symbolic link to regular file even if the filesystem entry
is a regular file.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
---
 builtin-update-index.c |    6 +++---
 cache.h                |    6 +++++-
 read-cache.c           |   12 +++++++-----
 3 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/builtin-update-index.c b/builtin-update-index.c
index 772aaba..cf8c069 100644
--- a/builtin-update-index.c
+++ b/builtin-update-index.c
@@ -109,11 +109,11 @@ static int add_file_to_cache(const char *path)
 	ce->ce_flags = htons(namelen);
 	fill_stat_cache_info(ce, &st);
 
-	if (trust_executable_bit)
+	if (trust_executable_bit && trust_symlink_fmt)
 		ce->ce_mode = create_ce_mode(st.st_mode);
 	else {
-		/* If there is an existing entry, pick the mode bits
-		 * from it, otherwise assume unexecutable.
+		/* If there is an existing entry, pick the mode bits and format
+		 * from it, otherwise assume unexecutable regular file.
 		 */
 		struct cache_entry *ent;
 		int pos = cache_name_pos(path, namelen);
diff --git a/cache.h b/cache.h
index 6cbb9d8..298cdd2 100644
--- a/cache.h
+++ b/cache.h
@@ -108,7 +108,11 @@ static inline unsigned int create_ce_mode(unsigned int mode)
 }
 static inline unsigned int ce_mode_from_stat(struct cache_entry *ce, unsigned int mode)
 {
-	extern int trust_executable_bit;
+	extern int trust_executable_bit, trust_symlink_fmt;
+	/* note: !trust_symlink_fmt trumps !trust_executable_bit */
+	if (!trust_symlink_fmt && S_ISREG(mode) &&
+	    ce && S_ISLNK(ntohl(ce->ce_mode)))
+		return ce->ce_mode;
 	if (!trust_executable_bit && S_ISREG(mode)) {
 		if (ce && S_ISREG(ntohl(ce->ce_mode)))
 			return ce->ce_mode;
diff --git a/read-cache.c b/read-cache.c
index 605b352..f09ee2e 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -116,7 +116,8 @@ static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st)
 
 	switch (ntohl(ce->ce_mode) & S_IFMT) {
 	case S_IFREG:
-		changed |= !S_ISREG(st->st_mode) ? TYPE_CHANGED : 0;
+		if (trust_symlink_fmt && !S_ISREG(st->st_mode))
+			changed |= TYPE_CHANGED;
 		/* We consider only the owner x bit to be relevant for
 		 * "mode changes"
 		 */
@@ -125,7 +126,8 @@ static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st)
 			changed |= MODE_CHANGED;
 		break;
 	case S_IFLNK:
-		changed |= !S_ISLNK(st->st_mode) ? TYPE_CHANGED : 0;
+		if (trust_symlink_fmt && !S_ISLNK(st->st_mode))
+			changed |= TYPE_CHANGED;
 		break;
 	default:
 		die("internal error: ce_mode is %o", ntohl(ce->ce_mode));
@@ -344,11 +346,11 @@ int add_file_to_index(const char *path, int verbose)
 	ce->ce_flags = htons(namelen);
 	fill_stat_cache_info(ce, &st);
 
-	if (trust_executable_bit)
+	if (trust_executable_bit && trust_symlink_fmt)
 		ce->ce_mode = create_ce_mode(st.st_mode);
 	else {
-		/* If there is an existing entry, pick the mode bits
-		 * from it, otherwise assume unexecutable.
+		/* If there is an existing entry, pick the mode bits and format
+		 * from it, otherwise assume unexecutable regular file.
 		 */
 		struct cache_entry *ent;
 		int pos = cache_name_pos(path, namelen);
-- 
1.5.0.19.gddff

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

* [PATCH] Create a symbolic link as a regular file on filesystems without symlinks.
  2007-02-27 21:41   ` [PATCH] Do not change the file type if the filesystem does not support symlinks Johannes Sixt
@ 2007-02-27 21:41     ` Johannes Sixt
  2007-02-27 21:41       ` [PATCH] diff-lib.c: Ignore type differences if the filesystem does not support symlinks Johannes Sixt
  2007-02-27 22:44       ` [PATCH] Create a symbolic link as a regular file on filesystems without symlinks Johannes Schindelin
  2007-02-27 22:54     ` [PATCH] Do not change the file type if the filesystem does not support symlinks Johannes Schindelin
  1 sibling, 2 replies; 18+ messages in thread
From: Johannes Sixt @ 2007-02-27 21:41 UTC (permalink / raw)
  To: git; +Cc: Johannes Sixt

If core.symlinks = false, the filesystem is actually populated with
a regular file that contains the link text.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
---
 builtin-apply.c |    2 +-
 entry.c         |    5 +++++
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/builtin-apply.c b/builtin-apply.c
index bec95d6..1636807 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -2284,7 +2284,7 @@ static int try_create_file(const char *path, unsigned int mode, const char *buf,
 {
 	int fd;
 
-	if (S_ISLNK(mode))
+	if (trust_symlink_fmt && S_ISLNK(mode))
 		/* Although buf:size is counted string, it also is NUL
 		 * terminated.
 		 */
diff --git a/entry.c b/entry.c
index c2641dd..3d5c0e4 100644
--- a/entry.c
+++ b/entry.c
@@ -100,6 +100,11 @@ static int write_entry(struct cache_entry *ce, char *path, struct checkout *stat
 		if (to_tempfile) {
 			strcpy(path, ".merge_link_XXXXXX");
 			fd = mkstemp(path);
+		} else if (!trust_symlink_fmt) {
+			/* write a regular file */
+			fd = create_file(path, 0666);
+		}
+		if (to_tempfile || !trust_symlink_fmt) {
 			if (fd < 0) {
 				free(new);
 				return error("git-checkout-index: unable to create "
-- 
1.5.0.19.gddff

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

* [PATCH] diff-lib.c: Ignore type differences if the filesystem does not support symlinks.
  2007-02-27 21:41     ` [PATCH] Create a symbolic link as a regular file on filesystems without symlinks Johannes Sixt
@ 2007-02-27 21:41       ` Johannes Sixt
  2007-02-27 21:41         ` [PATCH] Describe core.symlinks in the man pages Johannes Sixt
  2007-02-27 22:44       ` [PATCH] Create a symbolic link as a regular file on filesystems without symlinks Johannes Schindelin
  1 sibling, 1 reply; 18+ messages in thread
From: Johannes Sixt @ 2007-02-27 21:41 UTC (permalink / raw)
  To: git; +Cc: Johannes Sixt

If core.symlinks = false, the diff engine now compares the symlink in the
index or in the database with the file contents on disk (instead of insisting
in a symlink in the working copy).

As a side effect, git status now reports a change as "modified" instead of
"typechange".

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
---
 diff-lib.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/diff-lib.c b/diff-lib.c
index 60c0fa6..3a12f65 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -134,6 +134,9 @@ int run_diff_files(struct rev_info *revs, int silent_on_removed)
 		    S_ISREG(newmode) && S_ISREG(oldmode) &&
 		    ((newmode ^ oldmode) == 0111))
 			newmode = oldmode;
+		else if (!trust_symlink_fmt &&
+		    S_ISREG(newmode) && S_ISLNK(oldmode))
+			newmode = oldmode;
 		diff_change(&revs->diffopt, oldmode, newmode,
 			    ce->sha1, (changed ? null_sha1 : ce->sha1),
 			    ce->name, NULL);
-- 
1.5.0.19.gddff

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

* [PATCH] Describe core.symlinks in the man pages.
  2007-02-27 21:41       ` [PATCH] diff-lib.c: Ignore type differences if the filesystem does not support symlinks Johannes Sixt
@ 2007-02-27 21:41         ` Johannes Sixt
  0 siblings, 0 replies; 18+ messages in thread
From: Johannes Sixt @ 2007-02-27 21:41 UTC (permalink / raw)
  To: git; +Cc: Johannes Sixt

---
 Documentation/config.txt           |    7 +++++++
 Documentation/git-update-index.txt |    5 +++++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 9fec769..08d13ca 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -116,6 +116,13 @@ core.fileMode::
 	the working copy are ignored; useful on broken filesystems like FAT.
 	See gitlink:git-update-index[1]. True by default.
 
+core.symlinks::
+	If false, symbolic links are checked out as small plain files that
+	contain the link text. gitlink:git-update-index[1] and
+	gitlink:git-add[1] will not change the recorded type to regular
+	file. Useful on filesystems like FAT that do not support
+	symbolic links. True by default.
+
 core.gitProxy::
 	A "proxy command" to execute (as 'command host port') instead
 	of establishing direct connection to the remote server when
diff --git a/Documentation/git-update-index.txt b/Documentation/git-update-index.txt
index b161c8b..cd5e014 100644
--- a/Documentation/git-update-index.txt
+++ b/Documentation/git-update-index.txt
@@ -295,6 +295,11 @@ in the index and the file mode on the filesystem if they differ only on
 executable bit.   On such an unfortunate filesystem, you may
 need to use `git-update-index --chmod=`.
 
+Quite similarly, if `core.symlinks` configuration variable is set
+to 'false' (see gitlink:git-config[1]), symbolic links are checked out
+as plain files, and this command does not modify a recorded file mode
+from symbolic link to regular file.
+
 The command looks at `core.ignorestat` configuration variable.  See
 'Using "assume unchanged" bit' section above.
 
-- 
1.5.0.19.gddff

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

* Re: [PATCH] Create a symbolic link as a regular file on filesystems without symlinks.
  2007-02-27 21:41     ` [PATCH] Create a symbolic link as a regular file on filesystems without symlinks Johannes Sixt
  2007-02-27 21:41       ` [PATCH] diff-lib.c: Ignore type differences if the filesystem does not support symlinks Johannes Sixt
@ 2007-02-27 22:44       ` Johannes Schindelin
  2007-02-28 17:18         ` Johannes Sixt
  1 sibling, 1 reply; 18+ messages in thread
From: Johannes Schindelin @ 2007-02-27 22:44 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: git

Hi,

On Tue, 27 Feb 2007, Johannes Sixt wrote:

> diff --git a/builtin-apply.c b/builtin-apply.c
> index bec95d6..1636807 100644
> --- a/builtin-apply.c
> +++ b/builtin-apply.c
> @@ -2284,7 +2284,7 @@ static int try_create_file(const char *path, unsigned int mode, const char *buf,
>  {
>  	int fd;
>  
> -	if (S_ISLNK(mode))
> +	if (trust_symlink_fmt && S_ISLNK(mode))

First of all why "_fmt"? I would have called it "trust_symlinks".

> diff --git a/entry.c b/entry.c
> index c2641dd..3d5c0e4 100644
> --- a/entry.c
> +++ b/entry.c
> @@ -100,6 +100,11 @@ static int write_entry(struct cache_entry *ce, char *path, struct checkout *stat
>  		if (to_tempfile) {
>  			strcpy(path, ".merge_link_XXXXXX");
>  			fd = mkstemp(path);
> +		} else if (!trust_symlink_fmt) {
> +			/* write a regular file */
> +			fd = create_file(path, 0666);
> +		}
> +		if (to_tempfile || !trust_symlink_fmt) {

Wouldn't this be better:

-  		if (to_tempfile) {
-  			strcpy(path, ".merge_link_XXXXXX");
-  			fd = mkstemp(path);
+  		if (to_tempfile || !trusk_symlink_fmt) {
+			if (to_tempfile) {
+	  			strcpy(path, ".merge_link_XXXXXX");
+				fd = mkstemp(path);
+			} else
+				fd = create_file(path, 0666);

Hmm?

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

* Re: [PATCH] Do not change the file type if the filesystem does not support symlinks.
  2007-02-27 21:41   ` [PATCH] Do not change the file type if the filesystem does not support symlinks Johannes Sixt
  2007-02-27 21:41     ` [PATCH] Create a symbolic link as a regular file on filesystems without symlinks Johannes Sixt
@ 2007-02-27 22:54     ` Johannes Schindelin
  2007-02-28 17:40       ` Johannes Sixt
  1 sibling, 1 reply; 18+ messages in thread
From: Johannes Schindelin @ 2007-02-27 22:54 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: git

Hi,

On Tue, 27 Feb 2007, Johannes Sixt wrote:

> diff --git a/read-cache.c b/read-cache.c
> index 605b352..f09ee2e 100644
> --- a/read-cache.c
> +++ b/read-cache.c
> @@ -116,7 +116,8 @@ static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st)
>  
>  	switch (ntohl(ce->ce_mode) & S_IFMT) {
>  	case S_IFREG:
> -		changed |= !S_ISREG(st->st_mode) ? TYPE_CHANGED : 0;
> +		if (trust_symlink_fmt && !S_ISREG(st->st_mode))
> +			changed |= TYPE_CHANGED;

Really? If the cache entry says S_IFREG we should not expect a symlink 
here, right?

> @@ -125,7 +126,8 @@ static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st)
>  			changed |= MODE_CHANGED;
>  		break;
>  	case S_IFLNK:
> -		changed |= !S_ISLNK(st->st_mode) ? TYPE_CHANGED : 0;
> +		if (trust_symlink_fmt && !S_ISLNK(st->st_mode))
> +			changed |= TYPE_CHANGED;

This does not handle the case symlink->directory, right?

Ciao,
Dscho

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

* Re: Implement core.symlinks to support filesystems without symlinks
  2007-02-27 21:41 Implement core.symlinks to support filesystems without symlinks Johannes Sixt
  2007-02-27 21:41 ` [PATCH] Add a flag core.symlinks analogous to core.filemode Johannes Sixt
@ 2007-02-27 23:13 ` Robin Rosenberg
  2007-02-28  0:07   ` Johannes Schindelin
  1 sibling, 1 reply; 18+ messages in thread
From: Robin Rosenberg @ 2007-02-27 23:13 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: git

tisdag 27 februari 2007 22:41 skrev Johannes Sixt:
> 
> Here is a small patch series that adds a configuration variable 
core.symlinks.
> From the manual:
> 
> core.symlinks::
> 	If false, symbolic links are checked out as small plain files that
> 	contain the link text. gitlink:git-update-index[1] and
> 	gitlink:git-add[1] will not change the recorded type to regular
> 	file. Useful on filesystems like FAT that do not support
> 	symbolic links. True by default.

How useful is that? The problem is that those links won't work so the checkout 
will be broken. Creating copies would be less broken since the "links" could 
still be used. It should be possible to use the index to see which file is an 
original and which is a symblink, provided both are in the same repository.
Then maybe fall back to this approach if the symlink target cannot be 
resolved.

I'm not sure how people use symbolic links in git, but I'd imagine they 
typically point to a file  in the same repository.

-- robin

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

* Re: Implement core.symlinks to support filesystems without symlinks
  2007-02-27 23:13 ` Implement core.symlinks to support filesystems without symlinks Robin Rosenberg
@ 2007-02-28  0:07   ` Johannes Schindelin
  2007-02-28 22:48     ` Robin Rosenberg
  0 siblings, 1 reply; 18+ messages in thread
From: Johannes Schindelin @ 2007-02-28  0:07 UTC (permalink / raw)
  To: Robin Rosenberg; +Cc: Johannes Sixt, git

Hi,

On Wed, 28 Feb 2007, Robin Rosenberg wrote:

> tisdag 27 februari 2007 22:41 skrev Johannes Sixt:
> > 
> > Here is a small patch series that adds a configuration variable 
> > core.symlinks.
> >
> > From the manual:
> > 
> > core.symlinks::
> > 	If false, symbolic links are checked out as small plain files that
> > 	contain the link text. gitlink:git-update-index[1] and
> > 	gitlink:git-add[1] will not change the recorded type to regular
> > 	file. Useful on filesystems like FAT that do not support
> > 	symbolic links. True by default.
> 
> How useful is that? The problem is that those links won't work so the 
> checkout will be broken. Creating copies would be less broken since the 
> "links" could still be used. It should be possible to use the index to 
> see which file is an original and which is a symblink, provided both are 
> in the same repository. Then maybe fall back to this approach if the 
> symlink target cannot be resolved.

Basically, there is no proper way to solve it (other than switching to 
Linux, but that goes without saying).

Your solution would fall short if one of the two files is changed. Since 
they are supposed to be symlinks, the application expects them to be 
identical, and weird sh*t happens.

E.g. if you have a symlink "ln -s Makefile.host Makefile", and a script 
which changes "Makefile.host", and a subdirectory Makefile accessing the 
root Makefile, you will not be happy.

So, any way you go, if you have a repository containing symlinks, and you 
have an OS which does not support symlinks, you are screwed.

But since we already have a symlink in git.git, and _want_ to compile git 
on MinGW nevertheless, we should support symlinks _somehow_. Even if that 
means that advanced usage of symlinks will fail.

I agree with Johannes here how to go about this partial "support" of 
symlinks, since I cannot think of any sane way to retain the information 
(where the symlink points to) in the index.

Ciao,
Dscho

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

* Re: [PATCH] Create a symbolic link as a regular file on filesystems without symlinks.
  2007-02-27 22:44       ` [PATCH] Create a symbolic link as a regular file on filesystems without symlinks Johannes Schindelin
@ 2007-02-28 17:18         ` Johannes Sixt
  0 siblings, 0 replies; 18+ messages in thread
From: Johannes Sixt @ 2007-02-28 17:18 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin

On Tuesday 27 February 2007 23:44, Johannes Schindelin wrote:
> On Tue, 27 Feb 2007, Johannes Sixt wrote:
> > -	if (S_ISLNK(mode))
> > +	if (trust_symlink_fmt && S_ISLNK(mode))
>
> First of all why "_fmt"? I would have called it "trust_symlinks".

Because the file type is encoded in a mask named S_IFMT ;)
But the more I think about it, I'll rename it to has_symlinks.

> Wouldn't this be better:
>
> -  		if (to_tempfile) {
> -  			strcpy(path, ".merge_link_XXXXXX");
> -  			fd = mkstemp(path);
> +  		if (to_tempfile || !trusk_symlink_fmt) {
> +			if (to_tempfile) {
> +	  			strcpy(path, ".merge_link_XXXXXX");
> +				fd = mkstemp(path);
> +			} else
> +				fd = create_file(path, 0666);
>
> Hmm?

Sure; it amounts to the same, but is shorter.

-- Hannes

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

* Re: [PATCH] Do not change the file type if the filesystem does not support symlinks.
  2007-02-27 22:54     ` [PATCH] Do not change the file type if the filesystem does not support symlinks Johannes Schindelin
@ 2007-02-28 17:40       ` Johannes Sixt
  2007-02-28 17:53         ` Johannes Schindelin
  0 siblings, 1 reply; 18+ messages in thread
From: Johannes Sixt @ 2007-02-28 17:40 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin

On Tuesday 27 February 2007 23:54, Johannes Schindelin wrote:
> On Tue, 27 Feb 2007, Johannes Sixt wrote:
> > diff --git a/read-cache.c b/read-cache.c
> > index 605b352..f09ee2e 100644
> > --- a/read-cache.c
> > +++ b/read-cache.c
> > @@ -116,7 +116,8 @@ static int ce_match_stat_basic(struct cache_entry
> > *ce, struct stat *st)
> >
> >  	switch (ntohl(ce->ce_mode) & S_IFMT) {
> >  	case S_IFREG:
> > -		changed |= !S_ISREG(st->st_mode) ? TYPE_CHANGED : 0;
> > +		if (trust_symlink_fmt && !S_ISREG(st->st_mode))
> > +			changed |= TYPE_CHANGED;
>
> Really? If the cache entry says S_IFREG we should not expect a symlink
> here, right?

Don't know what I was smoking here. This hunk just doesn't need to be there at 
all...

>
> > @@ -125,7 +126,8 @@ static int ce_match_stat_basic(struct cache_entry
> > *ce, struct stat *st) changed |= MODE_CHANGED;
> >  		break;
> >  	case S_IFLNK:
> > -		changed |= !S_ISLNK(st->st_mode) ? TYPE_CHANGED : 0;
> > +		if (trust_symlink_fmt && !S_ISLNK(st->st_mode))
> > +			changed |= TYPE_CHANGED;
>
> This does not handle the case symlink->directory, right?

Something like:

		if (!S_ISLNK(st->st_mode) &&
		    (trust_symlink_fmt || !S_ISREG(st->st_mode)))
			changed |= TYPE_CHANGE;

BTW, considering the size of the entire patch series, I'm thinking of 
submitting it in a single patch.

-- Hannes

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

* Re: [PATCH] Do not change the file type if the filesystem does not support symlinks.
  2007-02-28 17:40       ` Johannes Sixt
@ 2007-02-28 17:53         ` Johannes Schindelin
  0 siblings, 0 replies; 18+ messages in thread
From: Johannes Schindelin @ 2007-02-28 17:53 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: git

Hi,

On Wed, 28 Feb 2007, Johannes Sixt wrote:

> On Tuesday 27 February 2007 23:54, Johannes Schindelin wrote:
> > On Tue, 27 Feb 2007, Johannes Sixt wrote:
> >
> > > @@ -125,7 +126,8 @@ static int ce_match_stat_basic(struct cache_entry
> > > *ce, struct stat *st) changed |= MODE_CHANGED;
> > >  		break;
> > >  	case S_IFLNK:
> > > -		changed |= !S_ISLNK(st->st_mode) ? TYPE_CHANGED : 0;
> > > +		if (trust_symlink_fmt && !S_ISLNK(st->st_mode))
> > > +			changed |= TYPE_CHANGED;
> >
> > This does not handle the case symlink->directory, right?
> 
> Something like:
> 
> 		if (!S_ISLNK(st->st_mode) &&
> 		    (trust_symlink_fmt || !S_ISREG(st->st_mode)))
> 			changed |= TYPE_CHANGE;

Yes.

> BTW, considering the size of the entire patch series, I'm thinking of 
> submitting it in a single patch.

Makes sense.

Ciao,
Dscho

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

* Re: Implement core.symlinks to support filesystems without symlinks
  2007-02-28  0:07   ` Johannes Schindelin
@ 2007-02-28 22:48     ` Robin Rosenberg
  2007-03-01  1:18       ` Johannes Schindelin
  0 siblings, 1 reply; 18+ messages in thread
From: Robin Rosenberg @ 2007-02-28 22:48 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Johannes Sixt, git

onsdag 28 februari 2007 01:07 skrev Johannes Schindelin:
>>
> Basically, there is no proper way to solve it (other than switching to 
> Linux, but that goes without saying).

> Your solution would fall short if one of the two files is changed. Since 
> they are supposed to be symlinks, the application expects them to be 
> identical, and weird sh*t happens.
As will it when the file contain something completly different than expected. 
Another SCM does copies instead and that works, though it's not very beautiful,
but the checkout "works" 99% of the time, rather than not at all. As you code 
Most apps won't care if the original and the copy are different, but the user may
notice (or not...).

> E.g. if you have a symlink "ln -s Makefile.host Makefile", and a script 
> which changes "Makefile.host", and a subdirectory Makefile accessing the 
> root Makefile, you will not be happy.
If...

> So, any way you go, if you have a repository containing symlinks, and you 
> have an OS which does not support symlinks, you are screwed.
As I said, I've seen the scheme sort of work. I can still work with the checkout, though
not entirely as I would like to work (but that includes the platform too). All tools can 
use a copy, none can use a textfile containing the pointed to file.

> But since we already have a symlink in git.git, and _want_ to compile git 
> on MinGW nevertheless, we should support symlinks _somehow_. Even if that 
> means that advanced usage of symlinks will fail.
> 
> I agree with Johannes here how to go about this partial "support" of 
> symlinks, since I cannot think of any sane way to retain the information 
> (where the symlink points to) in the index.
Don't update the symblink. We know it's a link. You don't want to anyway in your 
non-symlink supporting environment, or add git-ln.

-- robin

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

* Re: Implement core.symlinks to support filesystems without symlinks
  2007-02-28 22:48     ` Robin Rosenberg
@ 2007-03-01  1:18       ` Johannes Schindelin
  2007-03-01 11:56         ` Robin Rosenberg
  0 siblings, 1 reply; 18+ messages in thread
From: Johannes Schindelin @ 2007-03-01  1:18 UTC (permalink / raw)
  To: Robin Rosenberg; +Cc: Johannes Sixt, git

Hi,

On Wed, 28 Feb 2007, Robin Rosenberg wrote:

> onsdag 28 februari 2007 01:07 skrev Johannes Schindelin:
>
> > Your solution would fall short if one of the two files is changed. 
> > Since they are supposed to be symlinks, the application expects them 
> > to be identical, and weird sh*t happens.
>
> As will it when the file contain something completly different than 
> expected.

My points are these:

- If your project depends on symlinks, and you are on a system that does 
  not do symlinks, you're screwed. However, you might want to checkout the 
  project nevertheless.

- If you have a symlink, and your system does not do symlinks, you want 
  the information where the symlink points to, at least _somewhere_. 
  Without digging deep into Git internals.

- If you have a symlink, and your system ..., you want it to fail _early_.

The last point is reaaaaally important. There is a reason why we have 
compiler errors, instead of just blindly compiling it, and if that 
particular code path is triggered, explode in the face of the user.

So, all I would like to do on top of Johannes' patch is to add a _big_ 
_fat_ warning whenever Git realizes it has to substitute a file for a 
link, but I DON'T WANT THE BLOODY FILE TO BE COPIED.

Ciao,
Dscho

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

* Re: Implement core.symlinks to support filesystems without symlinks
  2007-03-01  1:18       ` Johannes Schindelin
@ 2007-03-01 11:56         ` Robin Rosenberg
  2007-03-01 17:13           ` Johannes Schindelin
  2007-03-01 19:24           ` Johannes Sixt
  0 siblings, 2 replies; 18+ messages in thread
From: Robin Rosenberg @ 2007-03-01 11:56 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Johannes Sixt, git

torsdag 01 mars 2007 02:18 skrev Johannes Schindelin:
> My points are these:
> 
> - If your project depends on symlinks, and you are on a system that does 
>   not do symlinks, you're screwed. However, you might want to checkout the 
>   project nevertheless.
> 
> - If you have a symlink, and your system does not do symlinks, you want 
>   the information where the symlink points to, at least _somewhere_. 
>   Without digging deep into Git internals.
> 
> - If you have a symlink, and your system ..., you want it to fail _early_.
> 
> The last point is reaaaaally important. There is a reason why we have 
> compiler errors, instead of just blindly compiling it, and if that 
> particular code path is triggered, explode in the face of the user.
> 
> So, all I would like to do on top of Johannes' patch is to add a _big_ 
> _fat_ warning whenever Git realizes it has to substitute a file for a 
> link, but I DON'T WANT THE BLOODY FILE TO BE COPIED.

I do want it to fail early initially (checkout), no default workaround, until 
I SAY I want  copies (or text links, this is apparently a preference. By 
default git should complain loudly that it cannot create links. 

- What do you want to do today?
	a) Screw me with copies
	b) Screw me with text links
	c) Screw me with shortcuts (cygwin does this which is fine as long as I stay 
within cygwin, so it is ok as a default behaviour there, but not otherwise)

I case of a link pointing to / I certainly do not want a copy either. :). 
There is no sane way of figuring out what I want.

-- robin

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

* Re: Implement core.symlinks to support filesystems without symlinks
  2007-03-01 11:56         ` Robin Rosenberg
@ 2007-03-01 17:13           ` Johannes Schindelin
  2007-03-01 19:24           ` Johannes Sixt
  1 sibling, 0 replies; 18+ messages in thread
From: Johannes Schindelin @ 2007-03-01 17:13 UTC (permalink / raw)
  To: Robin Rosenberg; +Cc: Johannes Sixt, git

Hi,

On Thu, 1 Mar 2007, Robin Rosenberg wrote:

> - What do you want to do today?
> 	a) Screw me with copies
> 	b) Screw me with text links
> 	c) Screw me with shortcuts (cygwin does this which is fine as long 
>	   as I stay within cygwin, so it is ok as a default behaviour 
>	   there, but not otherwise)

I think we already wasted enough quality time on this Windows hell. I will 
not, repeat, not waste any more time on this issue.

Ciao,
Dscho

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

* Re: Implement core.symlinks to support filesystems without symlinks
  2007-03-01 11:56         ` Robin Rosenberg
  2007-03-01 17:13           ` Johannes Schindelin
@ 2007-03-01 19:24           ` Johannes Sixt
  1 sibling, 0 replies; 18+ messages in thread
From: Johannes Sixt @ 2007-03-01 19:24 UTC (permalink / raw)
  To: git; +Cc: Robin Rosenberg, Johannes Schindelin

On Thursday 01 March 2007 12:56, Robin Rosenberg wrote:
> torsdag 01 mars 2007 02:18 skrev Johannes Schindelin:
> > So, all I would like to do on top of Johannes' patch is to add a _big_
> > _fat_ warning whenever Git realizes it has to substitute a file for a
> > link, but I DON'T WANT THE BLOODY FILE TO BE COPIED.
>
> I do want it to fail early initially (checkout), no default workaround,
> until I SAY I want  copies (or text links, this is apparently a preference.
> By default git should complain loudly that it cannot create links.

Oh, git will fail early: symlink(2) will complain.

> - What do you want to do today?
> 	a) Screw me with copies
> 	b) Screw me with text links
> 	c) Screw me with shortcuts (cygwin does this which is fine as long as I
> stay within cygwin, so it is ok as a default behaviour there, but not
> otherwise)

The patch implements behavior b), and it will need to be turned on in a 
conscious act, or it won't "screw you".

-- Hannes

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

end of thread, other threads:[~2007-03-01 19:24 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-27 21:41 Implement core.symlinks to support filesystems without symlinks Johannes Sixt
2007-02-27 21:41 ` [PATCH] Add a flag core.symlinks analogous to core.filemode Johannes Sixt
2007-02-27 21:41   ` [PATCH] Do not change the file type if the filesystem does not support symlinks Johannes Sixt
2007-02-27 21:41     ` [PATCH] Create a symbolic link as a regular file on filesystems without symlinks Johannes Sixt
2007-02-27 21:41       ` [PATCH] diff-lib.c: Ignore type differences if the filesystem does not support symlinks Johannes Sixt
2007-02-27 21:41         ` [PATCH] Describe core.symlinks in the man pages Johannes Sixt
2007-02-27 22:44       ` [PATCH] Create a symbolic link as a regular file on filesystems without symlinks Johannes Schindelin
2007-02-28 17:18         ` Johannes Sixt
2007-02-27 22:54     ` [PATCH] Do not change the file type if the filesystem does not support symlinks Johannes Schindelin
2007-02-28 17:40       ` Johannes Sixt
2007-02-28 17:53         ` Johannes Schindelin
2007-02-27 23:13 ` Implement core.symlinks to support filesystems without symlinks Robin Rosenberg
2007-02-28  0:07   ` Johannes Schindelin
2007-02-28 22:48     ` Robin Rosenberg
2007-03-01  1:18       ` Johannes Schindelin
2007-03-01 11:56         ` Robin Rosenberg
2007-03-01 17:13           ` Johannes Schindelin
2007-03-01 19:24           ` Johannes Sixt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.