Git development
 help / color / mirror / Atom feed
* Re: [PATCH] gitweb: merge boolean feature subroutines
From: Matt Kraai @ 2009-01-04 15:58 UTC (permalink / raw)
  To: demerphq; +Cc: Junio C Hamano, git
In-Reply-To: <9b18b3110901040341n5ff5fa09s878228131d11d2a6@mail.gmail.com>

On Sun, Jan 04, 2009 at 12:41:14PM +0100, demerphq wrote:
> Why execute more opcodes, and return a slightly surprising false, when
> you dont have to?
> 
> Is it really deep perl magic to do:
> 
>   return $val eq 'true';
> 
> instead of
> 
>   return $val eq 'true' ? 1 : 0;
> 
> or the actual use:
> 
>    if ($val eq 'true') {
>       return 1
>    } else {
>       return 0
>    }
>
> Isn't the former superior just on pure minimalism metrics? Theres less
> code to understand, less code to go wrong, and as a bonus it returns a
> true boolean. Isn't that just a win-win-win? I mean most perl
> programmers I know would instantly convert the latter two to the first
> just on the grounds that the first version is the clearest expression
> of the desired intent.

I agree that what you suggest is better than the alternatives you
present.  Unfortunately, none of them match the current behavior.
Here's the current code:

	if ($val eq 'true') {
		return 1;
	} elsif ($val eq 'false') {
		return 0;
	}

	return $_[0];

Is there a way to use the form you suggest while falling back to the
default if $val isn't set to 'true' or 'false'?

-- 
Matt                                                 http://ftbfs.org/

^ permalink raw reply

* [PATCH next] git-cherry usage: correct nesting of commit-ish options
From: Markus Heidelberg @ 2009-01-04 16:11 UTC (permalink / raw)
  To: gitster; +Cc: git


Signed-off-by: Markus Heidelberg <markus.heidelberg@web.de>
---

What is the preferred way to say the patch is against next? In the
subject like this?
Another question: should this patch be split up into two, one for
maint/master and another for next?

 Documentation/git-cherry.txt |    2 +-
 builtin-log.c                |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/git-cherry.txt b/Documentation/git-cherry.txt
index 556ea23..7deefda 100644
--- a/Documentation/git-cherry.txt
+++ b/Documentation/git-cherry.txt
@@ -7,7 +7,7 @@ git-cherry - Find commits not merged upstream
 
 SYNOPSIS
 --------
-'git cherry' [-v] [<upstream>] [<head>] [<limit>]
+'git cherry' [-v] [<upstream> [<head> [<limit>]]]
 
 DESCRIPTION
 -----------
diff --git a/builtin-log.c b/builtin-log.c
index 243f857..7e9616e 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -1071,7 +1071,7 @@ static int add_pending_commit(const char *arg, struct rev_info *revs, int flags)
 }
 
 static const char cherry_usage[] =
-"git cherry [-v] [<upstream>] [<head>] [<limit>]";
+"git cherry [-v] [<upstream> [<head> [<limit>]]]";
 int cmd_cherry(int argc, const char **argv, const char *prefix)
 {
 	struct rev_info revs;
-- 
1.6.1.35.g0c23

^ permalink raw reply related

* Re: [PATCH next] git-cherry usage: correct nesting of commit-ish options
From: Markus Heidelberg @ 2009-01-04 16:16 UTC (permalink / raw)
  To: gitster; +Cc: git
In-Reply-To: <200901041711.23026.markus.heidelberg@web.de>

Markus Heidelberg, 04.01.2009:
> 
> Signed-off-by: Markus Heidelberg <markus.heidelberg@web.de>
> ---
> 
> What is the preferred way to say the patch is against next? In the
> subject like this?
> Another question: should this patch be split up into two, one for
> maint/master and another for next?

For the second patch against next I meant it being based on origin/next
that already includes the extracted patch for maint/master.

^ permalink raw reply

* [PATCH] git.c: make autocorrected aliases work
From: Adeodato Simó @ 2009-01-04 17:08 UTC (permalink / raw)
  To: git, gitster; +Cc: Adeodato Simó

help_unknown_cmd() is able to autocorrect a command to an alias, and not
only to internal or external commands. However, main() was not passing the
autocorrected command through handle_alias(), hence it failed if it was an
alias.

This commit makes the autocorrected command go through handle_alias, once
handle_internal_command() and execv_dashed_external() have been tried. Since
this is done twice in main() now, moved that logic to a new run_argv()
function.

Signed-off-by: Adeodato Simó <dato@net.com.org.es>
---
 git.c |   46 +++++++++++++++++++++++++++-------------------
 1 files changed, 27 insertions(+), 19 deletions(-)

diff --git a/git.c b/git.c
index e0d9071..f443b4c 100644
--- a/git.c
+++ b/git.c
@@ -416,12 +416,35 @@ static void execv_dashed_external(const char **argv)
 	strbuf_release(&cmd);
 }
 
