Skip to contentSkip to conversation

Disable USE_SYMLINK_HEAD by default

PATCH In review Pavel Roskin 11 participants 40 messages Jun 15, 2016 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Disable USE_SYMLINK_HEAD by default

Disable USE_SYMLINK_HEAD by default. Recommend using it only for compatibility with older software.

Treat USE_SYMLINK_HEAD like other optional defines - check whether it's defined, not its value.

---
Applying this patch before 1.0 may be controversial, but I think there is a very good reason for that. There should be exactly one git 1.0 repository format. Now we have two that are present in the sources and that have received testing from the git users.

Of those two formats, I prefer the one that is platform independent and not very demanding with regard to filesystems and transfer protocols. That format should be good enough so that we don't plan to change it as soon as version 1.0 is released. Any third party software claiming to support git 1.0 should need to support one repository format.

Makefile +4 -1
index 63cb998..585552e 100644
@@ -18,6 +18,10 @@
 #
 # Define NO_STRCASESTR if you don't have strcasestr.
 #
+# Define USE_SYMLINK_HEAD if you want .git/HEAD to be a symbolic link.
+# This feature is phased out, enable it only for compatibility with other
+# software.  Don't enable it on Windows.
+#
 # Define PPC_SHA1 environment variable when running make to make use of
 # a bundled SHA1 routine optimized for PowerPC.
 #
@@ -210,7 +214,6 @@ ifeq ($(uname_O),Cygwin)
 	NEEDS_LIBICONV = YesPlease
 	NO_IPV6 = YesPlease
 	X = .exe
-	ALL_CFLAGS += -DUSE_SYMLINK_HEAD=0
 endif
 ifeq ($(uname_S),OpenBSD)
 	NO_STRCASESTR = YesPlease
refs.c +1 -5
index a52b038..9b88742 100644
@@ -6,10 +6,6 @@
 /* We allow "recursive" symbolic refs. Only within reason, though */
 #define MAXDEPTH 5
 
