fetch-pack.c: move shallow update code out of fetch_pack()
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
							parent
							
								
									8e277383e0
								
							
						
					
					
						commit
						a796ccee51
					
				
							
								
								
									
										22
									
								
								fetch-pack.c
								
								
								
								
							
							
						
						
									
										22
									
								
								fetch-pack.c
								
								
								
								
							|  | @ -925,6 +925,18 @@ static int remove_duplicates_in_refs(struct ref **ref, int nr) | ||||||
| 	return dst; | 	return dst; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | static void update_shallow(struct fetch_pack_args *args) | ||||||
|  | { | ||||||
|  | 	if (args->depth > 0 && alternate_shallow_file) { | ||||||
|  | 		if (*alternate_shallow_file == '\0') { /* --unshallow */ | ||||||
|  | 			unlink_or_warn(git_path("shallow")); | ||||||
|  | 			rollback_lock_file(&shallow_lock); | ||||||
|  | 		} else | ||||||
|  | 			commit_lock_file(&shallow_lock); | ||||||
|  | 		return; | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
| struct ref *fetch_pack(struct fetch_pack_args *args, | struct ref *fetch_pack(struct fetch_pack_args *args, | ||||||
| 		       int fd[], struct child_process *conn, | 		       int fd[], struct child_process *conn, | ||||||
| 		       const struct ref *ref, | 		       const struct ref *ref, | ||||||
|  | @ -943,15 +955,7 @@ struct ref *fetch_pack(struct fetch_pack_args *args, | ||||||
| 		die("no matching remote head"); | 		die("no matching remote head"); | ||||||
| 	} | 	} | ||||||
| 	ref_cpy = do_fetch_pack(args, fd, ref, sought, nr_sought, pack_lockfile); | 	ref_cpy = do_fetch_pack(args, fd, ref, sought, nr_sought, pack_lockfile); | ||||||
|  | 	update_shallow(args); | ||||||
| 	if (args->depth > 0 && alternate_shallow_file) { |  | ||||||
| 		if (*alternate_shallow_file == '\0') { /* --unshallow */ |  | ||||||
| 			unlink_or_warn(git_path("shallow")); |  | ||||||
| 			rollback_lock_file(&shallow_lock); |  | ||||||
| 		} else |  | ||||||
| 			commit_lock_file(&shallow_lock); |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	reprepare_packed_git(); | 	reprepare_packed_git(); | ||||||
| 	return ref_cpy; | 	return ref_cpy; | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Nguyễn Thái Ngọc Duy
						Nguyễn Thái Ngọc Duy