aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-04-03 12:38:11 -0700
committerJunio C Hamano <gitster@pobox.com>2014-04-03 12:38:11 -0700
commitb407d40933f9c37af16ca3dc275e615ab4fdd8c5 (patch)
treea22498a4d0d7d253f43cb2bde8b032b2374b12b2
parent2b06c1e57eecde25ff762cc12939d8a6d8f143cc (diff)
parent1b32decefd840e0ca5d18eefd6472fd8624dd849 (diff)
downloadgit-b407d40933f9c37af16ca3dc275e615ab4fdd8c5.tar.gz
Merge branch 'nd/log-show-linear-break'
Attempts to show where a single-strand-of-pearls break in "git log" output. * nd/log-show-linear-break: log: add --show-linear-break to help see non-linear history object.h: centralize object flag allocation
-rw-r--r--Documentation/rev-list-options.txt7
-rw-r--r--bisect.c3
-rw-r--r--builtin/blame.c2
-rw-r--r--bundle.c1
-rw-r--r--commit.c2
-rw-r--r--fetch-pack.c1
-rw-r--r--http-push.c3
-rw-r--r--log-tree.c4
-rw-r--r--object.h13
-rw-r--r--revision.c48
-rw-r--r--revision.h11
-rw-r--r--sha1_name.c2
-rw-r--r--upload-pack.c2
-rw-r--r--walker.c1
14 files changed, 89 insertions, 11 deletions
diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt
index 9a3da3646e..b8139610b9 100644
--- a/Documentation/rev-list-options.txt
+++ b/Documentation/rev-list-options.txt
@@ -758,6 +758,13 @@ This enables parent rewriting, see 'History Simplification' below.
This implies the `--topo-order` option by default, but the
`--date-order` option may also be specified.
+--show-linear-break[=<barrier>]::
+ When --graph is not used, all history branches are flattened
+ which can make it hard to see that the two consecutive commits
+ do not belong to a linear branch. This option puts a barrier
+ in between them in that case. If `<barrier>` is specified, it
+ is the string that will be shown instead of the default one.
+
ifdef::git-rev-list[]
--count::
Print a number stating how many commits would have been
diff --git a/bisect.c b/bisect.c
index 8448d27877..d6e851d783 100644
--- a/bisect.c
+++ b/bisect.c
@@ -21,8 +21,7 @@ static const char *argv_checkout[] = {"checkout", "-q", NULL, "--", NULL};
static const char *argv_show_branch[] = {"show-branch", NULL, NULL};
static const char *argv_update_ref[] = {"update-ref", "--no-deref", "BISECT_HEAD", NULL, NULL};
-/* bits #0-15 in revision.h */
-
+/* Remember to update object flag allocation in object.h */
#define COUNTED (1u<<16)
/*
diff --git a/builtin/blame.c b/builtin/blame.c
index e5b5d71bad..88cb799727 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -74,7 +74,7 @@ static unsigned blame_copy_score;
#define BLAME_DEFAULT_MOVE_SCORE 20
#define BLAME_DEFAULT_COPY_SCORE 40
-/* bits #0..7 in revision.h, #8..11 used for merge_bases() in commit.c */
+/* Remember to update object flag allocation in object.h */
#define METAINFO_SHOWN (1u<<12)
#define MORE_THAN_ONE_PATH (1u<<13)
diff --git a/bundle.c b/bundle.c
index a85e0e4532..1222952075 100644
--- a/bundle.c
+++ b/bundle.c
@@ -120,6 +120,7 @@ static int list_refs(struct ref_list *r, int argc, const char **argv)
return 0;
}
+/* Remember to update object flag allocation in object.h */
#define PREREQ_MARK (1u<<16)
int verify_bundle(struct bundle_header *header, int verbose)
diff --git a/commit.c b/commit.c
index 0f28902bc3..f4793316a2 100644
--- a/commit.c
+++ b/commit.c
@@ -721,7 +721,7 @@ void sort_in_topological_order(struct commit_list **list, enum rev_sort_order so
/* merge-base stuff */
-/* bits #0..15 in revision.h */
+/* Remember to update object flag allocation in object.h */
#define PARENT1 (1u<<16)
#define PARENT2 (1u<<17)
#define STALE (1u<<18)
diff --git a/fetch-pack.c b/fetch-pack.c
index 90d47da8a9..eeee2bb7e0 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -26,6 +26,7 @@ static int agent_supported;
static struct lock_file shallow_lock;
static const char *alternate_shallow_file;
+/* Remember to update object flag allocation in object.h */
#define COMPLETE (1U << 0)
#define COMMON (1U << 1)
#define COMMON_REF (1U << 2)
diff --git a/http-push.c b/http-push.c
index d4b40c9c60..f2c56c8454 100644
--- a/http-push.c
+++ b/http-push.c
@@ -64,8 +64,7 @@ enum XML_Status {
#define LOCK_TIME 600
#define LOCK_REFRESH 30
-/* bits #0-15 in revision.h */
-
+/* Remember to update object flag allocation in object.h */
#define LOCAL (1u<<16)
#define REMOTE (1u<<17)
#define FETCHING (1u<<18)
diff --git a/log-tree.c b/log-tree.c
index 5ce217d5eb..cf2f86c866 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -805,12 +805,16 @@ int log_tree_commit(struct rev_info *opt, struct commit *commit)
if (opt->line_level_traverse)
return line_log_print(opt, commit);
+ if (opt->track_linear && !opt->linear && !opt->reverse_output_stage)
+ printf("\n%s\n", opt->break_bar);
shown = log_tree_diff(opt, commit, &log);
if (!shown && opt->loginfo && opt->always_show_header) {
log.parent = NULL;
show_log(opt);
shown = 1;
}
+ if (opt->track_linear && !opt->linear && opt->reverse_output_stage)
+ printf("\n%s\n", opt->break_bar);
opt->loginfo = NULL;
maybe_flush_or_die(stdout, "stdout");
return shown;
diff --git a/object.h b/object.h
index 732bf4d7e7..6e12f2c7f4 100644
--- a/object.h
+++ b/object.h
@@ -26,6 +26,19 @@ struct object_array {
#define OBJECT_ARRAY_INIT { 0, 0, NULL }
#define TYPE_BITS 3
+/*
+ * object flag allocation:
+ * revision.h: 0---------10 26
+ * fetch-pack.c: 0---4
+ * walker.c: 0-2
+ * upload-pack.c: 11----------------19
+ * builtin/blame.c: 12-13
+ * bisect.c: 16
+ * bundle.c: 16
+ * http-push.c: 16-----19
+ * commit.c: 16-----19
+ * sha1_name.c: 20
+ */
#define FLAG_BITS 27
/*
diff --git a/revision.c b/revision.c
index 85085501f6..794a8835c0 100644
--- a/revision.c
+++ b/revision.c
@@ -1837,6 +1837,14 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
revs->notes_opt.use_default_notes = 1;
} else if (!strcmp(arg, "--show-signature")) {
revs->show_signature = 1;
+ } else if (!strcmp(arg, "--show-linear-break") ||
+ starts_with(arg, "--show-linear-break=")) {
+ if (starts_with(arg, "--show-linear-break="))
+ revs->break_bar = xstrdup(arg + 20);
+ else
+ revs->break_bar = " ..........";
+ revs->track_linear = 1;
+ revs->track_first_time = 1;
} else if (starts_with(arg, "--show-notes=") ||
starts_with(arg, "--notes=")) {
struct strbuf buf = STRBUF_INIT;
@@ -1960,6 +1968,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
unkv[(*unkc)++] = arg;
return opts;
}
+ if (revs->graph && revs->track_linear)
+ die("--show-linear-break and --graph are incompatible");
return 1;
}
@@ -2902,6 +2912,27 @@ enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit)
return action;
}
+static void track_linear(struct rev_info *revs, struct commit *commit)
+{
+ if (revs->track_first_time) {
+ revs->linear = 1;
+ revs->track_first_time = 0;
+ } else {
+ struct commit_list *p;
+ for (p = revs->previous_parents; p; p = p->next)
+ if (p->item == NULL || /* first commit */
+ !hashcmp(p->item->object.sha1, commit->object.sha1))
+ break;
+ revs->linear = p != NULL;
+ }
+ if (revs->reverse) {
+ if (revs->linear)
+ commit->object.flags |= TRACK_LINEAR;
+ }
+ free_commit_list(revs->previous_parents);
+ revs->previous_parents = copy_commit_list(commit->parents);
+}
+
static struct commit *get_revision_1(struct rev_info *revs)
{
if (!revs->commits)
@@ -2941,6 +2972,8 @@ static struct commit *get_revision_1(struct rev_info *revs)
die("Failed to simplify parents of commit %s",
sha1_to_hex(commit->object.sha1));
default:
+ if (revs->track_linear)
+ track_linear(revs, commit);
return commit;
}
} while (revs->commits);
@@ -3107,14 +3140,23 @@ struct commit *get_revision(struct rev_info *revs)
revs->reverse_output_stage = 1;
}
- if (revs->reverse_output_stage)
- return pop_commit(&revs->commits);
+ if (revs->reverse_output_stage) {
+ c = pop_commit(&revs->commits);
+ if (revs->track_linear)
+ revs->linear = !!(c && c->object.flags & TRACK_LINEAR);
+ return c;
+ }
c = get_revision_internal(revs);
if (c && revs->graph)
graph_update(revs->graph, c);
- if (!c)
+ if (!c) {
free_saved_parents(revs);
+ if (revs->previous_parents) {
+ free_commit_list(revs->previous_parents);
+ revs->previous_parents = NULL;
+ }
+ }
return c;
}
diff --git a/revision.h b/revision.h
index 1eb94c1548..d9907dd460 100644
--- a/revision.h
+++ b/revision.h
@@ -7,6 +7,7 @@
#include "commit.h"
#include "diff.h"
+/* Remember to update object flag allocation in object.h */
#define SEEN (1u<<0)
#define UNINTERESTING (1u<<1)
#define TREESAME (1u<<2)
@@ -18,7 +19,8 @@
#define SYMMETRIC_LEFT (1u<<8)
#define PATCHSAME (1u<<9)
#define BOTTOM (1u<<10)
-#define ALL_REV_FLAGS ((1u<<11)-1)
+#define TRACK_LINEAR (1u<<26)
+#define ALL_REV_FLAGS (((1u<<11)-1) | TRACK_LINEAR)
#define DECORATE_SHORT_REFS 1
#define DECORATE_FULL_REFS 2
@@ -137,6 +139,10 @@ struct rev_info {
preserve_subject:1;
unsigned int disable_stdin:1;
unsigned int leak_pending:1;
+ /* --show-linear-break */
+ unsigned int track_linear:1,
+ track_first_time:1,
+ linear:1;
enum date_mode date_mode;
@@ -197,6 +203,9 @@ struct rev_info {
/* copies of the parent lists, for --full-diff display */
struct saved_parents *saved_parents_slab;
+
+ struct commit_list *previous_parents;
+ const char *break_bar;
};
extern int ref_excluded(struct string_list *, const char *path);
diff --git a/sha1_name.c b/sha1_name.c
index 6fca8692d2..2b6322fad0 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -819,6 +819,8 @@ static int get_sha1_1(const char *name, int len, unsigned char *sha1, unsigned l
* For future extension, ':/!' is reserved. If you want to match a message
* beginning with a '!', you have to repeat the exclamation mark.
*/
+
+/* Remember to update object flag allocation in object.h */
#define ONELINE_SEEN (1u<<20)
static int handle_one_ref(const char *path,
diff --git a/upload-pack.c b/upload-pack.c
index 286a9ed3ea..01de944a0a 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -17,7 +17,7 @@
static const char upload_pack_usage[] = "git upload-pack [--strict] [--timeout=<n>] <dir>";
-/* bits #0..7 in revision.h, #8..10 in commit.c */
+/* Remember to update object flag allocation in object.h */
#define THEY_HAVE (1u << 11)
#define OUR_REF (1u << 12)
#define WANTED (1u << 13)
diff --git a/walker.c b/walker.c
index 633596e06f..1dd86b8f33 100644
--- a/walker.c
+++ b/walker.c
@@ -60,6 +60,7 @@ static int process_tree(struct walker *walker, struct tree *tree)
return 0;
}
+/* Remember to update object flag allocation in object.h */
#define COMPLETE (1U << 0)
#define SEEN (1U << 1)
#define TO_SCAN (1U << 2)