-#ifndef USE_SYMLINK_HEAD
-#define USE_SYMLINK_HEAD 1
-#endif
-
 int validate_symref(const char *path)
 {
 	struct stat st;
@@ -120,7 +116,7 @@ int create_symref(const char *git_HEAD, 
 	char ref[1000];
 	int fd, len, written;
 
-#if USE_SYMLINK_HEAD
+#ifdef USE_SYMLINK_HEAD
 	unlink(git_HEAD);
 	if (!symlink(refs_heads_master, git_HEAD))
 		return 0;
Signature · 2 lines
Regards,
Pavel Roskin
#1 lore raw
Quoted 1 line · Pavel Roskin

Applying this patch before 1.0 may be controversial,...

If I am not mistaken, I thought the last thread on the list showed general consensus that symlinks were preferred when available. So applying this patch anytime would be controversial...

Quoted 1 line

but I think there is a very good reason for that.

Which is...? I do not think this paragraph justifies it:

Quoted 3 lines

There should be exactly one git 1.0 repository format. Now we have two that are present in the sources and that have received testing from the git users.

The one format is that .git/HEAD can either be a symlink or regular file text symref; both variants are tested -- wouldn't that be good enough?

The only thing I can think of that might be inconvenient is if you try doing "cp -a" off of a filesystem that supports symlinks to another filesystem that does not -- probably that would fail copying the symlinked .git/HEAD. But if that is the problem, you could always git-clone, which should do the right thing, I think.

#2 lore raw
Quoted 8 lines · Junio C Hamano
Quoted 1 line · Pavel Roskin

Applying this patch before 1.0 may be controversial,...

If I am not mistaken, I thought the last thread on the list showed general consensus that symlinks were preferred when available. So applying this patch anytime would be controversial...

I must have missed that. If you mean "Re: Getting rid of symlinks in .git?", I don't see any such consensus there. The discussion drifts to insignificant details, and I see arguments like "I couldn't care less" and speculations about speed without any hard data at hand.

Quoted 11 lines
Quoted 1 line

but I think there is a very good reason for that.

Which is...? I do not think this paragraph justifies it:

Quoted 3 lines

There should be exactly one git 1.0 repository format. Now we have two that are present in the sources and that have received testing from the git users.

The one format is that .git/HEAD can either be a symlink or regular file text symref; both variants are tested -- wouldn't that be good enough?

No. Even if git itself is tested, other tools are not. What's worse, the developers of those tools don't even know they are supposed to test for two HEAD formats unless they track git changes and mailing lists very carefully.

In particular, StGIT still needs fixing.

Quoted 6 lines

The only thing I can think of that might be inconvenient is if you try doing "cp -a" off of a filesystem that supports symlinks to another filesystem that does not -- probably that would fail copying the symlinked .git/HEAD. But if that is the problem, you could always git-clone, which should do the right thing, I think.

I'm talking from my experience now. If there is an option, there are users that have it enabled and those who have it disabled (by definition). As is often happens, one of the configurations is more popular with developers. The other configuration almost inevitably starts suffering from the "bit rot".

It could have been prevented if the format choice was encapsulated by git prior to its introduction. But git-symbolic-ref didn't exist before symrefs were implemented. Old code outside git accesses .git/HEAD manually. Fixing git alone is not enough if git files are accessed without git.

Extra complexity of any format discourages third party applications or makes them more complex and less safe to use.

I can understand if the complexity has a balance of requirements issue behind it. For example, coexistence of packed and unpacked files comes from the conflicting requirements to handle files quickly and not to consume too much hard disk space and bandwidth.

But there is no strong (compared to portability) reason to have symlinks, except maybe backward compatibility. It's a weak argument before 1.0 release. Let's not wait until it becomes stronger.

Signature · 2 lines
Regards,
Pavel Roskin
#3 lore raw
Quoted 9 lines · Pavel Roskin

In particular, StGIT still needs fixing.

Quoted 6 lines

The only thing I can think of that might be inconvenient is if you try doing "cp -a" off of a filesystem that supports symlinks to another filesystem that does not -- probably that would fail copying the symlinked .git/HEAD. But if that is the problem, you could always git-clone, which should do the right thing, I think.

Quoted 5 lines

I'm talking from my experience now. If there is an option, there are users that have it enabled and those who have it disabled (by definition). As is often happens, one of the configurations is more popular with developers. The other configuration almost inevitably starts suffering from the "bit rot".

That's a real concern, I should agree.

#4 lore raw
Quoted 11 lines · Junio C Hamano
Quoted 7 lines · Pavel Roskin

In particular, StGIT still needs fixing.

Quoted 1 line

...

I'm talking from my experience now. If there is an option, there are users that have it enabled and those who have it disabled (by definition). As is often happens, one of the configurations is more popular with developers. The other configuration almost inevitably starts suffering from the "bit rot".

That's a real concern, I should agree.

I think I need to qualify this comment. It is a real concern because we need to know when it is safe to start using textual symrefs everywhere, *if* we would want to do that switch.

I wonder how ready StGIT and Cogito are, but also I wonder how ready other things are. People built homebrew scripts around git without calling them Porcelains, and git is designed to be used that way. We do not know how many things we are breaking if we switch to do textual symrefs by default.

I just checked the latest gitweb, and it does not seem to be ready. I do not, however, necessarily think it is a high priority problem. It does not feel to me a realistic issue that you cannot serve a public repository on a filesystem incapable of symlinks via getweb. This change is breaking things for gitweb running on kernel.org machines without real benefit.

Thinking about it a bit more, the current setup to use symlinks on systems that supports them, and textual symrefs on others, is looking more and more sensible to me. If supporting symlink-challenged filesystems become a real issue for a "third party tool", certainly that will be updated, because people would want it. Switching to do textual symrefs by default everywhere is a way to *force* people to scramble and update their scripts everywhere, but I am not so sure that is worth it; I cannot justify why I'd be forcing them to do so, especially if supporting VFAT is a low priority for some of the tools.

"Bit rot" may first seem a concern, but actually it is not. I suspect that serverish applications such as gitweb view supporting symlink-challenged filesystems as a lower priority task, while more client-oriented applications rate it higher. The core support for textual symrefs cannot afford to rot as long as some Porcelain needs it, and worrying about it would not be a good justification to break everybody "just to see what breaks". On the other hand, if the support for textual symrefs rot, it probably deserves to --- the only reason that would happen would be because nobody uses them.

IOW, if we see real breakage in either git itself or Porcelains that use git, send in fixes to appropriate parties. I think that's being constructive. Otherwise, let's not break things just for the sake of consistency. I do not think that is helping anything.

#5 lore raw

Hi,

I think Junio is right: we should not force everybody not to use symlinks, only because there happens to be VFAT-, SMB- or HTTP-shared repositories. As Junio says, if there are people experiencing problems because they lack symbolic links, they should fix it.

On the other hand, I think it would be useful to be able to configure the behaviour via .git/config.

Ciao,
Dscho

#6 lore raw

Dear diary, on Tue, Nov 15, 2005 at 12:09:42PM CET, I got a letter where Johannes Schindelin <[email protected]> said that...

Quoted 4 lines

I think Junio is right: we should not force everybody not to use symlinks, only because there happens to be VFAT-, SMB- or HTTP-shared repositories. As Junio says, if there are people experiencing problems because they lack symbolic links, they should fix it.

I'm ambivalent here. I would like to have just a single behaviour here, since the symbolic ref otherwise really does not get much testing. But I can also understand that we are breaking tools here.

Still, for the reason above, I think we should aim at the symbolic refs being the canonical format in the next major release after 1.0, giving users time to fix their tools. I can see no advantage in symlinks except the backwards compatibility - speed argument was presented, but I don't buy that until I see hard data supporting that.

Quoted 2 lines

On the other hand, I think it would be useful to be able to configure the behaviour via .git/config.

Yes, I would very much like to have this. I still want to go symrefs-only for public repositories created for cg-admin-setuprepo, so that fetching over HTTP works properly.

Signature · 4 lines
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
VI has two modes: the one in which it beeps and the one in which
it doesn't.
#7 lore raw

Hi,

Quoted 11 lines · Petr Baudis

Dear diary, on Tue, Nov 15, 2005 at 12:09:42PM CET, I got a letter where Johannes Schindelin <[email protected]> said that...

Quoted 4 lines

I think Junio is right: we should not force everybody not to use symlinks, only because there happens to be VFAT-, SMB- or HTTP-shared repositories. As Junio says, if there are people experiencing problems because they lack symbolic links, they should fix it.

I'm ambivalent here. I would like to have just a single behaviour here, since the symbolic ref otherwise really does not get much testing. But I can also understand that we are breaking tools here.

Quoted 5 lines

Still, for the reason above, I think we should aim at the symbolic refs being the canonical format in the next major release after 1.0, giving users time to fix their tools. I can see no advantage in symlinks except the backwards compatibility - speed argument was presented, but I don't buy that until I see hard data supporting that.

<yousortofaskedforit>
Well, I can see no good reason for symrefs, except for backwards compatibility! Modern systems do support symlinks, you know?

Let´s face it. The main target for git is not Windows users. If we really want to support all idiocies of all possible ones, how about this one:

If I clone a repository to a USB stick on cygwin, and try to access it from my iBook, it does not work, because for *backward compatibility* reasons, files fitting the 8.3 format are stored in UPPER CASE.

So, I would like to have support for UPPER CASE files in .git, please? And since I cannot do my own testing, please could you force everybody´s git to write OBJECTS and MASTER in UPPER CASE? </yousortofaskedforit>

Ciao,
Dscho

#8 lore raw
Quoted 2 lines

Well, I can see no good reason for symrefs, except for backwards compatibility! Modern systems do support symlinks, you know?

What about less modern systems? I like to have tools that work on those, too.

Quoted 1 line

Let´s face it. The main target for git is not Windows users.

Yes, but they are a worthy secondary target.

Quoted 1 line

If we really want to support all idiocies of all possible ones,

I don't think we want that, but I don't think the symref vs. symlink issue is an idiocy either.

Quoted 9 lines

how about this one:

If I clone a repository to a USB stick on cygwin, and try to access it from my iBook, it does not work, because for *backward compatibility* reasons, files fitting the 8.3 format are stored in UPPER CASE.

So, I would like to have support for UPPER CASE files in .git, please? And since I cannot do my own testing, please could you force everybody´s git to write OBJECTS and MASTER in UPPER CASE?

Long and mixed-case filenames are supported almost universally. Why aren't you using FAT32 on your USB key? Even that decade-old filesystem supports them.

#38 lore raw
In reply to Pavel Roskin
Quoted 11 lines · Pavel Roskin
Quoted 3 lines · Junio C Hamano

The one format is that .git/HEAD can either be a symlink or regular file text symref; both variants are tested -- wouldn't that be good enough?

No. Even if git itself is tested, other tools are not. What's worse, the developers of those tools don't even know they are supposed to test for two HEAD formats unless they track git changes and mailing lists very carefully.

In particular, StGIT still needs fixing.

StGIT has been fixed for this in the latest snapshot (but not in the latest release). It now uses "git-symbolic-ref HEAD" to get the name of the current branch.

Signature · 1 line
Catalin
#9 lore raw
In reply to Johannes Schindelin
Quoted 3 lines · Johannes Schindelin

<yousortofaskedforit>
Well, I can see no good reason for symrefs, except for backwards compatibility! Modern systems do support symlinks, you know?

You misunderstood me here. I meant backward compatibility with git wrappers, not with old operating systems.

I meant, the only reason we don't want symrefs to be used by default is because there are wrappers around git that only work with symlinks. So, if we change the default behavior in git now, those wrappers will break on new repositories.

Quoted 10 lines

Let´s face it. The main target for git is not Windows users. If we really want to support all idiocies of all possible ones, how about this one:

If I clone a repository to a USB stick on cygwin, and try to access it from my iBook, it does not work, because for *backward compatibility* reasons, files fitting the 8.3 format are stored in UPPER CASE.

So, I would like to have support for UPPER CASE files in .git, please? And since I cannot do my own testing, please could you force everybody´s git to write OBJECTS and MASTER in UPPER CASE?

That was pretty funny :-)

Actually, what's different about symlinks is that they go beyond the paradigm of one data stream per file. There are two data streams accessible through the symlink, one being the data in the file it points to, and the other being the path to that file.

This doesn't map well to many data transfer protocols. We don't want git to work only over protocols that have explicit support for symlinks.

One example is http, sometimes the only protocol allowed to transcend corporate firewalls.

Another, more controversial example is CVS. Sourceforge doesn't support git, but I could store my git database in Sourceforge CVS, and thus share it with other contributors. Not being able to put .git/HEAD there would be an annoyance.

I believe Cygwin developers were actually more concerned about symlinks damaged by SMB than about any issues with storing them locally. After all, Cygwin is quite good at emulating POSIX, including symlinks.

Returning to your example, 8.3 format is a problem with storage. Those are behind us. It's problems with transfer that are going to limit us.

Signature · 2 lines
Regards,
Pavel Roskin
#10 lore raw
In reply to Petr Baudis
Quoted 11 lines · Petr Baudis

Dear diary, on Tue, Nov 15, 2005 at 12:09:42PM CET, I got a letter where Johannes Schindelin <[email protected]> said that...

Quoted 4 lines

I think Junio is right: we should not force everybody not to use symlinks, only because there happens to be VFAT-, SMB- or HTTP-shared repositories. As Junio says, if there are people experiencing problems because they lack symbolic links, they should fix it.

I'm ambivalent here. I would like to have just a single behaviour here, since the symbolic ref otherwise really does not get much testing. But I can also understand that we are breaking tools here.

Quoted 5 lines

Still, for the reason above, I think we should aim at the symbolic refs being the canonical format in the next major release after 1.0, giving users time to fix their tools. I can see no advantage in symlinks except the backwards compatibility - speed argument was presented, but I don't buy that until I see hard data supporting that.

I planned to write about symrefs long ago, and probably I waited for too long. I still hope it will be the default for 1.0 release, but if not, I hope the next release won't be too far away.

Quoted 6 lines
Quoted 2 lines

On the other hand, I think it would be useful to be able to configure the behaviour via .git/config.

Yes, I would very much like to have this. I still want to go symrefs-only for public repositories created for cg-admin-setuprepo, so that fetching over HTTP works properly.

Agreed. By the way, the symref doesn't need to be called HEAD - it could be "trunk" or "main" or "default-branch".

Signature · 2 lines
Regards,
Pavel Roskin
#11 lore raw
Quoted 10 lines · Pavel Roskin
Quoted 9 lines · Petr Baudis

I'm ambivalent here. I would like to have just a single behaviour here, since the symbolic ref otherwise really does not get much testing. But I can also understand that we are breaking tools here.

Still, for the reason above, I think we should aim at the symbolic refs being the canonical format in the next major release after 1.0, giving users time to fix their tools. I can see no advantage in symlinks except the backwards compatibility...

The voice of reason comes from Pasky; I agree with this.

Quoted 3 lines

I planned to write about symrefs long ago, and probably I waited for too long. I still hope it will be the default for 1.0 release, but if not, I hope the next release won't be too far away.

I think it is a bit too late for that, but please keep that patch; I'll hold on to it too.

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

On the other hand, I think it would be useful to be able to configure the behaviour via .git/config.

Yes, I would very much like to have this.

I am in favor of that. Something like this, perhaps:

core.filemode = 1 # trustworthy
core.usesymlink = 0 # new style

Quoted 2 lines

Agreed. By the way, the symref doesn't need to be called HEAD - it could be "trunk" or "main" or "default-branch".

Actually, I was thinking about changing get_sha1_basic() in sha1_name.c so that refs immediately under ${GIT_DIR-.git} are restricted to uppercase only. The other day I did

	$ git-update-ref linus blah

which created .git/linus in addition to .git/refs/heads/linus; this gives you considerable confusion.

#12 lore raw
Quoted 3 lines · Junio C Hamano

Pavel Roskin <[email protected]> writes:

The voice of reason comes from Pasky; I agree with this.

OK, let's prepare for post-1.0 switchover then.

Quoted 4 lines

I am in favor of that. Something like this, perhaps:

core.filemode = 1 # trustworthy
core.usesymlink = 0 # new style

Thanks for implemented this.

Signature · 2 lines
Regards,
Pavel Roskin
#13 lore raw
Quoted 6 lines · Pavel Roskin
Quoted 4 lines

I am in favor of that. Something like this, perhaps:

core.filemode = 1 # trustworthy
core.usesymlink = 0 # new style

Thanks for implemented this.

Thank from me, too, Johannes.

#14 lore raw
In reply to Petr Baudis
Quoted 1 line · Petr Baudis

being the canonical format in the next major release after 1.0, giving

Talking about versions...
Do we have an easy way to detect the format version of a git repository? If not, I suggest git-init-db to add something like

	echo "1" > .git/version

and let all the git-tools which read/write any files in .git themself test against version 1. Or is this overkill?

Josef

#15 lore raw

PATCH 1/1 Add .git/version

This patch series attempts to add .git/version support to init-db.c. THis is an overview of the patches.

First patch makes the Makefile build GIT_VERSION from the variables VERSION, PATCHLEVEL, and SUBLEVEL ala the kernel. These variables will be used later in init-db.c

Second patch adds support to init-db.c for writing the .git/version file.

- Martin -

#16 lore raw

PATCH 1/2 Build GIT_VERSION from VERSION, PATCHLEVEL, and SUBLEVEL variables.

This will allow scripts to be able to determine which git release they target (or require).

---

 Makefile |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

applies-to: 1e3fcf60526c196a46433e6947c9104ca236f230 968e5b59fba66a1b146c643e5161978c787d4273

Makefile +5 -1
index ebff990..74c6b9e 100644
@@ -50,7 +50,11 @@
 # Define USE_STDEV below if you want git to care about the underlying device
 # change being considered an inode change from the update-cache perspective.
 
-GIT_VERSION = 0.99.9.GIT
+VERSION = 0
+PATCHLEVEL = 99
+SUBLEVEL = 9
+EXTRAVERSION = GIT
+GIT_VERSION=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL).$(EXTRAVERSION)
 
 # CFLAGS and LDFLAGS are for the users to override from the command line.
 

