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

[PATCH 4/5] revision.c: refactor ref selection handler after --exclude

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Jan 25, 2017, 12:50 UTC
Message-ID
<20170125125054.7422-5-pclouds@gmail.com>
In-Reply-To
<20170125125054.7422-1-pclouds@gmail.com>

Behavior change: "--exclude --blah --remotes" will not exclude remote branches any more. Only "--exclude --remotes" does.

This is because --exclude is going to have a new friend --decorate-reflog who haves the same way. When you allow a distant --remotes to complement a previous option, things get complicated. In

    --exclude .. --decorate-reflog ... --remotes

Does it mean decorate remote reflogs, or does it mean exclude remotes from the selected revisions?

Granted, there may be valid use cases for such a combination (e.g. "decorate all reflogs except remote ones") but I feel option order is not a good fit to express them.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 revision.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/revision.c b/revision.c
index cda2606c66..45cffcab44 100644
--- a/revision.c
+++ b/revision.c
@@ -2152,10 +2152,24 @@ static int handle_refs_pseudo_opt(const char *submodule,
 		return 0;
 	}
 
-	clear_ref_exclusion(&revs->ref_excludes);
 	return 1;
 }
 
+static int handle_revision_pseudo_opt(const char *, struct rev_info *, int, const char **, int *);
+
+static int handle_revision_pseudo_opt_after_exclude(const char *submodule,
+						    struct rev_info *revs,
+						    int argc, const char **argv,
+						    int *flags)
+{
+	int ret;
+
+	ret = handle_revision_pseudo_opt(submodule, revs, argc, argv, flags);
+	clear_ref_exclusion(&revs->ref_excludes);
+	revs->handle_pseudo_opt = NULL;
+	return ret;
+}
+
 static int handle_revision_pseudo_opt(const char *submodule,
 				struct rev_info *revs,
 				int argc, const char **argv, int *flags)
@@ -2184,6 +2198,7 @@ static int handle_revision_pseudo_opt(const char *submodule,
 		revs->bisect = 1;
 	} else if ((argcount = parse_long_opt("exclude", argv, &optarg))) {
 		add_ref_exclusion(&revs->ref_excludes, optarg);
+		revs->handle_pseudo_opt = handle_revision_pseudo_opt_after_exclude;
 		return argcount;
 	} else if (!strcmp(arg, "--reflog")) {
 		add_reflogs_to_pending(revs, *flags);
-- 
2.11.0.157.gd943d85
Previous: Nguyễn Thái Ngọc DuyNext: Jacob Keller
Message 18 of 27 in “log: new option decorate reflog of remote refs”
  1. log: new option decorate reflog of remote refsNguyễn Thái Ngọc Duy, Jan 19, 2017
  2. Jeff KingJan 19, 2017
  3. Duy NguyenJan 20, 2017
  4. Jeff KingJan 20, 2017
  5. Jacob KellerJan 20, 2017
  6. Duy NguyenJan 21, 2017
  7. Jeff KingJan 21, 2017
  8. 0/5 Prep steps for --decorate-reflogNguyễn Thái Ngọc Duy, Jan 25, 2017
  9. 1/5 rev-list-options.txt: delete an empty lineNguyễn Thái Ngọc Duy, Jan 25, 2017
  10. 2/5 revision.c: group ref selection options togetherNguyễn Thái Ngọc Duy, Jan 25, 2017
  11. Jeff KingJan 25, 2017
  12. Duy NguyenJan 26, 2017
  13. Jeff KingJan 26, 2017
  14. Junio C HamanoJan 25, 2017
  15. Duy NguyenJan 26, 2017
  16. 3/5 revision.c: allow to change pseudo opt parsing functionNguyễn Thái Ngọc Duy, Jan 25, 2017
  17. 5/5 revision.c: add --decorate-reflogNguyễn Thái Ngọc Duy, Jan 25, 2017
  18. 4/5 revision.c: refactor ref selection handler after --excludeNguyễn Thái Ngọc Duy, Jan 25, 2017
  19. Jacob KellerJan 25, 2017
  20. Jeff KingJan 25, 2017
  21. Jeff KingJan 25, 2017
  22. Jacob KellerJan 25, 2017
  23. Junio C HamanoJan 25, 2017
  24. Duy NguyenJan 26, 2017
  25. Jeff KingJan 26, 2017
  26. Junio C HamanoJan 26, 2017
  27. Junio C HamanoJan 25, 2017

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.