summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8a534b6)
raw | patch | inline | side by side (parent: 8a534b6)
author | Jeff King <peff@peff.net> | |
Tue, 13 Sep 2011 21:58:19 +0000 (17:58 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 14 Sep 2011 18:57:25 +0000 (11:57 -0700) |
We were using a similar ad-hoc rev_list_args structure, but
this saves some code.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
this saves some code.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/checkout.c | patch | blob | history |
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 28cdc51b85e7d433dca085c0080f964d19a391b4..bb056e43bf96ffb2ad84b2a4d05c75e783345b60 100644 (file)
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
#include "ll-merge.h"
#include "resolve-undo.h"
#include "submodule.h"
+#include "argv-array.h"
static const char * const checkout_usage[] = {
"git checkout [options] <branch>",
report_tracking(new);
}
-struct rev_list_args {
- int argc;
- int alloc;
- const char **argv;
-};
-
-static void add_one_rev_list_arg(struct rev_list_args *args, const char *s)
-{
- ALLOC_GROW(args->argv, args->argc + 1, args->alloc);
- args->argv[args->argc++] = s;
-}
-
static int add_one_ref_to_rev_list_arg(const char *refname,
const unsigned char *sha1,
int flags,
void *cb_data)
{
- add_one_rev_list_arg(cb_data, refname);
+ argv_array_push(cb_data, refname);
return 0;
}
*/
static void orphaned_commit_warning(struct commit *commit)
{
- struct rev_list_args args = { 0, 0, NULL };
+ struct argv_array args = ARGV_ARRAY_INIT;
struct rev_info revs;
- add_one_rev_list_arg(&args, "(internal)");
- add_one_rev_list_arg(&args, sha1_to_hex(commit->object.sha1));
- add_one_rev_list_arg(&args, "--not");
+ argv_array_push(&args, "(internal)");
+ argv_array_push(&args, sha1_to_hex(commit->object.sha1));
+ argv_array_push(&args, "--not");
for_each_ref(add_one_ref_to_rev_list_arg, &args);
- add_one_rev_list_arg(&args, "--");
- add_one_rev_list_arg(&args, NULL);
+ argv_array_push(&args, "--");
init_revisions(&revs, NULL);
if (setup_revisions(args.argc - 1, args.argv, &revs, NULL) != 1)
else
describe_detached_head(_("Previous HEAD position was"), commit);
+ argv_array_clear(&args);
clear_commit_marks(commit, -1);
for_each_ref(clear_commit_marks_from_one_ref, NULL);
}