git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git-rev-parse question.
@ 2005-08-23  8:02 Junio C Hamano
  2005-08-23 17:07 ` Linus Torvalds
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2005-08-23  8:02 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: git

I have been looking at what git-rev-parse does and could not
figure out a way to convince it to give me only arguments with
a '-' prefix.  Specifically, I wanted to remove the hardcoded -p
and -M flags from git-diff-script.  Running

    $ sh -x git-diff-script -C HEAD^ HEAD

reveals that none of the following would pick up "-C" from the
command line:

    rev=($(git-rev-parse --revs-only "$@")) || exit
    flags=($(git-rev-parse --no-revs --flags "$@"))
    files=($(git-rev-parse --no-revs --no-flags "$@"))

I am not even sure if the current implementation of rev-parse
matches what you originally wanted it to do; I suspect it does
not.  I would like to know what was the intended behaviour
first, so that I can enhance it to be usable for my purpose
without breaking things.

What I want the rev-parse flags to mean is as follows.  By "rev
argument", I mean what get_sha1() can understand.  I have to
admit that some flags are what I introduced while I was
butchering it without really knowing the original intention:

  output format:
  --sq		output in a format usable for shell "eval".
  --symbolic	output rev argument in symbolic form, not SHA1.

  output selection:
  --flags	show only arguments with '-' prefix.
  --no-flags	do not show arguments with '-' prefix.

  --revs-only	show only arguments meant for rev-list.
  --no-revs	show arguments not meant for rev-list.

  input munging:
  --default R	if no revision, pretend R is given.
  --not		pretend all rev arguments without prefix ^ have
                prefix ^, and the ones with prefix ^ do not.
  --all		pretend all refs under $GIT_DIR/refs are given
  		on the command line.

  special:
  --verify	make sure only one rev argument is given, nothing else.

I think flags/no-flags and revs-only/no-revs *should* be
orthogonal.  That is, "rev-parse --flags --no-revs" should give
parameters that start with '-' and not meant for rev-list
(e.g. '-C' in earlier example); "rev-parse --revs-only
--merge-order HEAD Documentation/" should yield "--merge-order
HEAD".

Also there is an undocumented --show-prefix.  What is it?

-jc

PS. BTW, any response about unsuspecting companies?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: git-rev-parse question.
  2005-08-23  8:02 git-rev-parse question Junio C Hamano
@ 2005-08-23 17:07 ` Linus Torvalds
  2005-08-23 17:47   ` Linus Torvalds
  0 siblings, 1 reply; 3+ messages in thread
From: Linus Torvalds @ 2005-08-23 17:07 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git



On Tue, 23 Aug 2005, Junio C Hamano wrote:
>
> I have been looking at what git-rev-parse does and could not
> figure out a way to convince it to give me only arguments with
> a '-' prefix.

Gaah. Understandable. It got broken during some cleanup.

Try this trivial patch, it should work better.

NOTE! The behaviour of "--" for git-rev-parse is somewhat unclear. Right 
now it prints it out with "--flags", which is probably wrong.

		Linus
---
Subject: Fix git-rev-parse --default and --flags handling

This makes the argument to --default and any --flags arguments should up 
correctly.

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
---
diff --git a/rev-parse.c b/rev-parse.c
--- a/rev-parse.c
+++ b/rev-parse.c
@@ -107,7 +107,7 @@ static void show_arg(char *arg)
 	if (do_rev_argument && is_rev_argument(arg))
 		show_rev_arg(arg);
 	else
-		show_norev(arg);
+		show(arg);
 }
 
 static void show_default(void)
@@ -122,7 +122,7 @@ static void show_default(void)
 			show_rev(NORMAL, sha1, s);
 			return;
 		}
-		show_arg(s);
+		show(s);
 	}
 }
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: git-rev-parse question.
  2005-08-23 17:07 ` Linus Torvalds
@ 2005-08-23 17:47   ` Linus Torvalds
  0 siblings, 0 replies; 3+ messages in thread
From: Linus Torvalds @ 2005-08-23 17:47 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git



On Tue, 23 Aug 2005, Linus Torvalds wrote:
> 
> Try this trivial patch, it should work better.

Actually, don't do the "show_default()" part of this. We should _not_ show 
the default string if we haev "--no-revs" and the string doesn't match a 
rev.

Also, this fixes "--" handlign with "--flags". Thinking about it for a 
few seconds made it obvious that we shouldn't show it.

		Linus
---
Subject: Fix git-rev-parse --default and --flags handling

This makes the argument to --default and any --flags arguments should up 
correctly, and makes "--" together with --flags act sanely.

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
---
diff --git a/rev-parse.c b/rev-parse.c
--- a/rev-parse.c
+++ b/rev-parse.c
@@ -107,7 +107,7 @@ static void show_arg(char *arg)
 	if (do_rev_argument && is_rev_argument(arg))
 		show_rev_arg(arg);
 	else
-		show_norev(arg);
+		show(arg);
 }
 
 static void show_default(void)
@@ -122,7 +122,7 @@ static void show_default(void)
 			show_rev(NORMAL, sha1, s);
 			return;
 		}
-		show_arg(s);
+		show_norev(s);
 	}
 }
 
@@ -149,7 +149,7 @@ int main(int argc, char **argv)
 		if (*arg == '-') {
 			if (!strcmp(arg, "--")) {
 				show_default();
-				if (revs_only)
+				if (revs_only || flags_only)
 					break;
 				as_is = 1;
 			}

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-08-23 17:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-23  8:02 git-rev-parse question Junio C Hamano
2005-08-23 17:07 ` Linus Torvalds
2005-08-23 17:47   ` Linus Torvalds

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).