git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 0/4] Writing refs in git-ssh-push
@ 2005-06-06 20:27 Daniel Barkalow
  2005-06-06 20:31 ` [PATCH 1/4] Operations on refs Daniel Barkalow
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Daniel Barkalow @ 2005-06-06 20:27 UTC (permalink / raw
  To: Linus Torvalds, Petr Baudis, Junio C Hamano; +Cc: git

This series adds -w to git-ssh-push (and git-ssh-pull, which is the same).

 - Add code for reading and writing ref files
 - Fix the environment variable for the path in rsh.c
 - Add support for transferring references in pull.c
 - Add support for refs in ssh protocol and options to invoke it

I'll send documentation updates in another patch this evening.

	-Daniel
*This .sig left intentionally blank*



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

* [PATCH 1/4] Operations on refs
  2005-06-06 20:27 [PATCH 0/4] Writing refs in git-ssh-push Daniel Barkalow
@ 2005-06-06 20:31 ` Daniel Barkalow
  2005-06-06 20:35 ` [PATCH 2/4] rsh.c environment variable Daniel Barkalow
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Daniel Barkalow @ 2005-06-06 20:31 UTC (permalink / raw
  To: Linus Torvalds, Petr Baudis, Junio C Hamano; +Cc: git

This patch adds code to read a hash out of a specified file under
{GIT_DIR}/refs/, and to write such files atomically and optionally with an
compare and lock.

Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>

Index: Makefile
===================================================================
--- 2dde8ae2d3300fb95e35facac622b9b54990624e/Makefile  (mode:100644 sha1:a5e7552e10bf50888814d43b1ba1a7276d130ca6)
+++ 9138b84eb683fc23a285445f7d7fc5a836ba01cb/Makefile  (mode:100644 sha1:c6e2eae2e68a47cdb88d2b1b7fec2c4cc230d506)
@@ -40,7 +40,7 @@
 	$(INSTALL) $(PROG) $(SCRIPTS) $(dest)$(bin)
 
 LIB_OBJS=read-cache.o sha1_file.o usage.o object.o commit.o tree.o blob.o \
-	 tag.o delta.o date.o index.o diff-delta.o patch-delta.o
+	 tag.o delta.o date.o index.o diff-delta.o patch-delta.o refs.o
 LIB_FILE=libgit.a
 LIB_H=cache.h object.h blob.h tree.h commit.h tag.h delta.h
 
Index: cache.h
===================================================================
--- 2dde8ae2d3300fb95e35facac622b9b54990624e/cache.h  (mode:100644 sha1:481f7c787040aadbbea877adbb3b9a4fd5f9b9d0)
+++ 9138b84eb683fc23a285445f7d7fc5a836ba01cb/cache.h  (mode:100644 sha1:d2dbb0088b2a540972cd3c896d76b6c8dc1844ab)
@@ -110,6 +110,7 @@
 #define INDEX_ENVIRONMENT "GIT_INDEX_FILE"
 
 extern char *get_object_directory(void);
+extern char *get_refs_directory(void);
 extern char *get_index_file(void);
 
 #define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES"
Index: refs.c
===================================================================
--- /dev/null  (tree:2dde8ae2d3300fb95e35facac622b9b54990624e)
+++ 9138b84eb683fc23a285445f7d7fc5a836ba01cb/refs.c  (mode:100644 sha1:9973d1fc21e9d14f4cf1d30cb59f55cdfd7fc1e7)
@@ -0,0 +1,173 @@
+#include "refs.h"
+#include "cache.h"
+
+#include <errno.h>
+
+static char *ref_file_name(const char *ref)
+{
+	char *base = get_refs_directory();
+	int baselen = strlen(base);
+	int reflen = strlen(ref);
+	char *ret = xmalloc(baselen + 2 + reflen);
+	sprintf(ret, "%s/%s", base, ref);
+	return ret;
+}
+
+static char *ref_lock_file_name(const char *ref)
+{
+	char *base = get_refs_directory();
+	int baselen = strlen(base);
+	int reflen = strlen(ref);
+	char *ret = xmalloc(baselen + 7 + reflen);
+	sprintf(ret, "%s/%s.lock", base, ref);
+	return ret;
+}
+
+static int read_ref_file(const char *filename, unsigned char *sha1) {
+	int fd = open(filename, O_RDONLY);
+	char hex[41];
+	if (fd < 0) {
+		return error("Couldn't open %s\n", filename);
+	}
+	if ((read(fd, hex, 41) < 41) ||
+	    (hex[40] != '\n') ||
+	    get_sha1_hex(hex, sha1)) {
+		error("Couldn't read a hash from %s\n", filename);
+		close(fd);
+		return -1;
+	}
+	close(fd);
+	return 0;
+}
+
+int get_ref_sha1(const char *ref, unsigned char *sha1)
+{
+	char *filename;
+	int retval;
+	if (check_ref_format(ref))
+		return -1;
+	filename = ref_file_name(ref);
+	retval = read_ref_file(filename, sha1);
+	free(filename);
+	return retval;
+}
+
+static int lock_ref_file(const char *filename, const char *lock_filename,
+			 const unsigned char *old_sha1)
+{
+	int fd = open(lock_filename, O_WRONLY | O_CREAT | O_EXCL, 0666);
+	unsigned char current_sha1[20];
+	int retval;
+	if (fd < 0) {
+		return error("Couldn't open lock file for %s: %s",
+			     filename, strerror(errno));
+	}
+	retval = read_ref_file(filename, current_sha1);
+	if (old_sha1) {
+		if (retval) {
+			close(fd);
+			unlink(lock_filename);
+			return error("Could not read the current value of %s",
+				     filename);
+		}
+		if (memcmp(current_sha1, old_sha1, 20)) {
+			close(fd);
+			unlink(lock_filename);
+			error("The current value of %s is %s",
+			      filename, sha1_to_hex(current_sha1));
+			return error("Expected %s",
+				     sha1_to_hex(old_sha1));
+		}
+	} else {
+		if (!retval) {
+			close(fd);
+			unlink(lock_filename);
+			return error("Unexpectedly found a value of %s for %s",
+				     sha1_to_hex(current_sha1), filename);
+		}
+	}
+	return fd;
+}
+
+int lock_ref_sha1(const char *ref, const unsigned char *old_sha1)
+{
+	char *filename;
+	char *lock_filename;
+	int retval;
+	if (check_ref_format(ref))
+		return -1;
+	filename = ref_file_name(ref);
+	lock_filename = ref_lock_file_name(ref);
+	retval = lock_ref_file(filename, lock_filename, old_sha1);
+	free(filename);
+	free(lock_filename);
+	return retval;
+}
+
+static int write_ref_file(const char *filename,
+			  const char *lock_filename, int fd,
+			  const unsigned char *sha1)
+{
+	char *hex = sha1_to_hex(sha1);
+	char term = '\n';
+	if (write(fd, hex, 40) < 40 ||
+	    write(fd, &term, 1) < 1) {
+		error("Couldn't write %s\n", filename);
+		close(fd);
+		return -1;
+	}
+	close(fd);
+	rename(lock_filename, filename);
+	return 0;
+}
+
+int write_ref_sha1(const char *ref, int fd, const unsigned char *sha1)
+{
+	char *filename;
+	char *lock_filename;
+	int retval;
+	if (fd < 0)
+		return -1;
+	if (check_ref_format(ref))
+		return -1;
+	filename = ref_file_name(ref);
+	lock_filename = ref_lock_file_name(ref);
+	retval = write_ref_file(filename, lock_filename, fd, sha1);
+	free(filename);
+	free(lock_filename);
+	return retval;
+}
+
+int check_ref_format(const char *ref)
+{
+	char *middle;
+	if (ref[0] == '.' || ref[0] == '/')
+		return -1;
+	middle = strchr(ref, '/');
+	if (!middle || !middle[1])
+		return -1;
+	if (strchr(middle + 1, '/'))
+		return -1;
+	return 0;
+}
+
+int write_ref_sha1_unlocked(const char *ref, const unsigned char *sha1)
+{
+	char *filename;
+	char *lock_filename;
+	int fd;
+	int retval;
+	if (check_ref_format(ref))
+		return -1;
+	filename = ref_file_name(ref);
+	lock_filename = ref_lock_file_name(ref);
+	fd = open(lock_filename, O_WRONLY | O_CREAT | O_EXCL, 0666);
+	if (fd < 0) {
+		error("Writing %s", lock_filename);
+		perror("Open");
+	}
+	retval = write_ref_file(filename, lock_filename, fd, sha1);
+	free(filename);
+	free(lock_filename);
+	return retval;
+}
Index: refs.h
===================================================================
--- /dev/null  (tree:2dde8ae2d3300fb95e35facac622b9b54990624e)
+++ 9138b84eb683fc23a285445f7d7fc5a836ba01cb/refs.h  (mode:100644 sha1:60cf48086f61c9206a343425ba9fdae3dce62937)
@@ -0,0 +1,21 @@
+#ifndef REFS_H
+#define REFS_H
+
+/** Reads the refs file specified into sha1 **/
+extern int get_ref_sha1(const char *ref, unsigned char *sha1);
+
+/** Locks ref and returns the fd to give to write_ref_sha1() if the ref
+ * has the given value currently; otherwise, returns -1.
+ **/
+extern int lock_ref_sha1(const char *ref, const unsigned char *old_sha1);
+
+/** Writes sha1 into the refs file specified, locked with the given fd. **/
+extern int write_ref_sha1(const char *ref, int fd, const unsigned char *sha1);
+
+/** Writes sha1 into the refs file specified. **/
+extern int write_ref_sha1_unlocked(const char *ref, const unsigned char *sha1);
+
+/** Returns 0 if target has the right format for a ref. **/
+extern int check_ref_format(const char *target);
+
+#endif /* REFS_H */
Index: sha1_file.c
===================================================================
--- 2dde8ae2d3300fb95e35facac622b9b54990624e/sha1_file.c  (mode:100644 sha1:a2ba4c81dba1b55b119d9ec3c42a7e4ce4ca1df5)
+++ 9138b84eb683fc23a285445f7d7fc5a836ba01cb/sha1_file.c  (mode:100644 sha1:7cfd43c51ba20ee85fe6056c67bbc88cc90dad81)
@@ -58,7 +58,7 @@
 	return get_sha1_hex(buffer, result);
 }
 
-static char *git_dir, *git_object_dir, *git_index_file;
+static char *git_dir, *git_object_dir, *git_index_file, *git_refs_dir;
 static void setup_git_env(void)
 {
 	git_dir = gitenv(GIT_DIR_ENVIRONMENT);
@@ -69,6 +69,8 @@
 		git_object_dir = xmalloc(strlen(git_dir) + 9);
 		sprintf(git_object_dir, "%s/objects", git_dir);
 	}
+	git_refs_dir = xmalloc(strlen(git_dir) + 6);
+	sprintf(git_refs_dir, "%s/refs", git_dir);
 	git_index_file = gitenv(INDEX_ENVIRONMENT);
 	if (!git_index_file) {
 		git_index_file = xmalloc(strlen(git_dir) + 7);
@@ -83,6 +85,13 @@
 	return git_object_dir;
 }
 
+char *get_refs_directory(void)
+{
+	if (!git_refs_dir)
+		setup_git_env();
+	return git_refs_dir;
+}
+
 char *get_index_file(void)
 {
 	if (!git_index_file)


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

* [PATCH 2/4] rsh.c environment variable
  2005-06-06 20:27 [PATCH 0/4] Writing refs in git-ssh-push Daniel Barkalow
  2005-06-06 20:31 ` [PATCH 1/4] Operations on refs Daniel Barkalow
