9 #include "fetch-pack.h"
11 #include "run-command.h"
13 static int transfer_unpack_limit
= -1;
14 static int fetch_unpack_limit
= -1;
15 static int unpack_limit
= 100;
16 static int prefer_ofs_delta
= 1;
17 static int no_done
= 0;
18 static struct fetch_pack_args args
= {
19 /* .uploadpack = */ "git-upload-pack",
22 static const char fetch_pack_usage
[] =
23 "git fetch-pack [--all] [--quiet|-q] [--keep|-k] [--thin] [--include-tag] [--upload-pack=<git-upload-pack>] [--depth=<n>] [--no-progress] [-v] [<host>:]<directory> [<refs>...]";
25 #define COMPLETE (1U << 0)
26 #define COMMON (1U << 1)
27 #define COMMON_REF (1U << 2)
28 #define SEEN (1U << 3)
29 #define POPPED (1U << 4)
34 * After sending this many "have"s if we do not get any new ACK , we
35 * give up traversing our history.
37 #define MAX_IN_VAIN 256
39 static struct commit_list
*rev_list
;
40 static int non_common_revs
, multi_ack
, use_sideband
;
42 static void rev_list_push(struct commit
*commit
, int mark
)
44 if (!(commit
->object
.flags
& mark
)) {
45 commit
->object
.flags
|= mark
;
47 if (!(commit
->object
.parsed
))
48 if (parse_commit(commit
))
51 commit_list_insert_by_date(commit
, &rev_list
);
53 if (!(commit
->object
.flags
& COMMON
))
58 static int rev_list_insert_ref(const char *path
, const unsigned char *sha1
, int flag
, void *cb_data
)
60 struct object
*o
= deref_tag(parse_object(sha1
), path
, 0);
62 if (o
&& o
->type
== OBJ_COMMIT
)
63 rev_list_push((struct commit
*)o
, SEEN
);
68 static int clear_marks(const char *path
, const unsigned char *sha1
, int flag
, void *cb_data
)
70 struct object
*o
= deref_tag(parse_object(sha1
), path
, 0);
72 if (o
&& o
->type
== OBJ_COMMIT
)
73 clear_commit_marks((struct commit
*)o
,
74 COMMON
| COMMON_REF
| SEEN
| POPPED
);
79 This function marks a rev and its ancestors as common.
80 In some cases, it is desirable to mark only the ancestors (for example
81 when only the server does not yet know that they are common).
84 static void mark_common(struct commit
*commit
,
85 int ancestors_only
, int dont_parse
)
87 if (commit
!= NULL
&& !(commit
->object
.flags
& COMMON
)) {
88 struct object
*o
= (struct object
*)commit
;
93 if (!(o
->flags
& SEEN
))
94 rev_list_push(commit
, SEEN
);
96 struct commit_list
*parents
;
98 if (!ancestors_only
&& !(o
->flags
& POPPED
))
100 if (!o
->parsed
&& !dont_parse
)
101 if (parse_commit(commit
))
104 for (parents
= commit
->parents
;
106 parents
= parents
->next
)
107 mark_common(parents
->item
, 0, dont_parse
);
113 Get the next rev to send, ignoring the common.
116 static const unsigned char *get_rev(void)
118 struct commit
*commit
= NULL
;
120 while (commit
== NULL
) {
122 struct commit_list
*parents
;
124 if (rev_list
== NULL
|| non_common_revs
== 0)
127 commit
= rev_list
->item
;
128 if (!commit
->object
.parsed
)
129 parse_commit(commit
);
130 parents
= commit
->parents
;
132 commit
->object
.flags
|= POPPED
;
133 if (!(commit
->object
.flags
& COMMON
))
136 if (commit
->object
.flags
& COMMON
) {
137 /* do not send "have", and ignore ancestors */
139 mark
= COMMON
| SEEN
;
140 } else if (commit
->object
.flags
& COMMON_REF
)
141 /* send "have", and ignore ancestors */
142 mark
= COMMON
| SEEN
;
144 /* send "have", also for its ancestors */
148 if (!(parents
->item
->object
.flags
& SEEN
))
149 rev_list_push(parents
->item
, mark
);
151 mark_common(parents
->item
, 1, 0);
152 parents
= parents
->next
;
155 rev_list
= rev_list
->next
;
158 return commit
->object
.sha1
;
169 static void consume_shallow_list(int fd
)
171 if (args
.stateless_rpc
&& args
.depth
> 0) {
172 /* If we sent a depth we will get back "duplicate"
173 * shallow and unshallow commands every time there
174 * is a block of have lines exchanged.
177 while (packet_read_line(fd
, line
, sizeof(line
))) {
178 if (!prefixcmp(line
, "shallow "))
180 if (!prefixcmp(line
, "unshallow "))
182 die("git fetch-pack: expected shallow list");
187 static enum ack_type
get_ack(int fd
, unsigned char *result_sha1
)
189 static char line
[1000];
190 int len
= packet_read_line(fd
, line
, sizeof(line
));
193 die("git fetch-pack: expected ACK/NAK, got EOF");
194 if (line
[len
-1] == '\n')
196 if (!strcmp(line
, "NAK"))
198 if (!prefixcmp(line
, "ACK ")) {
199 if (!get_sha1_hex(line
+4, result_sha1
)) {
200 if (strstr(line
+45, "continue"))
202 if (strstr(line
+45, "common"))
204 if (strstr(line
+45, "ready"))
209 die("git fetch_pack: expected ACK/NAK, got '%s'", line
);
212 static void send_request(int fd
, struct strbuf
*buf
)
214 if (args
.stateless_rpc
) {
215 send_sideband(fd
, -1, buf
->buf
, buf
->len
, LARGE_PACKET_MAX
);
218 safe_write(fd
, buf
->buf
, buf
->len
);
221 #define INITIAL_FLUSH 32
223 static int next_flush(int count
)
225 return INITIAL_FLUSH
+ count
;
228 static int find_common(int fd
[2], unsigned char *result_sha1
,
232 int count
= 0, flushes
= 0, flush_at
= INITIAL_FLUSH
, retval
;
233 const unsigned char *sha1
;
234 unsigned in_vain
= 0;
235 int got_continue
= 0;
237 struct strbuf req_buf
= STRBUF_INIT
;
238 size_t state_len
= 0;
240 if (args
.stateless_rpc
&& multi_ack
== 1)
241 die("--stateless-rpc requires multi_ack_detailed");
243 for_each_ref(clear_marks
, NULL
);
246 for_each_ref(rev_list_insert_ref
, NULL
);
249 for ( ; refs
; refs
= refs
->next
) {
250 unsigned char *remote
= refs
->old_sha1
;
251 const char *remote_hex
;
255 * If that object is complete (i.e. it is an ancestor of a
256 * local ref), we tell them we have it but do not have to
257 * tell them about its ancestors, which they already know
260 * We use lookup_object here because we are only
261 * interested in the case we *know* the object is
262 * reachable and we have already scanned it.
264 if (((o
= lookup_object(remote
)) != NULL
) &&
265 (o
->flags
& COMPLETE
)) {
269 remote_hex
= sha1_to_hex(remote
);
271 struct strbuf c
= STRBUF_INIT
;
272 if (multi_ack
== 2) strbuf_addstr(&c
, " multi_ack_detailed");
273 if (multi_ack
== 1) strbuf_addstr(&c
, " multi_ack");
274 if (no_done
) strbuf_addstr(&c
, " no-done");
275 if (use_sideband
== 2) strbuf_addstr(&c
, " side-band-64k");
276 if (use_sideband
== 1) strbuf_addstr(&c
, " side-band");
277 if (args
.use_thin_pack
) strbuf_addstr(&c
, " thin-pack");
278 if (args
.no_progress
) strbuf_addstr(&c
, " no-progress");
279 if (args
.include_tag
) strbuf_addstr(&c
, " include-tag");
280 if (prefer_ofs_delta
) strbuf_addstr(&c
, " ofs-delta");
281 packet_buf_write(&req_buf
, "want %s%s\n", remote_hex
, c
.buf
);
284 packet_buf_write(&req_buf
, "want %s\n", remote_hex
);
289 strbuf_release(&req_buf
);
294 if (is_repository_shallow())
295 write_shallow_commits(&req_buf
, 1);
297 packet_buf_write(&req_buf
, "deepen %d", args
.depth
);
298 packet_buf_flush(&req_buf
);
299 state_len
= req_buf
.len
;
301 if (args
.depth
> 0) {
303 unsigned char sha1
[20];
305 send_request(fd
[1], &req_buf
);
306 while (packet_read_line(fd
[0], line
, sizeof(line
))) {
307 if (!prefixcmp(line
, "shallow ")) {
308 if (get_sha1_hex(line
+ 8, sha1
))
309 die("invalid shallow line: %s", line
);
310 register_shallow(sha1
);
313 if (!prefixcmp(line
, "unshallow ")) {
314 if (get_sha1_hex(line
+ 10, sha1
))
315 die("invalid unshallow line: %s", line
);
316 if (!lookup_object(sha1
))
317 die("object not found: %s", line
);
318 /* make sure that it is parsed as shallow */
319 if (!parse_object(sha1
))
320 die("error in object: %s", line
);
321 if (unregister_shallow(sha1
))
322 die("no shallow found: %s", line
);
325 die("expected shallow/unshallow, got %s", line
);
327 } else if (!args
.stateless_rpc
)
328 send_request(fd
[1], &req_buf
);
330 if (!args
.stateless_rpc
) {
331 /* If we aren't using the stateless-rpc interface
332 * we don't need to retain the headers.
334 strbuf_setlen(&req_buf
, 0);
340 while ((sha1
= get_rev())) {
341 packet_buf_write(&req_buf
, "have %s\n", sha1_to_hex(sha1
));
343 fprintf(stderr
, "have %s\n", sha1_to_hex(sha1
));
345 if (flush_at
<= ++count
) {
348 packet_buf_flush(&req_buf
);
349 send_request(fd
[1], &req_buf
);
350 strbuf_setlen(&req_buf
, state_len
);
352 flush_at
= next_flush(count
);
355 * We keep one window "ahead" of the other side, and
356 * will wait for an ACK only on the next one
358 if (!args
.stateless_rpc
&& count
== INITIAL_FLUSH
)
361 consume_shallow_list(fd
[0]);
363 ack
= get_ack(fd
[0], result_sha1
);
364 if (args
.verbose
&& ack
)
365 fprintf(stderr
, "got ack %d %s\n", ack
,
366 sha1_to_hex(result_sha1
));
376 struct commit
*commit
=
377 lookup_commit(result_sha1
);
378 if (args
.stateless_rpc
380 && !(commit
->object
.flags
& COMMON
)) {
381 /* We need to replay the have for this object
382 * on the next RPC request so the peer knows
383 * it is in common with us.
385 const char *hex
= sha1_to_hex(result_sha1
);
386 packet_buf_write(&req_buf
, "have %s\n", hex
);
387 state_len
= req_buf
.len
;
389 mark_common(commit
, 0, 1);
393 if (ack
== ACK_ready
) {
402 if (got_continue
&& MAX_IN_VAIN
< in_vain
) {
404 fprintf(stderr
, "giving up\n");
410 if (!got_ready
|| !no_done
) {
411 packet_buf_write(&req_buf
, "done\n");
412 send_request(fd
[1], &req_buf
);
415 fprintf(stderr
, "done\n");
420 strbuf_release(&req_buf
);
422 consume_shallow_list(fd
[0]);
423 while (flushes
|| multi_ack
) {
424 int ack
= get_ack(fd
[0], result_sha1
);
427 fprintf(stderr
, "got ack (%d) %s\n", ack
,
428 sha1_to_hex(result_sha1
));
436 /* it is no error to fetch into a completely empty repo */
437 return count
? retval
: 0;
440 static struct commit_list
*complete
;
442 static int mark_complete(const char *path
, const unsigned char *sha1
, int flag
, void *cb_data
)
444 struct object
*o
= parse_object(sha1
);
446 while (o
&& o
->type
== OBJ_TAG
) {
447 struct tag
*t
= (struct tag
*) o
;
449 break; /* broken repository */
450 o
->flags
|= COMPLETE
;
451 o
= parse_object(t
->tagged
->sha1
);
453 if (o
&& o
->type
== OBJ_COMMIT
) {
454 struct commit
*commit
= (struct commit
*)o
;
455 commit
->object
.flags
|= COMPLETE
;
456 commit_list_insert_by_date(commit
, &complete
);
461 static void mark_recent_complete_commits(unsigned long cutoff
)
463 while (complete
&& cutoff
<= complete
->item
->date
) {
465 fprintf(stderr
, "Marking %s as complete\n",
466 sha1_to_hex(complete
->item
->object
.sha1
));
467 pop_most_recent_commit(&complete
, COMPLETE
);
471 static void filter_refs(struct ref
**refs
, int nr_match
, char **match
)
473 struct ref
**return_refs
;
474 struct ref
*newlist
= NULL
;
475 struct ref
**newtail
= &newlist
;
476 struct ref
*ref
, *next
;
477 struct ref
*fastarray
[32];
479 if (nr_match
&& !args
.fetch_all
) {
480 if (ARRAY_SIZE(fastarray
) < nr_match
)
481 return_refs
= xcalloc(nr_match
, sizeof(struct ref
*));
483 return_refs
= fastarray
;
484 memset(return_refs
, 0, sizeof(struct ref
*) * nr_match
);
490 for (ref
= *refs
; ref
; ref
= next
) {
492 if (!memcmp(ref
->name
, "refs/", 5) &&
493 check_ref_format(ref
->name
+ 5))
495 else if (args
.fetch_all
&&
496 (!args
.depth
|| prefixcmp(ref
->name
, "refs/tags/") )) {
499 newtail
= &ref
->next
;
503 int order
= path_match(ref
->name
, nr_match
, match
);
505 return_refs
[order
-1] = ref
;
506 continue; /* we will link it later */
512 if (!args
.fetch_all
) {
514 for (i
= 0; i
< nr_match
; i
++) {
515 ref
= return_refs
[i
];
519 newtail
= &ref
->next
;
522 if (return_refs
!= fastarray
)
528 static int everything_local(struct ref
**refs
, int nr_match
, char **match
)
532 unsigned long cutoff
= 0;
534 save_commit_buffer
= 0;
536 for (ref
= *refs
; ref
; ref
= ref
->next
) {
539 o
= parse_object(ref
->old_sha1
);
543 /* We already have it -- which may mean that we were
544 * in sync with the other side at some time after
545 * that (it is OK if we guess wrong here).
547 if (o
->type
== OBJ_COMMIT
) {
548 struct commit
*commit
= (struct commit
*)o
;
549 if (!cutoff
|| cutoff
< commit
->date
)
550 cutoff
= commit
->date
;
555 for_each_ref(mark_complete
, NULL
);
557 mark_recent_complete_commits(cutoff
);
561 * Mark all complete remote refs as common refs.
562 * Don't mark them common yet; the server has to be told so first.
564 for (ref
= *refs
; ref
; ref
= ref
->next
) {
565 struct object
*o
= deref_tag(lookup_object(ref
->old_sha1
),
568 if (!o
|| o
->type
!= OBJ_COMMIT
|| !(o
->flags
& COMPLETE
))
571 if (!(o
->flags
& SEEN
)) {
572 rev_list_push((struct commit
*)o
, COMMON_REF
| SEEN
);
574 mark_common((struct commit
*)o
, 1, 1);
578 filter_refs(refs
, nr_match
, match
);
580 for (retval
= 1, ref
= *refs
; ref
; ref
= ref
->next
) {
581 const unsigned char *remote
= ref
->old_sha1
;
582 unsigned char local
[20];
585 o
= lookup_object(remote
);
586 if (!o
|| !(o
->flags
& COMPLETE
)) {
591 "want %s (%s)\n", sha1_to_hex(remote
),
596 hashcpy(ref
->new_sha1
, local
);
600 "already have %s (%s)\n", sha1_to_hex(remote
),
606 static int sideband_demux(int in
, int out
, void *data
)
610 int ret
= recv_sideband("fetch-pack", xd
[0], out
);
615 static int get_pack(int xd
[2], char **pack_lockfile
)
618 const char *argv
[20];
622 int do_keep
= args
.keep_pack
;
623 struct child_process cmd
;
625 memset(&demux
, 0, sizeof(demux
));
627 /* xd[] is talking with upload-pack; subprocess reads from
628 * xd[0], spits out band#2 to stderr, and feeds us band#1
629 * through demux->out.
631 demux
.proc
= sideband_demux
;
634 if (start_async(&demux
))
635 die("fetch-pack: unable to fork off sideband"
641 memset(&cmd
, 0, sizeof(cmd
));
645 if (!args
.keep_pack
&& unpack_limit
) {
646 struct pack_header header
;
648 if (read_pack_header(demux
.out
, &header
))
649 die("protocol error: bad pack header");
650 snprintf(hdr_arg
, sizeof(hdr_arg
),
651 "--pack_header=%"PRIu32
",%"PRIu32
,
652 ntohl(header
.hdr_version
), ntohl(header
.hdr_entries
));
653 if (ntohl(header
.hdr_entries
) < unpack_limit
)
662 *av
++ = "index-pack";
664 if (!args
.quiet
&& !args
.no_progress
)
666 if (args
.use_thin_pack
)
667 *av
++ = "--fix-thin";
668 if (args
.lock_pack
|| unpack_limit
) {
669 int s
= sprintf(keep_arg
,
670 "--keep=fetch-pack %"PRIuMAX
" on ", (uintmax_t) getpid());
671 if (gethostname(keep_arg
+ s
, sizeof(keep_arg
) - s
))
672 strcpy(keep_arg
+ s
, "localhost");
677 *av
++ = "unpack-objects";
687 if (start_command(&cmd
))
688 die("fetch-pack: unable to fork off %s", argv
[0]);
689 if (do_keep
&& pack_lockfile
) {
690 *pack_lockfile
= index_pack_lockfile(cmd
.out
);
694 if (finish_command(&cmd
))
695 die("%s failed", argv
[0]);
696 if (use_sideband
&& finish_async(&demux
))
697 die("error in sideband demultiplexer");
701 static struct ref
*do_fetch_pack(int fd
[2],
702 const struct ref
*orig_ref
,
705 char **pack_lockfile
)
707 struct ref
*ref
= copy_ref_list(orig_ref
);
708 unsigned char sha1
[20];
710 if (is_repository_shallow() && !server_supports("shallow"))
711 die("Server does not support shallow clients");
712 if (server_supports("multi_ack_detailed")) {
714 fprintf(stderr
, "Server supports multi_ack_detailed\n");
716 if (server_supports("no-done")) {
718 fprintf(stderr
, "Server supports no-done\n");
722 else if (server_supports("multi_ack")) {
724 fprintf(stderr
, "Server supports multi_ack\n");
727 if (server_supports("side-band-64k")) {
729 fprintf(stderr
, "Server supports side-band-64k\n");
732 else if (server_supports("side-band")) {
734 fprintf(stderr
, "Server supports side-band\n");
737 if (server_supports("ofs-delta")) {
739 fprintf(stderr
, "Server supports ofs-delta\n");
741 prefer_ofs_delta
= 0;
742 if (everything_local(&ref
, nr_match
, match
)) {
746 if (find_common(fd
, sha1
, ref
) < 0)
748 /* When cloning, it is not unusual to have
751 warning("no common commits");
753 if (args
.stateless_rpc
)
755 if (get_pack(fd
, pack_lockfile
))
756 die("git fetch-pack: fetch failed.");
762 static int remove_duplicates(int nr_heads
, char **heads
)
766 for (src
= dst
= 0; src
< nr_heads
; src
++) {
767 /* If heads[src] is different from any of
768 * heads[0..dst], push it in.
771 for (i
= 0; i
< dst
; i
++) {
772 if (!strcmp(heads
[i
], heads
[src
]))
778 heads
[dst
] = heads
[src
];
784 static int fetch_pack_config(const char *var
, const char *value
, void *cb
)
786 if (strcmp(var
, "fetch.unpacklimit") == 0) {
787 fetch_unpack_limit
= git_config_int(var
, value
);
791 if (strcmp(var
, "transfer.unpacklimit") == 0) {
792 transfer_unpack_limit
= git_config_int(var
, value
);
796 if (strcmp(var
, "repack.usedeltabaseoffset") == 0) {
797 prefer_ofs_delta
= git_config_bool(var
, value
);
801 return git_default_config(var
, value
, cb
);
804 static struct lock_file lock
;
806 static void fetch_pack_setup(void)
808 static int did_setup
;
811 git_config(fetch_pack_config
, NULL
);
812 if (0 <= transfer_unpack_limit
)
813 unpack_limit
= transfer_unpack_limit
;
814 else if (0 <= fetch_unpack_limit
)
815 unpack_limit
= fetch_unpack_limit
;
819 int cmd_fetch_pack(int argc
, const char **argv
, const char *prefix
)
821 int i
, ret
, nr_heads
;
822 struct ref
*ref
= NULL
;
823 char *dest
= NULL
, **heads
;
825 char *pack_lockfile
= NULL
;
826 char **pack_lockfile_ptr
= NULL
;
827 struct child_process
*conn
;
831 for (i
= 1; i
< argc
; i
++) {
832 const char *arg
= argv
[i
];
835 if (!prefixcmp(arg
, "--upload-pack=")) {
836 args
.uploadpack
= arg
+ 14;
839 if (!prefixcmp(arg
, "--exec=")) {
840 args
.uploadpack
= arg
+ 7;
843 if (!strcmp("--quiet", arg
) || !strcmp("-q", arg
)) {
847 if (!strcmp("--keep", arg
) || !strcmp("-k", arg
)) {
848 args
.lock_pack
= args
.keep_pack
;
852 if (!strcmp("--thin", arg
)) {
853 args
.use_thin_pack
= 1;
856 if (!strcmp("--include-tag", arg
)) {
857 args
.include_tag
= 1;
860 if (!strcmp("--all", arg
)) {
864 if (!strcmp("-v", arg
)) {
868 if (!prefixcmp(arg
, "--depth=")) {
869 args
.depth
= strtol(arg
+ 8, NULL
, 0);
872 if (!strcmp("--no-progress", arg
)) {
873 args
.no_progress
= 1;
876 if (!strcmp("--stateless-rpc", arg
)) {
877 args
.stateless_rpc
= 1;
880 if (!strcmp("--lock-pack", arg
)) {
882 pack_lockfile_ptr
= &pack_lockfile
;
885 usage(fetch_pack_usage
);
888 heads
= (char **)(argv
+ i
+ 1);
889 nr_heads
= argc
- i
- 1;
893 usage(fetch_pack_usage
);
895 if (args
.stateless_rpc
) {
900 conn
= git_connect(fd
, (char *)dest
, args
.uploadpack
,
901 args
.verbose
? CONNECT_VERBOSE
: 0);
904 get_remote_heads(fd
[0], &ref
, 0, NULL
, 0, NULL
);
906 ref
= fetch_pack(&args
, fd
, conn
, ref
, dest
,
907 nr_heads
, heads
, pack_lockfile_ptr
);
909 printf("lock %s\n", pack_lockfile
);
914 if (finish_connect(conn
))
918 if (!ret
&& nr_heads
) {
919 /* If the heads to pull were given, we should have
920 * consumed all of them by matching the remote.
921 * Otherwise, 'git fetch remote no-such-ref' would
922 * silently succeed without issuing an error.
924 for (i
= 0; i
< nr_heads
; i
++)
925 if (heads
[i
] && heads
[i
][0]) {
926 error("no such remote ref %s", heads
[i
]);
932 sha1_to_hex(ref
->old_sha1
), ref
->name
);
939 struct ref
*fetch_pack(struct fetch_pack_args
*my_args
,
940 int fd
[], struct child_process
*conn
,
941 const struct ref
*ref
,
945 char **pack_lockfile
)
951 if (&args
!= my_args
)
952 memcpy(&args
, my_args
, sizeof(args
));
953 if (args
.depth
> 0) {
954 if (stat(git_path("shallow"), &st
))
958 if (heads
&& nr_heads
)
959 nr_heads
= remove_duplicates(nr_heads
, heads
);
962 die("no matching remote head");
964 ref_cpy
= do_fetch_pack(fd
, ref
, nr_heads
, heads
, pack_lockfile
);
966 if (args
.depth
> 0) {
967 struct cache_time mtime
;
968 struct strbuf sb
= STRBUF_INIT
;
969 char *shallow
= git_path("shallow");
972 mtime
.sec
= st
.st_mtime
;
973 mtime
.nsec
= ST_MTIME_NSEC(st
);
974 if (stat(shallow
, &st
)) {
976 die("shallow file was removed during fetch");
977 } else if (st
.st_mtime
!= mtime
.sec
979 || ST_MTIME_NSEC(st
) != mtime
.nsec
982 die("shallow file was changed during fetch");
984 fd
= hold_lock_file_for_update(&lock
, shallow
,
986 if (!write_shallow_commits(&sb
, 0)
987 || write_in_full(fd
, sb
.buf
, sb
.len
) != sb
.len
) {
988 unlink_or_warn(shallow
);
989 rollback_lock_file(&lock
);
991 commit_lock_file(&lock
);
996 reprepare_packed_git();