git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Suggestion: make --left-right work with --merge

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 29, 2008, 19:26 UTC
Message-ID
<7vfxvbd0nu.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<18375.58359.687664.855599@cargo.ozlabs.ibm.com>
Paul Mackerras <paulus@samba.org> writes:
Show 12 quoted lines
> Junio C Hamano writes:
>
>> Doesn't
>> 
>> 	git rev-parse --revs-only --no-flags "$@" | grep '^[0-9a-f]'
>> 
>> give you what you want?
>
> Well, it does, except for --merge, which is perhaps a special case.
>
> (Actually, what would git rev-parse --revs-only --no-flags output that
> isn't a SHA1 ID?  Why do you have the grep command there?)

Try it on user inputs like "master..next", "next...master". You wanted to grab only the positive ones, no?

> That's essentially what I do.  I think I'll just have to do special
> cases for --merge and --left-right.

Are you sure? I can imagine that --merge may be problematic, because it implicitly is about MERGE_HEAD...HEAD, but rev-parse may not know about it. I think --left-right and symmetric should be fine.

	$ set x --left-right master...next; shift
	$ git rev-parse --revs-only --no-flags "$@" |
          git name-rev --stdin
        88113cfea67557067f1363b210b803637d186632 (next)
        97b97c58e609a1cd23b3c2514f41cdb0405870ee (master)
        ^97b97c58e609a1cd23b3c2514f41cdb0405870ee (master)

In the above case, master is a strict ancestor of next, but the third line that is negative (and my grep would exclude) is generally the merge-base between the left and right positives. The two positives are what you wanted to exclude from the second round, aren't they?

And in order to handle them sanely without worrying about revision machinery and rev-parse going out-of-sync, I would almost suggest doing something like the attached patch and say:

	$ git rev-list --no-walk "$@"

The user options can contain --left-right and --boundary, so the output from this could begin with ">", "<" and "-". If you discard the ones that are prefixed with "-" (i.e. the user had the --boundary option in "$@"), grab the ones that are not prefixed (i.e. the user did not have the --left-right option in "$@"), and the ones prefixed with ">" and "<" (i.e. the user did have --left-right, and you would strip the prefix from such a line), you would find all positive ones the user specified, I think.

-- >8 -- revision --no-walk: do not refuse to show the list with negatives

Scripts may want to find out what revs the user gave from the command line.

	git rev-list --no-walk --boundary "$@"
would be a natural way to find out what revs (with flags) they
are, but --no-walk refused to work if there are negative ones.
Lift that restriction.
 
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 revision.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/revision.c b/revision.c
index 0eb6faa..c0931eb 100644
--- a/revision.c
+++ b/revision.c
@@ -129,8 +129,6 @@ void mark_parents_uninteresting(struct commit *commit)
 
 static void add_pending_object_with_mode(struct rev_info *revs, struct object *obj, const char *name, unsigned mode)
 {
-	if (revs->no_walk && (obj->flags & UNINTERESTING))
-		die("object ranges do not make sense when not walking revisions");
 	if (revs->reflog_info && obj->type == OBJ_COMMIT &&
 			add_reflog_for_walk(revs->reflog_info,
 				(struct commit *)obj, name))
Previous: Paul MackerrasNext: Paul Mackerras
Message 8 of 13 in “Suggestion: make --left-right work with --merge”
  1. Paul MackerrasFeb 27, 2008
  2. Junio C HamanoFeb 27, 2008
  3. Paul MackerrasFeb 27, 2008
  4. Junio C HamanoFeb 27, 2008
  5. Paul MackerrasFeb 28, 2008
  6. Junio C HamanoFeb 29, 2008
  7. Paul MackerrasFeb 29, 2008
  8. Junio C HamanoFeb 29, 2008
  9. Paul MackerrasMar 1, 2008
  10. Junio C HamanoMar 1, 2008
  11. Paul MackerrasMar 1, 2008
  12. Linus TorvaldsFeb 29, 2008
  13. Junio C HamanoFeb 29, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.