All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: git@vger.kernel.org, gitster@pobox.com
Subject: [PATCH 6/6] DWIM "git add remote ..."
Date: Wed, 5 Dec 2007 19:03:00 +0000 (GMT)	[thread overview]
Message-ID: <Pine.LNX.4.64.0712051902510.27959@racer.site> (raw)
In-Reply-To: <Pine.LNX.4.64.0712051858270.27959@racer.site>


It is wrong to divert to "git remote add" when you typed the
(more English) "git add remote".  But is it also pretty convenient.

So implement it, but do not document it ;-)

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 builtin-add.c     |    7 +++++++
 t/t5505-remote.sh |    6 ++++++
 2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/builtin-add.c b/builtin-add.c
index 5c29cc2..b5b4c2f 100644
--- a/builtin-add.c
+++ b/builtin-add.c
@@ -196,6 +196,13 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 	const char **pathspec;
 	struct dir_struct dir;
 
+	if (argc > 1 && !strcmp(argv[1], "remote") &&
+			access("remote", F_OK)) {
+		argv[1] = argv[0];
+		argv[0] = "remote";
+		return cmd_remote(argc, argv, prefix);
+	}
+
 	argc = parse_options(argc, argv, builtin_add_options,
 			  builtin_add_usage, 0);
 	if (patch_interactive)
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index 2376e0a..83ed70c 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -147,4 +147,10 @@ test_expect_success 'add --mirror && prune' '
 	 git rev-parse --verify refs/heads/side)
 '
 
+test_expect_success 'add remote' '
+	(cd test &&
+	 git add remote -f another-one ../one &&
+	 git diff master remotes/another-one/master)
+'
+
 test_done
-- 
1.5.3.7.2157.g9598e

  parent reply	other threads:[~2007-12-05 19:03 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-05 19:00 [PATCH 0/6] builtin-remote Johannes Schindelin
2007-12-05 19:00 ` (unknown) Johannes Schindelin
2007-12-05 19:01   ` your mail Johannes Schindelin
2007-12-05 19:05   ` [PATCH 1/6] path-list: add functions to work with unsorted lists Johannes Schindelin
2007-12-05 19:01 ` [PATCH 2/6] parseopt: add flag to stop on first non option Johannes Schindelin
2007-12-05 19:02 ` [PATCH 3/6] Test "git remote show" and "git remote prune" Johannes Schindelin
2007-12-05 21:59   ` René Scharfe
2007-12-05 22:38     ` Johannes Schindelin
2007-12-05 19:02 ` [PATCH 4/6] Make git-remote a builtin Johannes Schindelin
2007-12-05 21:40   ` [PATCH 7/6] builtin-remote: guard remote->url accesses by remote->url_nr check Johannes Schindelin
2007-12-05 19:02 ` [PATCH 5/6] builtin-remote: prune remotes correctly that were added with --mirror Johannes Schindelin
2007-12-05 19:03 ` Johannes Schindelin [this message]
2007-12-05 19:34   ` [PATCH 6/6] DWIM "git add remote ..." Linus Torvalds
2007-12-05 19:47     ` Johannes Schindelin

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=Pine.LNX.4.64.0712051902510.27959@racer.site \
    --to=johannes.schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.