Confusing git log --- First time bug submission please advise on best practices
My co-worker has an inconsistent git log output. Please see that attached files for output (I've made a best effort to remove confidential info from them).
Comparing the two log commands we can see that master and originssh/master have a shared common commit at
<John Doe> (4 hours ago) d85832d
More pom fixes
The top commit for originssh/master and the second to top for master.
I would expect that both logs would share an _identical_ history from that commit onward. But the log for master contains the following
<Jeremy Doe> (27 hours ago) 239ea21 (my-work)
renamed class
<Jeremy Doe> (28 hours ago) 27750b2
Merge branch 'master' of
http://githost.companyname-dev.local/trading-development/sports-container-framework
and
<Jeremy Doe> (2 days ago) a933acb
white space changes
<Jeremy Doe> (2 days ago) b5e51e7
Merge branch 'master' of
http://githost.companyname-dev.local/trading-development/sports-container-framework
<Jeremy Doe> (2 days ago) 3a0f787
removed public methods
<Jeremy Doe> (2 days ago) 4e91130
added the xml deserialisation
None of which appear in the originssh/master log. Is there a scenario in which this is expected. It was my understanding that any two commits with the same hash have exactly the same history.
Thanks for your time.
Technical details:
He is using the Windows git client version 1.8.5.2.msysgit.0 Running on Windows 7
Every command was run through git bash
Background:
He previously had tortoise-git installed, but I had him uninstall it to solve some ssh problems
While uninstalling tortoise-git we also reinstalled git - I don't know what the previous version of git was.
Output of
git branch -avv
* master 6833fd4 Completed merge
my-work 239ea21 renamed class
remotes/origin/HEAD -> origin/master
remotes/origin/master f269789 Cleaning up GIT step 1
remotes/originssh/master d85832d More pom fixes
The background on the originssh remote branch is that his origin uses an HTTP url which wasn't allowing him to push a large commit. I helped him to create originssh to allow the push to be made.
Quoted 35 lines · Francis Stephens
My co-worker has an inconsistent git log output. Please see that attached files for output (I've made a best effort to remove confidential info from them).
Comparing the two log commands we can see that master and originssh/master have a shared common commit at
<John Doe> (4 hours ago) d85832d
More pom fixesThe top commit for originssh/master and the second to top for master.
I would expect that both logs would share an _identical_ history from that commit onward. But the log for master contains the following
<Jeremy Doe> (27 hours ago) 239ea21 (my-work)
renamed class<Jeremy Doe> (28 hours ago) 27750b2
Merge branch 'master' of
http://githost.companyname-dev.local/trading-development/sports-container-frameworkand
<Jeremy Doe> (2 days ago) a933acb
white space changes<Jeremy Doe> (2 days ago) b5e51e7
Merge branch 'master' of
http://githost.companyname-dev.local/trading-development/sports-container-framework<Jeremy Doe> (2 days ago) 3a0f787
removed public methods
Quoted 8 lines
<Jeremy Doe> (2 days ago) 4e91130
added the xml deserialisationNone of which appear in the originssh/master log. Is there a scenario in which this is expected. It was my understanding that any two commits with the same hash have exactly the same history.
Thanks for your time.
The commits that are in the log for master and which are not in the log for originssh/master are merged in at "6833fd4 (HEAD, master); Completed merge".
As "git log" can only present the commits in a linear way, it shows the commits from the ancentry of both parents of HEAD in a reverse chronological order. This means that the commits from the two ancestries are mixed and commits that are shown after each other don't have to be parent and child. See the documentation of "git log" and the section "Commit Ordering": "By default, the commits are shown in reverse chronological order."
Vincent
Quoted 11 lines · Vincent van Ravesteijn
The commits that are in the log for master and which are not in the log for originssh/master are merged in at "6833fd4 (HEAD, master); Completed merge".
As "git log" can only present the commits in a linear way, it shows the commits from the ancentry of both parents of HEAD in a reverse chronological order. This means that the commits from the two ancestries are mixed and commits that are shown after each other don't have to be parent and child. See the documentation of "git log" and the section "Commit Ordering": "By default, the commits are shown in reverse chronological order."
git log --graph can help with getting a better picture.
Signature · 1 line
David Kastrup
Thanks for your clear response. I can see where I went wrong now.
Quoted 18 lines · David Kastrup
Quoted 11 lines · Vincent van Ravesteijn
The commits that are in the log for master and which are not in the log for originssh/master are merged in at "6833fd4 (HEAD, master); Completed merge".
As "git log" can only present the commits in a linear way, it shows the commits from the ancentry of both parents of HEAD in a reverse chronological order. This means that the commits from the two ancestries are mixed and commits that are shown after each other don't have to be parent and child. See the documentation of "git log" and the section "Commit Ordering": "By default, the commits are shown in reverse chronological order."
git log --graph can help with getting a better picture.
--
David Kastrup
Quoted 1 line · Francis Stephens
Thanks for your clear response. I can see where I went wrong now.
Maybe something like this would help avoid confusion a bit in the future? This toy patch puts a horizontal line as a break between two commits if they are not related, so we can clearly see linear commit segments.
--graph definitely helps, but it's too many threads for topic-based development model like git.git that I avoid it most of the time.
-- 8< --
log-tree.c +13 -0
@@ -795,6 +795,7 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct logint log_tree_commit (struct rev_info *opt,struct commit *commit) { +static struct commit_list *last_parents;struct log_info log;int shown;
@@ -805,6 +806,17 @@ int log_tree_commit(struct rev_info *opt, struct commit *commit)if (opt->line_level_traverse)return line_log_print (opt, commit); +if (last_parents) { +struct commit_list *p = last_parents; +int got_parent =0 ; +for (; p && !got_parent; p = p->next) + got_parent = !hashcmp (p->item->object.sha1, + commit->object.sha1); +if (!got_parent) +printf ("______________________________________________________________________\n" ); +free_commit_list (last_parents); + last_parents =NULL ; + } shown =log_tree_diff (opt, commit, &log);if (!shown && opt->loginfo && opt->always_show_header) { log.parent =NULL ;
@@ -813,5 +825,6 @@ int log_tree_commit(struct rev_info *opt, struct commit *commit) } opt->loginfo =NULL ;maybe_flush_or_die (stdout,"stdout" ); + last_parents =copy_commit_list (commit->parents);return shown; }
-- 8< --
Quoted 17 lines · David Kastrup
Quoted 15 lines
Quoted 11 lines · Vincent van Ravesteijn
The commits that are in the log for master and which are not in the log for originssh/master are merged in at "6833fd4 (HEAD, master); Completed merge".
As "git log" can only present the commits in a linear way, it shows the commits from the ancentry of both parents of HEAD in a reverse chronological order. This means that the commits from the two ancestries are mixed and commits that are shown after each other don't have to be parent and child. See the documentation of "git log" and the section "Commit Ordering": "By default, the commits are shown in reverse chronological order."
git log --graph can help with getting a better picture.
Quoted 7 lines · Duy Nguyen
Quoted 1 line · Francis Stephens
Thanks for your clear response. I can see where I went wrong now.
Maybe something like this would help avoid confusion a bit in the future? This toy patch puts a horizontal line as a break between two commits if they are not related, so we can clearly see linear commit segments.
FWIW, this would have saved a lot of head scratching at work over the years.
I'd love to see this in place.
Yves
Signature · 1 line
perl -Mre=debug -e "/just|another|perl|hacker/"
PATCH 1/1 log: add --show-linear-break to help see non-linear history
---
This is a more serious attempt to make non-linear history more visible without --graph. It looks like this
commit e4ddb05720710213108cd13ddd5a115e12a6211d
Author: Andy Spencer <[email protected]>
tree_entry_interesting: match against all pathspecs
..........
commit a0332337be53f266682279c72a5e553986638c87
Author: Jeff King <[email protected]>
t7700: do not use "touch" unnecessarily
commit 088304bf73b9b4149e04d2246fe08a06eef6e795
Author: Jeff King <[email protected]>
t7501: fix "empty commit" test with NO_PERL
..........
commit 74b4f7f27736f3e196a4eb3db41c68e37a6e2160
Author: Nguyễn Thái Ngọc Duy <[email protected]>
tree-walk.c: ignore trailing slash on submodule in tree_entry_interesting()
You can use fancier break bars from [1] instead of plain dots. I'm not sure it works with all combinations of rev-list. But at least log (with/out pathspec) and log --reverse work.
[1] http://www.ascii-art.de/ascii/ab/border.txt
Documentation/rev-list-options.txt | 7 +++++ log-tree.c | 4 +++ revision.c | 52 +++++++++++++++++++++++++++++++++++--- revision.h | 6 +++++ 4 files changed, 66 insertions(+), 3 deletions(-)
Documentation/rev-list-options.txt +7 -0
@@ -750,6 +750,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[=<break bar>]:: + When --graph is not used, all history branches are flatten and + could be hard to see that the two consecutive commits do not + belong to a linear branch. This option puts a break bar in + between them in that case. If `<break bar>` 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
log-tree.c +4 -0
@@ -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;
revision.c +49 -3
81 lines not on this page · raw message
revision.h +6 -0
@@ -134,6 +134,7 @@ struct rev_info { use_terminator:1, missing_newline:1, date_mode_explicit:1, + track_linear:1, preserve_subject:1; unsigned int disable_stdin:1; unsigned int leak_pending:1;
@@ -195,6 +196,11 @@ struct rev_info {/* copies of the parent lists, for --full-diff display */ struct saved_parents *saved_parents_slab; + +struct commit_list *previous_parents; +struct saved_linear *saved_linear_slab; +char *break_bar; +unsigned int linear; };extern int ref_excluded (struct string_list *,const char *path);
Signature · 1 line
1.8.5.2.240.g8478abd
PATCH v2 1/1 log: add --nonlinear-barrier to help see non-linear history
---
v2 renames the option name to --nonlinear-barrier and fixes using it with --dense. Best used with --no-merges to see patch series.
Documentation/rev-list-options.txt | 7 ++++++ log-tree.c | 4 +++ revision.c | 51 +++++++++++++++++++++++++++++++++++--- revision.h | 6 +++++ 4 files changed, 65 insertions(+), 3 deletions(-)
Documentation/rev-list-options.txt +7 -0
@@ -750,6 +750,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. +--nonlinear-barrier[=<barrier>]:: + When --graph is not used, all history branches are flatten and + could be 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
log-tree.c +4 -0
@@ -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;
revision.c +48 -3
80 lines not on this page · raw message
revision.h +6 -0
@@ -134,6 +134,7 @@ struct rev_info { use_terminator:1, missing_newline:1, date_mode_explicit:1, + track_linear:1, preserve_subject:1; unsigned int disable_stdin:1; unsigned int leak_pending:1;
@@ -195,6 +196,11 @@ struct rev_info {/* copies of the parent lists, for --full-diff display */ struct saved_parents *saved_parents_slab; + +struct commit_list *previous_parents; +struct saved_linear *saved_linear_slab; +char *break_bar; +unsigned int linear; };extern int ref_excluded (struct string_list *,const char *path);
Signature · 1 line
1.9.0.40.gaa8c3ea
Re: [PATCH v2] log: add --nonlinear-barrier to help see non-linear history
Quoted 16 lines · Nguyễn Thái Ngọc Duy
Signed-off-by Nguyễn Thái Ngọc Duy <[email protected]>---
v2 renames the option name to --nonlinear-barrier and fixes using it with --dense. Best used with --no-merges to see patch series.Documentation/rev-list-options.txt | 7 ++++++ log-tree.c | 4 +++ revision.c | 51 +++++++++++++++++++++++++++++++++++--- revision.h | 6 +++++ 4 files changed, 65 insertions(+), 3 deletions(-)Documentation/rev-list-options.txt +0
-0
Documentation/rev-list-options.txt This enables parent rewriting, see 'History Simplification' below. · line 754
Quoted 5 lines
Documentation/rev-list-options.txt +2
-0@@ -750,6 +750,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. +--nonlinear-barrier[=<barrier>]:: + When --graph is not used, all history branches are flatten and
s/flatten/flattened/
Documentation/rev-list-options.txt This enables parent rewriting, see 'History Simplification' below. · line 755
Quoted 1 line
Documentation/rev-list-options.txt +1
-0+ could be hard to see that the two consecutive commits do not
s/and could be/which can make it/
Quoted 7 lines
Documentation/rev-list-options.txt +4
-0+ 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
Re: [PATCH v2] log: add --nonlinear-barrier to help see non-linear history
In reply to Nguyễn Thái Ngọc DuyQuoted 4 lines · Nguyễn Thái Ngọc Duy
Signed-off-by Nguyễn Thái Ngọc Duy <[email protected]>---
v2 renames the option name to --nonlinear-barrier and fixes using it with --dense. Best used with --no-merges to see patch series.
I think that the earlier name "show linear-break" is more easily understood than the new name, but maybe that is just me. It's not like you are blocking something from going forward with a barrier, and internally it is called a "break-bar".
Quoted 11 lines
Documentation/rev-list-options.txt | 7 ++++++ log-tree.c | 4 +++ revision.c | 51 +++++++++++++++++++++++++++++++++++--- revision.h | 6 +++++ 4 files changed, 65 insertions(+), 3 deletions(-)Documentation/rev-list-options.txt +0
-0
Documentation/rev-list-options.txt This enables parent rewriting, see 'History Simplification' below. · line 754
Quoted 5 lines
Documentation/rev-list-options.txt +2
-0@@ -750,6 +750,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. +--nonlinear-barrier[=<barrier>]:: + When --graph is not used, all history branches are flatten and
s/flatten and/flattened and it/, perhaps?
Quoted 16 lines
Documentation/rev-list-options.txt +5
-0+ could be 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 beenlog-tree.c +0
-0@@ -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);
log-tree.c int log_tree_commit(struct rev_info *opt, struct commit *commit) · line 817
Quoted 10 lines
log-tree.c +4
-0+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);
Each time get_revision() returns a commit, it is inspected and opt->linear is updated, this function is called and we show the break in the single-strand-of-pearls if this is not a parent of the commit we showed immediately before. If we are showing the commit in reverse, we have to go the other way around, showing the commit and then the break.
OK. It makes sense to me.
log-tree.c int log_tree_commit(struct rev_info *opt, struct commit *commit) · line 820
Quoted 3 lines
log-tree.c +0
-0opt->loginfo =NULL ;maybe_flush_or_die (stdout,"stdout" );return shown;
Does this new feature interact with -z format output in any way? Should it, and if so how?
Quoted 35 lines
revision.c +20
-0@@ -1832,6 +1832,12 @@ 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,"--nonlinear-barrier" )) { + revs->track_linear =1 ; + revs->break_bar =" .........." ; + }else if (starts_with (arg,"--nonlinear-barrier=" )) { + revs->track_linear =1 ; + revs->break_bar =xstrdup (arg +20 ); }else if (starts_with (arg,"--show-notes=" ) ||starts_with (arg,"--notes=" )) {struct strbuf buf =STRBUF_INIT ;@@ -2897,6 +2903,32 @@ enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit)return action; } +define_commit_slab (saved_linear, int); + +static void track_linear (struct rev_info *revs,struct commit *commit) +{ +struct commit_list *p = revs->previous_parents; + +if (p) { +int got_parent =0 ; +for (; p && !got_parent; p = p->next) + got_parent = !hashcmp (p->item->object.sha1, + commit->object.sha1); + revs->linear = got_parent; +free_commit_list (revs->previous_parents); + }else
revision.c enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit) · line 2929
Quoted 10 lines
revision.c +10
-0+ revs->linear =1 ; +if (revs->reverse) { +if (!revs->saved_linear_slab) { + revs->saved_linear_slab =xmalloc (sizeof (struct saved_linear )); +init_saved_linear (revs->saved_linear_slab); + } + + *saved_linear_at (revs->saved_linear_slab, commit) = revs->linear; + } + revs->previous_parents =copy_commit_list (commit->parents);
We are showing commit, and the parents (after history simplification) of the commit we showed before this commit is kept in previous-parents. If we are one of them, we are showing linearly, which makes sense. While we are accumulating the output in the forward direction in preparation for later emitting them in reverse, we need to save away the linear-ness bit somewhere, and a slab is a logical place to save that, which also makes sense. But why do you need a full int? Doesn't an unsigned char wide enough?
I also wondered if the saved-parents slab we already have can be easily reused for this, but it probably would not help.
I do not quite understand the "if we do not have previous parents" bit, though. Is it meant to trigger only at the very beginning?
Thanks.
Re: [PATCH v2] log: add --nonlinear-barrier to help see non-linear history
Quoted 11 lines · Junio C Hamano
Quoted 4 lines · Nguyễn Thái Ngọc Duy
Signed-off-by Nguyễn Thái Ngọc Duy <[email protected]>---
v2 renames the option name to --nonlinear-barrier and fixes using it with --dense. Best used with --no-merges to see patch series.I think that the earlier name "show linear-break" is more easily understood than the new name, but maybe that is just me. It's not like you are blocking something from going forward with a barrier, and internally it is called a "break-bar".
I'll change it back.
Quoted 5 lines
Quoted 3 lines
opt->loginfo = NULL; maybe_flush_or_die(stdout, "stdout"); return shown;Does this new feature interact with -z format output in any way?
Hmm.. never thought of it. Right now it's part of the previous commit.
Quoted 1 line
Should it, and if so how?
No idea.
Quoted 25 lines
Quoted 14 lines
revision.c +14
-0+define_commit_slab (saved_linear, int); + +static void track_linear (struct rev_info *revs,struct commit *commit) +{ +struct commit_list *p = revs->previous_parents; + +if (p) { +int got_parent =0 ; +for (; p && !got_parent; p = p->next) + got_parent = !hashcmp (p->item->object.sha1, + commit->object.sha1); + revs->linear = got_parent; +free_commit_list (revs->previous_parents); + }else revision.c enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit) · line 2929
Quoted 10 lines
revision.c +10
-0+ revs->linear =1 ; +if (revs->reverse) { +if (!revs->saved_linear_slab) { + revs->saved_linear_slab =xmalloc (sizeof (struct saved_linear )); +init_saved_linear (revs->saved_linear_slab); + } + + *saved_linear_at (revs->saved_linear_slab, commit) = revs->linear; + } + revs->previous_parents =copy_commit_list (commit->parents);
Quoted 8 lines
We are showing commit, and the parents (after history simplification) of the commit we showed before this commit is kept in previous-parents. If we are one of them, we are showing linearly, which makes sense. While we are accumulating the output in the forward direction in preparation for later emitting them in reverse, we need to save away the linear-ness bit somewhere, and a slab is a logical place to save that, which also makes sense. But why do you need a full int? Doesn't an unsigned char wide enough?
Yes it is. Will change.
Quoted 2 lines
I also wondered if the saved-parents slab we already have can be easily reused for this, but it probably would not help.
That could end up a maintenance nightmare. revision.c is complex enough as it is.
Quoted 2 lines
I do not quite understand the "if we do not have previous parents" bit, though. Is it meant to trigger only at the very beginning?
Only at the beginning.
Signature · 1 line
Duy
Re: [PATCH v2] log: add --nonlinear-barrier to help see non-linear history
Quoted 4 lines · Duy Nguyen
Quoted 2 lines
I do not quite understand the "if we do not have previous parents" bit, though. Is it meant to trigger only at the very beginning?
Only at the beginning.
Then I am not sure !revs->previous_parents match that condition.
What happens in a history with more than one root commits and the first one the revision traversal finds is one of the roots? When showing the second commit, after processing the root and storing its parent list, which is NULL, to revs->previous_parents, wouldn't it mistakenly think that it is the first round and fail to show the break line?
PATCH v3 1/2 object.h: centralize object flag allocation
In reply to Nguyễn Thái Ngọc DuyWhile the field "flags" is mainly used by the revision walker, it is also used in many other places. Centralize the whole flag allocation to one place for a better overview (and easier to move flags if we have too).
---
The next step could be define (instead of document) all of them in a single place. But that may result in naming conflicts and stuff for little gain.
bisect.c | 3 +-- builtin/blame.c | 2 +- bundle.c | 1 + commit.c | 2 +- fetch-pack.c | 1 + http-push.c | 3 +-- object.h | 13 +++++++++++++ revision.h | 1 + sha1_name.c | 2 ++ upload-pack.c | 2 +- walker.c | 1 + 11 files changed, 24 insertions(+), 7 deletions(-)
bisect.c +1 -2
@@ -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)/*
builtin/blame.c +1 -1
@@ -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)
bundle.c +1 -0
@@ -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)
commit.c +1 -1
@@ -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)
fetch-pack.c +1 -0
@@ -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)
http-push.c +1 -2
@@ -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)
object.h +13 -0
@@ -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 +* 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/*
revision.h +1 -0
@@ -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)
sha1_name.c +2 -0
@@ -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,
upload-pack.c +1 -1
@@ -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)
walker.c +1 -0
@@ -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)
Signature · 1 line
1.9.0.201.g13d9d8b
PATCH v3 2/2 log: add --show-linear-break to help see non-linear history
Option explanation is in rev-list-options.txt. The interaction with -z is left undecided.
---
* Revert back to the old option name --show-linear-break
* Get rid of saved_linear, use another flag in struct object instead
* Fix not showing the break bar after a root commit if the dag graph has multiple roots
* Make it work with --graph (although I don't really see the point of using both at the same time)
* Let the next contributor deal with -z
Documentation/rev-list-options.txt | 7 ++++++ log-tree.c | 9 ++++++++ object.h | 2 +- revision.c | 45 +++++++++++++++++++++++++++++++++++--- revision.h | 9 +++++++- 5 files changed, 67 insertions(+), 5 deletions(-)
Documentation/rev-list-options.txt +7 -0
@@ -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
log-tree.c +9 -0
@@ -805,12 +805,21 @@ 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) { +if (opt->graph) +graph_show_padding (opt->graph); +else +puts ("\n" ); +printf ("%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;
object.h +1 -1
@@ -28,7 +28,7 @@ struct object_array {#define TYPE_BITS 3/* * object flag allocation: -* revision.h: 0------10 +* revision.h: 0------10 26 * fetch-pack.c: 0---4 * walker.c: 0-2 * upload-pack.c: 11---------19
revision.c +42 -3
74 lines not on this page · raw message
revision.h +8 -1
@@ -19,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
@@ -138,6 +139,9 @@ struct rev_info { preserve_subject:1 ; unsigned int disable_stdin:1; unsigned int leak_pending:1; +/* --show-linear-break */ + unsigned int track_linear:1, + linear:1;enum date_mode date_mode;
@@ -198,6 +202,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);
Signature · 1 line
1.9.0.201.g13d9d8b
Re: [PATCH v3 2/2] log: add --show-linear-break to help see non-linear history
Quoted 5 lines · Nguyễn Thái Ngọc Duy
Option explanation is in rev-list-options.txt. The interaction with -z is left undecided.
Signed-off-by Nguyễn Thái Ngọc Duy <[email protected]>---
Thanks.
Quoted 2 lines
* Revert back to the old option name --show-linear-break
* Get rid ofsaved_linear, use another flag in struct object instead
I cannot offhand say if I like this change or not. A flag bit is a scarce and limited resource; commit slabs felt more suited for implementation of corner case eye-candies.
Quoted 2 lines
* Fix not showing the break bar after a root commit if the dag graph has multiple roots
I definitely do not like the way a commit-list data structure is abused to hold a phoney element that points at a NULL with its item pointer. Allocate a single bit in revs that says "I haven't done anything yet" if you want to catch the "first-ness" without breaking what commit_list_insert() and friends are expecting to see---they never expect to see a NULL asked to be on the list, AFAIK.
Quoted 2 lines
* Make it work with --graph (although I don't really see the point of using both at the same time)
I do not see the point, either. I vaguely recall that the previous iteration refused the combination at the option parser level, which I think would be the right thing to do.
Quoted 1 line
* Let the next contributor deal with -z
That is fine.
Re: [PATCH v3 2/2] log: add --show-linear-break to help see non-linear history
Quoted 5 lines · Junio C Hamano
Quoted 1 line
* Get rid of
saved_linear, use another flag in struct object insteadI cannot offhand say if I like this change or not. A flag bit is a scarce and limited resource; commit slabs felt more suited for implementation of corner case eye-candies.
My thinking was like this:
OK an int for a flag is wasteful and Junio suggested that unsigned char is used. But that still wastes 7 bits. So what if I rename it to commit_flags and make it usable as a flag storage for other parts as well? Wait don't we have some flags in struct object#flags. It turns out we have _7_ flags left that nobody touches. Let's take one. If we run out of flags in future, we can bring back commit_flags slab, rearrange the flags and move rarely used ones to commit_flags.
Signature · 1 line
Duy
PATCH v4 1/2 object.h: centralize object flag allocation
In reply to Nguyễn Thái Ngọc DuyWhile the field "flags" is mainly used by the revision walker, it is also used in many other places. Centralize the whole flag allocation to one place for a better overview (and easier to move flags if we have too).
--- bisect.c | 3 +-- builtin/blame.c | 2 +- bundle.c | 1 + commit.c | 2 +- fetch-pack.c | 1 + http-push.c | 3 +-- object.h | 13 +++++++++++++ revision.h | 1 + sha1_name.c | 2 ++ upload-pack.c | 2 +- walker.c | 1 + 11 files changed, 24 insertions(+), 7 deletions(-)
bisect.c +1 -2
@@ -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)/*
builtin/blame.c +1 -1
@@ -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)
bundle.c +1 -0
@@ -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)
commit.c +1 -1
@@ -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)
fetch-pack.c +1 -0
@@ -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)
http-push.c +1 -2
@@ -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)
object.h +13 -0
@@ -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 +* 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/*
revision.h +1 -0
@@ -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)
sha1_name.c +2 -0
@@ -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,
upload-pack.c +1 -1
@@ -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)
walker.c +1 -0
@@ -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)
Signature · 1 line
1.9.1.345.ga1a145c
PATCH v4 2/2 log: add --show-linear-break to help see non-linear history
Option explanation is in rev-list-options.txt. The interaction with -z is left undecided.
---
Quoted 5 lines · Junio C Hamano
Quoted 1 line
* Get rid of
saved_linear, use another flag in struct object insteadI cannot offhand say if I like this change or not. A flag bit is a scarce and limited resource; commit slabs felt more suited for implementation of corner case eye-candies.
I leave it in bit 26. We can move it out when we run low on flag bits.
Quoted 9 lines
Quoted 2 lines
* Fix not showing the break bar after a root commit if the dag graph has multiple roots
I definitely do not like the way a commit-list data structure is abused to hold a phoney element that points at a NULL with its item pointer. Allocate a single bit in revs that says "I haven't done anything yet" if you want to catch the "first-ness" without breaking what
commit_list_insert()and friends are expecting to see---they never expect to see a NULL asked to be on the list, AFAIK.
Fixed.
Quoted 6 lines
Quoted 2 lines
* Make it work with --graph (although I don't really see the point of using both at the same time)
I do not see the point, either. I vaguely recall that the previous iteration refused the combination at the option parser level, which I think would be the right thing to do.
Fixed.
Documentation/rev-list-options.txt | 7 ++++++ log-tree.c | 4 ++++ object.h | 2 +- revision.c | 48 +++++++++++++++++++++++++++++++++++--- revision.h | 10 +++++++- 5 files changed, 66 insertions(+), 5 deletions(-)
Documentation/rev-list-options.txt +7 -0
@@ -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
log-tree.c +4 -0
@@ -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;
object.h +1 -1
@@ -28,7 +28,7 @@ struct object_array {#define TYPE_BITS 3/* * object flag allocation: -* revision.h: 0---------10 +* revision.h: 0---------10 26 * fetch-pack.c: 0---4 * walker.c: 0-2 * upload-pack.c: 11----------------19
revision.c +45 -3
83 lines not on this page · raw message
revision.h +9 -1
@@ -19,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
@@ -138,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;
@@ -198,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);
Signature · 1 line
1.9.1.345.ga1a145c
Re: [PATCH v4 2/2] log: add --show-linear-break to help see non-linear history
Quoted 26 lines · Nguyễn Thái Ngọc Duy
Option explanation is in rev-list-options.txt. The interaction with -z is left undecided.
Signed-off-by Nguyễn Thái Ngọc Duy <[email protected]>---
Quoted 5 lines · Junio C Hamano
Quoted 1 line
* Get rid of
saved_linear, use another flag in struct object insteadI cannot offhand say if I like this change or not. A flag bit is a scarce and limited resource; commit slabs felt more suited for implementation of corner case eye-candies.
I leave it in bit 26. We can move it out when we run low on flag bits.
Quoted 9 lines
Quoted 2 lines
* Fix not showing the break bar after a root commit if the dag graph has multiple roots
I definitely do not like the way a commit-list data structure is abused to hold a phoney element that points at a NULL with its item pointer. Allocate a single bit in revs that says "I haven't done anything yet" if you want to catch the "first-ness" without breaking what
commit_list_insert()and friends are expecting to see---they never expect to see a NULL asked to be on the list, AFAIK.Fixed.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
* Make it work with --graph (although I don't really see the point of using both at the same time)
I do not see the point, either. I vaguely recall that the previous iteration refused the combination at the option parser level, which I think would be the right thing to do.
Fixed.
All changes look good to me.
Especially on the last one because the new "printf()" calls do not even attempt to call into the graph API to tell it that it created a gutter above or give it a chance to draw all vertical lines to connect the graph part.
Will replace and advance them to "Will merge to 'next'" state.
Thanks.