git-2.22.0/builtin/replace.c
/*
 * Write the contents of the object named by "sha1" to the file "filename".
 * If "raw" is true, then the object's raw contents are printed according to
 * "type". Otherwise, we pretty-print the contents for human editing.
 */
Write the contents of the object named by "sha1" to the file "filename".
If "raw" is true, then the object's raw contents are printed according to
"type". Otherwise, we pretty-print the contents for human editing.
Write the contents of the object named by " sha1 " to the file " filename " . If " raw " is true then the object ' s raw contents are printed according to " type " . Otherwise we pretty - print the contents for human editing .
static int export_object(const struct object_id *oid, enum object_type type,
			  int raw, const char *filename)
{
	struct child_process cmd = CHILD_PROCESS_INIT;
	int fd;
	fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666);
	if (fd < 0)
		return error_errno(_("unable to open %s for writing"), filename);
	argv_array_push(&cmd.args, "--no-replace-objects");
	argv_array_push(&cmd.args, "cat-file");
	if (raw)
		argv_array_push(&cmd.args, type_name(type));
	else
		argv_array_push(&cmd.args, "-p");
	argv_array_push(&cmd.args, oid_to_hex(oid));
	cmd.git_cmd = 1;
	cmd.out = fd;
	if (run_command(&cmd))
		return error(_("cat-file reported failure"));
	return 0;
}
static int export_object ( const struct object_id * oid , enum object_type type , int raw , const char * filename ) { struct child_process cmd = CHILD_PROCESS_INIT ; int fd ; fd = open ( filename , O_WRONLY | O_CREAT | O_TRUNC , 0666 ) ; if ( fd < 0 ) return error_errno ( _ ( " " ) , filename ) ; argv_array_push ( & cmd . args , " " ) ; argv_array_push ( & cmd . args , " " ) ; if ( raw ) argv_array_push ( & cmd . args , type_name ( type ) ) ; else argv_array_push ( & cmd . args , " " ) ; argv_array_push ( & cmd . args , oid_to_hex ( oid ) ) ; cmd . git_cmd = 1 ; cmd . out = fd ; if ( run_command ( & cmd ) ) return error ( _ ( " " ) ) ; return 0 ; }
Write the contents of the object named by "sha1" to the file "filename".
Write the contents of the object named by " sha1 " to the file " filename " .