summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-26 18:34:30 (GMT)
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-26 18:34:30 (GMT)
commit042a4ed7c51f909fa53a8fa2f1024a1938812f27 (patch)
tree1a5c5383a49dd5405e725a877ac73f667b5a0261
parent641e1cac73acd67d0b1830dfd7196bca58dffbf2 (diff)
downloadgit-042a4ed7c51f909fa53a8fa2f1024a1938812f27.zip
git-042a4ed7c51f909fa53a8fa2f1024a1938812f27.tar.gz
git-042a4ed7c51f909fa53a8fa2f1024a1938812f27.tar.bz2
git-rev-parse: add "--not" flag to mark subsequent heads negative
If you have two lists of heads, and you want to see ones reachable from list $a but not from list $b, just do git-rev-list $(git-rev-parse $a --not $b) which is useful for both bisecting (where "b" would be the list of known good revisions, and "a" would be the latest found bad head) and for just seeing what the difference between two sets of heads are if you want to generate a pack-file for the difference.
-rw-r--r--rev-parse.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/rev-parse.c b/rev-parse.c
index 9249fa5..c134ffd 100644
--- a/rev-parse.c
+++ b/rev-parse.c
@@ -13,6 +13,10 @@ static int revs_only = 0;
static int do_rev_argument = 1;
static int output_revs = 0;
+#define NORMAL 0
+#define REVERSED 1
+static int show_type = NORMAL;
+
static int get_extended_sha1(char *name, unsigned char *sha1);
/*
@@ -42,20 +46,12 @@ static int is_rev_argument(const char *arg)
}
}
-static void show_rev(unsigned char *sha1)
+static void show_rev(int type, unsigned char *sha1)
{
if (no_revs)
return;
output_revs++;
- puts(sha1_to_hex(sha1));
-}
-
-static void show_antirev(unsigned char *sha1)
-{
- if (no_revs)
- return;
- output_revs++;
- printf("^%s\n", sha1_to_hex(sha1));
+ printf("%s%s\n", type == show_type ? "" : "^", sha1_to_hex(sha1));
}
static void show_rev_arg(char *rev)
@@ -139,7 +135,7 @@ static void show_default(void)
def = NULL;
if (!get_extended_sha1(s, sha1)) {
- show_rev(sha1);
+ show_rev(NORMAL, sha1);
return;
}
show_arg(s);
@@ -185,6 +181,10 @@ int main(int argc, char **argv)
single_rev = 1;
continue;
}
+ if (!strcmp(arg, "--not")) {
+ show_type ^= REVERSED;
+ continue;
+ }
show_arg(arg);
continue;
}
@@ -200,8 +200,8 @@ int main(int argc, char **argv)
if (no_revs)
continue;
def = NULL;
- show_rev(end);
- show_antirev(sha1);
+ show_rev(NORMAL, end);
+ show_rev(REVERSED, sha1);
continue;
}
}
@@ -211,14 +211,14 @@ int main(int argc, char **argv)
if (no_revs)
continue;
def = NULL;
- show_rev(sha1);
+ show_rev(NORMAL, sha1);
continue;
}
if (*arg == '^' && !get_extended_sha1(arg+1, sha1)) {
if (no_revs)
continue;
def = NULL;
- show_antirev(sha1);
+ show_rev(REVERSED, sha1);
continue;
}
show_default();