Remove unnecessary pack-*.keep file after successful git-clone
Once a clone is successful we no longer need to hold onto the .keep file created by the transport. Delete the file so we can later repack the complete repository. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Shawn O. Pearce committed
Jul 8, 2008 at 04:46 UTC
1db4a75c8d18d8827ac710e87219b349558d9196
2 files changed
+24
-3
builtin-clone.c
+5
-2
@@ -337,6 +337,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
337
const struct ref *refs, *head_points_at, *remote_head, *mapped_refs;
338
char branch_top[256], key[256], value[256];
339
struct strbuf reflog_msg;
340
+ struct transport *transport = NULL;
341
342
struct refspec refspec;
343
@@ -458,8 +459,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
459
refs = clone_local(path, git_dir);
460
else {
461
struct remote *remote = remote_get(argv[0]);
461
- struct transport *transport =
462
- transport_get(remote, remote->url[0]);
462
+ transport = transport_get(remote, remote->url[0]);
463
464
if (!transport->get_refs_list || !transport->fetch)
465
die("Don't know how to clone %s", transport->url);
@@ -529,6 +529,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
529
option_no_checkout = 1;
530
}
531
532
+ if (transport)
533
+ transport_unlock_pack(transport);
534
+
535
if (!option_no_checkout) {
536
struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
537
struct unpack_trees_options opts;
t/t5601-clone.sh
+19
-1
@@ -17,14 +17,32 @@ test_expect_success setup '
17
18
'
19
20
-test_expect_success 'clone with excess parameters' '
20
+test_expect_success 'clone with excess parameters (1)' '
21
22
+ rm -fr dst &&
23
+ test_must_fail git clone -n src dst junk
24
+
25
+'
26
+
27
+test_expect_success 'clone with excess parameters (2)' '
28
+
29
+ rm -fr dst &&
30
test_must_fail git clone -n "file://$(pwd)/src" dst junk
31
32
'
33
34
+test_expect_success 'clone does not keep pack' '
35
+
36
+ rm -fr dst &&
37
+ git clone -n "file://$(pwd)/src" dst &&
38
+ ! test -f dst/file &&
39
+ ! (echo dst/.git/objects/pack/pack-* | grep "\.keep")
40
+
41
+'
42
+
43
test_expect_success 'clone checks out files' '
44
45
+ rm -fr dst &&
46
git clone src dst &&
47
test -f dst/file
48