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

Make pull() take some implicit data as explicit arguments

Currently it's a bit weird that pull() takes a single argument describing the commit but takes the write_ref from a global variable. This makes it take that as a parameter as well, which might be nicer for the libification in the future, but especially it will make for nicer code when we implement pull()ing multiple commits at once. Signed-off-by: Petr Baudis <pasky@suse.cz> Signed-off-by: Junio C Hamano <junkio@cox.net>

Petr Baudis committed Jul 27, 2006 at 23:56 UTC c6b69bdbc1b0b914aa0d1e59a29305fce82d6f06
5 files changed +12 -17
fetch.c
+2 -4
@@ -8,9 +8,6 @@
8 #include "blob.h"
9 #include "refs.h"
10
11 -const char *write_ref = NULL;
12 -const char *write_ref_log_details = NULL;
13 -
11 int get_tree = 0;
12 int get_history = 0;
13 int get_all = 0;
@@ -213,7 +210,8 @@ static int mark_complete(const char *path, const unsigned char *sha1)
210 return 0;
211 }
212
216 -int pull(char *target)
213 +int pull(char *target, const char *write_ref,
214 + const char *write_ref_log_details)
215 {
216 struct ref_lock *lock = NULL;
217 unsigned char sha1[20];
fetch.h
+4 -7
@@ -22,12 +22,6 @@ extern void prefetch(unsigned char *sha1);
22 */
23 extern int fetch_ref(char *ref, unsigned char *sha1);
24
25 -/* If set, the ref filename to write the target value to. */
26 -extern const char *write_ref;
27 -
28 -/* If set additional text will appear in the ref log. */
29 -extern const char *write_ref_log_details;
30 -
25 /* Set to fetch the target tree. */
26 extern int get_tree;
27
@@ -46,6 +40,9 @@ extern int get_recover;
40 /* Report what we got under get_verbosely */
41 extern void pull_say(const char *, const char *);
42
49 -extern int pull(char *target);
43 +/* If write_ref is set, the ref filename to write the target value to. */
44 +/* If write_ref_log_details is set, additional text will appear in the ref log. */
45 +extern int pull(char *target, const char *write_ref,
46 + const char *write_ref_log_details);
47
48 #endif /* PULL_H */
http-fetch.c
+2 -2
@@ -1216,6 +1216,7 @@ int fetch_ref(char *ref, unsigned char *sha1)
1216
1217 int main(int argc, char **argv)
1218 {
1219 + const char *write_ref = NULL;
1220 char *commit_id;
1221 char *url;
1222 char *path;
@@ -1250,7 +1251,6 @@ int main(int argc, char **argv)
1251 }
1252 commit_id = argv[arg];
1253 url = argv[arg + 1];
1253 - write_ref_log_details = url;
1254
1255 http_init();
1256
@@ -1268,7 +1268,7 @@ int main(int argc, char **argv)
1268 alt->path_len = strlen(path);
1269 }
1270
1271 - if (pull(commit_id))
1271 + if (pull(commit_id, write_ref, url))
1272 rc = 1;
1273
1274 http_cleanup();
local-fetch.c
+2 -2
@@ -204,6 +204,7 @@ static const char local_pull_usage[] =
204 */
205 int main(int argc, char **argv)
206 {
207 + const char *write_ref = NULL;
208 char *commit_id;
209 int arg = 1;
210
@@ -240,9 +241,8 @@ int main(int argc, char **argv)
241 usage(local_pull_usage);
242 commit_id = argv[arg];
243 path = argv[arg + 1];
243 - write_ref_log_details = path;
244
245 - if (pull(commit_id))
245 + if (pull(commit_id, write_ref, path))
246 return 1;
247
248 return 0;
ssh-fetch.c
+2 -2
@@ -123,6 +123,7 @@ static const char ssh_fetch_usage[] =
123 " [-c] [-t] [-a] [-v] [--recover] [-w ref] commit-id url";
124 int main(int argc, char **argv)
125 {
126 + const char *write_ref = NULL;
127 char *commit_id;
128 char *url;
129 int arg = 1;
@@ -159,7 +160,6 @@ int main(int argc, char **argv)
160 }
161 commit_id = argv[arg];
162 url = argv[arg + 1];
162 - write_ref_log_details = url;
163
164 if (setup_connection(&fd_in, &fd_out, prog, url, arg, argv + 1))
165 return 1;
@@ -167,7 +167,7 @@ int main(int argc, char **argv)
167 if (get_version())
168 return 1;
169
170 - if (pull(commit_id))
170 + if (pull(commit_id, write_ref, url))
171 return 1;
172
173 return 0;