@ 2005-06-06 20:35 ` Daniel Barkalow
  2005-06-06 20:38 ` [PATCH 3/4] Generic support for pulling refs Daniel Barkalow
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Daniel Barkalow @ 2005-06-06 20:35 UTC (permalink / raw
  To: Linus Torvalds, Petr Baudis, Junio C Hamano; +Cc: git

rsh.c used to set the environment variable for the object database when
invoking the remote command. Now that there is a GIT_DIR variable, use
that instead.

Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>

Index: rsh.c
===================================================================
--- 5d261be8a54c55542223536a72c53fab564cc28a/rsh.c  (mode:100644 sha1:5d1cb9d578a8e679fc190a9d7d2c842ad811223f)
+++ 2dde8ae2d3300fb95e35facac622b9b54990624e/rsh.c  (mode:100644 sha1:3eb9d9160531de91cbccfc1fdea2e9007a9cbfec)
@@ -36,8 +36,8 @@
 	*(path++) = '\0';
 	/* ssh <host> 'cd /<path>; stdio-pull <arg...> <commit-id>' */
 	snprintf(command, COMMAND_SIZE, 
-		 "cd /%s; %s=objects %s",
-		 path, DB_ENVIRONMENT, remote_prog);
+		 "%s='/%s' %s",
+		 GIT_DIR_ENVIRONMENT, path, remote_prog);
 	posn = command + strlen(command);
 	for (i = 0; i < rmt_argc; i++) {
 		*(posn++) = ' ';


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

* [PATCH 3/4] Generic support for pulling refs
  2005-06-06 20:27 [PATCH 0/4] Writing refs in git-ssh-push Daniel Barkalow
  2005-06-06 20:31 ` [PATCH 1/4] Operations on refs Daniel Barkalow
  2005-06-06 20:35 ` [PATCH 2/4] rsh.c environment variable Daniel Barkalow
@ 2005-06-06 20:38 ` Daniel Barkalow
  2005-06-07 13:18   ` McMullan, Jason
  2005-06-06 20:43 ` [PATCH 4/4] -w support for git-ssh-pull/push Daniel Barkalow
  2005-06-07  3:17 ` [PATCH 0/4] Writing refs in git-ssh-push Linus Torvalds
  4 siblings, 1 reply; 11+ messages in thread
From: Daniel Barkalow @ 2005-06-06 20:38 UTC (permalink / raw
  To: Linus Torvalds, Petr Baudis, Junio C Hamano; +Cc: git

This adds support to pull.c for requesting a reference and writing it to a
file. All of the git-*-pull programs get stubs for now.

Index: http-pull.c
===================================================================
--- 9138b84eb683fc23a285445f7d7fc5a836ba01cb/http-pull.c  (mode:100644 sha1:551663e49234dc9b719ee4abb9f8dc8609d759aa)
+++ 8deba080337c75a41cb456cc8b59000654278e59/http-pull.c  (mode:100644 sha1:4f097e0d0bbd5ae28babf8b685dc3b02747f9f15)
@@ -92,6 +92,11 @@
 	return 0;
 }
 
+int fetch_ref(char *ref, unsigned char *sha1)
+{
+	return -1;
+}
+
 int main(int argc, char **argv)
 {
 	char *commit_id;
Index: local-pull.c
===================================================================
--- 9138b84eb683fc23a285445f7d7fc5a836ba01cb/local-pull.c  (mode:100644 sha1:e5d834ff2f7d6949ca2c7dd2424c65f6431a839b)
+++ 8deba080337c75a41cb456cc8b59000654278e59/local-pull.c  (mode:100644 sha1:867e78dbdd2fc5dacdad3c3e3ab5ef1bfde6ba51)
@@ -73,6 +73,11 @@
 	return -1;
 }
 
+int fetch_ref(char *ref, unsigned char *sha1)
+{
+	return -1;
+}
+
 static const char *local_pull_usage = 
 "git-local-pull [-c] [-t] [-a] [-l] [-s] [-n] [-v] [-d] commit-id path";
 
Index: pull.c
===================================================================
--- 9138b84eb683fc23a285445f7d7fc5a836ba01cb/pull.c  (mode:100644 sha1:cd77738ac62be17e7382bc3b368e686f11f7098d)
+++ 8deba080337c75a41cb456cc8b59000654278e59/pull.c  (mode:100644 sha1:a60f1e49bda1bf12e11e0abccfaf4201130f4303)
@@ -3,6 +3,11 @@
 #include "cache.h"
 #include "commit.h"
 #include "tree.h"
+#include "refs.h"
+
+const char *write_ref = NULL;
+
+const unsigned char *current_ref = NULL;
 
 int get_tree = 0;
 int get_history = 0;
@@ -105,16 +110,42 @@
 	return 0;
 }
 