---
0.99.9.GIT

#17 lore raw

PATCH 2/2 Make init-db record the version in $GIT_DIR/version when creating repo.

---

 Makefile  |    3 +++
 init-db.c |   15 +++++++++++++++
 2 files changed, 18 insertions(+), 0 deletions(-)

applies-to: ec55de586902d26b3f55c3d0aeabf94be1b82586 ec733719bfee2ade91416bd429eeefe6c4acb5a8

Makefile +3 -0
index 74c6b9e..c167120 100644
@@ -400,6 +400,9 @@ git-rev-list$X: LIBS += $(OPENSSL_LIBSSL
 
 init-db.o: init-db.c
 	$(CC) -c $(ALL_CFLAGS) \
+		-DVERSION='"$(VERSION)"' \
+		-DPATCHLEVEL='"$(PATCHLEVEL)"' \
+		-DSUBLEVEL='"$(SUBLEVEL)"' \
 		-DDEFAULT_GIT_TEMPLATE_DIR=$(call shellquote,"$(template_dir)") $*.c
 
 $(LIB_OBJS): $(LIB_H)
init-db.c +15 -0
index bd88291..6230e8e 100644
@@ -19,6 +19,17 @@ static void safe_create_dir(const char *
 	}
 }
 
+static void record_repo_version(const char *path)
+{
+	FILE *verfile = fopen(path, "w");
+	if (!verfile)
+		die ("Can not write to %s?", path);
+	
+	fprintf(verfile, "%d.%d.%d\n", VERSION, PATCHLEVEL, SUBLEVEL);
+	
+	fclose(verfile);
+}
+
 static int copy_file(const char *dst, const char *src, int mode)
 {
 	int fdi, fdo, status;
@@ -212,6 +223,10 @@ static void create_default_files(const c
 				fprintf(stderr, "Ignoring file modes\n");
 		}
 	}