+static int run_argv(int *argcp, const char ***argv)
+{
+	int done_alias = 0;
+
+	while (1) {
+		/* See if it's an internal command */
+		handle_internal_command(*argcp, *argv);
+
+		/* .. then try the external ones */
+		execv_dashed_external(*argv);
+
+		/* It could be an alias -- this works around the insanity
+		 * of overriding "git log" with "git show" by having
+		 * alias.log = show
+		 */
+		if (done_alias || !handle_alias(argcp, argv))
+			break;
+		done_alias = 1;
+	}
+
+	return done_alias;
+}
+
 
 int main(int argc, const char **argv)
 {
 	const char *cmd = argv[0] && *argv[0] ? argv[0] : "git-help";
 	char *slash = (char *)cmd + strlen(cmd);
-	int done_alias = 0;
+	int was_alias = 0;
 
 	/*
 	 * Take the basename of argv[0] as the command
@@ -478,32 +501,17 @@ int main(int argc, const char **argv)
 	 */
 	setup_path();
 
-	while (1) {
-		/* See if it's an internal command */
-		handle_internal_command(argc, argv);
-
-		/* .. then try the external ones */
-		execv_dashed_external(argv);
-
-		/* It could be an alias -- this works around the insanity
-		 * of overriding "git log" with "git show" by having
-		 * alias.log = show
-		 */
-		if (done_alias || !handle_alias(&argc, &argv))
-			break;
-		done_alias = 1;
-	}
+	was_alias = run_argv(&argc, &argv);
 
 	if (errno == ENOENT) {
-		if (done_alias) {
+		if (was_alias) {
 			fprintf(stderr, "Expansion of alias '%s' failed; "
 				"'%s' is not a git-command\n",
 				cmd, argv[0]);
 			exit(1);
 		}
 		argv[0] = help_unknown_cmd(cmd);
-		handle_internal_command(argc, argv);
-		execv_dashed_external(argv);
+		run_argv(&argc, &argv);
 	}
 
 	fprintf(stderr, "Failed to run command '%s': %s\n",
-- 
1.6.1.62.g677ca

^ permalink raw reply related

* [PATCH v2] git.c: make autocorrected aliases work
From: Adeodato Simó @ 2009-01-04 17:12 UTC (permalink / raw)
  To: git, gitster; +Cc: Adeodato Simó
In-Reply-To: <1231088899-11943-1-git-send-email-dato@net.com.org.es>

help_unknown_cmd() is able to autocorrect a command to an alias, and not
only to internal or external commands. However, main() was not passing the
autocorrected command through handle_alias(), hence it failed if it was an
alias.

This commit makes the autocorrected command go through handle_alias(), once
handle_internal_command() and execv_dashed_external() have been tried. Since
this is done twice in main() now, moved that logic to a new run_argv()
function.

Also, print the same "Expansion of alias 'x' failed" message when the alias
was autocorrected, rather than a generic "Failed to run command 'x'".

Signed-off-by: Adeodato Simó <dato@net.com.org.es>
---

Here's a version of the patch that improves the error reporting, in case
this is desired. With the previous patch 'aliasx' -> 'alias' -> 'enoent'
printed "Failed to run command 'aliasx'", now it correctly prints
"Expansion of alias 'alias' failed: 'enoent' is not a git-command".

This is the incremental diff:

diff -u b/git.c b/git.c
--- b/git.c
+++ b/git.c
@@ -444,7 +444,6 @@
 {
 	const char *cmd = argv[0] && *argv[0] ? argv[0] : "git-help";
 	char *slash = (char *)cmd + strlen(cmd);
-	int was_alias = 0;
 
 	/*
 	 * Take the basename of argv[0] as the command
@@ -501,17 +500,23 @@
 	 */
 	setup_path();
 
-	was_alias = run_argv(&argc, &argv);
-
-	if (errno == ENOENT) {
+	while (1) {
+		static int done_help = 0;
+		static int was_alias = 0;
+		was_alias = run_argv(&argc, &argv);
+		if (errno != ENOENT)
+			break;
 		if (was_alias) {
 			fprintf(stderr, "Expansion of alias '%s' failed; "
 				"'%s' is not a git-command\n",
 				cmd, argv[0]);
 			exit(1);
 		}
-		argv[0] = help_unknown_cmd(cmd);
-		run_argv(&argc, &argv);
+		if (!done_help) {
+			cmd = argv[0] = help_unknown_cmd(cmd);
+			done_help = 1;
+		} else
+			break;
 	}
 
 	fprintf(stderr, "Failed to run command '%s': %s\n",

 git.c |   53 +++++++++++++++++++++++++++++++++--------------------
 1 files changed, 33 insertions(+), 20 deletions(-)

diff --git a/git.c b/git.c
index e0d9071..ee331aa 100644
--- a/git.c
+++ b/git.c
@@ -416,12 +416,34 @@ static void execv_dashed_external(const char **argv)
 	strbuf_release(&cmd);
 }
 
+static int run_argv(int *argcp, const char ***argv)
+{
+	int done_alias = 0;
+
+	while (1) {
+		/* See if it's an internal command */
+		handle_internal_command(*argcp, *argv);
+
+		/* .. then try the external ones */
+		execv_dashed_external(*argv);
+
+		/* It could be an alias -- this works around the insanity
+		 * of overriding "git log" with "git show" by having
+		 * alias.log = show
+		 */
+		if (done_alias || !handle_alias(argcp, argv))
+			break;
+		done_alias = 1;
+	}
+
+	return done_alias;
+}
+
 
 int main(int argc, const char **argv)
 {
 	const char *cmd = argv[0] && *argv[0] ? argv[0] : "git-help";
 	char *slash = (char *)cmd + strlen(cmd);
-	int done_alias = 0;
 
 	/*
 	 * Take the basename of argv[0] as the command
@@ -479,31 +501,22 @@ int main(int argc, const char **argv)
 	setup_path();
 
 	while (1) {
-		/* See if it's an internal command */
-		handle_internal_command(argc, argv);
-
-		/* .. then try the external ones */
-		execv_dashed_external(argv);
-
-		/* It could be an alias -- this works around the insanity
-		 * of overriding "git log" with "git show" by having
-		 * alias.log = show
-		 */
-		if (done_alias || !handle_alias(&argc, &argv))
+		static int done_help = 0;
+		static int was_alias = 0;
+		was_alias = run_argv(&argc, &argv);
+		if (errno != ENOENT)
 			break;
-		done_alias = 1;
-	}
-
-	if (errno == ENOENT) {
-		if (done_alias) {
+		if (was_alias) {
 			fprintf(stderr, "Expansion of alias '%s' failed; "
 				"'%s' is not a git-command\n",
 				cmd, argv[0]);
 			exit(1);
 		}
-		argv[0] = help_unknown_cmd(cmd);
-		handle_internal_command(argc, argv);
-		execv_dashed_external(argv);
+		if (!done_help) {
+			cmd = argv[0] = help_unknown_cmd(cmd);
+			done_help = 1;
+		} else
+			break;
 	}
 
 	fprintf(stderr, "Failed to run command '%s': %s\n",
-- 
1.6.1.62.g677ca

^ permalink raw reply related

* [PATCH v2 resend] git.c: make autocorrected aliases work
From: Adeodato Simó @ 2009-01-04 17:16 UTC (permalink / raw)
  To: git, gitster; +Cc: Adeodato Simó
In-Reply-To: <1231089128-12066-1-git-send-email-dato@net.com.org.es>

help_unknown_cmd() is able to autocorrect a command to an alias, and not
only to internal or external commands. However, main() was not passing the
autocorrected command through handle_alias(), hence it failed if it was an
alias.

This commit makes the autocorrected command go through handle_alias(), once
handle_internal_command() and execv_dashed_external() have been tried. Since
this is done twice in main() now, moved that logic to a new run_argv()
function.

Also, print the same "Expansion of alias 'x' failed" message when the alias
was autocorrected, rather than a generic "Failed to run command 'x'".

Signed-off-by: Adeodato Simó <dato@net.com.org.es>
---

Meh, I didn't realize that by attaching an incremental diff, I'd break
`git am`. Sorry about that.

 git.c |   53 +++++++++++++++++++++++++++++++++--------------------
 1 files changed, 33 insertions(+), 20 deletions(-)

diff --git a/git.c b/git.c
index e0d9071..ee331aa 100644
--- a/git.c
+++ b/git.c
@@ -416,12 +416,34 @@ static void execv_dashed_external(const char **argv)
 	strbuf_release(&cmd);
 }
 
+static int run_argv(int *argcp, const char ***argv)
+{
+	int done_alias = 0;
+
+	while (1) {
+		/* See if it's an internal command */
+		handle_internal_command(*argcp, *argv);
+
+		/* .. then try the external ones */
+		execv_dashed_external(*argv);
+
+		/* It could be an alias -- this works around the insanity
+		 * of overriding "git log" with "git show" by having
+		 * alias.log = show
+		 */
+		if (done_alias || !handle_alias(argcp, argv))
+			break;
+		done_alias = 1;
+	}
+
+	return done_alias;
+}
+
 
 int main(int argc, const char **argv)
 {
 	const char *cmd = argv[0] && *argv[0] ? argv[0] : "git-help";
 	char *slash = (char *)cmd + strlen(cmd);
-	int done_alias = 0;
 
 	/*
 	 * Take the basename of argv[0] as the command
@@ -479,31 +501,22 @@ int main(int argc, const char **argv)
 	setup_path();
 
 	while (1) {
-		/* See if it's an internal command */
-		handle_internal_command(argc, argv);
-
-		/* .. then try the external ones */
-		execv_dashed_external(argv);
-
-		/* It could be an alias -- this works around the insanity
-		 * of overriding "git log" with "git show" by having
-		 * alias.log = show
-		 */
-		if (done_alias || !handle_alias(&argc, &argv))
+		static int done_help = 0;
+		static int was_alias = 0;
+		was_alias = run_argv(&argc, &argv);
+		if (errno != ENOENT)
 			break;
-		done_alias = 1;
-	}
-
-	if (errno == ENOENT) {
-		if (done_alias) {
+		if (was_alias) {
 			fprintf(stderr, "Expansion of alias '%s' failed; "
 				"'%s' is not a git-command\n",
 				cmd, argv[0]);
 			exit(1);
 		}
-		argv[0] = help_unknown_cmd(cmd);
-		handle_internal_command(argc, argv);
-		execv_dashed_external(argv);
+		if (!done_help) {
+			cmd = argv[0] = help_unknown_cmd(cmd);
+			done_help = 1;
+		} else
+			break;
 	}
 
 	fprintf(stderr, "Failed to run command '%s': %s\n",
-- 
1.6.1.62.g677ca

^ permalink raw reply related

* Re: [PATCH v2 resend] git.c: make autocorrected aliases work
From: Alexander Potashev @ 2009-01-04 17:28 UTC (permalink / raw)
  To: Adeodato Simó; +Cc: git, gitster
In-Reply-To: <1231089361-12619-1-git-send-email-dato@net.com.org.es>

On 18:16 Sun 04 Jan     , Adeodato Simó wrote:
> help_unknown_cmd() is able to autocorrect a command to an alias, and not
> only to internal or external commands. However, main() was not passing the
> autocorrected command through handle_alias(), hence it failed if it was an
> alias.
> 
> This commit makes the autocorrected command go through handle_alias(), once
> handle_internal_command() and execv_dashed_external() have been tried. Since
> this is done twice in main() now, moved that logic to a new run_argv()
> function.
> 
> Also, print the same "Expansion of alias 'x' failed" message when the alias
> was autocorrected, rather than a generic "Failed to run command 'x'".
> 
> Signed-off-by: Adeodato Simó <dato@net.com.org.es>
> ---
> 
> Meh, I didn't realize that by attaching an incremental diff, I'd break
> `git am`. Sorry about that.
> 
>  git.c |   53 +++++++++++++++++++++++++++++++++--------------------
>  1 files changed, 33 insertions(+), 20 deletions(-)
> 
> diff --git a/git.c b/git.c
> index e0d9071..ee331aa 100644
> --- a/git.c
> +++ b/git.c
> @@ -416,12 +416,34 @@ static void execv_dashed_external(const char **argv)
>  	strbuf_release(&cmd);
>  }
>  
> +static int run_argv(int *argcp, const char ***argv)
> +{
> +	int done_alias = 0;
> +
> +	while (1) {
> +		/* See if it's an internal command */
> +		handle_internal_command(*argcp, *argv);
> +
> +		/* .. then try the external ones */
> +		execv_dashed_external(*argv);
> +
> +		/* It could be an alias -- this works around the insanity
> +		 * of overriding "git log" with "git show" by having
> +		 * alias.log = show
> +		 */
> +		if (done_alias || !handle_alias(argcp, argv))
> +			break;
> +		done_alias = 1;
> +	}
> +
> +	return done_alias;
> +}
> +
>  
>  int main(int argc, const char **argv)
>  {
>  	const char *cmd = argv[0] && *argv[0] ? argv[0] : "git-help";
>  	char *slash = (char *)cmd + strlen(cmd);
> -	int done_alias = 0;
>  
>  	/*
>  	 * Take the basename of argv[0] as the command
> @@ -479,31 +501,22 @@ int main(int argc, const char **argv)
>  	setup_path();
>  
>  	while (1) {
> -		/* See if it's an internal command */
> -		handle_internal_command(argc, argv);
> -
> -		/* .. then try the external ones */
> -		execv_dashed_external(argv);
> -
> -		/* It could be an alias -- this works around the insanity
> -		 * of overriding "git log" with "git show" by having
> -		 * alias.log = show
> -		 */
> -		if (done_alias || !handle_alias(&argc, &argv))
> +		static int done_help = 0;
> +		static int was_alias = 0;
> +		was_alias = run_argv(&argc, &argv);
> +		if (errno != ENOENT)
>  			break;
> -		done_alias = 1;
> -	}
> -
> -	if (errno == ENOENT) {
> -		if (done_alias) {
> +		if (was_alias) {
>  			fprintf(stderr, "Expansion of alias '%s' failed; "
>  				"'%s' is not a git-command\n",
>  				cmd, argv[0]);
>  			exit(1);

Why not using 'die' here?

		die("Expansion of alias '%s' failed;
			'%s' is not a git-command",
  			cmd, argv[0]);

DISCLAIMER: I have never used git's 'die'

>  		}
> -		argv[0] = help_unknown_cmd(cmd);
> -		handle_internal_command(argc, argv);
> -		execv_dashed_external(argv);
> +		if (!done_help) {
> +			cmd = argv[0] = help_unknown_cmd(cmd);
> +			done_help = 1;
> +		} else
> +			break;
>  	}
>  
>  	fprintf(stderr, "Failed to run command '%s': %s\n",
> -- 
> 1.6.1.62.g677ca

^ permalink raw reply

* Re: [PATCH next] git-cherry usage: correct nesting of commit-ish options
From: Miklos Vajna @ 2009-01-04 17:35 UTC (permalink / raw)
  To: Markus Heidelberg; +Cc: gitster, git
In-Reply-To: <200901041711.23026.markus.heidelberg@web.de>

[-- Attachment #1: Type: text/plain, Size: 493 bytes --]

On Sun, Jan 04, 2009 at 05:11:22PM +0100, Markus Heidelberg <markus.heidelberg@web.de> wrote:
> Another question: should this patch be split up into two, one for
> maint/master and another for next?

AFAIK sending patches against next is not preferred at all. You should
send your patches against master, or - if you have a strong reason - on
top of a given topic branch.

In the later case I just use to write "This applies on top of
'xx/foo-bar'." between the three dashes and the diffstat.

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply

* Re: git-branch --print-current
From: Arnaud Lacombe @ 2009-01-04 17:55 UTC (permalink / raw)
  To: demerphq; +Cc: Karl Chen, Git mailing list
In-Reply-To: <9b18b3110901040449x65c63d6fo3d9fec9ddd5670c@mail.gmail.com>

Hi,

On Sun, Jan 4, 2009 at 7:49 AM, demerphq <demerphq@gmail.com> wrote:
> 2009/1/4 Karl Chen <quarl@cs.berkeley.edu>:
>> On 2009-01-04 00:21 PST, Arnaud Lacombe writes:
>>    Arnaud> $ git branch | awk '/^\*/ {print $2}'
>>
>> Yet another addition to the list of ways to pipeline it, this one
>> probably the shortest :)
>
> Unfortunately it doesnt work well when you arent on a branch:
>
>  $ git branch | awk '/^\*/ {print $2}'
>  (no
>
> So far two apparently expert git people have given solutions to this
> problem that don't elegantly handle the edge cases.
>
my bad:
$ git branch | awk '/^\*/ {print substr($0, 3)}'

 - Arnaud

^ permalink raw reply

* Re: [PATCH next] git-cherry usage: correct nesting of commit-ish options
From: Markus Heidelberg @ 2009-01-04 18:01 UTC (permalink / raw)
  To: Miklos Vajna; +Cc: gitster, git
In-Reply-To: <20090104173559.GG21154@genesis.frugalware.org>

Miklos Vajna, 04.01.2009:
> On Sun, Jan 04, 2009 at 05:11:22PM +0100, Markus Heidelberg <markus.heidelberg@web.de> wrote:
> > Another question: should this patch be split up into two, one for
> > maint/master and another for next?
> 
> AFAIK sending patches against next is not preferred at all.

>From Documentation/SubmittingPatches:

    If you are preparing a work based on "next" branch,
    that is fine, but please mark it as such.

I guess the only reason is a required dependency not available in
'master'.

> You should
> send your patches against master, or - if you have a strong reason - on
> top of a given topic branch.

This patch depends on a commit in 'next'. But right, I could have
mentioned that it's against 'mh/cherry-default' as Junio suggested a few
days ago.

^ permalink raw reply

* Re: git-branch --print-current
From: Adeodato Simó @ 2009-01-04 18:02 UTC (permalink / raw)
  To: Karl Chen; +Cc: Arnaud Lacombe, Git mailing list
In-Reply-To: <quack.20090104T0440.lthbpun1bxo@roar.cs.berkeley.edu>

* Karl Chen [Sun, 04 Jan 2009 04:40:51 -0800]:

>     Arnaud> $ git branch | awk '/^\*/ {print $2}'

> Yet another addition to the list of ways to pipeline it, this one
> probably the shortest :)

Heh, if we're playing golf:

              $ git branch | sed -n 's/^\* //p'

-- 
Adeodato Simó                                     dato at net.com.org.es
Debian Developer                                  adeodato at debian.org
 
Que no te vendan amor sin espinas
                -- Joaquín Sabina, Noches de boda

^ permalink raw reply

* [PATCH] remove trailing '\n's in 'die' macros
From: Alexander Potashev @ 2009-01-04 18:38 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List, Alexander Potashev

'\n's in the end of format strings given to 'die' are redundant because
die uses error reporting function like 'static void report(const char
*prefix, const char *err, va_list params)' which always adds a '\n'.

Signed-off-by: Alexander Potashev <aspotashev@gmail.com>
---
 builtin-cat-file.c        |    2 +-
 builtin-clone.c           |   14 +++++++-------
 builtin-fetch.c           |    2 +-
 builtin-init-db.c         |    2 +-
 builtin-log.c             |    2 +-
 builtin-mailinfo.c        |    2 +-
 builtin-merge-recursive.c |    2 +-
 builtin-update-index.c    |    2 +-
 connect.c                 |    2 +-
 daemon.c                  |    2 +-
 diff.c                    |    2 +-
 git.c                     |    2 +-
 grep.c                    |    2 +-
 imap-send.c               |    6 +++---
 index-pack.c              |    2 +-
 pack-redundant.c          |    8 ++++----
 16 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/builtin-cat-file.c b/builtin-cat-file.c
index 30d00a6..8fad19d 100644
--- a/builtin-cat-file.c
+++ b/builtin-cat-file.c
@@ -137,7 +137,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
 		break;
 
 	default:
-		die("git cat-file: unknown option: %s\n", exp_type);
+		die("git cat-file: unknown option: %s", exp_type);
 	}
 
 	if (!buf)
diff --git a/builtin-clone.c b/builtin-clone.c
index 2feac9c..f1a1a0c 100644
--- a/builtin-clone.c
+++ b/builtin-clone.c
@@ -192,15 +192,15 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest)
 
 	dir = opendir(src->buf);
 	if (!dir)
-		die("failed to open %s\n", src->buf);
+		die("failed to open %s", src->buf);
 
 	if (mkdir(dest->buf, 0777)) {
 		if (errno != EEXIST)
-			die("failed to create directory %s\n", dest->buf);
+			die("failed to create directory %s", dest->buf);
 		else if (stat(dest->buf, &buf))
-			die("failed to stat %s\n", dest->buf);
+			die("failed to stat %s", dest->buf);
 		else if (!S_ISDIR(buf.st_mode))
-			die("%s exists and is not a directory\n", dest->buf);
+			die("%s exists and is not a directory", dest->buf);
 	}
 
 	strbuf_addch(src, '/');
@@ -224,16 +224,16 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest)
 		}
 
 		if (unlink(dest->buf) && errno != ENOENT)
-			die("failed to unlink %s\n", dest->buf);
+			die("failed to unlink %s", dest->buf);
 		if (!option_no_hardlinks) {
 			if (!link(src->buf, dest->buf))
 				continue;
 			if (option_local)
-				die("failed to create link %s\n", dest->buf);
+				die("failed to create link %s", dest->buf);
 			option_no_hardlinks = 1;
 		}
 		if (copy_file(dest->buf, src->buf, 0666))
-			die("failed to copy file to %s\n", dest->buf);
+			die("failed to copy file to %s", dest->buf);
 	}
 	closedir(dir);
 }
diff --git a/builtin-fetch.c b/builtin-fetch.c
index 7568163..de6f307 100644
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
@@ -607,7 +607,7 @@ static void set_option(const char *name, const char *value)
 {
 	int r = transport_set_option(transport, name, value);
 	if (r < 0)
-		die("Option \"%s\" value \"%s\" is not valid for %s\n",
+		die("Option \"%s\" value \"%s\" is not valid for %s",
 			name, value, transport->url);
 	if (r > 0)
 		warning("Option \"%s\" is ignored for %s\n",
diff --git a/builtin-init-db.c b/builtin-init-db.c
index d30c3fe..ee3911f 100644
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
@@ -29,7 +29,7 @@ static void safe_create_dir(const char *dir, int share)
 		}
 	}
 	else if (share && adjust_shared_perm(dir))
-		die("Could not make %s writable by group\n", dir);
+		die("Could not make %s writable by group", dir);
 }
 
 static void copy_templates_1(char *path, int baselen,
diff --git a/builtin-log.c b/builtin-log.c
index 99d1137..1fc1ae0 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -824,7 +824,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 			committer = git_committer_info(IDENT_ERROR_ON_NO_NAME);
 			endpos = strchr(committer, '>');
 			if (!endpos)
-				die("bogus committer info %s\n", committer);
+				die("bogus committer info %s", committer);
 			add_signoff = xmemdupz(committer, endpos - committer + 1);
 		}
 		else if (!strcmp(argv[i], "--attach")) {
diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
index e890f7a..f7c8c08 100644
--- a/builtin-mailinfo.c
+++ b/builtin-mailinfo.c
@@ -494,7 +494,7 @@ static void convert_to_utf8(struct strbuf *line, const char *charset)
 		return;
 	out = reencode_string(line->buf, metainfo_charset, charset);
 	if (!out)
-		die("cannot convert from %s to %s\n",
+		die("cannot convert from %s to %s",
 		    charset, metainfo_charset);
 	strbuf_attach(line, out, strlen(out), strlen(out));
 }
diff --git a/builtin-merge-recursive.c b/builtin-merge-recursive.c
index 6b534c1..703045b 100644
--- a/builtin-merge-recursive.c
+++ b/builtin-merge-recursive.c
@@ -33,7 +33,7 @@ int cmd_merge_recursive(int argc, const char **argv, const char *prefix)
 	}
 
 	if (argc < 4)
-		die("Usage: %s <base>... -- <head> <remote> ...\n", argv[0]);
+		die("Usage: %s <base>... -- <head> <remote> ...", argv[0]);
 
 	for (i = 1; i < argc; ++i) {
 		if (!strcmp(argv[i], "--"))
diff --git a/builtin-update-index.c b/builtin-update-index.c
index 65d5775..5604977 100644
--- a/builtin-update-index.c
+++ b/builtin-update-index.c
@@ -486,7 +486,7 @@ static int unresolve_one(const char *path)
 static void read_head_pointers(void)
 {
 	if (read_ref("HEAD", head_sha1))
-		die("No HEAD -- no initial commit yet?\n");
+		die("No HEAD -- no initial commit yet?");
 	if (read_ref("MERGE_HEAD", merge_head_sha1)) {
 		fprintf(stderr, "Not in the middle of a merge.\n");
 		exit(0);
diff --git a/connect.c b/connect.c
index 2f55ad2..2f23ab3 100644
--- a/connect.c
+++ b/connect.c
@@ -315,7 +315,7 @@ static int git_tcp_connect_sock(char *host, int flags)
 		/* Not numeric */
 		struct servent *se = getservbyname(port,"tcp");
 		if ( !se )
-			die("Unknown port %s\n", port);
+			die("Unknown port %s", port);
 		nport = se->s_port;
 	}
 
diff --git a/daemon.c b/daemon.c
index 60bf6c7..540700e 100644
--- a/daemon.c
+++ b/daemon.c
@@ -716,7 +716,7 @@ static int socksetup(char *listen_addr, int listen_port, int **socklist_p)
 
 	gai = getaddrinfo(listen_addr, pbuf, &hints, &ai0);
 	if (gai)
-		die("getaddrinfo() failed: %s\n", gai_strerror(gai));
+		die("getaddrinfo() failed: %s", gai_strerror(gai));
 
 	for (ai = ai0; ai; ai = ai->ai_next) {
 		int sockfd;
diff --git a/diff.c b/diff.c
index 0484601..c159a5f 100644
--- a/diff.c
+++ b/diff.c
@@ -2039,7 +2039,7 @@ static void diff_fill_sha1_info(struct diff_filespec *one)
 			if (lstat(one->path, &st) < 0)
 				die("stat %s", one->path);
 			if (index_path(one->sha1, one->path, &st, 0))
-				die("cannot hash %s\n", one->path);
+				die("cannot hash %s", one->path);
 		}
 	}
 	else
diff --git a/git.c b/git.c
index e0d9071..a53e24f 100644
--- a/git.c
+++ b/git.c
@@ -158,7 +158,7 @@ static int handle_alias(int *argcp, const char ***argv)
 			if (ret >= 0 && WIFEXITED(ret) &&
 			    WEXITSTATUS(ret) != 127)
 				exit(WEXITSTATUS(ret));
-			die("Failed to run '%s' when expanding alias '%s'\n",
+			die("Failed to run '%s' when expanding alias '%s'",
 			    alias_string + 1, alias_command);
 		}
 		count = split_cmdline(alias_string, &new_argv);
diff --git a/grep.c b/grep.c
index 600f69f..49e9319 100644
--- a/grep.c
+++ b/grep.c
@@ -395,7 +395,7 @@ static int match_expr_eval(struct grep_opt *o,
 		h |= match_expr_eval(o, x->u.binary.right, bol, eol, ctx, 1);
 		break;
 	default:
-		die("Unexpected node type (internal error) %d\n", x->node);
+		die("Unexpected node type (internal error) %d", x->node);
 	}
 	if (collect_hits)
 		x->hit |= h;
diff --git a/imap-send.c b/imap-send.c
index 3703dbd..c3fa0df 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -115,9 +115,9 @@ static int nfvasprintf(char **strp, const char *fmt, va_list ap)
 
 	len = vsnprintf(tmp, sizeof(tmp), fmt, ap);
 	if (len < 0)
-		die("Fatal: Out of memory\n");
+		die("Fatal: Out of memory");
 	if (len >= sizeof(tmp))
-		die("imap command overflow !\n");
+		die("imap command overflow!");
 	*strp = xmemdupz(tmp, len);
 	return len;
 }
@@ -482,7 +482,7 @@ static int nfsnprintf(char *buf, int blen, const char *fmt, ...)
 
 	va_start(va, fmt);
 	if (blen <= 0 || (unsigned)(ret = vsnprintf(buf, blen, fmt, va)) >= (unsigned)blen)
-		die("Fatal: buffer too small. Please report a bug.\n");
+		die("Fatal: buffer too small. Please report a bug.");
 	va_end(va);
 	return ret;
 }
diff --git a/index-pack.c b/index-pack.c
index 60ed41a..2931511 100644
--- a/index-pack.c
+++ b/index-pack.c
@@ -178,7 +178,7 @@ static char *open_pack_file(char *pack_name)
 		} else
 			output_fd = open(pack_name, O_CREAT|O_EXCL|O_RDWR, 0600);
 		if (output_fd < 0)
