Skip to content
Snippets Groups Projects
Select Git revision
  • v3.12-rc6
  • master default protected
  • objtool-32bit
  • objtool
  • v5.9
  • v5.9-rc8
  • v5.9-rc7
  • v5.9-rc6
  • v5.9-rc5
  • v5.9-rc4
  • v5.9-rc3
  • v5.9-rc2
  • v5.9-rc1
  • v5.8
  • v5.8-rc7
  • v5.8-rc6
  • v5.8-rc5
  • v5.8-rc4
  • v5.8-rc3
  • v5.8-rc2
  • v5.8-rc1
  • v5.7
  • v5.7-rc7
  • v5.7-rc6
24 results

anubis.c

Blame
  • Forked from Jonas Rabenstein / Linux
    Source project has a limited visibility.
    clone-pack.c 6.54 KiB
    #include "cache.h"
    #include "refs.h"
    #include "pkt-line.h"
    #include <sys/wait.h>
    
    static const char clone_pack_usage[] =
    "git-clone-pack [--exec=<git-upload-pack>] [<host>:]<directory> [<heads>]*";
    static const char *exec = "git-upload-pack";
    
    static void clone_handshake(int fd[2], struct ref *ref)
    {
    	unsigned char sha1[20];
    
    	while (ref) {
    		packet_write(fd[1], "want %s\n", sha1_to_hex(ref->old_sha1));
    		ref = ref->next;
    	}
    	packet_flush(fd[1]);
    
    	/* We don't have nuttin' */
    	packet_write(fd[1], "done\n");
    	if (get_ack(fd[0], sha1))
    		error("Huh! git-clone-pack got positive ack for %s", sha1_to_hex(sha1));
    }
    
    static int is_master(struct ref *ref)
    {
    	return !strcmp(ref->name, "refs/heads/master");
    }
    
    static void write_one_ref(struct ref *ref)
    {
    	char *path = git_path("%s", ref->name);
    	int fd;
    	char *hex;
    
    	if (!strncmp(ref->name, "refs/", 5) &&
    	    check_ref_format(ref->name + 5)) {
    		error("refusing to create funny ref '%s' locally", ref->name);
    		return;
    	}
    
    	if (safe_create_leading_directories(path))
    		die("unable to create leading directory for %s", ref->name);
    	fd = open(path, O_CREAT | O_EXCL | O_WRONLY, 0666);
    	if (fd < 0)
    		die("unable to create ref %s", ref->name);
    	hex = sha1_to_hex(ref->old_sha1);
    	hex[40] = '\n';
    	if (write(fd, hex, 41) != 41)
    		die("unable to write ref %s", ref->name);
    	close(fd);
    }
    
    static void write_refs(struct ref *ref)
    {
    	struct ref *head = NULL, *head_ptr, *master_ref;
    	char *head_path;
    
    	/* Upload-pack must report HEAD first */
    	if (!strcmp(ref->name, "HEAD")) {
    		head = ref;
    		ref = ref->next;
    	}
    	head_ptr = NULL;
    	master_ref = NULL;
    	while (ref) {
    		if (is_master(ref))
    			master_ref = ref;
    		if (head &&