+
+	/* record the version of the git repo */
+	strcpy(path + len, "version");
+	record_repo_version(path);
 }
 
 static const char init_db_usage[] =

---
0.99.9.GIT

#18 lore raw

Re: [PATCH] Add .git/version

In reply to Martin Atukunda
Quoted 2 lines · Martin Atukunda

This patch series attempts to add .git/version support to init-db.c. THis is an overview of the patches.

As .git/version is part of the repository, it should contain the version of the repository format used. Do you really want to link the version of the repository format with the version of git which created the repository? It think it is better to detach a repository version from version of git.

Why? Ideally, the git commands first should check if they can handle the repository format. If they can not handle the version, they should bail out with an error [*]
Now suppose we want to release Git 2 without change the repository format at all. Thus, even if Git 1 tool *would* work with repositories created by Git 2, they will fail in the version check!

If this is meant to be used in scripts (as your commit comment mentions):
a script should never touch any files in the repository directly, but go via commands supplied with git. So these scripts should actually check against the version of installed git. Thus, such a version string should go into git-var or better simply use the existing "git --version"?

Josef

[*] Junio: This should be done before Git 1.0 - it is needed to be able to change the repository format in the future without taking the risk that old git commands possibly corrupt a repo in the new format. This has nothing to do with backwards compatibility. Without a version, we are forced to be forwards compatible ;-)
Needed in init-db.c is a "echo 1 >.git/version"; and the mentioned check in the tools against this version.