-			die("unable to create %s: %s\n", pack_name, strerror(errno));
+			die("unable to create %s: %s", pack_name, strerror(errno));
 		pack_fd = output_fd;
 	} else {
 		input_fd = open(pack_name, O_RDONLY);
diff --git a/pack-redundant.c b/pack-redundant.c
index 25b81a4..e93eb96 100644
--- a/pack-redundant.c
+++ b/pack-redundant.c
@@ -463,7 +463,7 @@ static void minimize(struct pack_list **min)
 		pll_free(perm_all);
 	}
 	if (perm_ok == NULL)
-		die("Internal error: No complete sets found!\n");
+		die("Internal error: No complete sets found!");
 
 	/* find the permutation with the smallest size */
 	perm = perm_ok;
@@ -573,14 +573,14 @@ static struct pack_list * add_pack_file(char *filename)
 	struct packed_git *p = packed_git;
 
 	if (strlen(filename) < 40)
-		die("Bad pack filename: %s\n", filename);
+		die("Bad pack filename: %s", filename);
 
 	while (p) {
 		if (strstr(p->pack_name, filename))
 			return add_pack(p);
 		p = p->next;
 	}
-	die("Filename %s not found in packed_git\n", filename);
+	die("Filename %s not found in packed_git", filename);
 }
 
 static void load_all(void)
