@matheusbsbs / matheus-bagliano / commits / efc7fa5355
Fork 0

Retire git-clone-pack

The program is not used by git-clone since git-fetch-pack was extended to allow its caller do what git-clone-pack alone did, and git-clone was updated to use it. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Jun 20, 2006 at 23:54 UTC efc7fa5355da79326f92716eef37ddd71c7ec034
9 files changed +7 -263
.gitignore
-1
@@ -17,7 +17,6 @@ git-cherry
17 git-cherry-pick
18 git-clean
19 git-clone
20 -git-clone-pack
20 git-commit
21 git-commit-tree
22 git-convert-objects
Documentation/git-clone-pack.txt deleted
-64
@@ -1,64 +0,0 @@
1 -git-clone-pack(1)
2 -=================
3 -
4 -NAME
5 -----
6 -git-clone-pack - Clones a repository by receiving packed objects
7 -
8 -
9 -SYNOPSIS
10 ---------
11 -'git-clone-pack' [--exec=<git-upload-pack>] [<host>:]<directory> [<head>...]
12 -
13 -DESCRIPTION
14 ------------
15 -Clones a repository into the current repository by invoking
16 -'git-upload-pack', possibly on the remote host via ssh, in
17 -the named repository, and stores the sent pack in the local
18 -repository.
19 -
20 -OPTIONS
21 --------
22 ---exec=<git-upload-pack>::
23 - Use this to specify the path to 'git-upload-pack' on the
24 - remote side, if it is not found on your $PATH.
25 - Installations of sshd ignore the user's environment
26 - setup scripts for login shells (e.g. .bash_profile) and
27 - your privately installed git may not be found on the system
28 - default $PATH. Another workaround suggested is to set
29 - up your $PATH in ".bashrc", but this flag is for people
30 - who do not want to pay the overhead for non-interactive
31 - shells by having a lean .bashrc file (they set most of
32 - the things up in .bash_profile).
33 -
34 -<host>::
35 - A remote host that houses the repository. When this
36 - part is specified, 'git-upload-pack' is invoked via
37 - ssh.
38 -
39 -<directory>::
40 - The repository to sync from.
41 -
42 -<head>...::
43 - The heads to update. This is relative to $GIT_DIR
44 - (e.g. "HEAD", "refs/heads/master"). When unspecified,
45 - all heads are updated to match the remote repository.
46 -+
47 -Usually all the refs from existing repository are stored
48 -under the same name in the new repository. Giving explicit
49 -<head> arguments instead writes the object names and refs to
50 -the standard output, just like get-fetch-pack does.
51 -
52 -Author
53 -------
54 -Written by Linus Torvalds <torvalds@osdl.org>
55 -
56 -Documentation
57 ---------------
58 -Documentation by Junio C Hamano.
59 -
60 -
61 -GIT
62 ----
63 -Part of the gitlink:git[7] suite
64 -
Documentation/git-clone.txt
+2 -2
@@ -62,7 +62,7 @@ OPTIONS
62 --quiet::
63 -q::
64 Operate quietly. This flag is passed to "rsync" and
65 - "git-clone-pack" commands when given.
65 + "git-fetch-pack" commands when given.
66
67 -n::
68 No checkout of HEAD is performed after the clone is complete.
@@ -85,7 +85,7 @@ OPTIONS
85 --upload-pack <upload-pack>::
86 -u <upload-pack>::
87 When given, and the repository to clone from is handled
88 - by 'git-clone-pack', '--exec=<upload-pack>' is passed to
88 + by 'git-fetch-pack', '--exec=<upload-pack>' is passed to
89 the command to specify non-default path for the command
90 run on the other end.
91
Documentation/git-receive-pack.txt
+1 -2
@@ -18,8 +18,7 @@ information fed from the remote end.
18 This command is usually not invoked directly by the end user.
19 The UI for the protocol is on the 'git-send-pack' side, and the
20 program pair is meant to be used to push updates to remote
21 -repository. For pull operations, see 'git-fetch-pack' and
22 -'git-clone-pack'.
21 +repository. For pull operations, see 'git-fetch-pack'.
22
23 The command allows for creation and fast forwarding of sha1 refs
24 (heads/tags) on the remote end (strictly speaking, it is the
Documentation/git-upload-pack.txt
+1 -1
@@ -12,7 +12,7 @@ SYNOPSIS
12
13 DESCRIPTION
14 -----------
15 -Invoked by 'git-clone-pack' and/or 'git-fetch-pack', learns what
15 +Invoked by 'git-fetch-pack', learns what
16 objects the other side is missing, and sends them after packing.
17
18 This command is usually not invoked directly by the end user.
Documentation/git.txt
+1 -5
@@ -192,10 +192,6 @@ the working tree.
192 Synching repositories
193 ~~~~~~~~~~~~~~~~~~~~~
194
195 -gitlink:git-clone-pack[1]::
196 - Clones a repository into the current repository (engine
197 - for ssh and local transport).
198 -
195 gitlink:git-fetch-pack[1]::
196 Updates from a remote repository (engine for ssh and
197 local transport).
@@ -237,7 +233,7 @@ gitlink:git-update-server-info[1]::
233 clients discover references and packs on it.
234
235 gitlink:git-upload-pack[1]::
240 - Invoked by 'git-clone-pack' and 'git-fetch-pack' to push
236 + Invoked by 'git-fetch-pack' to push
237 what are asked for.
238
239 gitlink:git-upload-tar[1]::
INSTALL
+1 -1
@@ -96,7 +96,7 @@ Issues of note:
96
97 $ mkdir manual && cd manual
98 $ git init-db
99 - $ git clone-pack git://git.kernel.org/pub/scm/git/git.git man html |
99 + $ git fetch-pack git://git.kernel.org/pub/scm/git/git.git man html |
100 while read a b
101 do
102 echo $a >.git/$b
Makefile
+1 -1
@@ -149,7 +149,7 @@ SIMPLE_PROGRAMS = \
149
150 # ... and all the rest that could be moved out of bindir to gitexecdir
151 PROGRAMS = \
152 - git-checkout-index$X git-clone-pack$X \
152 + git-checkout-index$X \
153 git-convert-objects$X git-fetch-pack$X git-fsck-objects$X \
154 git-hash-object$X git-index-pack$X git-local-fetch$X \
155 git-mailinfo$X git-merge-base$X \
clone-pack.c deleted
-186
@@ -1,186 +0,0 @@
1 -#include "cache.h"
2 -#include "refs.h"
3 -#include "pkt-line.h"
4 -
5 -static const char clone_pack_usage[] =
6 -"git-clone-pack [--exec=<git-upload-pack>] [<host>:]<directory> [<heads>]*";
7 -static const char *exec = "git-upload-pack";
8 -
9 -static int quiet = 0;
10 -
11 -static void clone_handshake(int fd[2], struct ref *ref)
12 -{
13 - unsigned char sha1[20];
14 -
15 - while (ref) {
16 - packet_write(fd[1], "want %s\n", sha1_to_hex(ref->old_sha1));
17 - ref = ref->next;
18 - }
19 - packet_flush(fd[1]);
20 -
21 - /* We don't have nuttin' */
22 - packet_write(fd[1], "done\n");
23 - if (get_ack(fd[0], sha1))
24 - error("Huh! git-clone-pack got positive ack for %s", sha1_to_hex(sha1));
25 -}
26 -
27 -static int is_master(struct ref *ref)
28 -{
29 - return !strcmp(ref->name, "refs/heads/master");
30 -}
31 -
32 -static void write_one_ref(struct ref *ref)
33 -{
34 - char *path = git_path("%s", ref->name);
35 - int fd;
36 - char *hex;
37 -
38 - if (!strncmp(ref->name, "refs/", 5) &&
39 - check_ref_format(ref->name + 5)) {
40 - error("refusing to create funny ref '%s' locally", ref->name);
41 - return;
42 - }
43 -
44 - if (safe_create_leading_directories(path))
45 - die("unable to create leading directory for %s", ref->name);
46 - fd = open(path, O_CREAT | O_EXCL | O_WRONLY, 0666);
47 - if (fd < 0)
48 - die("unable to create ref %s", ref->name);
49 - hex = sha1_to_hex(ref->old_sha1);
50 - hex[40] = '\n';
51 - if (write(fd, hex, 41) != 41)
52 - die("unable to write ref %s", ref->name);
53 - close(fd);
54 -}
55 -
56 -static void write_refs(struct ref *ref)
57 -{
58 - struct ref *head = NULL, *head_ptr, *master_ref;
59 - char *head_path;
60 -
61 - /* Upload-pack must report HEAD first */
62 - if (!strcmp(ref->name, "HEAD")) {
63 - head = ref;
64 - ref = ref->next;
65 - }
66 - head_ptr = NULL;
67 - master_ref = NULL;
68 - while (ref) {
69 - if (is_master(ref))
70 - master_ref = ref;
71 - if (head &&
72 - !memcmp(ref->old_sha1, head->old_sha1, 20) &&
73 - !strncmp(ref->name, "refs/heads/",11) &&
74 - (!head_ptr || ref == master_ref))
75 - head_ptr = ref;
76 -
77 - write_one_ref(ref);
78 - ref = ref->next;
79 - }
80 - if (!head) {
81 - fprintf(stderr, "No HEAD in remote.\n");
82 - return;
83 - }
84 -
85 - head_path = strdup(git_path("HEAD"));
86 - if (!head_ptr) {
87 - /*
88 - * If we had a master ref, and it wasn't HEAD, we need to undo the
89 - * symlink, and write a standalone HEAD. Give a warning, because that's
90 - * really really wrong.
91 - */
92 - if (master_ref) {
93 - error("HEAD doesn't point to any refs! Making standalone HEAD");
94 - unlink(head_path);
95 - }
96 - write_one_ref(head);
97 - free(head_path);
98 - return;
99 - }
100 -
101 - /* We reset to the master branch if it's available */
102 - if (master_ref)
103 - return;
104 -
105 - fprintf(stderr, "Setting HEAD to %s\n", head_ptr->name);
106 -
107 - /*
108 - * Uhhuh. Other end didn't have master. We start HEAD off with
109 - * the first branch with the same value.
110 - */
111 - if (create_symref(head_path, head_ptr->name) < 0)
112 - die("unable to link HEAD to %s", head_ptr->name);
113 - free(head_path);
114 -}
115 -
116 -static int clone_pack(int fd[2], int nr_match, char **match)
117 -{
118 - struct ref *refs;
119 - int status;
120 -
121 - get_remote_heads(fd[0], &refs, nr_match, match, 1);
122 - if (!refs) {
123 - packet_flush(fd[1]);
124 - die("no matching remote head");
125 - }
126 - clone_handshake(fd, refs);
127 -
128 - status = receive_keep_pack(fd, "git-clone-pack", quiet);
129 - if (!quiet)
130 - fprintf(stderr, "\n");
131 -
132 - if (!status) {
133 - if (nr_match == 0)
134 - write_refs(refs);
135 - else
136 - while (refs) {
137 - printf("%s %s\n",
138 - sha1_to_hex(refs->old_sha1),
139 - refs->name);
140 - refs = refs->next;
141 - }
142 - }
143 - return status;
144 -}
145 -
146 -int main(int argc, char **argv)
147 -{
148 - int i, ret, nr_heads;
149 - char *dest = NULL, **heads;
150 - int fd[2];
151 - pid_t pid;
152 -
153 - setup_git_directory();
154 -
155 - nr_heads = 0;
156 - heads = NULL;
157 - for (i = 1; i < argc; i++) {
158 - char *arg = argv[i];
159 -
160 - if (*arg == '-') {
161 - if (!strcmp("-q", arg)) {
162 - quiet = 1;
163 - continue;
164 - }
165 - if (!strncmp("--exec=", arg, 7)) {
166 - exec = arg + 7;
167 - continue;
168 - }
169 - usage(clone_pack_usage);
170 - }
171 - dest = arg;
172 - heads = argv + i + 1;
173 - nr_heads = argc - i - 1;
174 - break;
175 - }
176 - if (!dest)
177 - usage(clone_pack_usage);
178 - pid = git_connect(fd, dest, exec);
179 - if (pid < 0)
180 - return 1;
181 - ret = clone_pack(fd, nr_heads, heads);
182 - close(fd[0]);
183 - close(fd[1]);
184 - finish_connect(pid);
185 - return ret;
186 -}