#19 lore raw

Re: [PATCH] Add .git/version

Quoted 8 lines · Josef Weidendorfer

On Thursday 17 November 2005 14:25, Martin Atukunda wrote:

As .git/version is part of the repository, it should contain the version of the repository format used. Do you really want to link the version of the repository format with the version of git which created the repository? It think it is better to detach a repository version from version of git.

Quoted 7 lines

Why? Ideally, the git commands first should check if they can handle the repository format. If they can not handle the version, they should bail out with an error [*]
Now suppose we want to release Git 2 without change the repository format at all. Thus, even if Git 1 tool *would* work with repositories created by Git 2, they will fail in the version check!

Not that I have an opinion on these changes, but Netscape 7 still handles HTTP 1.1. Just because we up the major-number for git doesn't mean we have to do the same for the repository format version.

Signature · 3 lines
Andreas Ericsson                   [email protected]
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231
#20 lore raw

Re: [PATCH] Add .git/version

Quoted 11 lines · Andreas Ericsson
Quoted 7 lines

Why? Ideally, the git commands first should check if they can handle the repository format. If they can not handle the version, they should bail out with an error [*]
Now suppose we want to release Git 2 without change the repository format at all. Thus, even if Git 1 tool *would* work with repositories created by Git 2, they will fail in the version check!