+static int interpret_target(char *target, unsigned char *sha1)
+{
+	if (!get_sha1_hex(target, sha1))
+		return 0;
+	if (!check_ref_format(target)) {
+		if (!fetch_ref(target, sha1)) {
+			return 0;
+		}
+	}
+	return -1;
+}
+
+
 int pull(char *target)
 {
-	int retval;
 	unsigned char sha1[20];
-	retval = get_sha1_hex(target, sha1);
-	if (retval)
-		return retval;
-	retval = make_sure_we_have_it(commitS, sha1);
-	if (retval)
-		return retval;
-	memcpy(current_commit_sha1, sha1, 20);
-	return process_commit(sha1);
+	int fd = -1;
+
+	if (write_ref && current_ref) {
+		fd = lock_ref_sha1(write_ref, current_ref);
+		if (fd < 0)
+			return -1;
+	}
+
+	if (interpret_target(target, sha1))
+		return error("Could not interpret %s as something to pull",
+			     target);
+	if (process_commit(sha1))
+		return -1;
+	
+	if (write_ref) {
+		if (current_ref) {
+			write_ref_sha1(write_ref, fd, sha1);
+		} else {
+			write_ref_sha1_unlocked(write_ref, sha1);
+		}
+	}
+	return 0;
 }
Index: pull.h
===================================================================
--- 9138b84eb683fc23a285445f7d7fc5a836ba01cb/pull.h  (mode:100644 sha1:3cd14cfb811a755a8770a0d01e8e2f96ba604058)
+++ 8deba080337c75a41cb456cc8b59000654278e59/pull.h  (mode:100644 sha1:83295892d1e401e4719ae26f16de07d6eb61a8d2)
@@ -4,6 +4,14 @@
 /** To be provided by the particular implementation. **/
 extern int fetch(unsigned char *sha1);
 
