git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, ben.knoble@gmail.com,
	jayatheerthkulkarni2005@gmail.com
Subject: [[GSOC][PATCH v3] 2/3] docs: update function signature, add UNUSED macro
Date: Fri, 21 Mar 2025 20:00:21 +0530	[thread overview]
Message-ID: <20250321143022.5406-2-jayatheerthkulkarni2005@gmail.com> (raw)
In-Reply-To: <20250321143022.5406-1-jayatheerthkulkarni2005@gmail.com>

Modify function signatures to include struct repository
for better compatibility. Also update builtin.h
accordingly and use UNUSED to prevent warnings.

Signed-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>
---
 Documentation/MyFirstContribution.adoc | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/Documentation/MyFirstContribution.adoc b/Documentation/MyFirstContribution.adoc
index 7b856be41e..45efe117ab 100644
--- a/Documentation/MyFirstContribution.adoc
+++ b/Documentation/MyFirstContribution.adoc
@@ -142,9 +142,13 @@ followed by the name of the subcommand, in a source file named after the
 subcommand and contained within `builtin/`. So it makes sense to implement your
 command in `builtin/psuh.c`. Create that file, and within it, write the entry
 point for your command in a function matching the style and signature:
-
 ----
-int cmd_psuh(int argc, const char **argv, const char *prefix)
+int cmd_psuh(int argc, const char **argv, const char *prefix, struct repository *repo)
+----
+Before proceeding further, we should use the UNUSED macro to suppress warnings about unused parameters in the function.
+This prevents the compiler from generating warnings when certain parameters are not used within the function body:
+----
+int cmd_psuh(int argc UNUSED, const char **argv UNUSED, const char *prefix UNUSED, struct repository *repo UNUSED)
 ----
 
 We'll also need to add the declaration of psuh; open up `builtin.h`, find the
@@ -152,7 +156,7 @@ declaration for `cmd_pull`, and add a new line for `psuh` immediately before it,
 in order to keep the declarations alphabetically sorted:
 
 ----
-int cmd_psuh(int argc, const char **argv, const char *prefix);
+int cmd_psuh(int argc, const char **argv, const char *prefix, struct repository *repo);
 ----
 
 Be sure to `#include "builtin.h"` in your `psuh.c`. You'll also need to
@@ -168,7 +172,7 @@ Throughout the tutorial, we will mark strings for translation as necessary; you
 should also do so when writing your user-facing commands in the future.
 
 ----
-int cmd_psuh(int argc, const char **argv, const char *prefix)
+int cmd_psuh(int argc UNUSED, const char **argv UNUSED, const char *prefix UNUSED, struct repository *repo UNUSED)
 {
 	printf(_("Pony saying hello goes here.\n"));
 	return 0;
@@ -199,6 +203,9 @@ with the command name, a function pointer to the command implementation, and a
 setup option flag. For now, let's keep mimicking `push`. Find the line where
 `cmd_push` is registered, copy it, and modify it for `cmd_psuh`, placing the new
 line in alphabetical order (immediately before `cmd_pull`).
+----
+{ "psuh", cmd_psuh, RUN_SETUP}
+----
 
 The options are documented in `builtin.h` under "Adding a new built-in." Since
 we hope to print some data about the user's current workspace context later,
@@ -285,6 +292,8 @@ Modify your `cmd_psuh` implementation to dump the args you're passed, keeping
 existing `printf()` calls in place:
 
 ----
+int cmd_psuh(int argc, const char **argv, const char *prefix, struct repository *repo UNUSED)
+{
 	int i;
 
 	...
@@ -298,7 +307,8 @@ existing `printf()` calls in place:
 
 	printf(_("Your current working directory:\n<top-level>%s%s\n"),
 	       prefix ? "/" : "", prefix ? prefix : "");
-
+	...
+}
 ----
 
 Build and try it. As you may expect, there's pretty much just whatever we give
-- 
2.48.1


  reply	other threads:[~2025-03-21 14:30 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-15 18:15 [GSOC][PATCH 1/3] Remove outdated mentoring mailing list reference and clarify tutorial prerequisites K Jayatheerth
2025-03-15 18:15 ` [GSOC][PATCH 2/3] Update function signature and UNUSED to include struct repository and modify builtin.h accordingly K Jayatheerth
2025-03-15 18:15 ` [GSOC][PATCH 3/3] Replace git_config(...) with repo_config(...) for modern Git compatibility K Jayatheerth
2025-03-15 18:21   ` JAYATHEERTH K
2025-03-17 21:57 ` [GSOC][PATCH 1/3] Remove outdated mentoring mailing list reference and clarify tutorial prerequisites Junio C Hamano
2025-03-19 17:02   ` [GSOC][PATCH v2] Remove outdated mentoring mailing list reference K Jayatheerth
2025-03-21 10:36     ` Junio C Hamano
2025-03-21 14:30       ` [[GSOC][PATCH v3] 1/3] docs: drop inactive mentoring list, add C prereq K Jayatheerth
2025-03-21 14:30         ` K Jayatheerth [this message]
2025-03-23 22:08           ` [[GSOC][PATCH v3] 2/3] docs: update function signature, add UNUSED macro Junio C Hamano
2025-03-21 14:30         ` [[GSOC][PATCH v3] 3/3] docs: replace git_config with repo_config K Jayatheerth
2025-03-23 22:08           ` Junio C Hamano
2025-03-24  1:42             ` JAYATHEERTH K
2025-03-24  4:46               ` Junio C Hamano
2025-03-24 13:03                 ` [[GSOC][PATCH v4] 2/3] docs: update function signature, add UNUSED macro K Jayatheerth
2025-03-24 13:03                   ` [[GSOC][PATCH v4] 3/3] docs: replace git_config with repo_config K Jayatheerth
2025-03-24 13:10                 ` [[GSOC][PATCH v3] " JAYATHEERTH K
2025-03-26  2:37                   ` Junio C Hamano
2025-03-26  3:15                     ` JAYATHEERTH K
2025-03-29 17:42                       ` JAYATHEERTH K
2025-03-21 14:32       ` [GSOC][PATCH v2] Remove outdated mentoring mailing list reference JAYATHEERTH K

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=20250321143022.5406-2-jayatheerthkulkarni2005@gmail.com \
    --to=jayatheerthkulkarni2005@gmail.com \
    --cc=ben.knoble@gmail.com \
    --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 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).