Not that I have an opinion on these changes, but Netscape 7 still handles HTTP 1.1. Just because we up the major-number for git doesn't mean we have to do the same for the repository format version.

Of course we do not want that.
My comment was about this, as the proposed patch installed a .git/version file with the git version in it, which would lead to this strange result.

Josef

#21 lore raw

Re: [PATCH] Add .git/version

Quoted 9 lines · Josef Weidendorfer
Quoted 8 lines · Andreas Ericsson
Quoted 7 lines

Why? Ideally, the git commands first should check if they can handle the repository format. If they can not handle the version, they should bail out with an error [*]
Now suppose we want to release Git 2 without change the repository format at all. Thus, even if Git 1 tool *would* work with repositories created by Git 2, they will fail in the version check!

Quoted 9 lines
Quoted 3 lines

Not that I have an opinion on these changes, but Netscape 7 still handles HTTP 1.1. Just because we up the major-number for git doesn't mean we have to do the same for the repository format version.

Of course we do not want that.
My comment was about this, as the proposed patch installed a .git/version file with the git version in it, which would lead to this strange result.

I agree, I'll resubmit a patch to create a .git/version file that simply says 1.

which specific git commands would most likely want to know about the version of the repo format? I could look at them to see what needs to be changed so that they don't corrupt a repo, or as Johannes said, the use of this file would become handy only when an incompatible change is made. In which case, init-db.c just creates it for now, as a simple safe guard.

- Martin -

Signature · 1 line
Due to a shortage of devoted followers, the production of great leaders has been discontinued.
#22 lore raw

PATCH 1/1 Add .git/version (Take 2)

Currently the version number can be considered version 1, so this patch just sets it to that. This patch supercedes my earlier attempt that erroneously used the git version number as the repo format version.

---

 init-db.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

applies-to: d1bb16b919a119cca6ee001f755f83251a2c2964 31e78e387d708da5e09f40436d5fdc9e9ec5e16c

init-db.c +17 -0
index bd88291..e403dac 100644
@@ -9,6 +9,8 @@
 #define DEFAULT_GIT_TEMPLATE_DIR "/usr/share/git-core/templates/"
 #endif
 
+#define REPO_VERSION 1
+
 static void safe_create_dir(const char *dir)
 {
 	if (mkdir(dir, 0777) < 0) {
@@ -19,6 +21,17 @@ static void safe_create_dir(const char *
 	}
 }
 
+static void record_repo_version(const char *path)
+{
+	FILE *verfile = fopen(path, "w");
+	if (!verfile)
+		die ("Can not write to %s?", path);
+	
+	fprintf(verfile, "%d\n", REPO_VERSION);
+	
+	fclose(verfile);
+}
+
 static int copy_file(const char *dst, const char *src, int mode)
 {
 	int fdi, fdo, status;
@@ -212,6 +225,10 @@ static void create_default_files(const c
 				fprintf(stderr, "Ignoring file modes\n");
 		}
 	}
+
+	/* record the version of the git repo */
+	strcpy(path + len, "version");
+	record_repo_version(path);
 }
 
 static const char init_db_usage[] =

---
0.99.9.GIT

Signature · 1 line
Due to a shortage of devoted followers, the production of great leaders has been discontinued.
#23 lore raw

Re: [PATCH] Add .git/version

In reply to Josef Weidendorfer
Quoted 7 lines · Josef Weidendorfer

[*] Junio: This should be done before Git 1.0 - it is needed to be able to change the repository format in the future without taking the risk that old git commands possibly corrupt a repo in the new format. This has nothing to do with backwards compatibility. Without a version, we are forced to be forwards compatible ;-)
Needed in init-db.c is a "echo 1 >.git/version"; and the mentioned check in the tools against this version.

I agree with the general direction.

- Futureproofing is good.

- We want repository-format-version but that may be too long. Just saying version is a bit confusing. Abbreviating it to repository-version makes it sound as if somebody took a snapshot (i.e. tar-tree $commit). Whatever name we choose, let's pick a one not so confusing.

- Not having .git/version (or whatever name) signals the tools our repository is in the original format. This will keep the existing repositories happy. What this means is that the tools need to check for the absense of .git/version in this round. When we change the repository format, we will have .git/version file that records it.

