Skip to contentSkip to conversation

revision: add --except option

PATCH Superseded Felipe Contreras 2 participants 3 messages Jun 15, 2016 Documentation

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 revision: add --except option

So that it's possible to remove certain refs from the list without removing the objects that are referenced by other refs.

For example this repository:

C (crap)
B (test)
A (HEAD, master)

When using '--branches --except crap':

B (test)
A (HEAD, master)

But when using '--branches --not crap' nothing will come out.

---

I don't like the complexity of recalculate_flag(), but it seems to be the most straight-forward way of making --not and --except work.

 Documentation/git-rev-parse.txt        |  6 ++++
 contrib/completion/git-completion.bash |  2 +-
 revision.c                             | 52 ++++++++++++++++++++++++++++-
 revision.h                             |  3 +-
 t/t6112-rev-list-except.sh             | 60 ++++++++++++++++++++++++++++++++++
 5 files changed, 120 insertions(+), 3 deletions(-)
 create mode 100755 t/t6112-rev-list-except.sh
Documentation/git-rev-parse.txt +6 -0
index 2b126c0..fe5cc6b 100644
@@ -110,6 +110,12 @@ can be used.
 	strip '{caret}' prefix from the object names that already have
 	one.
 
+--except::
+	Skip the following object names. For example:
+	'--branches --except master' will show all the branches, except master.
+	This differs from --not in that --except will still show the object, if
+	they are referenced by another object name.
+
 --symbolic::
 	Usually the object names are output in SHA-1 form (with
 	possible '{caret}' prefix); this option makes them output in a
contrib/completion/git-completion.bash +1 -1
index 5da920e..aed8c12 100644
@@ -1386,7 +1386,7 @@ _git_ls_tree ()
 
 # Options that go well for log, shortlog and gitk
 __git_log_common_options="
-	--not --all
+	--not --except --all
 	--branches --tags --remotes
 	--first-parent --merges --no-merges
 	--max-count=
revision.c +51 -1

81 lines not on this page · raw message

revision.h +2 -1
index 95859ba..89f5037 100644
@@ -17,7 +17,8 @@
 #define SYMMETRIC_LEFT	(1u<<8)
 #define PATCHSAME	(1u<<9)
 #define BOTTOM		(1u<<10)
-#define ALL_REV_FLAGS	((1u<<11)-1)
+#define SKIP		(1u<<11)
+#define ALL_REV_FLAGS	((1u<<12)-1)
 
 #define DECORATE_SHORT_REFS	1
 #define DECORATE_FULL_REFS	2
t/t6112-rev-list-except.sh new file +60 -0

60 lines not on this page · raw message

Signature · 1 line
1.8.4-337-g7358a66-dirty
#1 lore raw

Am 8/31/2013 23:26, schrieb Felipe Contreras:

Documentation/git-rev-parse.txt can be used. · line 117

Quoted 5 lines

+--except::

Documentation/git-rev-parse.txt +4 -0
+	Skip the following object names. For example:
+	'--branches --except master' will show all the branches, except master.
+	This differs from --not in that --except will still show the object, if
+	they are referenced by another object name.

--except needs a bit more documentation, in particular, how it interacts with --not.

It would be better to settle on the meaning of --except before throwing back and forth implementations.

-- Hannes

#2 lore raw
Quoted 2 lines · Johannes Sixt

It would be better to settle on the meaning of --except before throwing back and forth implementations.

I've lost the count of features that get discussed endlessly, and nobody implements them ever. The implementation should dictate the behavior, because it doesn't matter if you have described perfect behavior, and the implementation is nearly impossible. If you disagree, feel free to write the code.

Talk is cheap, show me the code. -- Linus Torvalds

Signature · 1 line
Felipe Contreras