git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Colin Curtis <colinpcurtis@gmail.com>
To: git@vger.kernel.org
Cc: Colin Curtis <colinpcurtis@gmail.com>
Subject: [PATCH 1/2] add cmd_gud to open git-scm.com webpage
Date: Tue,  7 Sep 2021 22:13:39 -0700	[thread overview]
Message-ID: <20210908051340.13332-2-colinpcurtis826@ucla.edu> (raw)
In-Reply-To: <20210908051340.13332-1-colinpcurtis826@ucla.edu>

From: Colin Curtis <colinpcurtis@gmail.com>

---
 .gitignore                |  1 +
 Documentation/git-gud.txt | 33 +++++++++++++++++++++++++++++++++
 Makefile                  |  3 ++-
 builtin.h                 |  1 +
 builtin/gud.c             | 27 +++++++++++++++++++++++++++
 git.c                     |  1 +
 t/t9904-git-gud.sh        | 16 ++++++++++++++++
 7 files changed, 81 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/git-gud.txt
 create mode 100644 builtin/gud.c
 create mode 100755 t/t9904-git-gud.sh

diff --git a/.gitignore b/.gitignore
index 311841f9be..5fec146bd8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -75,6 +75,7 @@
 /git-gc
 /git-get-tar-commit-id
 /git-grep
+/git-gud
 /git-hash-object
 /git-help
 /git-http-backend
diff --git a/Documentation/git-gud.txt b/Documentation/git-gud.txt
new file mode 100644
index 0000000000..357ff915a6
--- /dev/null
+++ b/Documentation/git-gud.txt
@@ -0,0 +1,33 @@
+git-gud(1)
+===========
+
+NAME
+----
+git-gud - Display git-scm.com website
+
+SYNOPSIS
+--------
+[verse]
+'git gud' [-d | --display] [<pathspec>...]
+
+DESCRIPTION
+-----------
+
+'git gud' command opens the webpage for git-scm.com in the default
+web browser.
+
+OPTIONS
+-------
+-d::
+--display::
+	Opens the webpage for git-scm.com in the default browser
+
+OUTPUT
+------
+If the '[-d | --display]' option is present, then the command opens
+up the git-scm.com webpage in the default web browser.  Otherwise,
+nothing is done.
+
+GIT
+---
+Part of the linkgit:git[1] suite
diff --git a/Makefile b/Makefile
index 429c276058..379cd91a97 100644
--- a/Makefile
+++ b/Makefile
@@ -1108,6 +1108,7 @@ BUILTIN_OBJS += builtin/fsck.o
 BUILTIN_OBJS += builtin/gc.o
 BUILTIN_OBJS += builtin/get-tar-commit-id.o
 BUILTIN_OBJS += builtin/grep.o
+BUILTIN_OBJS += builtin/gud.o
 BUILTIN_OBJS += builtin/hash-object.o
 BUILTIN_OBJS += builtin/help.o
 BUILTIN_OBJS += builtin/index-pack.o
@@ -1513,7 +1514,7 @@ ifndef NO_ICONV
 		ifdef NEEDS_LIBINTL_BEFORE_LIBICONV
 			ICONV_LINK += -lintl
 		endif
-		EXTLIBS += $(ICONV_LINK) -liconv
+		EXTLIBS += $(ICONV_LINK) /usr/local/Cellar/libiconv/1.16/lib/libiconv.dylib # -liconv
 	endif
 endif
 ifdef ICONV_OMITS_BOM
diff --git a/builtin.h b/builtin.h
index 16ecd5586f..e183a1a8d4 100644
--- a/builtin.h
+++ b/builtin.h
@@ -162,6 +162,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix);
 int cmd_gc(int argc, const char **argv, const char *prefix);
 int cmd_get_tar_commit_id(int argc, const char **argv, const char *prefix);
 int cmd_grep(int argc, const char **argv, const char *prefix);
+int cmd_gud(int argc, const char **argv, const char *prefix);
 int cmd_hash_object(int argc, const char **argv, const char *prefix);
 int cmd_help(int argc, const char **argv, const char *prefix);
 int cmd_index_pack(int argc, const char **argv, const char *prefix);
diff --git a/builtin/gud.c b/builtin/gud.c
new file mode 100644
index 0000000000..04808a08f5
--- /dev/null
+++ b/builtin/gud.c
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include "builtin.h"
+#include "parse-options.h"
+
+static int display_page;
+
+static const char * const builtin_gud_usage[] = {
+	N_("git gud [<options>]"),
+	NULL
+};
+
+static struct option builtin_gud_options[] = {
+        OPT_BOOL('d', "display", &display_page, N_("display the webpage for git-scm.com")),
+		OPT_END()
+};
+
+int cmd_gud(int argc, const char **argv, const char *prefix)
+{    
+
+    argc = parse_options(argc, argv, prefix,
+                builtin_gud_options, builtin_gud_usage, 0);
+    if (display_page) {
+        system("open https://git-scm.com/book/en/v2");
+    }
+    
+    return 0;
+}
\ No newline at end of file
diff --git a/git.c b/git.c
index 18bed9a996..2da1f4d2d4 100644
--- a/git.c
+++ b/git.c
@@ -536,6 +536,7 @@ static struct cmd_struct commands[] = {
 	{ "gc", cmd_gc, RUN_SETUP },
 	{ "get-tar-commit-id", cmd_get_tar_commit_id, NO_PARSEOPT },
 	{ "grep", cmd_grep, RUN_SETUP_GENTLY },
+	{ "gud", cmd_gud, RUN_SETUP },
 	{ "hash-object", cmd_hash_object },
 	{ "help", cmd_help },
 	{ "index-pack", cmd_index_pack, RUN_SETUP_GENTLY | NO_PARSEOPT },
diff --git a/t/t9904-git-gud.sh b/t/t9904-git-gud.sh
new file mode 100755
index 0000000000..47fa97498c
--- /dev/null
+++ b/t/t9904-git-gud.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+test_description='git-gud test
+
+This test runs git-gud and makes sure it does not crash.'
+
+. ./test-lib.sh
+
+test_expect_success 'runs correctly with no args' '
+	git gud
+'
+
+test_expect_success 'runs correctly with -d option' '
+	git gud -d
+'
+
+test_done
-- 
2.30.1 (Apple Git-130)


  reply	other threads:[~2021-09-08  5:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-08  5:13 [PATCH 0/2] Add cmd_gud and detect libiconv path for Mac OS Colin Curtis
2021-09-08  5:13 ` Colin Curtis [this message]
2021-09-08  5:13 ` [PATCH 2/2] add liconv link for makefile Colin Curtis
2021-09-08  5:52   ` Carlo Arenas
2021-09-08  6:01 ` [PATCH 0/2] Add cmd_gud and detect libiconv path for Mac OS Bagas Sanjaya
2021-09-08 10:50 ` Ævar Arnfjörð Bjarmason

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=20210908051340.13332-2-colinpcurtis826@ucla.edu \
    --to=colinpcurtis@gmail.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).