- You can run git-init-db on an existing repository. This is sometimes handy if you added a new hook in the template suite and want to copy it over (it never overwrites but happily copies what you do not have). This mechanism needs to be told about the version file -- specifically, it should check version in the template area and refuse to do use that template if it does not match the repository. Similarly, when creating a repository from scratch, it should not copy the version file from templates.

#24 lore raw

Re: [PATCH] Add .git/version

Quoted 6 lines · Junio C Hamano

- We want repository-format-version but that may be too long. Just saying version is a bit confusing. Abbreviating it to repository-version makes it sound as if somebody took a snapshot (i.e. tar-tree $commit). Whatever name we choose, let's pick a one not so confusing.

My one argument against this is that I don't see why we have to have a separate file for this.

Why not just add a "core.version" flag to the config file? If no version exists, assume it's version 1. And then, if we ever start using some other version, make git-init-db always create the config file (the way we already do for "core.filemode")

Sure, people can edit the version flag by hand, but hey, that's true even if it's in a separate .git/version file.

Linus

#25 lore raw

Re: [PATCH] Add .git/version

Quoted 2 lines · Linus Torvalds

My one argument against this is that I don't see why we have to have a separate file for this.

True.

Quoted 1 line

Why not just add a "core.version" flag to the config file?

True, perhaps core.repository-format-version?

#26 lore raw

Re: [PATCH] Add .git/version

In reply to Linus Torvalds

Hi,

Quoted 8 lines · Linus Torvalds
Quoted 6 lines · Junio C Hamano

- We want repository-format-version but that may be too long. Just saying version is a bit confusing. Abbreviating it to repository-version makes it sound as if somebody took a snapshot (i.e. tar-tree $commit). Whatever name we choose, let's pick a one not so confusing.

Quoted 7 lines

My one argument against this is that I don't see why we have to have a separate file for this.

Why not just add a "core.version" flag to the config file? If no version exists, assume it's version 1. And then, if we ever start using some other version, make git-init-db always create the config file (the way we already do for "core.filemode")

Note that git-sh-setup and setup_git_directory() should check for it and complain if it finds a value > 1. Else there is not much which prevents old tools (like current) to access future versions.

The actual number may come later. The check can't.

Ciao,
Dscho

#27 lore raw

Re: [PATCH] Add .git/version

In reply to Martin Atukunda

Hi,

Quoted 1 line · Martin Atukunda

This patch series attempts to add .git/version support to init-db.c.

Wouldn't it make more sense to add the variable VERSION to git-var? After all, git is designed to be backwards compatible; newer versions are supposed to work with ancient repositories.

I think you are more interested in knowing which version the tools are at.

Ciao,
Dscho

#28 lore raw

Re: [PATCH] Add .git/version

Quoted 11 lines · Johannes Schindelin

Hi,

Quoted 1 line · Martin Atukunda

This patch series attempts to add .git/version support to init-db.c.

Wouldn't it make more sense to add the variable VERSION to git-var? After all, git is designed to be backwards compatible; newer versions are supposed to work with ancient repositories.

I think you are more interested in knowing which version the tools are at.

Actually this patch series is more a response to the thread "Re: [PATCH] Disable USE_SYMLINK_HEAD by default" in particular see this message [email protected] by Josef Weidendorfer.

We've had at least one change that was backwards incompatible, though this was in the ancient days of git development. This patch allows git to record what version of the git tools created the repo we are dealing with. Just in case future changes require this.

- Martin -

Signature · 1 line
Due to a shortage of devoted followers, the production of great leaders has been discontinued.
#29 lore raw

Re: [PATCH] Add .git/version

Hi,

Quoted 8 lines · Martin Atukunda
Quoted 2 lines · Johannes Schindelin

I think you are more interested in knowing which version the tools are at.

Actually this patch series is more a response to the thread "Re: [PATCH] Disable USE_SYMLINK_HEAD by default" in particular see this message [email protected] by Josef Weidendorfer.

When we disable USE_SYMLINK_HEAD by default, tools are expected to work with USE_SYMLINK_HEAD enabled, too, so .git/version is not needed for that.

But yes, it might be handy to know at some time. But I think it would make sense to add .git/version *then*, because you can distinguish repositories before/after the change by testing for .git/version.

Ciao,
Dscho

#30 lore raw

Re: [PATCH] Add .git/version

Quoted 3 lines · Johannes Schindelin

But yes, it might be handy to know at some time. But I think it would make sense to add .git/version *then*, because you can distinguish repositories before/after the change by testing for .git/version.

No, as old git tools then still could corrupt a repository with a new format, as they currently do not check any kind of format version; it would work if the git 1 tools would bail out if a .git/version is found ;-)

Josef

#31 lore raw
In reply to Petr Baudis
Quoted 3 lines · Petr Baudis

Yes, I would very much like to have this. I still want to go symrefs-only for public repositories created for cg-admin-setuprepo, so that fetching over HTTP works properly.

Sorry, I must have missed that part. How does fetch-over-HTTP break with symlinked HEAD?

