Skip to content

Commit dcc1b38

Browse files
committed
Merge branch 'cc/replace-edit'
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
2 parents b5f7b21 + 36857e0 commit dcc1b38

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

builtin/replace.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ static const char * const git_replace_usage[] = {
2323
};
2424

2525
enum replace_format {
26-
REPLACE_FORMAT_SHORT,
27-
REPLACE_FORMAT_MEDIUM,
28-
REPLACE_FORMAT_LONG
26+
REPLACE_FORMAT_SHORT,
27+
REPLACE_FORMAT_MEDIUM,
28+
REPLACE_FORMAT_LONG
2929
};
3030

3131
struct show_data {
@@ -193,22 +193,22 @@ static int replace_object(const char *object_ref, const char *replace_ref, int f
193193
*/
194194
static void export_object(const unsigned char *sha1, const char *filename)
195195
{
196-
const char *argv[] = { "--no-replace-objects", "cat-file", "-p", NULL, NULL };
197-
struct child_process cmd = { argv };
196+
struct child_process cmd = { NULL };
198197
int fd;
199198

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

204-
argv[3] = sha1_to_hex(sha1);
203+
argv_array_push(&cmd.args, "--no-replace-objects");
204+
argv_array_push(&cmd.args, "cat-file");
205+
argv_array_push(&cmd.args, "-p");
206+
argv_array_push(&cmd.args, sha1_to_hex(sha1));
205207
cmd.git_cmd = 1;
206208
cmd.out = fd;
207209

208210
if (run_command(&cmd))
209211
die("cat-file reported failure");
210-
211-
close(fd);
212212
}
213213

214214
/*

daemon.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,6 @@ static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen)
778778
logerror("unable to fork");
779779
else
780780
add_child(&cld, addr, addrlen);
781-
close(incoming);
782781
}
783782

784783
static void child_handler(int signo)

0 commit comments

Comments
 (0)