+extern int fetch_ref(char *ref, unsigned char *sha1);
+
+/** If set, the ref filename to write the target value to. **/
+extern const char *write_ref;
+
+/** If set, the hash that the current value of write_ref must be. **/
+extern const unsigned char *current_ref;
+
 /** Set to fetch the target tree. */
 extern int get_tree;
 
Index: ssh-pull.c
===================================================================
--- 9138b84eb683fc23a285445f7d7fc5a836ba01cb/ssh-pull.c  (mode:100644 sha1:f4ab89836455a40aaab3ff4114396185f6d5655a)
+++ 8deba080337c75a41cb456cc8b59000654278e59/ssh-pull.c  (mode:100644 sha1:c0cee73facbbb3ced2e566789ba1dda57b245f47)
@@ -39,6 +39,11 @@
 	return 0;
 }
 
+int fetch_ref(char *ref, unsigned char *sha1)
+{
+	return -1;
+}
+
 int main(int argc, char **argv)
 {
 	char *commit_id;


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

* [PATCH 4/4] -w support for git-ssh-pull/push
  2005-06-06 20:27 [PATCH 0/4] Writing refs in git-ssh-push Daniel Barkalow
                   ` (2 preceding siblings ...)
  2005-06-06 20:38 ` [PATCH 3/4] Generic support for pulling refs Daniel Barkalow
@ 2005-06-06 20:43 ` Daniel Barkalow
  2005-06-07  3:17 ` [PATCH 0/4] Writing refs in git-ssh-push Linus Torvalds
  4 siblings, 0 replies; 11+ messages in thread
From: Daniel Barkalow @ 2005-06-06 20:43 UTC (permalink / raw
  To: Linus Torvalds, Petr Baudis, Junio C Hamano; +Cc: git

This adds support for -w to git-ssh-pull and git-ssh-push to make
receiving side write the commit that was transferred to a reference file.

Index: ssh-pull.c
===================================================================
--- 8deba080337c75a41cb456cc8b59000654278e59/ssh-pull.c  (mode:100644 sha1:c0cee73facbbb3ced2e566789ba1dda57b245f47)
+++ 8293f31cb78c1c7aaf6e521e99a9d2d2a05fabec/ssh-pull.c  (mode:100644 sha1:3d1ff5ef0107da9f56f5f7024af9e2d02f7eec57)
@@ -2,6 +2,7 @@
 #include "commit.h"
 #include "rsh.h"
 #include "pull.h"
+#include "refs.h"
 
 static int fd_in;
 static int fd_out;
@@ -41,7 +42,15 @@
 
 int fetch_ref(char *ref, unsigned char *sha1)
 {
-	return -1;
+	signed char remote;
+	char type = 'r';
+	write(fd_out, &type, 1);
+	write(fd_out, ref, strlen(ref) + 1);
+	read(fd_in, &remote, 1);
+	if (remote < 0)
+		return remote;
+	read(fd_in, sha1, 20);
+	return 0;
 }
 
 int main(int argc, char **argv)
@@ -63,11 +72,14 @@
 			get_history = 1;
 		} else if (argv[arg][1] == 'v') {
 			get_verbosely = 1;
+		} else if (argv[arg][1] == 'w') {
+			write_ref = argv[arg + 1];
+			arg++;
 		}
 		arg++;
 	}
 	if (argc < arg + 2) {
-		usage("git-ssh-pull [-c] [-t] [-a] [-v] [-d] commit-id url");
+		usage("git-ssh-pull [-c] [-t] [-a] [-v] [-d] [-w ref] commit-id url");
 		return 1;
 	}
 	commit_id = argv[arg];
