# git-rev-parse: pass on "--" flag when required

2 messages from 2005-10-21 to 2005-10-21. Participants: Linus Torvalds.
Thread: https://gitlist.dev/t/2170

## Linus Torvalds, 2005-10-21 00:16

Subject: git-rev-parse: pass on "--" flag when required
Message-ID: <Pine.LNX.4.64.0510201711380.10477@g5.osdl.org>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0510201711380.10477%40g5.osdl.org

```

If rev-parse output includes both flags and files, we should pass on any 
"--" marker we see, so that the end result can also tell the difference 
between a flag and a filename that begins with '-'.

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
---
diff --git a/rev-parse.c b/rev-parse.c
index 85230df..9ae2512 100644
--- a/rev-parse.c
+++ b/rev-parse.c
@@ -174,6 +174,9 @@ int main(int argc, char **argv)
 		if (*arg == '-') {
 			if (!strcmp(arg, "--")) {
 				as_is = 1;
+				/* Pass on the "--" if we show anything but files.. */
+				if (filter & (DO_FLAGS | DO_REVS))
+					show_file(arg);
 				continue;
 			}
 			if (!strcmp(arg, "--default")) {

```

## Linus Torvalds, 2005-10-21 00:24

Subject: Re: git-rev-parse: pass on "--" flag when required
Message-ID: <Pine.LNX.4.64.0510201720420.10477@g5.osdl.org>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0510201720420.10477%40g5.osdl.org
In-Reply-To: <Pine.LNX.4.64.0510201711380.10477@g5.osdl.org>

```


On Thu, 20 Oct 2005, Linus Torvalds wrote:
> 
> If rev-parse output includes both flags and files, we should pass on any 
> "--" marker we see, so that the end result can also tell the difference 
> between a flag and a filename that begins with '-'.

Btw, if it wasn't obvious, this is also required to keep files and revs 
separate.

I don't think we have anything that cares right now, but I'm working on 
trying to get "git-rev-list" to limit its output to the files given on the 
command line, and then I want to be able to do

	gitk -- rev-list.c

and in my version of git-rev-list, the "--" is required to separate out 
the revs from the names (since otherwise it's just too error-prone).

That requires that git-rev-parse not only honor "--", but pass it through 
when the output can contain both revs/flags _and_ filenames.

			Linus

```
