Skip to content

Commit

Permalink
Merge branch 'cc/replace-edit'
Browse files Browse the repository at this point in the history
Teach "git replace" an "--edit" mode.

* cc/replace-edit:
  replace: use argv_array in export_object
  avoid double close of descriptors handed to run_command
  replace: replace spaces with tabs in indentation
  • Loading branch information
Junio C Hamano committed Jul 16, 2014
2 parents b5f7b21 + 36857e0 commit dcc1b38
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
16 changes: 8 additions & 8 deletions builtin/replace.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ static const char * const git_replace_usage[] = {
};

enum replace_format {
REPLACE_FORMAT_SHORT,
REPLACE_FORMAT_MEDIUM,
REPLACE_FORMAT_LONG
REPLACE_FORMAT_SHORT,
REPLACE_FORMAT_MEDIUM,
REPLACE_FORMAT_LONG
};

struct show_data {
Expand Down Expand Up @@ -193,22 +193,22 @@ static int replace_object(const char *object_ref, const char *replace_ref, int f
*/
static void export_object(const unsigned char *sha1, const char *filename)
{
const char *argv[] = { "--no-replace-objects", "cat-file", "-p", NULL, NULL };
struct child_process cmd = { argv };
struct child_process cmd = { NULL };
int fd;

fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666);
if (fd < 0)
die_errno("unable to open %s for writing", filename);

argv[3] = sha1_to_hex(sha1);
argv_array_push(&cmd.args, "--no-replace-objects");
argv_array_push(&cmd.args, "cat-file");
argv_array_push(&cmd.args, "-p");
argv_array_push(&cmd.args, sha1_to_hex(sha1));
cmd.git_cmd = 1;
cmd.out = fd;

if (run_command(&cmd))
die("cat-file reported failure");

close(fd);
}

/*
Expand Down
1 change: 0 additions & 1 deletion daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,6 @@ static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen)
logerror("unable to fork");
else
add_child(&cld, addr, addrlen);
close(incoming);
}

static void child_handler(int signo)
Expand Down

0 comments on commit dcc1b38

Please sign in to comment.