All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Roskin <proski@gnu.org>
To: git <git@vger.kernel.org>
Subject: [PATCH] Fix "prefix" mixup in git-rev-list
Date: Wed, 24 Aug 2005 17:58:42 -0400	[thread overview]
Message-ID: <1124920722.17909.9.camel@dv> (raw)

Hello!

Recent changes in git have broken cg-log.  git-rev-list no longer prints
"commit" in front of commit hashes.  It turn out a local "prefix"
variable in main() shadows a file-scoped "prefix" variable.

The patch removed the local "prefix" variable since its value is never
used (in the intended way, that is).  The call to setup_git_directory()
is kept since it has useful side effects.

The file-scoped "prefix" variable is renamed to "commit_prefix" just in
case someone reintroduces "prefix" to hold the return value of
setup_git_directory().

Signed-off-by: Pavel Roskin <proski@gnu.org>

diff --git a/rev-list.c b/rev-list.c
--- a/rev-list.c
+++ b/rev-list.c
@@ -33,7 +33,7 @@ static int blob_objects = 0;
 static int verbose_header = 0;
 static int show_parents = 0;
 static int hdr_termination = 0;
-static const char *prefix = "";
+static const char *commit_prefix = "";
 static unsigned long max_age = -1;
 static unsigned long min_age = -1;
 static int max_count = -1;
@@ -48,14 +48,14 @@ static void show_commit(struct commit *c
 {
 	commit->object.flags |= SHOWN;
 	if (show_breaks) {
-		prefix = "| ";
+		commit_prefix = "| ";
 		if (commit->object.flags & DISCONTINUITY) {
-			prefix = "^ ";     
+			commit_prefix = "^ ";     
 		} else if (commit->object.flags & BOUNDARY) {
-			prefix = "= ";
+			commit_prefix = "= ";
 		} 
         }        		
-	printf("%s%s", prefix, sha1_to_hex(commit->object.sha1));
+	printf("%s%s", commit_prefix, sha1_to_hex(commit->object.sha1));
 	if (show_parents) {
 		struct commit_list *parents = commit->parents;
 		while (parents) {
@@ -481,9 +481,9 @@ static void handle_one_commit(struct com
 int main(int argc, char **argv)
 {
 	struct commit_list *list = NULL;
-	const char *prefix = setup_git_directory();
 	int i, limited = 0;
 
+	setup_git_directory();
 	for (i = 1 ; i < argc; i++) {
 		int flags;
 		char *arg = argv[i];
@@ -511,9 +511,9 @@ int main(int argc, char **argv)
 			verbose_header = 1;
 			hdr_termination = '\n';
 			if (commit_format == CMIT_FMT_ONELINE)
-				prefix = "";
+				commit_prefix = "";
 			else
-				prefix = "commit ";
+				commit_prefix = "commit ";
 			continue;
 		}
 		if (!strncmp(arg, "--no-merges", 11)) {


-- 
Regards,
Pavel Roskin

                 reply	other threads:[~2005-08-24 21:59 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=1124920722.17909.9.camel@dv \
    --to=proski@gnu.org \
    --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 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.