Index: ssh-push.c
===================================================================
--- 8deba080337c75a41cb456cc8b59000654278e59/ssh-push.c  (mode:100644 sha1:bd381ac9d1787dc979b1eba5bd72c1fd644a094b)
+++ 8293f31cb78c1c7aaf6e521e99a9d2d2a05fabec/ssh-push.c  (mode:100644 sha1:79fb6fc05f859a9daa4597296bfe8c1440949833)
@@ -1,7 +1,6 @@
 #include "cache.h"
 #include "rsh.h"
-#include <sys/socket.h>
-#include <errno.h>
+#include "refs.h"
 
 unsigned char local_version = 1;
 unsigned char remote_version = 0;
@@ -64,6 +63,27 @@
 	return 0;
 }
 
+int serve_ref(int fd_in, int fd_out)
+{
+	char ref[PATH_MAX];
+	unsigned char sha1[20];
+	int posn = 0;
+	signed char remote = 0;
+	do {
+		if (read(fd_in, ref + posn, 1) < 1)
+			return -1;
+		posn++;
+	} while (ref[posn - 1]);
+	if (get_ref_sha1(ref, sha1))
+		remote = -1;
+	write(fd_out, &remote, 1);
+	if (remote)
+		return 0;
+	write(fd_out, sha1, 20);
+        return 0;
+}
+
+
 void service(int fd_in, int fd_out) {
 	char type;
 	int retval;
@@ -78,6 +98,8 @@
 			return;
 		if (type == 'o' && serve_object(fd_in, fd_out))
 			return;
+		if (type == 'r' && serve_ref(fd_in, fd_out))
+			return;
 	} while (1);
 }
 
@@ -88,10 +110,12 @@
         char *url;
 	int fd_in, fd_out;
 	while (arg < argc && argv[arg][0] == '-') {
+		if (argv[arg][1] == 'w')
+			arg++;
                 arg++;
         }
         if (argc < arg + 2) {
-		usage("git-ssh-push [-c] [-t] [-a] commit-id url");
+		usage("git-ssh-push [-c] [-t] [-a] [-w ref] commit-id url");
                 return 1;
         }
 	commit_id = argv[arg];


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

* Re: [PATCH 0/4] Writing refs in git-ssh-push
  2005-06-06 20:27 [PATCH 0/4] Writing refs in git-ssh-push Daniel Barkalow
                   ` (3 preceding siblings ...)
  2005-06-06 20:43 ` [PATCH 4/4] -w support for git-ssh-pull/push Daniel Barkalow
@ 2005-06-07  3:17 ` Linus Torvalds
  2005-06-07  5:22   ` Daniel Barkalow
  2005-06-07  7:30   ` Thomas Glanzmann
  4 siblings, 2 replies; 11+ messages in thread
From: Linus Torvalds @ 2005-06-07  3:17 UTC (permalink / raw
  To: Daniel Barkalow; +Cc: Junio C Hamano, Git Mailing List



Two comments on git-ssh-push from a quick try-to-use-it-but-fail..

 - hardcoding the name of the command on the other side kind of sucks. 
   Especially when the user may end up having to install his own version
   under his own subdirectory. You really want to have some way of saying 
   "execute /home/user/bin/git-ssh-pull", and since it will depend on the 
   site you're pushing to, it should probably be available as a cmd line 
   option.

   I have a

	PATH=$PATH:~/bin

   in my .bashrc, but sshd at the other end doesn't end up caring..

 - the host/path parsing is pretty simplistic and just silly. Nobody I 
   know uses that ssh://host/path format, people use the shorter host:path 
   format.

Both look pretty simple to fix, but now I'm going to put the kids to bed.

		Linus

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

* Re: [PATCH 0/4] Writing refs in git-ssh-push
  2005-06-07  3:17 ` [PATCH 0/4] Writing refs in git-ssh-push Linus Torvalds
@ 2005-06-07  5:22   ` Daniel Barkalow
  2005-06-07  5:54     ` Frank Sorenson
  2005-06-07  7:30   ` Thomas Glanzmann
  1 sibling, 1 reply; 11+ messages in thread
From: Daniel Barkalow @ 2005-06-07  5:22 UTC (permalink / raw
  To: Linus Torvalds; +Cc: Junio C Hamano, Git Mailing List, Radoslaw Szkodzinski

On Mon, 6 Jun 2005, Linus Torvalds wrote:

> Two comments on git-ssh-push from a quick try-to-use-it-but-fail..
> 
>  - hardcoding the name of the command on the other side kind of sucks. 
>    Especially when the user may end up having to install his own version
>    under his own subdirectory. You really want to have some way of saying 
>    "execute /home/user/bin/git-ssh-pull", and since it will depend on the 
>    site you're pushing to, it should probably be available as a cmd line 
>    option.
> 
>    I have a
> 
> 	PATH=$PATH:~/bin
> 
>    in my .bashrc, but sshd at the other end doesn't end up caring..

sshd is pretty odd that way; I think ~/.ssh/environment might get you your
local path. I thought it was just my sshd that was strange like that, but
it's probably common if yours does it too. I'm not sure if there's a
standard way to pick up a per-user version of the remote program. It seems
like cvs doesn't do anything clever, and sftp makes it a compile-time
option.

I think an environment variable for the directory to find
git-ssh-(other) in would be easiest to script when needed and would also
reduce the chances of specifying the wrong program on the remote side
(which would generate really confusing errors).

>  - the host/path parsing is pretty simplistic and just silly. Nobody I 
>    know uses that ssh://host/path format, people use the shorter host:path 
>    format.

I was going for uniformity between git-http-pull and git-ssh-pull, and
between git-ssh-pull and git-ssh-push. But user@host:path is probably the
right thing, although Radoslaw (cc:ed) will want to propose something for
SSH on a non-standard port.

> Both look pretty simple to fix, but now I'm going to put the kids to bed.

Yeah, they're usability issues, and I'm too willing to put up with my own
programs being awkward.

	-Daniel
*This .sig left intentionally blank*


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

* Re: [PATCH 0/4] Writing refs in git-ssh-push
  2005-06-07  5:22   ` Daniel Barkalow
@ 2005-06-07  5:54     ` Frank Sorenson
  0 siblings, 0 replies; 11+ messages in thread
From: Frank Sorenson @ 2005-06-07  5:54 UTC (permalink / raw
  To: Daniel Barkalow
  Cc: Linus Torvalds, Junio C Hamano, Git Mailing List,
	Radoslaw Szkodzinski

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Daniel Barkalow wrote:
> On Mon, 6 Jun 2005, Linus Torvalds wrote:
> 
> 
>>Two comments on git-ssh-push from a quick try-to-use-it-but-fail..
>>
>> - hardcoding the name of the command on the other side kind of sucks. 
>>   Especially when the user may end up having to install his own version
>>   under his own subdirectory. You really want to have some way of saying 
>>   "execute /home/user/bin/git-ssh-pull", and since it will depend on the 
>>   site you're pushing to, it should probably be available as a cmd line 
>>   option.
>>
>>   I have a
>>
>>	PATH=$PATH:~/bin
>>
>>   in my .bashrc, but sshd at the other end doesn't end up caring..
> 
> 
> sshd is pretty odd that way; I think ~/.ssh/environment might get you your
> local path. I thought it was just my sshd that was strange like that, but
> it's probably common if yours does it too. I'm not sure if there's a
> standard way to pick up a per-user version of the remote program. It seems
> like cvs doesn't do anything clever, and sftp makes it a compile-time
> option.
> 
> I think an environment variable for the directory to find
> git-ssh-(other) in would be easiest to script when needed and would also
> reduce the chances of specifying the wrong program on the remote side
> (which would generate really confusing errors).

- From the ssh(1) manpage (openssh):
Additionally, ssh reads $HOME/.ssh/environment, and adds lines of the
format "VARNAME=value" to the environment if the file exists and if
users are allowed to change their environment.  For more information,
see the PermitUserEnvironment option in sshd_config(5).

The default given in sshd_config(5) is not to allow the user-specified
environment, because "Enabling environment processing may enable users
to bypass access restrictions in some configurations using mechanisms
such as LD_PRELOAD."

It looks like something we probably can't count on for sure.

Frank
- --
Frank Sorenson - KD7TZK
Systems Manager, Computer Science Department
Brigham Young University
frank@tuxrocks.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCpTaiaI0dwg4A47wRAhoJAJ9h4MUqGZWsT7+22FHaavd2N4ETqQCfTYR3
4qibBinO4TUgsdTNMrtgaxk=
=Uutj
-----END PGP SIGNATURE-----

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

* Re: [PATCH 0/4] Writing refs in git-ssh-push
  2005-06-07  3:17 ` [PATCH 0/4] Writing refs in git-ssh-push Linus Torvalds
  2005-06-07  5:22   ` Daniel Barkalow
@ 2005-06-07  7:30   ` Thomas Glanzmann
  1 sibling, 0 replies; 11+ messages in thread