@@ -636,7 +636,7 @@ int main(int argc, char **argv)
 			add_pack_file(*(argv + i++));
 
 	if (local_packs == NULL)
-		die("Zero packs found!\n");
+		die("Zero packs found!");
 
 	load_all_objects();
 
-- 
1.6.0.6

^ permalink raw reply related

* [PATCH] Replace deprecated dashed git commands in usage
From: Alexander Potashev @ 2009-01-04 18:39 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List, Alexander Potashev

Signed-off-by: Alexander Potashev <aspotashev@gmail.com>
---
 builtin-merge.c        |    4 ++--
 builtin-receive-pack.c |    2 +-
 builtin-verify-pack.c  |    2 +-
 merge-index.c          |    2 +-
 merge-tree.c           |    2 +-
 mktag.c                |    2 +-
 mktree.c               |    2 +-
 patch-id.c             |    2 +-
 unpack-file.c          |    2 +-
 upload-pack.c          |    2 +-
 10 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/builtin-merge.c b/builtin-merge.c
index cf86975..261a92e 100644
--- a/builtin-merge.c
+++ b/builtin-merge.c
@@ -36,8 +36,8 @@ struct strategy {
 };
 
 static const char * const builtin_merge_usage[] = {
-	"git-merge [options] <remote>...",
-	"git-merge [options] <msg> HEAD <remote>",
+	"git merge [options] <remote>...",
+	"git merge [options] <msg> HEAD <remote>",
 	NULL
 };
 
