git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Kristian Høgsberg" <krh@redhat.com>
To: git@vger.kernel.org
Cc: "Kristian Høgsberg" <krh@redhat.com>
Subject: [PATCH] Introduce entry point for launching add--interactive.
Date: Mon, 30 Jul 2007 18:21:23 -0400	[thread overview]
Message-ID: <11858340832222-git-send-email-krh@redhat.com> (raw)

This refactors builtin-add.c a little to provide a unique entry point
for launching git add --interactive, which will be used by
builtin-commit too.  If we later want to make add --interactive a
builtin or change how it is launched, we just start from this function.

Signed-off-by: Kristian Høgsberg <krh@redhat.com>
---

Oh, oops, just one more change outside builtin-commit.c.  This is mostly
stylistic, but it seems reasonable to reasonable to have a well-defined
entry point for launcing git add --interactive.

 builtin-add.c |   14 +++++++++-----
 commit.h      |    2 ++
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/builtin-add.c b/builtin-add.c
index 7345479..7044d43 100644
--- a/builtin-add.c
+++ b/builtin-add.c
@@ -135,6 +135,13 @@ static int git_add_config(const char *var, const char *value)
 	return git_default_config(var, value);
 }
 
+int interactive_add(void)
+{
+	const char *argv[2] = { "add--interactive", NULL };
+
+	return run_command_v_opt(argv, RUN_GIT_CMD);
+}
+
 static struct lock_file lock_file;
 
 static const char ignore_warning[] =
@@ -154,12 +161,9 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 			add_interactive++;
 	}
 	if (add_interactive) {
-		const char *args[] = { "add--interactive", NULL };
-
-		if (add_interactive != 1 || argc != 2)
+		if (argc != 2)
 			die("add --interactive does not take any parameters");
-		execv_git_cmd(args);
-		exit(1);
+		exit(interactive_add());
 	}
 
 	git_config(git_add_config);
diff --git a/commit.h b/commit.h
index 9f640ba..64e1d4b 100644
--- a/commit.h
+++ b/commit.h
@@ -129,4 +129,6 @@ create_commit(const unsigned char *tree_sha1,
 	      const char *author_info, const char *committer_info,
 	      const char *message, int length);
 
+extern int interactive_add(void);
+
 #endif /* COMMIT_H */
-- 
1.5.2.GIT

                 reply	other threads:[~2007-07-30 22:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11858340832222-git-send-email-krh@redhat.com \
    --to=krh@redhat.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).