git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Heikki Orsila <heikki.orsila@iki.fi>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Make core.sharedRepository more generic
Date: Tue, 15 Apr 2008 22:22:10 -0700	[thread overview]
Message-ID: <7vk5iytlvh.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: 20080415091326.GA18100@zakalwe.fi

Heikki Orsila <heikki.orsila@iki.fi> writes:

> git init --shared=0xxx, where '0xxx' is an octal number, will create
> a repository with file modes set to '0xxx'. Users with a safe umask
> value (0077) can use this option to force file modes. For example,
> '0640' is a group-readable but not group-writable regardless of
> user's umask value. Values compatible with old Git versions are written
> as they were before, for compatibility reasons. That is, "1" for
> "group" and "2" for "everybody".
>
> "git config core.sharedRepository 0xxx" is also handled.
>
> Signed-off-by: Heikki Orsila <heikki.orsila@iki.fi>
> ---
> This is version 5 of the generic shared mode patch.

Looking better.

> Btw, the current behavior (not introduced by this patch) of
> "config core.sharedRepository group" writes string "group" to the 
> repository, so it creates incompatible repositories.

Yes, but that is what the user explicitly does, so I do not see it as a
grave problem compared to the one you fixed during this iteration.

But the patch breaks t1301.  I would suggest this fix on top of your
version.

---

 path.c                 |    5 ++++-
 t/t1301-shared-repo.sh |   40 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 1 deletions(-)

diff --git a/path.c b/path.c
index cfa0529..2ae7cd9 100644
--- a/path.c
+++ b/path.c
@@ -268,7 +268,10 @@ int adjust_shared_perm(const char *path)
 	mode = st.st_mode;
 
 	if (shared_repository) {
-		mode = (mode & ~0777) | shared_repository;
+		int tweak = shared_repository;
+		if (!(mode & S_IWUSR))
+			tweak &= ~0222;
+		mode = (mode & ~0777) | tweak;
 	} else {
 		/* Preserve old PERM_UMASK behaviour */
 		if (mode & S_IWUSR)
diff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh
index 6bfe19a..586dab1 100755
--- a/t/t1301-shared-repo.sh
+++ b/t/t1301-shared-repo.sh
@@ -33,4 +33,44 @@ test_expect_success 'update-server-info honors core.sharedRepository' '
 	esac
 '
 
+for u in	0660:rw-rw---- \
+		0640:rw-r----- \
+		0600:rw------- \
+		0666:rw-rw-rw- \
+		0664:rw-rw-r--
+do
+	x=$(expr "$u" : ".*:\([rw-]*\)") &&
+	y=$(echo "$x" | sed -e "s/w/-/g") &&
+	u=$(expr "$u" : "\([0-7]*\)") &&
+	git config core.sharedrepository "$u" &&
+	umask 0277 &&
+
+	test_expect_success "shared = $u ($y) ro" '
+
+		rm -f .git/info/refs &&
+		git update-server-info &&
+		actual="$(ls -l .git/info/refs)" &&
+		actual=${actual%% *} &&
+		test "x$actual" = "x-$y" || {
+			ls -lt .git/info
+			false
+		}
+	'
+
+	umask 077 &&
+	test_expect_success "shared = $u ($x) rw" '
+
+		rm -f .git/info/refs &&
+		git update-server-info &&
+		actual="$(ls -l .git/info/refs)" &&
+		actual=${actual%% *} &&
+		test "x$actual" = "x-$x" || {
+			ls -lt .git/info
+			false
+		}
+
+	'
+
+done
+
 test_done

  reply	other threads:[~2008-04-16  5:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-15  9:13 [PATCH] Make core.sharedRepository more generic Heikki Orsila
2008-04-16  5:22 ` Junio C Hamano [this message]
  -- strict thread matches above, loose matches on Subject: below --
2008-04-16  8:34 Heikki Orsila
2008-04-12 18:51 Heikki Orsila
2008-04-12 18:56 ` Heikki Orsila
2008-04-12 19:15 ` Samuel Tardieu
2008-04-12 19:46   ` Heikki Orsila
2008-04-12 19:50   ` Heikki Orsila
2008-04-12 22:20     ` Samuel Tardieu

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=7vk5iytlvh.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=heikki.orsila@iki.fi \
    /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).