#32 lore raw
Quoted 8 lines · Junio C Hamano
Quoted 3 lines · Petr Baudis

Yes, I would very much like to have this. I still want to go symrefs-only for public repositories created for cg-admin-setuprepo, so that fetching over HTTP works properly.

Sorry, I must have missed that part. How does fetch-over-HTTP break with symlinked HEAD?

With symlinks, cogito doesn't know which branch it is fetching if the branch is not explicitly specified.

The old behavior was to fetch the "master" branch by default. Currently, cogito uses HEAD, but it cannot read the symlink, it can only read the SHA1. So, if somebody decides to use "cg-switch" on the public repository (admittedly not a very good idea), all the clients that are not using an explicit branch will unknowingly switch to another branch upon update.

It also could be useful for users to know the branch name. I, for one, would like to know if HEAD links to "stable" or "sandbox4crazyhacks", even if both have the same SHA1 at the moment.

Signature · 2 lines
Regards,
Pavel Roskin
#33 lore raw
Quoted 2 lines · Pavel Roskin
Quoted 2 lines

Sorry, I must have missed that part. How does fetch-over-HTTP break with symlinked HEAD?

Symlinks can also be problematic for push-over-HTTP, since there are no guarantees about the backend on the server (eg. pushing into a subversion repo with mod_dav_svn.)

Signature · 2 lines
For a successful technology, reality must take precedence over public
relations, for nature cannot be fooled.
#34 lore raw
In reply to Pavel Roskin
Quoted 7 lines · Pavel Roskin
Quoted 6 lines · Junio C Hamano
Quoted 3 lines · Petr Baudis

Yes, I would very much like to have this. I still want to go symrefs-only for public repositories created for cg-admin-setuprepo, so that fetching over HTTP works properly.

Quoted 5 lines
Quoted 2 lines

Sorry, I must have missed that part. How does fetch-over-HTTP break with symlinked HEAD?

With symlinks, cogito doesn't know which branch it is fetching if the branch is not explicitly specified.

Ah, thanks.

git-clone-pack has the same problem. It basically "guesses" by:

- If the master branch exists, and the object name of the branch tip matches the object name of HEAD, assume HEAD points at master. Even when there are other branches that happen to share the same branch head.

- Otherwise, if there is a branch whose tip matches the object name of HEAD, assume HEAD points at it. It just picks "one-of-them" if more than one branches match.

- If there is no branch that matches HEAD, issue a warning and create HEAD that records the object name, not pointing anywhere.

To solve this generally we would need to extend what ls-remote returns, I suppose.

#35 lore raw
In reply to Pavel Roskin
Quoted 7 lines · Pavel Roskin

With symlinks, cogito doesn't know which branch it is fetching if the branch is not explicitly specified.

The old behavior was to fetch the "master" branch by default. Currently, cogito uses HEAD, but it cannot read the symlink, it can only read the SHA1.

Hmm? Why not just use "git-symbolic-ref HEAD" to figure it out? That works with both symlinks and symrefs (and indeed, was added for that reason).

Linus

#36 lore raw

Dear diary, on Tue, Nov 15, 2005 at 06:33:44PM CET, I got a letter where Linus Torvalds <[email protected]> said that...

Quoted 11 lines · Pavel Roskin
Quoted 7 lines

With symlinks, cogito doesn't know which branch it is fetching if the branch is not explicitly specified.

The old behavior was to fetch the "master" branch by default. Currently, cogito uses HEAD, but it cannot read the symlink, it can only read the SHA1.

Hmm? Why not just use "git-symbolic-ref HEAD" to figure it out? That works with both symlinks and symrefs (and indeed, was added for that reason).

If you show me a way how to do git-symbolic-ref over HTTP, I will be most grateful. :-)

Seriously though, if people have huge problem with having symbolic refs by default, that's unfortunate since we have two possibilities which are not equally tested, but I can live with it - just give me a way to configure that behaviour per-repository, so that I can make GIT use symbolic refs in public repositories (or I can whip up a patch myself at the evening, after all...).

Signature · 4 lines
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
VI has two modes: the one in which it beeps and the one in which
it doesn't.
#37 lore raw
Quoted 3 lines · Petr Baudis

If you show me a way how to do git-symbolic-ref over HTTP, I will be most grateful. :-)

Hmm, why do you care?

If you do a fetch over http, you'd just fetch HEAD directly. If that's just a SHA1 (like it will be with a symlink) you'll just use that as the branch (and don't care about what branch it was). And if it's a symref, you can see what the branch should be and fetch that. No?

Linus

#39 lore raw
In reply to Catalin Marinas
Quoted 6 lines · Catalin Marinas
Quoted 1 line · Pavel Roskin

In particular, StGIT still needs fixing.

StGIT has been fixed for this in the latest snapshot (but not in the latest release). It now uses "git-symbolic-ref HEAD" to get the name of the current branch.

Indeed. I misinterpreted an error message.

Signature · 2 lines
Regards,
Pavel Roskin