diff options
author | Junio C Hamano <gitster@pobox.com> | 2014-07-16 11:25:47 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-07-16 11:25:47 -0700 |
commit | dcc1b3851779ba1e3f55c1116852d87999d2c936 (patch) | |
tree | 830c6d990a782ca462d3a09d86d763f0ea2c9ca1 /builtin | |
parent | b5f7b21e5983b1f3a86c1b37f9244eda97dfb65a (diff) | |
parent | 36857e0026f5a7855f941a955bf7014408a816dd (diff) | |
download | git-dcc1b3851779ba1e3f55c1116852d87999d2c936.tar.gz git-dcc1b3851779ba1e3f55c1116852d87999d2c936.tar.xz |
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
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/replace.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/builtin/replace.c b/builtin/replace.c index 1bb491d3c..25841708f 100644 --- a/builtin/replace.c +++ b/builtin/replace.c @@ -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 { @@ -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); } /* |