diff --git a/builtin-receive-pack.c b/builtin-receive-pack.c
index db67c31..929df19 100644
--- a/builtin-receive-pack.c
+++ b/builtin-receive-pack.c
@@ -9,7 +9,7 @@
 #include "remote.h"
 #include "transport.h"
 
-static const char receive_pack_usage[] = "git-receive-pack <git-dir>";
+static const char receive_pack_usage[] = "git receive-pack <git-dir>";
 
 enum deny_action {
 	DENY_IGNORE,
diff --git a/builtin-verify-pack.c b/builtin-verify-pack.c
index 25a29f1..0ee0a9a 100644
--- a/builtin-verify-pack.c
+++ b/builtin-verify-pack.c
@@ -107,7 +107,7 @@ static int verify_one_pack(const char *path, int verbose)
 	return err;
 }
 
-static const char verify_pack_usage[] = "git-verify-pack [-v] <pack>...";
+static const char verify_pack_usage[] = "git verify-pack [-v] <pack>...";
 
 int cmd_verify_pack(int argc, const char **argv, const char *prefix)
 {
diff --git a/merge-index.c b/merge-index.c
index 7827e87..a6e1921 100644
--- a/merge-index.c
+++ b/merge-index.c
@@ -91,7 +91,7 @@ int main(int argc, char **argv)
 	signal(SIGCHLD, SIG_DFL);
 
 	if (argc < 3)
-		usage("git-merge-index [-o] [-q] <merge-program> (-a | [--] <filename>*)");
+		usage("git merge-index [-o] [-q] <merge-program> (-a | [--] <filename>*)");
 
 	setup_git_directory();
 	read_cache();
diff --git a/merge-tree.c b/merge-tree.c
index 2d1413e..4f567a4 100644
--- a/merge-tree.c
+++ b/merge-tree.c
@@ -3,7 +3,7 @@
 #include "xdiff-interface.h"
 #include "blob.h"
 
-static const char merge_tree_usage[] = "git-merge-tree <base-tree> <branch1> <branch2>";
+static const char merge_tree_usage[] = "git merge-tree <base-tree> <branch1> <branch2>";
 static int resolve_directories = 1;
 
 struct merge_list {
diff --git a/mktag.c b/mktag.c
index ba3d495..9a93ce2 100644
--- a/mktag.c
+++ b/mktag.c
@@ -157,7 +157,7 @@ int main(int argc, char **argv)
 	unsigned char result_sha1[20];
 
 	if (argc != 1)
-		usage("git-mktag < signaturefile");
+		usage("git mktag < signaturefile");
 
 	setup_git_directory();
 
diff --git a/mktree.c b/mktree.c
index 514fd9b..0f98bc7 100644
--- a/mktree.c
+++ b/mktree.c
@@ -61,7 +61,7 @@ static void write_tree(unsigned char *sha1)
 	write_sha1_file(buf.buf, buf.len, tree_type, sha1);
 }
 
-static const char mktree_usage[] = "git-mktree [-z]";
+static const char mktree_usage[] = "git mktree [-z]";
 
 int main(int ac, char **av)
 {
diff --git a/patch-id.c b/patch-id.c
index 871f1d2..429c3a2 100644
--- a/patch-id.c
+++ b/patch-id.c
@@ -72,7 +72,7 @@ static void generate_id_list(void)
 	flush_current_id(patchlen, sha1, &ctx);
 }
 
-static const char patch_id_usage[] = "git-patch-id < patch";
+static const char patch_id_usage[] = "git patch-id < patch";
 
 int main(int argc, char **argv)
 {
diff --git a/unpack-file.c b/unpack-file.c
index bcdc8bb..75c5f51 100644
--- a/unpack-file.c
+++ b/unpack-file.c
@@ -26,7 +26,7 @@ int main(int argc, char **argv)
 	unsigned char sha1[20];
 
 	if (argc != 2)
-		usage("git-unpack-file <sha1>");
+		usage("git unpack-file <sha1>");
 	if (get_sha1(argv[1], sha1))
 		die("Not a valid object name %s", argv[1]);
 
diff --git a/upload-pack.c b/upload-pack.c
index e5adbc0..24ab49d 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -11,7 +11,7 @@
 #include "list-objects.h"
 #include "run-command.h"
 
-static const char upload_pack_usage[] = "git-upload-pack [--strict] [--timeout=nn] <dir>";
+static const char upload_pack_usage[] = "git upload-pack [--strict] [--timeout=nn] <dir>";
 
 /* bits #0..7 in revision.h, #8..10 in commit.c */
 #define THEY_HAVE	(1u << 11)
-- 
1.6.0.6

^ permalink raw reply related

* Re: [PATCH rfc v2] git-sh-setup: Fix scripts whose PWD is a symlink to a work-dir on OS X
From: Marcel Koeppen @ 2009-01-04 18:49 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Marcel M. Cary, git, jnareb, ae, j.sixt
In-Reply-To: <7v8wps59ss.fsf@gitster.siamese.dyndns.org>


Am 03.01.2009 um 23:01 schrieb Junio C Hamano:

> "Marcel M. Cary" <marcel@oak.homeunix.org> writes:
>
>> I sent the first rev of this patch to just Brian.  It didn't have
>> either of the unit test changes.  He said it fixed all but t2300.3,
>> where cd_to_toplevel doesn't actually "cd", so I made the same change
>> to the unit test itself.  Can someone with OS X try running the test
>> suite with v2 of this patch?  I don't have OS X readily available.
>
> I think I saw a success report on the list.  Care to resend it with
> Sign-off (by you) and
>
> 	Tested-by: tester <test@er.xz> (on PLATFORM)
>
> lines as you see necessary for application?
>
> Thanks.


Hi,

please add

Tested-by: Marcel Koeppen <git-dev@marzelpan.de> (on Mac OS X 10.5.6)

	Marcel

^ permalink raw reply

* Re: [PATCH] cvsserver: add option to configure commit message
From: Junio C Hamano @ 2009-01-04 19:20 UTC (permalink / raw)
  To: Lars Noschinski; +Cc: Fabian Emmes, git
In-Reply-To: <20090104112318.GB7732@lars.home.noschinski.de>

Lars Noschinski <lars@public.noschinski.de> writes:

> It is "Fabian and Lars developed it and Fabian is the one who mailed it
> for inclusion". We could just leave off the second S-o-b line, if this
> is less irritating?

Oh, no, no.  It is not an irritation at all.  I found it unusual and
that's all.

Thanks.

^ permalink raw reply

* Re: git-rev-parse --symbolic-abbrev-name
From: Junio C Hamano @ 2009-01-04 19:36 UTC (permalink / raw)
  To: Karl Chen; +Cc: Miklos Vajna, David Aguilar, Git mailing list
In-Reply-To: <quack.20090104T0434.lthfxjz1c8x_-_@roar.cs.berkeley.edu>

Karl Chen <quarl@cs.berkeley.edu> writes:

> ... you really think "branchfoo" instead of
> "refs/heads/branchfoo" is a narrow special case?

Of course it is narrower.  There are namespaces other than "heads" under
refs, and not everybody is interested in branches.

> obviously all those people posting on blogs don't know about it :)

Yes, and that won't be helped by any new option to the plumbing.

The above two does not necessarily mean that it is useless to add a new
option to help a narrow special case that is common, though.

^ permalink raw reply

* Re: Git-1.6.0.2-preview20080923
From: Sebastian Schuberth @ 2009-01-04 19:55 UTC (permalink / raw)
  To: Peter Krefting; +Cc: msysgit, Steffen Prohaska, Git Mailing List
In-Reply-To: <Pine.LNX.4.64.0809261026000.10516@ds9.cixit.se>

> > I updated the installer to Git-1.6.0.2-preview20080923.
>
> One issue that I see is that the installer does not seem to clean up
> the previously installed version on upgrade. I installed over the
> previous version to C:\Git, and I now have two git-add.exe files:
>
>  Directory of c:\git\bin
>
> 2008-06-22  18:41           925 184 git-add.exe
>
>  Directory of c:\git\libexec\git-core
>
> 2008-09-23  07:55           881 664 git-add.exe

I'm currently testing a patch that fixes this.

--
Sebastian

^ permalink raw reply

* Re: [PATCH 2/3] unpack-trees: fix path search bug in verify_absent
From: Clemens Buchacher @ 2009-01-04 20:01 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Johannes Schindelin, git
In-Reply-To: <7vtz8fz8yd.fsf@gitster.siamese.dyndns.org>

Hi,

On Sun, Jan 04, 2009 at 02:01:14AM -0800, Junio C Hamano wrote:
>     The function's purpose is ....  Before entering the loop to count the
>     number of entries to skip, this check to detect if we do not even have
>     to count appears.  When this check triggers, we know we do not want to
>     skip anything, and returning constant 0 is much clearer than returning
>     a variable cnt that was initialized to 0 near the beginning of the
>     function; we haven't even started using it to count yet.
> 
> But the point is, if that is the reason the author thinks it is an
> improvement, that probably needs to be stated.

If you want to check the validity of the patch you have to view it in
context anyways. Compared to understanding the change to the code, it takes
much longer to parse and understand the above paragraph _plus_ verify its
agreement with the code. I think you will agree that there is a limit to the
amount of documentation that's still useful.

My estimate of this limit is apparently much lower than what is expected by
the main contributors to this project. I respect that and I will try not to
waste your time any further.

What's sad, however, is that we are now discussing style and commenting
issues of a line of code, which, as by my analysis of [PATCH 3/3] never
actually gets executed in the first place. I would have been much more
curious about your comments on that.

Best regards,
Clemens

^ permalink raw reply

* Re: git-rev-parse --symbolic-abbrev-name
From: Arnaud Lacombe @ 2009-01-04 20:23 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Karl Chen, Miklos Vajna, David Aguilar, Git mailing list
In-Reply-To: <7v63kuyibi.fsf@gitster.siamese.dyndns.org>

[-- Attachment #1: Type: text/plain, Size: 1367 bytes --]

Hi,

On Sun, Jan 4, 2009 at 2:36 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Karl Chen <quarl@cs.berkeley.edu> writes:
>
>> ... you really think "branchfoo" instead of
>> "refs/heads/branchfoo" is a narrow special case?
>
> Of course it is narrower.  There are namespaces other than "heads" under
> refs, and not everybody is interested in branches.
>
>> obviously all those people posting on blogs don't know about it :)
>
> Yes, and that won't be helped by any new option to the plumbing.
>
> The above two does not necessarily mean that it is useless to add a new
> option to help a narrow special case that is common, though.
>
You'll find hereafter two patches which implements this in
git-symbolic-ref and git-rev-parse. Feel free to choose the one you
find the best. If you choose to integrate one of these, tells me and
I'll do a proper documentation bits and patch submission.

Sample output:

~/git/% ./git-rev-parse --symbolic-short-name HEAD
master
~/git/% ./git-symbolic-ref -a HEAD
master
~/git/% git checkout v1.6.1
~/git/% ./git-rev-parse --symbolic-short-name HEAD
HEAD
~/git/% ./git-symbolic-ref -a HEAD
fatal: ref HEAD is not a symbolic ref
~/git/% ./git-symbolic-ref -qa HEAD
~/git/%

Thanks in advance,

 - Arnaud

ps: I choose --symbolic-short-name as the opposite of
--symbolic-full-name for consistency.
ps2: sorry for the bogus mime-type

[-- Attachment #2: git-rev-parse_symbolic-short-name.diff --]
[-- Type: application/octet-stream, Size: 1507 bytes --]

diff --git a/builtin-rev-parse.c b/builtin-rev-parse.c
index 81d5a6f..70f4a33 100644
--- a/builtin-rev-parse.c
+++ b/builtin-rev-parse.c
@@ -24,6 +24,7 @@ static int show_type = NORMAL;
 
 #define SHOW_SYMBOLIC_ASIS 1
 #define SHOW_SYMBOLIC_FULL 2
+#define SHOW_SYMBOLIC_SHORT 3
 static int symbolic;
 static int abbrev;
 static int output_sq;
@@ -110,7 +111,10 @@ static void show_rev(int type, const unsigned char *sha1, const char *name)
 	def = NULL;
 
 	if (symbolic && name) {
-		if (symbolic == SHOW_SYMBOLIC_FULL) {
+		switch (symbolic) {
+		case SHOW_SYMBOLIC_FULL:
+		case SHOW_SYMBOLIC_SHORT:
+			{
 			unsigned char discard[20];
 			char *full;
 
@@ -125,13 +129,20 @@ static void show_rev(int type, const unsigned char *sha1, const char *name)
 				 */
 				break;
 			case 1: /* happy */
+				if (symbolic == SHOW_SYMBOLIC_SHORT) {
+					char *p;
+					p = strrchr(full, (int)'/');
+					if (p != NULL)
+						full = p + 1;
+				}
 				show_with_type(type, full);
 				break;
 			default: /* ambiguous */
 				error("refname '%s' is ambiguous", name);
-				break;
 			}
-		} else {
+			break;
+			}
+		default:
 			show_with_type(type, name);
 		}
 	}
@@ -506,6 +517,10 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
 				symbolic = SHOW_SYMBOLIC_FULL;
 				continue;
 			}
+			if (!strcmp(arg, "--symbolic-short-name")) {
+				symbolic = SHOW_SYMBOLIC_SHORT;
+				continue;
+			}
 			if (!strcmp(arg, "--all")) {
 				for_each_ref(show_reference, NULL);
 				continue;

[-- Attachment #3: git-symbolic-refs_abbrev-name.diff --]
[-- Type: application/octet-stream, Size: 1300 bytes --]

diff --git a/builtin-symbolic-ref.c b/builtin-symbolic-ref.c
index bfc78bb..ff9ff46 100644
--- a/builtin-symbolic-ref.c
+++ b/builtin-symbolic-ref.c
@@ -8,7 +8,7 @@ static const char * const git_symbolic_ref_usage[] = {
 	NULL
 };
 
-static void check_symref(const char *HEAD, int quiet)
+static void check_symref(const char *HEAD, int quiet, int abbrev)
 {
 	unsigned char sha1[20];
 	int flag;
@@ -22,15 +22,21 @@ static void check_symref(const char *HEAD, int quiet)
 		else
 			exit(1);
 	}
+	if (abbrev) {
+		char *p = strrchr(refs_heads_master, (int)'/');
+		if (p != NULL)
+			refs_heads_master = p + 1;
+	}
 	puts(refs_heads_master);
 }
 
 int cmd_symbolic_ref(int argc, const char **argv, const char *prefix)
 {
-	int quiet = 0;
+	int abbrev = 0, quiet = 0;
 	const char *msg = NULL;
 	struct option options[] = {
 		OPT__QUIET(&quiet),
+		OPT_BOOLEAN('a', NULL, &abbrev, "show only branch name"),
 		OPT_STRING('m', NULL, &msg, "reason", "reason of the update"),
 		OPT_END(),
 	};
@@ -41,7 +47,7 @@ int cmd_symbolic_ref(int argc, const char **argv, const char *prefix)
 		die("Refusing to perform update with empty message");
 	switch (argc) {
 	case 1:
-		check_symref(argv[0], quiet);
+		check_symref(argv[0], quiet, abbrev);
 		break;
 	case 2:
 		create_symref(argv[0], argv[1], msg);

^ permalink raw reply related

* Re: [PATCH] gitweb: merge boolean feature subroutines
From: Junio C Hamano @ 2009-01-04 21:25 UTC (permalink / raw)
  To: demerphq; +Cc: Matt Kraai, git
In-Reply-To: <9b18b3110901040341n5ff5fa09s878228131d11d2a6@mail.gmail.com>

demerphq <demerphq@gmail.com> writes:

> Is it really deep perl magic to do:
>
>   return $val eq 'true';
>
> instead of
>
>   return $val eq 'true' ? 1 : 0;

No, neither are magicky.  But your argument to favor the former over the
latter that goes down to XS level was all about deep magic, and you wrote
yourself:

> ... It is not a good idea to use 0 as a replacement for perls false, as
> the two have different behaviour.

My point is that any caller that cares about the differences of "Perl's
true false" and 0 when talking about a function that returns a yes/no
value is already soaked too deep in Perl's deep magic.  I would want the
code to be maintainable by people who does not care the deep voodoo, and
for that reason, I do not want the callers to care.

Having said that, I think it is perfectly fine to favor returning "$val eq
'true'" over returning "$val eq 'true ? 1 : 0".  But that is not because
it is truer way to say false from Perl experts' point of view, but because
it is shorter and more to the point.

^ permalink raw reply

* [PATCH v2 tested] git-sh-setup: Fix scripts whose PWD is a symlink to a work-dir on OS X
From: Marcel M. Cary @ 2009-01-04 21:27 UTC (permalink / raw)
  To: gitster; +Cc: git, jnareb, ae, j.sixt, git-dev, Marcel M. Cary
In-Reply-To: <AC726FD4-AE7F-4EC0-82E5-62C6D03C4E5A@marzelpan.de>

On Mac OS X and possibly BSDs, /bin/pwd reads PWD from the environment
if available and shows the logical path by default rather than the
physical one.

Unset PWD before running /bin/pwd in both cd_to_toplevel and its
test.

Still use the external /bin/pwd because in my Bash on Linux,
the builtin pwd prints the same result whether or not PWD is set.

Signed-off-by: Marcel M. Cary <marcel@oak.homeunix.org>
Tested-by: Marcel Koeppen <git-dev@marzelpan.de>
---

Junio C Hamano wrote:
> I think I saw a success report on the list.  Care to resend it with
> Sign-off (by you) and
> 
>         Tested-by: tester <test@er.xz> (on PLATFORM)
> 
> lines as you see necessary for application?

Same as before but with S-o-b/T-b lines.

Marcel Koeppen wrote:
> [I don't know why my replies get lost, so I dropped all individual
> recipients on this third try...]

I noticed that Brian Gernhardt's message also didn't make it to the
list, even though it was addressed to the list.  I'm not sure why.


 git-sh-setup.sh           |    2 +-
 t/t2300-cd-to-toplevel.sh |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index f07d96b..2142308 100755
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -96,7 +96,7 @@ cd_to_toplevel () {
 		..|../*|*/..|*/../*)
 			# Interpret $cdup relative to the physical, not logical, cwd.
 			# Probably /bin/pwd is more portable than passing -P to cd or pwd.
-			phys="$(/bin/pwd)/$cdup"
+			phys="$(unset PWD; /bin/pwd)/$cdup"
 			;;
 		*)
 			# There's no "..", so no need to make things absolute.
diff --git a/t/t2300-cd-to-toplevel.sh b/t/t2300-cd-to-toplevel.sh
index beddb4e..e42cbfe 100755
--- a/t/t2300-cd-to-toplevel.sh
+++ b/t/t2300-cd-to-toplevel.sh
@@ -10,12 +10,12 @@ test_cd_to_toplevel () {
 			cd '"'$1'"' &&
 			. git-sh-setup &&
 			cd_to_toplevel &&
-			[ "$(/bin/pwd)" = "$TOPLEVEL" ]
+			[ "$(unset PWD; /bin/pwd)" = "$TOPLEVEL" ]
 		)
 	'
 }
 
-TOPLEVEL="$(/bin/pwd)/repo"
+TOPLEVEL="$(unset PWD; /bin/pwd)/repo"
 mkdir -p repo/sub/dir
 mv .git repo/
 SUBDIRECTORY_OK=1
-- 
1.6.1

^ permalink raw reply related

* [PATCH v2 tested-v2] git-sh-setup: Fix scripts whose PWD is a symlink to a work-dir on OS X
From: Marcel M. Cary @ 2009-01-04 21:47 UTC (permalink / raw)
  To: gitster; +Cc: git, jnareb, ae, j.sixt, git-dev, Marcel M. Cary
In-Reply-To: <8C7E36D0-C037-427D-B6E2-4050CC767CD0@marzelpan.de>

On Mac OS X and possibly BSDs, /bin/pwd reads PWD from the environment
if available and shows the logical path by default rather than the
physical one.

Unset PWD before running /bin/pwd in both cd_to_toplevel and its
test.

Still use the external /bin/pwd because in my Bash on Linux,
the builtin pwd prints the same result whether or not PWD is set.

Signed-off-by: Marcel M. Cary <marcel@oak.homeunix.org>
Tested-by: Marcel Koeppen <git-dev@marzelpan.de> (on Mac OS X 10.5.6)
---

> please add
> 
> Tested-by: Marcel Koeppen <git-dev@marzelpan.de> (on Mac OS X 10.5.6)

Now with the OS, in detail.


 git-sh-setup.sh           |    2 +-
 t/t2300-cd-to-toplevel.sh |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index f07d96b..2142308 100755
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -96,7 +96,7 @@ cd_to_toplevel () {
 		..|../*|*/..|*/../*)
 			# Interpret $cdup relative to the physical, not logical, cwd.
 			# Probably /bin/pwd is more portable than passing -P to cd or pwd.
-			phys="$(/bin/pwd)/$cdup"
+			phys="$(unset PWD; /bin/pwd)/$cdup"
 			;;
 		*)
 			# There's no "..", so no need to make things absolute.
diff --git a/t/t2300-cd-to-toplevel.sh b/t/t2300-cd-to-toplevel.sh
index beddb4e..e42cbfe 100755
--- a/t/t2300-cd-to-toplevel.sh
+++ b/t/t2300-cd-to-toplevel.sh
@@ -10,12 +10,12 @@ test_cd_to_toplevel () {
 			cd '"'$1'"' &&
 			. git-sh-setup &&
 			cd_to_toplevel &&
-			[ "$(/bin/pwd)" = "$TOPLEVEL" ]
+			[ "$(unset PWD; /bin/pwd)" = "$TOPLEVEL" ]
 		)
 	'
 }
 
-TOPLEVEL="$(/bin/pwd)/repo"
+TOPLEVEL="$(unset PWD; /bin/pwd)/repo"
 mkdir -p repo/sub/dir
 mv .git repo/
 SUBDIRECTORY_OK=1
-- 
1.6.1

^ permalink raw reply related

* Re: git-branch --print-current
From: Jakub Narebski @ 2009-01-04 21:48 UTC (permalink / raw)
  To: Adeodato Simó; +Cc: Karl Chen, Arnaud Lacombe, Git mailing list
In-Reply-To: <20090104180208.GA12298@chistera.yi.org>

Adeodato Simó <dato@net.com.org.es> writes:
> * Karl Chen [Sun, 04 Jan 2009 04:40:51 -0800]:
> 
> >     Arnaud> $ git branch | awk '/^\*/ {print $2}'
> 
> > Yet another addition to the list of ways to pipeline it, this one
> > probably the shortest :)
> 
> Heh, if we're playing golf:
> 
>               $ git branch | sed -n 's/^\* //p'

Even if you want to reimplement __git_ps1 provided with bash
completion in completion/git-completion.bash instead of reusing it,
you still have to deal with many situations: not being in git
repository, being on detached HEAD, being in intermediate state
(during git-am, git-rebase, git-bisect etc.), etc.  Additionally you
would probably want name of git repository and relative path inside
git repository in prompt.

Therefore you need to use script anyway. And for scripting you should
use plumbing (which output format shouldn't change) and not porcelain
git-branch (which output might change, for example having '-v' on by
default, or something; and you might have color.ui set to true by
mistake and have to deal with color codes). And then you don't need
sed nor awk: POSIX shell features would be enough:

  BR=$(git symbolic-ref HEAD 2>/dev/null)
  BR=${BR#refs/heads/}
  BR=${BR:-HEAD} # one of possibilities to show detached HEAD / no branch

-- 
Jakub Narebski
Poland
ShadeHawk on #git

^ permalink raw reply

* Re: [PATCH] gitweb: merge boolean feature subroutines
From: Jakub Narebski @ 2009-01-04 22:07 UTC (permalink / raw)
  To: Matt Kraai; +Cc: demerphq, Junio C Hamano, git
In-Reply-To: <20090104155858.GC4205@ftbfs.org>

Matt Kraai <kraai@ftbfs.org> writes:

> I agree that what you suggest is better than the alternatives you
> present.  Unfortunately, none of them match the current behavior.
> Here's the current code:
> 
> 	if ($val eq 'true') {
> 		return 1;
> 	} elsif ($val eq 'false') {
> 		return 0;
> 	}
> 
> 	return $_[0];
> 
> Is there a way to use the form you suggest while falling back to the
> default if $val isn't set to 'true' or 'false'?

IIRC the return value is actually threestate: 1 for true, 0 for false,
and undef for non-bool config value.

BTW. git_get_project_config currently emulates old one git-config call
per configuration variable, with git-config normalizing boolean values
(returning 'true' or 'false'). But it could return Perl truish or Perl
falsish instead, as we now use "git config -l -z" + caching config
variables, and it is Perl that does normalization of boolean values.

-- 
Jakub Narebski
Poland
ShadeHawk on #git

^ permalink raw reply

* unclear description of git-rm on kernel.org
From: alec resnick @ 2009-01-04 22:10 UTC (permalink / raw)
  To: git

Hi!

I was trying to remove a number of files from a git repo I had.  I
read http://kernel.org/pub/software/scm/git/docs/v1.4.4.4/git-rm.html
which I interpreted to mean that git-rm removed only from the index,
and not from the working tree.  In retrospect, the short description
is clear: "git-rm - Remove files from the working tree and from the
index," but I was confused by the language:
"<file>…

    Files to remove from the index and optionally, from the working
tree as well.
-f

    Remove files from the working tree as well as from the index."

Because of "optionally" and the very existence of the "-f" option
suggests that you have to do something extra to ask git-rm to mess
with the working tree.

The manpage is much clearer, and while I recovered the files I
accidentally removed simply with git checkout, I suggest that the
webpage be made a bit clearer.  In particular, adding info about how
to _only_ remove files from the index would be helpful.

I'd be happy to make the changes to the webpage; I don't know how to
do that or if it's appropriate.

Thanks!


-a.

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox