threads / patch / 1029

patchgit-ssh-pull: commit-id consistency

Subject: [PATCH] git-ssh-pull: commit-id consistency

## tl;dr

3 messages between Jun 26, 2005 and Jun 27, 2005. Diffs are folded; open one to read it.

replies: 2people: 2as markdown or json

Sven Verdoolaege· Jun 26, 2005, 19:45 UTC · lore

I thought about keeping the check for a leading dot or slash, but then I figured that you'd get an error from the other side pretty quickly.

skimo -- In contrast to other plumbing tools, git-ssh-pu{sh,ll} only allow a very restrictive form of commit-id filenames. This patch removes this restriction.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>

--- commit 00437f1bafcb710bb809cd2e87cdaeae340a67b8 tree 480e77cde9afbd0b0abd33e3f272288739b01a7e parent 641e1cac73acd67d0b1830dfd7196bca58dffbf2 author Sven Verdoolaege <skimo@kotnet.org> Sun, 26 Jun 2005 19:41:44 +0200 committer Sven Verdoolaege <skimo@kotnet.org> Sun, 26 Jun 2005 19:41:44 +0200

 pull.c     |    7 ++-----
 ssh-push.c |    2 +-
 2 files changed, 3 insertions(+), 6 deletions(-)
Show changes to 2 files +3 −6

pull.c, ssh-push.c

diff --git a/pull.c b/pull.c
--- a/pull.c
+++ b/pull.c
@@ -152,11 +152,8 @@ static int interpret_target(char *target
 {
 	if (!get_sha1_hex(target, sha1))
 		return 0;
-	if (!check_ref_format(target)) {
-		if (!fetch_ref(target, sha1)) {
-			return 0;
-		}
-	}
+	if (!fetch_ref(target, sha1))
+		return 0;
 	return -1;
 }
 
diff --git a/ssh-push.c b/ssh-push.c
--- a/ssh-push.c
+++ b/ssh-push.c
@@ -74,7 +74,7 @@ int serve_ref(int fd_in, int fd_out)
 			return -1;
 		posn++;
 	} while (ref[posn - 1]);
-	if (get_ref_sha1(ref, sha1))
+	if (get_sha1(ref, sha1))
 		remote = -1;
 	write(fd_out, &remote, 1);
 	if (remote)
Daniel Barkalow· Jun 26, 2005, 20:11 UTC · re: Sven Verdoolaege · lore

Re: [PATCH] git-ssh-pull: commit-id consistency

On Sun, 26 Jun 2005, Sven Verdoolaege wrote:
Show 9 quoted lines
> I thought about keeping the check for a leading dot or slash,
> but then I figured that you'd get an error from the other
> side pretty quickly.
> 
> skimo
> --
> In contrast to other plumbing tools, git-ssh-pu{sh,ll} only
> allow a very restrictive form of commit-id filenames.
> This patch removes this restriction.

There are a few problems with this: not all pull methods can handle vagueness; HTTP, for instance, needs to know exactly what URL to request, and it can't deal with having the user request just anything. Also, it's not particularly useful to support just anything as the hash to start from, when you have to specify exactly the file to write the ref to (the -w argument), which would be a lot more difficult and flaky, because we can't just look for the only thing that works.

More generally, I think we should require explicit instructions, even when we might be able to figure things out, when we're moving data between repositories, similar to how we are strict about the data stored in repositories (although, of course, we need to support a few more cases).

In addition, I think that stuff outside of objects/ and refs/ (and, when we have something in it, info/) should be considered private, and not transmitted from place to place.

One thing that might be a good idea, however, is to allow using symlinks from .git/ to refs/<x>/<y> on the local side of git-ssh-push by converting them to <x>/<y>. That way, when you push "HEAD", it will actually push refs/heads/my-current-branch instead. Of course, the -w issue remains, because you may have different names on the other side (i.e., on the local side, it might be refs/heads/new-diff-algo, but the remote side might be refs/heads/my-latest).

Really, the right solution is to keep this sort of info somewhere and have scripts do the right thing with exact specifications.

	-Daniel
*This .sig left intentionally blank*
Sven Verdoolaege· Jun 27, 2005, 19:03 UTC · re: Sven Verdoolaege · lore

As requested by Daniel, this new version leaves *-pull alone and only changes the behaviour of git-ssh-push.

skimo -- In contrast to other plumbing tools, git-ssh-push only allow a very restrictive form of commit-id filenames. This patch removes this restriction.

Acked-by: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>

--- commit 28ec093e92206cd907249e741ca1d19f14da4cf3 tree 5ad7b33ec80c2c04272cb0abd4531e1d9abfbbe1 parent e18088451d92fbf83bfb57fd48201eda117f8103 author Sven Verdoolaege <skimo@kotnet.org> Mon, 27 Jun 2005 20:12:40 +0200 committer Sven Verdoolaege <skimo@kotnet.org> Mon, 27 Jun 2005 20:12:40 +0200

 Documentation/git-ssh-push.txt |    2 +-
 ssh-push.c                     |   18 ++++++++++++++----
 2 files changed, 15 insertions(+), 5 deletions(-)
Show changes to 2 files +15 −5

Documentation/git-ssh-push.txt, ssh-push.c

diff --git a/Documentation/git-ssh-push.txt b/Documentation/git-ssh-push.txt
--- a/Documentation/git-ssh-push.txt
+++ b/Documentation/git-ssh-push.txt
@@ -20,7 +20,7 @@ git-ssh-pull, aside from which end you r
 OPTIONS
 -------
 commit-id::
-        Either the hash or the filename under $GIT_DIR/refs/ to push.
+        Id of commit to push.
 
 -c::
         Get the commit objects.
diff --git a/ssh-push.c b/ssh-push.c
--- a/ssh-push.c
+++ b/ssh-push.c
@@ -2,6 +2,8 @@
 #include "rsh.h"
 #include "refs.h"
 
+#include <string.h>
+
 unsigned char local_version = 1;
 unsigned char remote_version = 0;
 
@@ -103,6 +105,9 @@ void service(int fd_in, int fd_out) {
 	} while (1);
 }
 
+static const char *ssh_push_usage =
+	"git-ssh-push [-c] [-t] [-a] [-w ref] commit-id url";
+
 int main(int argc, char **argv)
 {
 	int arg = 1;
@@ -110,18 +115,23 @@ int main(int argc, char **argv)
         char *url;
 	int fd_in, fd_out;
 	const char *prog = getenv("GIT_SSH_PULL") ? : "git-ssh-pull";
+	unsigned char sha1[20];
+	char hex[41];
 
 	while (arg < argc && argv[arg][0] == '-') {
 		if (argv[arg][1] == 'w')
 			arg++;
                 arg++;
         }
-        if (argc < arg + 2) {
-		usage("git-ssh-push [-c] [-t] [-a] [-w ref] commit-id url");
-                return 1;
-        }
+	if (argc < arg + 2)
+		usage(ssh_push_usage);
 	commit_id = argv[arg];
 	url = argv[arg + 1];
+	if (get_sha1(commit_id, sha1))
+		usage(ssh_push_usage);
+	memcpy(hex, sha1_to_hex(sha1), sizeof(hex));
+	argv[arg] = hex;
+
 	if (setup_connection(&fd_in, &fd_out, prog, url, arg, argv + 1))
 		return 1;
 

← back to recent threads