From: Thomas Glanzmann @ 2005-06-07  7:30 UTC (permalink / raw
  To: Linus Torvalds; +Cc: Daniel Barkalow, Junio C Hamano, Git Mailing List

Hello,

> 	PATH=$PATH:~/bin in my .bashrc,

this should work because ssh executes a *not* login shell when you execute a
remote command. And bash reads .bashrc always and .bash_profile only for login
shell. Is bash your login shell?

For me it works:

(excalibur) [~] cat .bashrc
export PATH=$PATH:~/bin
(excalibur) [~] ssh localhost env | grep PATH
PATH=/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/cip/adm/sithglan/bin

In university I had to put the following in my .cshrc (because I have tcsh as
login shell and can't change it) to make bk push and stuff working:

(faui00u) [~] cat .cshrc
setenv PATH /opt/csw/bin:/usr/X11R6/bin:/sbin:/usr/bin:/usr/sbin:/local/bin:/bin:/local/bitkeeper/bin

	Thomas

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

* Re: [PATCH 3/4] Generic support for pulling refs
  2005-06-06 20:38 ` [PATCH 3/4] Generic support for pulling refs Daniel Barkalow
@ 2005-06-07 13:18   ` McMullan, Jason
  2005-06-07 16:45     ` Daniel Barkalow
  0 siblings, 1 reply; 11+ messages in thread
From: McMullan, Jason @ 2005-06-07 13:18 UTC (permalink / raw
  To: Daniel Barkalow
  Cc: Linus Torvalds, Petr Baudis, Junio C Hamano, GIT Mailling list

[-- Attachment #1: Type: text/plain, Size: 531 bytes --]

On Mon, 2005-06-06 at 16:38 -0400, Daniel Barkalow wrote:
> This adds support to pull.c for requesting a reference and writing it to a
> file. All of the git-*-pull programs get stubs for now.
>
> [snip snip]

Well, looks like you beat me to the punch, Daniel!

I hereby concede the Deathmatch to git-ssh-pu{sh,ll}, and withdraw
git-sync from consideration.

Way to go Daniel!

"Welcome to Git Thunderdome. Two codes enter, one code leaves."

-- 
Jason McMullan <jason.mcmullan@timesys.com>
TimeSys Corporation


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: [PATCH 3/4] Generic support for pulling refs
  2005-06-07 13:18   ` McMullan, Jason
@ 2005-06-07 16:45     ` Daniel Barkalow
  0 siblings, 0 replies; 11+ messages in thread
From: Daniel Barkalow @ 2005-06-07 16:45 UTC (permalink / raw
  To: McMullan, Jason; +Cc: GIT Mailling list

On Tue, 7 Jun 2005, McMullan, Jason wrote:

> Well, looks like you beat me to the punch, Daniel!
> 
> I hereby concede the Deathmatch to git-ssh-pu{sh,ll}, and withdraw
> git-sync from consideration.
> 
> Way to go Daniel!
> 
> "Welcome to Git Thunderdome. Two codes enter, one code leaves."

Of course, my secret is that I actually wrote it all in advance, so I just
had to polish it up, rebase, and document the program that was already
in...

Back on topic, are there things you need that git-ssh-* doesn't do? It
would still be good to get the code to write objects to temporary files
until they're determined to be valid.

	-Daniel
*This .sig left intentionally blank*


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

end of thread, other threads:[~2005-06-07 16:42 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-06 20:27 [PATCH 0/4] Writing refs in git-ssh-push Daniel Barkalow
2005-06-06 20:31 ` [PATCH 1/4] Operations on refs Daniel Barkalow
2005-06-06 20:35 ` [PATCH 2/4] rsh.c environment variable Daniel Barkalow
2005-06-06 20:38 ` [PATCH 3/4] Generic support for pulling refs Daniel Barkalow
2005-06-07 13:18   ` McMullan, Jason
2005-06-07 16:45     ` Daniel Barkalow
2005-06-06 20:43 ` [PATCH 4/4] -w support for git-ssh-pull/push Daniel Barkalow
2005-06-07  3:17 ` [PATCH 0/4] Writing refs in git-ssh-push Linus Torvalds
2005-06-07  5:22   ` Daniel Barkalow
2005-06-07  5:54     ` Frank Sorenson
2005-06-07  7:30   ` Thomas Glanzmann

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).