2005-08-21 11:51:10 +02:00
|
|
|
#include "cache.h"
|
2017-06-14 20:07:36 +02:00
|
|
|
#include "config.h"
|
2017-12-12 09:55:35 +01:00
|
|
|
#include "pretty.h"
|
2005-08-21 11:51:10 +02:00
|
|
|
#include "refs.h"
|
2006-05-23 14:15:35 +02:00
|
|
|
#include "builtin.h"
|
2009-04-22 23:41:25 +02:00
|
|
|
#include "color.h"
|
2015-10-31 20:06:45 +01:00
|
|
|
#include "argv-array.h"
|
2009-05-21 09:33:18 +02:00
|
|
|
#include "parse-options.h"
|
2017-06-08 20:08:12 +02:00
|
|
|
#include "dir.h"
|
2018-05-19 07:28:27 +02:00
|
|
|
#include "commit-slab.h"
|
2005-08-21 11:51:10 +02:00
|
|
|
|
2009-05-21 09:33:18 +02:00
|
|
|
static const char* show_branch_usage[] = {
|
2015-02-11 22:44:19 +01:00
|
|
|
N_("git show-branch [-a | --all] [-r | --remotes] [--topo-order | --date-order]\n"
|
2015-01-20 20:30:28 +01:00
|
|
|
" [--current] [--color[=<when>] | --no-color] [--sparse]\n"
|
|
|
|
" [--more=<n> | --list | --independent | --merge-base]\n"
|
|
|
|
" [--no-name | --sha1-name] [--topics] [(<rev> | <glob>)...]"),
|
2015-01-13 08:44:47 +01:00
|
|
|
N_("git show-branch (-g | --reflog)[=<n>[,<base>]] [--list] [<ref>]"),
|
2009-05-21 09:33:18 +02:00
|
|
|
NULL
|
|
|
|
};
|
2005-08-21 11:51:10 +02:00
|
|
|
|
2009-04-22 23:41:25 +02:00
|
|
|
static int showbranch_use_color = -1;
|
|
|
|
|
2015-10-31 20:06:45 +01:00
|
|
|
static struct argv_array default_args = ARGV_ARRAY_INIT;
|
2006-01-09 22:29:23 +01:00
|
|
|
|
2018-05-19 07:28:28 +02:00
|
|
|
/*
|
|
|
|
* TODO: convert this use of commit->object.flags to commit-slab
|
|
|
|
* instead to store a pointer to ref name directly. Then use the same
|
|
|
|
* UNINTERESTING definition from revision.h here.
|
|
|
|
*/
|
2005-08-21 11:51:10 +02:00
|
|
|
#define UNINTERESTING 01
|
|
|
|
|
|
|
|
#define REV_SHIFT 2
|
Shrink "struct object" a bit
This shrinks "struct object" by a small amount, by getting rid of the
"struct type *" pointer and replacing it with a 3-bit bitfield instead.
In addition, we merge the bitfields and the "flags" field, which
incidentally should also remove a useless 4-byte padding from the object
when in 64-bit mode.
Now, our "struct object" is still too damn large, but it's now less
obviously bloated, and of the remaining fields, only the "util" (which is
not used by most things) is clearly something that should be eventually
discarded.
This shrinks the "git-rev-list --all" memory use by about 2.5% on the
kernel archive (and, perhaps more importantly, on the larger mozilla
archive). That may not sound like much, but I suspect it's more on a
64-bit platform.
There are other remaining inefficiencies (the parent lists, for example,
probably have horrible malloc overhead), but this was pretty obvious.
Most of the patch is just changing the comparison of the "type" pointer
from one of the constant string pointers to the appropriate new TYPE_xxx
small integer constant.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-15 01:45:13 +02:00
|
|
|
#define MAX_REVS (FLAG_BITS - REV_SHIFT) /* should not exceed bits_per_int - REV_SHIFT */
|
2005-08-21 11:51:10 +02:00
|
|
|
|
2006-12-15 00:58:56 +01:00
|
|
|
#define DEFAULT_REFLOG 4
|
|
|
|
|
2009-04-22 23:41:25 +02:00
|
|
|
static const char *get_color_code(int idx)
|
|
|
|
{
|
color: delay auto-color decision until point of use
When we read a color value either from a config file or from
the command line, we use git_config_colorbool to convert it
from the tristate always/never/auto into a single yes/no
boolean value.
This has some timing implications with respect to starting
a pager.
If we start (or decide not to start) the pager before
checking the colorbool, everything is fine. Either isatty(1)
will give us the right information, or we will properly
check for pager_in_use().
However, if we decide to start a pager after we have checked
the colorbool, things are not so simple. If stdout is a tty,
then we will have already decided to use color. However, the
user may also have configured color.pager not to use color
with the pager. In this case, we need to actually turn off
color. Unfortunately, the pager code has no idea which color
variables were turned on (and there are many of them
throughout the code, and they may even have been manipulated
after the colorbool selection by something like "--color" on
the command line).
This bug can be seen any time a pager is started after
config and command line options are checked. This has
affected "git diff" since 89d07f7 (diff: don't run pager if
user asked for a diff style exit code, 2007-08-12). It has
also affect the log family since 1fda91b (Fix 'git log'
early pager startup error case, 2010-08-24).
This patch splits the notion of parsing a colorbool and
actually checking the configuration. The "use_color"
variables now have an additional possible value,
GIT_COLOR_AUTO. Users of the variable should use the new
"want_color()" wrapper, which will lazily determine and
cache the auto-color decision.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-18 07:04:23 +02:00
|
|
|
if (want_color(showbranch_use_color))
|
2011-04-05 07:40:23 +02:00
|
|
|
return column_colors_ansi[idx % column_colors_ansi_max];
|
2009-04-22 23:41:25 +02:00
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *get_color_reset_code(void)
|
|
|
|
{
|
color: delay auto-color decision until point of use
When we read a color value either from a config file or from
the command line, we use git_config_colorbool to convert it
from the tristate always/never/auto into a single yes/no
boolean value.
This has some timing implications with respect to starting
a pager.
If we start (or decide not to start) the pager before
checking the colorbool, everything is fine. Either isatty(1)
will give us the right information, or we will properly
check for pager_in_use().
However, if we decide to start a pager after we have checked
the colorbool, things are not so simple. If stdout is a tty,
then we will have already decided to use color. However, the
user may also have configured color.pager not to use color
with the pager. In this case, we need to actually turn off
color. Unfortunately, the pager code has no idea which color
variables were turned on (and there are many of them
throughout the code, and they may even have been manipulated
after the colorbool selection by something like "--color" on
the command line).
This bug can be seen any time a pager is started after
config and command line options are checked. This has
affected "git diff" since 89d07f7 (diff: don't run pager if
user asked for a diff style exit code, 2007-08-12). It has
also affect the log family since 1fda91b (Fix 'git log'
early pager startup error case, 2010-08-24).
This patch splits the notion of parsing a colorbool and
actually checking the configuration. The "use_color"
variables now have an additional possible value,
GIT_COLOR_AUTO. Users of the variable should use the new
"want_color()" wrapper, which will lazily determine and
cache the auto-color decision.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-18 07:04:23 +02:00
|
|
|
if (want_color(showbranch_use_color))
|
2009-04-22 23:41:25 +02:00
|
|
|
return GIT_COLOR_RESET;
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2005-08-21 11:51:10 +02:00
|
|
|
static struct commit *interesting(struct commit_list *list)
|
|
|
|
{
|
|
|
|
while (list) {
|
|
|
|
struct commit *commit = list->item;
|
|
|
|
list = list->next;
|
|
|
|
if (commit->object.flags & UNINTERESTING)
|
|
|
|
continue;
|
|
|
|
return commit;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct commit_name {
|
2005-08-30 02:19:47 +02:00
|
|
|
const char *head_name; /* which head's ancestor? */
|
|
|
|
int generation; /* how many parents away from head_name */
|
2005-08-21 11:51:10 +02:00
|
|
|
};
|
|
|
|
|
2018-05-19 07:28:27 +02:00
|
|
|
define_commit_slab(commit_name_slab, struct commit_name *);
|
|
|
|
static struct commit_name_slab name_slab;
|
|
|
|
|
|
|
|
static struct commit_name *commit_to_name(struct commit *commit)
|
|
|
|
{
|
|
|
|
return *commit_name_slab_at(&name_slab, commit);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-08-30 02:19:47 +02:00
|
|
|
/* Name the commit as nth generation ancestor of head_name;
|
2005-08-21 11:51:10 +02:00
|
|
|
* we count only the first-parent relationship for naming purposes.
|
|
|
|
*/
|
2005-08-30 02:19:47 +02:00
|
|
|
static void name_commit(struct commit *commit, const char *head_name, int nth)
|
2005-08-21 11:51:10 +02:00
|
|
|
{
|
|
|
|
struct commit_name *name;
|
2018-05-19 07:28:27 +02:00
|
|
|
|
|
|
|
name = *commit_name_slab_at(&name_slab, commit);
|
|
|
|
if (!name) {
|
|
|
|
name = xmalloc(sizeof(*name));
|
|
|
|
*commit_name_slab_at(&name_slab, commit) = name;
|
|
|
|
}
|
2005-08-30 02:19:47 +02:00
|
|
|
name->head_name = head_name;
|
2005-08-21 11:51:10 +02:00
|
|
|
name->generation = nth;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Parent is the first parent of the commit. We may name it
|
2005-08-30 02:19:47 +02:00
|
|
|
* as (n+1)th generation ancestor of the same head_name as
|
2005-12-08 23:10:02 +01:00
|
|
|
* commit is nth generation ancestor of, if that generation
|
2005-08-21 11:51:10 +02:00
|
|
|
* number is better than the name it already has.
|
|
|
|
*/
|
|
|
|
static void name_parent(struct commit *commit, struct commit *parent)
|
|
|
|
{
|
2018-05-19 07:28:27 +02:00
|
|
|
struct commit_name *commit_name = commit_to_name(commit);
|
|
|
|
struct commit_name *parent_name = commit_to_name(parent);
|
2005-08-21 11:51:10 +02:00
|
|
|
if (!commit_name)
|
|
|
|
return;
|
|
|
|
if (!parent_name ||
|
|
|
|
commit_name->generation + 1 < parent_name->generation)
|
2005-08-30 02:19:47 +02:00
|
|
|
name_commit(parent, commit_name->head_name,
|
2005-08-21 11:51:10 +02:00
|
|
|
commit_name->generation + 1);
|
|
|
|
}
|
|
|
|
|
2005-08-30 02:19:47 +02:00
|
|
|
static int name_first_parent_chain(struct commit *c)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
while (c) {
|
|
|
|
struct commit *p;
|
2018-05-19 07:28:27 +02:00
|
|
|
if (!commit_to_name(c))
|
2005-08-30 02:19:47 +02:00
|
|
|
break;
|
|
|
|
if (!c->parents)
|
|
|
|
break;
|
|
|
|
p = c->parents->item;
|
2018-05-19 07:28:27 +02:00
|
|
|
if (!commit_to_name(p)) {
|
2005-08-30 02:19:47 +02:00
|
|
|
name_parent(c, p);
|
|
|
|
i++;
|
|
|
|
}
|
2006-07-23 19:51:04 +02:00
|
|
|
else
|
|
|
|
break;
|
2005-08-30 02:19:47 +02:00
|
|
|
c = p;
|
|
|
|
}
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void name_commits(struct commit_list *list,
|
|
|
|
struct commit **rev,
|
|
|
|
char **ref_name,
|
|
|
|
int num_rev)
|
|
|
|
{
|
|
|
|
struct commit_list *cl;
|
|
|
|
struct commit *c;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* First give names to the given heads */
|
|
|
|
for (cl = list; cl; cl = cl->next) {
|
|
|
|
c = cl->item;
|
2018-05-19 07:28:27 +02:00
|
|
|
if (commit_to_name(c))
|
2005-08-30 02:19:47 +02:00
|
|
|
continue;
|
|
|
|
for (i = 0; i < num_rev; i++) {
|
|
|
|
if (rev[i] == c) {
|
|
|
|
name_commit(c, ref_name[i], 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Then commits on the first parent ancestry chain */
|
|
|
|
do {
|
|
|
|
i = 0;
|
|
|
|
for (cl = list; cl; cl = cl->next) {
|
|
|
|
i += name_first_parent_chain(cl->item);
|
|
|
|
}
|
|
|
|
} while (i);
|
|
|
|
|
|
|
|
/* Finally, any unnamed commits */
|
|
|
|
do {
|
|
|
|
i = 0;
|
|
|
|
for (cl = list; cl; cl = cl->next) {
|
|
|
|
struct commit_list *parents;
|
|
|
|
struct commit_name *n;
|
|
|
|
int nth;
|
|
|
|
c = cl->item;
|
2018-05-19 07:28:27 +02:00
|
|
|
if (!commit_to_name(c))
|
2005-08-30 02:19:47 +02:00
|
|
|
continue;
|
2018-05-19 07:28:27 +02:00
|
|
|
n = commit_to_name(c);
|
2005-08-30 02:19:47 +02:00
|
|
|
parents = c->parents;
|
|
|
|
nth = 0;
|
|
|
|
while (parents) {
|
|
|
|
struct commit *p = parents->item;
|
2013-04-05 23:15:50 +02:00
|
|
|
struct strbuf newname = STRBUF_INIT;
|
2005-08-30 02:19:47 +02:00
|
|
|
parents = parents->next;
|
|
|
|
nth++;
|
2018-05-19 07:28:27 +02:00
|
|
|
if (commit_to_name(p))
|
2005-08-30 02:19:47 +02:00
|
|
|
continue;
|
2005-09-25 08:33:02 +02:00
|
|
|
switch (n->generation) {
|
|
|
|
case 0:
|
2013-04-05 23:15:50 +02:00
|
|
|
strbuf_addstr(&newname, n->head_name);
|
2005-09-25 08:33:02 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2013-04-05 23:15:50 +02:00
|
|
|
strbuf_addf(&newname, "%s^", n->head_name);
|
2005-09-25 08:33:02 +02:00
|
|
|
break;
|
|
|
|
default:
|
2013-04-05 23:15:50 +02:00
|
|
|
strbuf_addf(&newname, "%s~%d",
|
|
|
|
n->head_name, n->generation);
|
2005-10-12 00:22:48 +02:00
|
|
|
break;
|
2005-09-25 08:33:02 +02:00
|
|
|
}
|
2005-10-12 00:22:48 +02:00
|
|
|
if (nth == 1)
|
2013-04-05 23:15:50 +02:00
|
|
|
strbuf_addch(&newname, '^');
|
2005-10-12 00:22:48 +02:00
|
|
|
else
|
2013-04-05 23:15:50 +02:00
|
|
|
strbuf_addf(&newname, "^%d", nth);
|
|
|
|
name_commit(p, strbuf_detach(&newname, NULL), 0);
|
2005-08-30 02:19:47 +02:00
|
|
|
i++;
|
|
|
|
name_first_parent_chain(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while (i);
|
|
|
|
}
|
|
|
|
|
2005-08-21 11:51:10 +02:00
|
|
|
static int mark_seen(struct commit *commit, struct commit_list **seen_p)
|
|
|
|
{
|
|
|
|
if (!commit->object.flags) {
|
2006-07-16 09:00:09 +02:00
|
|
|
commit_list_insert(commit, seen_p);
|
2005-08-21 11:51:10 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void join_revs(struct commit_list **list_p,
|
|
|
|
struct commit_list **seen_p,
|
|
|
|
int num_rev, int extra)
|
|
|
|
{
|
|
|
|
int all_mask = ((1u << (REV_SHIFT + num_rev)) - 1);
|
|
|
|
int all_revs = all_mask & ~((1u << REV_SHIFT) - 1);
|
|
|
|
|
|
|
|
while (*list_p) {
|
|
|
|
struct commit_list *parents;
|
2005-11-10 08:36:15 +01:00
|
|
|
int still_interesting = !!interesting(*list_p);
|
2015-10-24 18:21:31 +02:00
|
|
|
struct commit *commit = pop_commit(list_p);
|
2005-08-21 11:51:10 +02:00
|
|
|
int flags = commit->object.flags & all_mask;
|
|
|
|
|
2005-11-10 08:36:15 +01:00
|
|
|
if (!still_interesting && extra <= 0)
|
2005-08-21 11:51:10 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
mark_seen(commit, seen_p);
|
|
|
|
if ((flags & all_revs) == all_revs)
|
|
|
|
flags |= UNINTERESTING;
|
|
|
|
parents = commit->parents;
|
|
|
|
|
|
|
|
while (parents) {
|
|
|
|
struct commit *p = parents->item;
|
|
|
|
int this_flag = p->object.flags;
|
|
|
|
parents = parents->next;
|
|
|
|
if ((this_flag & flags) == flags)
|
|
|
|
continue;
|
2013-10-24 10:53:01 +02:00
|
|
|
parse_commit(p);
|
2005-08-21 11:51:10 +02:00
|
|
|
if (mark_seen(p, seen_p) && !still_interesting)
|
|
|
|
extra--;
|
|
|
|
p->object.flags |= flags;
|
2010-11-27 02:58:14 +01:00
|
|
|
commit_list_insert_by_date(p, list_p);
|
2005-08-21 11:51:10 +02:00
|
|
|
}
|
|
|
|
}
|
2005-11-11 00:47:58 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Postprocess to complete well-poisoning.
|
|
|
|
*
|
|
|
|
* At this point we have all the commits we have seen in
|
2006-07-16 09:00:09 +02:00
|
|
|
* seen_p list. Mark anything that can be reached from
|
|
|
|
* uninteresting commits not interesting.
|
2005-11-11 00:47:58 +01:00
|
|
|
*/
|
|
|
|
for (;;) {
|
|
|
|
int changed = 0;
|
|
|
|
struct commit_list *s;
|
|
|
|
for (s = *seen_p; s; s = s->next) {
|
|
|
|
struct commit *c = s->item;
|
|
|
|
struct commit_list *parents;
|
|
|
|
|
|
|
|
if (((c->object.flags & all_revs) != all_revs) &&
|
|
|
|
!(c->object.flags & UNINTERESTING))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* The current commit is either a merge base or
|
|
|
|
* already uninteresting one. Mark its parents
|
|
|
|
* as uninteresting commits _only_ if they are
|
|
|
|
* already parsed. No reason to find new ones
|
|
|
|
* here.
|
|
|
|
*/
|
|
|
|
parents = c->parents;
|
|
|
|
while (parents) {
|
|
|
|
struct commit *p = parents->item;
|
|
|
|
parents = parents->next;
|
|
|
|
if (!(p->object.flags & UNINTERESTING)) {
|
|
|
|
p->object.flags |= UNINTERESTING;
|
|
|
|
changed = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!changed)
|
|
|
|
break;
|
|
|
|
}
|
2005-08-21 11:51:10 +02:00
|
|
|
}
|
|
|
|
|
2005-10-12 00:22:48 +02:00
|
|
|
static void show_one_commit(struct commit *commit, int no_name)
|
2005-08-21 11:51:10 +02:00
|
|
|
{
|
2008-10-09 21:12:12 +02:00
|
|
|
struct strbuf pretty = STRBUF_INIT;
|
2007-06-11 09:34:54 +02:00
|
|
|
const char *pretty_str = "(unavailable)";
|
2018-05-19 07:28:27 +02:00
|
|
|
struct commit_name *name = commit_to_name(commit);
|
2007-06-11 09:34:54 +02:00
|
|
|
|
|
|
|
if (commit->object.parsed) {
|
2011-05-27 00:27:24 +02:00
|
|
|
pp_commit_easy(CMIT_FMT_ONELINE, commit, &pretty);
|
2007-09-10 12:35:06 +02:00
|
|
|
pretty_str = pretty.buf;
|
2007-06-11 09:34:54 +02:00
|
|
|
}
|
2017-02-15 22:40:52 +01:00
|
|
|
skip_prefix(pretty_str, "[PATCH] ", &pretty_str);
|
2005-10-12 00:22:48 +02:00
|
|
|
|
|
|
|
if (!no_name) {
|
|
|
|
if (name && name->head_name) {
|
|
|
|
printf("[%s", name->head_name);
|
|
|
|
if (name->generation) {
|
|
|
|
if (name->generation == 1)
|
|
|
|
printf("^");
|
|
|
|
else
|
|
|
|
printf("~%d", name->generation);
|
|
|
|
}
|
|
|
|
printf("] ");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
printf("[%s] ",
|
2018-03-12 03:27:30 +01:00
|
|
|
find_unique_abbrev(&commit->object.oid,
|
2010-05-24 10:50:44 +02:00
|
|
|
DEFAULT_ABBREV));
|
2005-08-21 11:51:10 +02:00
|
|
|
}
|
2007-06-11 09:34:54 +02:00
|
|
|
puts(pretty_str);
|
2007-09-10 12:35:06 +02:00
|
|
|
strbuf_release(&pretty);
|
2005-08-21 11:51:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static char *ref_name[MAX_REVS + 1];
|
|
|
|
static int ref_name_cnt;
|
|
|
|
|
2005-12-23 21:47:18 +01:00
|
|
|
static const char *find_digit_prefix(const char *s, int *v)
|
|
|
|
{
|
|
|
|
const char *p;
|
|
|
|
int ver;
|
|
|
|
char ch;
|
|
|
|
|
|
|
|
for (p = s, ver = 0;
|
|
|
|
'0' <= (ch = *p) && ch <= '9';
|
|
|
|
p++)
|
|
|
|
ver = ver * 10 + ch - '0';
|
|
|
|
*v = ver;
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int version_cmp(const char *a, const char *b)
|
|
|
|
{
|
|
|
|
while (1) {
|
|
|
|
int va, vb;
|
|
|
|
|
|
|
|
a = find_digit_prefix(a, &va);
|
|
|
|
b = find_digit_prefix(b, &vb);
|
|
|
|
if (va != vb)
|
|
|
|
return va - vb;
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
int ca = *a;
|
|
|
|
int cb = *b;
|
|
|
|
if ('0' <= ca && ca <= '9')
|
|
|
|
ca = 0;
|
|
|
|
if ('0' <= cb && cb <= '9')
|
|
|
|
cb = 0;
|
|
|
|
if (ca != cb)
|
|
|
|
return ca - cb;
|
|
|
|
if (!ca)
|
|
|
|
break;
|
|
|
|
a++;
|
|
|
|
b++;
|
|
|
|
}
|
|
|
|
if (!*a && !*b)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-25 08:26:20 +02:00
|
|
|
static int compare_ref_name(const void *a_, const void *b_)
|
|
|
|
{
|
|
|
|
const char * const*a = a_, * const*b = b_;
|
2005-12-23 21:47:18 +01:00
|
|
|
return version_cmp(*a, *b);
|
2005-08-25 08:26:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void sort_ref_range(int bottom, int top)
|
|
|
|
{
|
2016-10-01 18:19:48 +02:00
|
|
|
QSORT(ref_name + bottom, top - bottom, compare_ref_name);
|
2005-08-25 08:26:20 +02:00
|
|
|
}
|
|
|
|
|
2015-05-25 20:38:48 +02:00
|
|
|
static int append_ref(const char *refname, const struct object_id *oid,
|
show-branch --reflog: show the reflog message at the top.
This changes the output so the list at the top shows the reflog
message, along with their relative timestamps.
You can use --reflog=<n> to show <n> most recent log entries, or
use --reflog=<n>,<b> to show <n> entries going back from the
entry <b>. <b> can be either a number (so --reflog=4,20 shows 4
records starting from @{20}) or a timestamp (e.g. --reflog='4,1 day').
Here is a sample output (with --list option):
$ git show-branch --reflog=10 --list jc/show-reflog
[jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
[jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
[jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow retrievi
[jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
[jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --reflog: use
This shows what I did more cleanly:
$ git show-branch --reflog=10 jc/show-reflog
! [jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
! [jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
! [jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_
! [jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read
! [jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend rea
! [jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow
! [jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
! [jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --r
----------
+ [jc/show-reflog@{0}] show-branch --reflog: show the reflog
+ [jc/show-reflog@{2}] show-branch --reflog: show the reflog
+++ [jc/show-reflog@{1}] show-branch --reflog: show the reflog
+++++ [jc/show-reflog@{4}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{5}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{6}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{7}] read_ref_at(): allow retrieving the r
+ [jc/show-reflog@{9}] show-branch --reflog: use updated rea
+ [jc/show-reflog@{9}^] read_ref_at(): allow reporting the c
+ [jc/show-reflog@{9}~2] show-branch --reflog: show the refl
+ [jc/show-reflog@{9}~3] read_ref_at(): allow retrieving the
++++++++++ [jc/show-reflog@{8}] dwim_ref(): Separate name-to-ref DWIM
At @{9}, I had a commit to complete 5 patch series, but I wanted
to consolidate two commits that enhances read_ref_at() into one
(they were @{9}^ and @{9}~3), and another two that touch show-branch
into one (@{9} and @{9}~2).
I first saved them with "format-patch -4", and then did a reset
at @{8}. At @{7}, I applied one of them with "am", and then
used "git-apply" on the other one, and amended the commit at
@{6} (so @{6} and @{7} has the same parent). I did not like the
log message, so I amended again at @{5}.
Then I cherry-picked @{9}~2 to create @{3} (the log message
shows that it needs to learn to set GIT_REFLOG_ACTION -- it uses
"git-commit" and the log entry is attributed for it). Another
cherry-pick built @{2} out of @{9}, but what I wanted to do was
to squash these two into one, so I did a "reset HEAD^" at @{1}
and then made the final commit by amending what was at the top.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-19 10:20:23 +01:00
|
|
|
int allow_dups)
|
2005-08-21 11:51:10 +02:00
|
|
|
{
|
Convert lookup_commit* to struct object_id
Convert lookup_commit, lookup_commit_or_die,
lookup_commit_reference, and lookup_commit_reference_gently to take
struct object_id arguments.
Introduce a temporary in parse_object buffer in order to convert this
function. This is required since in order to convert parse_object and
parse_object_buffer, lookup_commit_reference_gently and
lookup_commit_or_die would need to be converted. Not introducing a
temporary would therefore require that lookup_commit_or_die take a
struct object_id *, but lookup_commit would take unsigned char *,
leaving a confusing and hard-to-use interface.
parse_object_buffer will lose this temporary in a later patch.
This commit was created with manual changes to commit.c, commit.h, and
object.c, plus the following semantic patch:
@@
expression E1, E2;
@@
- lookup_commit_reference_gently(E1.hash, E2)
+ lookup_commit_reference_gently(&E1, E2)
@@
expression E1, E2;
@@
- lookup_commit_reference_gently(E1->hash, E2)
+ lookup_commit_reference_gently(E1, E2)
@@
expression E1;
@@
- lookup_commit_reference(E1.hash)
+ lookup_commit_reference(&E1)
@@
expression E1;
@@
- lookup_commit_reference(E1->hash)
+ lookup_commit_reference(E1)
@@
expression E1;
@@
- lookup_commit(E1.hash)
+ lookup_commit(&E1)
@@
expression E1;
@@
- lookup_commit(E1->hash)
+ lookup_commit(E1)
@@
expression E1, E2;
@@
- lookup_commit_or_die(E1.hash, E2)
+ lookup_commit_or_die(&E1, E2)
@@
expression E1, E2;
@@
- lookup_commit_or_die(E1->hash, E2)
+ lookup_commit_or_die(E1, E2)
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-05-07 00:10:10 +02:00
|
|
|
struct commit *commit = lookup_commit_reference_gently(oid, 1);
|
2005-12-23 21:47:18 +01:00
|
|
|
int i;
|
|
|
|
|
2005-08-21 11:51:10 +02:00
|
|
|
if (!commit)
|
|
|
|
return 0;
|
2005-12-23 21:47:18 +01:00
|
|
|
|
show-branch --reflog: show the reflog message at the top.
This changes the output so the list at the top shows the reflog
message, along with their relative timestamps.
You can use --reflog=<n> to show <n> most recent log entries, or
use --reflog=<n>,<b> to show <n> entries going back from the
entry <b>. <b> can be either a number (so --reflog=4,20 shows 4
records starting from @{20}) or a timestamp (e.g. --reflog='4,1 day').
Here is a sample output (with --list option):
$ git show-branch --reflog=10 --list jc/show-reflog
[jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
[jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
[jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow retrievi
[jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
[jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --reflog: use
This shows what I did more cleanly:
$ git show-branch --reflog=10 jc/show-reflog
! [jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
! [jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
! [jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_
! [jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read
! [jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend rea
! [jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow
! [jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
! [jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --r
----------
+ [jc/show-reflog@{0}] show-branch --reflog: show the reflog
+ [jc/show-reflog@{2}] show-branch --reflog: show the reflog
+++ [jc/show-reflog@{1}] show-branch --reflog: show the reflog
+++++ [jc/show-reflog@{4}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{5}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{6}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{7}] read_ref_at(): allow retrieving the r
+ [jc/show-reflog@{9}] show-branch --reflog: use updated rea
+ [jc/show-reflog@{9}^] read_ref_at(): allow reporting the c
+ [jc/show-reflog@{9}~2] show-branch --reflog: show the refl
+ [jc/show-reflog@{9}~3] read_ref_at(): allow retrieving the
++++++++++ [jc/show-reflog@{8}] dwim_ref(): Separate name-to-ref DWIM
At @{9}, I had a commit to complete 5 patch series, but I wanted
to consolidate two commits that enhances read_ref_at() into one
(they were @{9}^ and @{9}~3), and another two that touch show-branch
into one (@{9} and @{9}~2).
I first saved them with "format-patch -4", and then did a reset
at @{8}. At @{7}, I applied one of them with "am", and then
used "git-apply" on the other one, and amended the commit at
@{6} (so @{6} and @{7} has the same parent). I did not like the
log message, so I amended again at @{5}.
Then I cherry-picked @{9}~2 to create @{3} (the log message
shows that it needs to learn to set GIT_REFLOG_ACTION -- it uses
"git-commit" and the log entry is attributed for it). Another
cherry-pick built @{2} out of @{9}, but what I wanted to do was
to squash these two into one, so I did a "reset HEAD^" at @{1}
and then made the final commit by amending what was at the top.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-19 10:20:23 +01:00
|
|
|
if (!allow_dups) {
|
|
|
|
/* Avoid adding the same thing twice */
|
|
|
|
for (i = 0; i < ref_name_cnt; i++)
|
|
|
|
if (!strcmp(refname, ref_name[i]))
|
|
|
|
return 0;
|
|
|
|
}
|
2005-10-23 10:18:42 +02:00
|
|
|
if (MAX_REVS <= ref_name_cnt) {
|
2016-09-15 16:59:07 +02:00
|
|
|
warning(Q_("ignoring %s; cannot handle more than %d ref",
|
|
|
|
"ignoring %s; cannot handle more than %d refs",
|
|
|
|
MAX_REVS), refname, MAX_REVS);
|
2005-08-21 11:51:10 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2006-09-02 06:16:31 +02:00
|
|
|
ref_name[ref_name_cnt++] = xstrdup(refname);
|
2005-08-21 11:51:10 +02:00
|
|
|
ref_name[ref_name_cnt] = NULL;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-05-25 20:38:46 +02:00
|
|
|
static int append_head_ref(const char *refname, const struct object_id *oid,
|
|
|
|
int flag, void *cb_data)
|
2005-08-21 11:51:10 +02:00
|
|
|
{
|
2015-05-25 20:38:46 +02:00
|
|
|
struct object_id tmp;
|
2005-11-21 09:43:12 +01:00
|
|
|
int ofs = 11;
|
2013-11-30 21:55:40 +01:00
|
|
|
if (!starts_with(refname, "refs/heads/"))
|
2005-08-21 11:51:10 +02:00
|
|
|
return 0;
|
2005-11-21 09:43:12 +01:00
|
|
|
/* If both heads/foo and tags/foo exists, get_sha1 would
|
|
|
|
* get confused.
|
|
|
|
*/
|
sha1_name: convert get_sha1* to get_oid*
Now that all the callers of get_sha1 directly or indirectly use struct
object_id, rename the functions starting with get_sha1 to start with
get_oid. Convert the internals in sha1_name.c to use struct object_id
as well, and eliminate explicit length checks where possible. Convert a
use of 40 in get_oid_basic to GIT_SHA1_HEXSZ.
Outside of sha1_name.c and cache.h, this transition was made with the
following semantic patch:
@@
expression E1, E2;
@@
- get_sha1(E1, E2.hash)
+ get_oid(E1, &E2)
@@
expression E1, E2;
@@
- get_sha1(E1, E2->hash)
+ get_oid(E1, E2)
@@
expression E1, E2;
@@
- get_sha1_committish(E1, E2.hash)
+ get_oid_committish(E1, &E2)
@@
expression E1, E2;
@@
- get_sha1_committish(E1, E2->hash)
+ get_oid_committish(E1, E2)
@@
expression E1, E2;
@@
- get_sha1_treeish(E1, E2.hash)
+ get_oid_treeish(E1, &E2)
@@
expression E1, E2;
@@
- get_sha1_treeish(E1, E2->hash)
+ get_oid_treeish(E1, E2)
@@
expression E1, E2;
@@
- get_sha1_commit(E1, E2.hash)
+ get_oid_commit(E1, &E2)
@@
expression E1, E2;
@@
- get_sha1_commit(E1, E2->hash)
+ get_oid_commit(E1, E2)
@@
expression E1, E2;
@@
- get_sha1_tree(E1, E2.hash)
+ get_oid_tree(E1, &E2)
@@
expression E1, E2;
@@
- get_sha1_tree(E1, E2->hash)
+ get_oid_tree(E1, E2)
@@
expression E1, E2;
@@
- get_sha1_blob(E1, E2.hash)
+ get_oid_blob(E1, &E2)
@@
expression E1, E2;
@@
- get_sha1_blob(E1, E2->hash)
+ get_oid_blob(E1, E2)
@@
expression E1, E2, E3, E4;
@@
- get_sha1_with_context(E1, E2, E3.hash, E4)
+ get_oid_with_context(E1, E2, &E3, E4)
@@
expression E1, E2, E3, E4;
@@
- get_sha1_with_context(E1, E2, E3->hash, E4)
+ get_oid_with_context(E1, E2, E3, E4)
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-07-14 01:49:28 +02:00
|
|
|
if (get_oid(refname + ofs, &tmp) || oidcmp(&tmp, oid))
|
2005-11-21 09:43:12 +01:00
|
|
|
ofs = 5;
|
2015-05-25 20:38:48 +02:00
|
|
|
return append_ref(refname + ofs, oid, 0);
|
2005-08-21 11:51:10 +02:00
|
|
|
}
|
|
|
|
|
2015-05-25 20:38:46 +02:00
|
|
|
static int append_remote_ref(const char *refname, const struct object_id *oid,
|
|
|
|
int flag, void *cb_data)
|
2006-12-22 14:58:39 +01:00
|
|
|
{
|
2015-05-25 20:38:46 +02:00
|
|
|
struct object_id tmp;
|
2006-12-22 14:58:39 +01:00
|
|
|
int ofs = 13;
|
2013-11-30 21:55:40 +01:00
|
|
|
if (!starts_with(refname, "refs/remotes/"))
|
2006-12-22 14:58:39 +01:00
|
|
|
return 0;
|
|
|
|
/* If both heads/foo and tags/foo exists, get_sha1 would
|
|
|
|
* get confused.
|
|
|
|
*/
|
sha1_name: convert get_sha1* to get_oid*
Now that all the callers of get_sha1 directly or indirectly use struct
object_id, rename the functions starting with get_sha1 to start with
get_oid. Convert the internals in sha1_name.c to use struct object_id
as well, and eliminate explicit length checks where possible. Convert a
use of 40 in get_oid_basic to GIT_SHA1_HEXSZ.
Outside of sha1_name.c and cache.h, this transition was made with the
following semantic patch:
@@
expression E1, E2;
@@
- get_sha1(E1, E2.hash)
+ get_oid(E1, &E2)
@@
expression E1, E2;
@@
- get_sha1(E1, E2->hash)
+ get_oid(E1, E2)
@@
expression E1, E2;
@@
- get_sha1_committish(E1, E2.hash)
+ get_oid_committish(E1, &E2)
@@
expression E1, E2;
@@
- get_sha1_committish(E1, E2->hash)
+ get_oid_committish(E1, E2)
@@
expression E1, E2;
@@
- get_sha1_treeish(E1, E2.hash)
+ get_oid_treeish(E1, &E2)
@@
expression E1, E2;
@@
- get_sha1_treeish(E1, E2->hash)
+ get_oid_treeish(E1, E2)
@@
expression E1, E2;
@@
- get_sha1_commit(E1, E2.hash)
+ get_oid_commit(E1, &E2)
@@
expression E1, E2;
@@
- get_sha1_commit(E1, E2->hash)
+ get_oid_commit(E1, E2)
@@
expression E1, E2;
@@
- get_sha1_tree(E1, E2.hash)
+ get_oid_tree(E1, &E2)
@@
expression E1, E2;
@@
- get_sha1_tree(E1, E2->hash)
+ get_oid_tree(E1, E2)
@@
expression E1, E2;
@@
- get_sha1_blob(E1, E2.hash)
+ get_oid_blob(E1, &E2)
@@
expression E1, E2;
@@
- get_sha1_blob(E1, E2->hash)
+ get_oid_blob(E1, E2)
@@
expression E1, E2, E3, E4;
@@
- get_sha1_with_context(E1, E2, E3.hash, E4)
+ get_oid_with_context(E1, E2, &E3, E4)
@@
expression E1, E2, E3, E4;
@@
- get_sha1_with_context(E1, E2, E3->hash, E4)
+ get_oid_with_context(E1, E2, E3, E4)
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-07-14 01:49:28 +02:00
|
|
|
if (get_oid(refname + ofs, &tmp) || oidcmp(&tmp, oid))
|
2006-12-22 14:58:39 +01:00
|
|
|
ofs = 5;
|
2015-05-25 20:38:48 +02:00
|
|
|
return append_ref(refname + ofs, oid, 0);
|
2006-12-22 14:58:39 +01:00
|
|
|
}
|
|
|
|
|
2015-05-25 20:38:46 +02:00
|
|
|
static int append_tag_ref(const char *refname, const struct object_id *oid,
|
|
|
|
int flag, void *cb_data)
|
2005-08-21 11:51:10 +02:00
|
|
|
{
|
2013-11-30 21:55:40 +01:00
|
|
|
if (!starts_with(refname, "refs/tags/"))
|
2005-08-21 11:51:10 +02:00
|
|
|
return 0;
|
2015-05-25 20:38:48 +02:00
|
|
|
return append_ref(refname + 5, oid, 0);
|
2005-08-21 11:51:10 +02:00
|
|
|
}
|
|
|
|
|
2005-12-05 00:58:50 +01:00
|
|
|
static const char *match_ref_pattern = NULL;
|
|
|
|
static int match_ref_slash = 0;
|
|
|
|
|
2015-05-25 20:38:45 +02:00
|
|
|
static int append_matching_ref(const char *refname, const struct object_id *oid,
|
|
|
|
int flag, void *cb_data)
|
2005-12-05 00:58:50 +01:00
|
|
|
{
|
|
|
|
/* we want to allow pattern hold/<asterisk> to show all
|
|
|
|
* branches under refs/heads/hold/, and v0.99.9? to show
|
|
|
|
* refs/tags/v0.99.9a and friends.
|
|
|
|
*/
|
|
|
|
const char *tail;
|
2017-06-08 20:08:12 +02:00
|
|
|
int slash = count_slashes(refname);
|
2005-12-05 00:58:50 +01:00
|
|
|
for (tail = refname; *tail && match_ref_slash < slash; )
|
|
|
|
if (*tail++ == '/')
|
|
|
|
slash--;
|
|
|
|
if (!*tail)
|
|
|
|
return 0;
|
2017-06-22 23:38:08 +02:00
|
|
|
if (wildmatch(match_ref_pattern, tail, 0))
|
2005-12-05 00:58:50 +01:00
|
|
|
return 0;
|
2013-11-30 21:55:40 +01:00
|
|
|
if (starts_with(refname, "refs/heads/"))
|
2015-05-25 20:38:46 +02:00
|
|
|
return append_head_ref(refname, oid, flag, cb_data);
|
2013-11-30 21:55:40 +01:00
|
|
|
if (starts_with(refname, "refs/tags/"))
|
2015-05-25 20:38:46 +02:00
|
|
|
return append_tag_ref(refname, oid, flag, cb_data);
|
2015-05-25 20:38:48 +02:00
|
|
|
return append_ref(refname, oid, 0);
|
2005-12-05 00:58:50 +01:00
|
|
|
}
|
|
|
|
|
2006-12-22 14:58:39 +01:00
|
|
|
static void snarf_refs(int head, int remotes)
|
2005-08-21 11:51:10 +02:00
|
|
|
{
|
2005-08-25 08:26:20 +02:00
|
|
|
if (head) {
|
|
|
|
int orig_cnt = ref_name_cnt;
|
2015-05-25 20:38:28 +02:00
|
|
|
|
2015-05-25 20:38:46 +02:00
|
|
|
for_each_ref(append_head_ref, NULL);
|
2005-08-25 08:26:20 +02:00
|
|
|
sort_ref_range(orig_cnt, ref_name_cnt);
|
|
|
|
}
|
2006-12-22 14:58:39 +01:00
|
|
|
if (remotes) {
|
2005-08-25 08:26:20 +02:00
|
|
|
int orig_cnt = ref_name_cnt;
|
2015-05-25 20:38:28 +02:00
|
|
|
|
2015-05-25 20:38:46 +02:00
|
|
|
for_each_ref(append_remote_ref, NULL);
|
2005-08-25 08:26:20 +02:00
|
|
|
sort_ref_range(orig_cnt, ref_name_cnt);
|
|
|
|
}
|
2005-08-21 11:51:10 +02:00
|
|
|
}
|
|
|
|
|
2017-02-15 22:40:52 +01:00
|
|
|
static int rev_is_head(const char *head, const char *name,
|
2005-08-21 11:51:10 +02:00
|
|
|
unsigned char *head_sha1, unsigned char *sha1)
|
|
|
|
{
|
2017-02-14 18:27:45 +01:00
|
|
|
if (!head || (head_sha1 && sha1 && hashcmp(head_sha1, sha1)))
|
2005-08-21 11:51:10 +02:00
|
|
|
return 0;
|
2017-02-15 22:40:52 +01:00
|
|
|
skip_prefix(head, "refs/heads/", &head);
|
|
|
|
if (!skip_prefix(name, "refs/heads/", &name))
|
|
|
|
skip_prefix(name, "heads/", &name);
|
2006-09-12 05:17:35 +02:00
|
|
|
return !strcmp(head, name);
|
2005-08-21 11:51:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int show_merge_base(struct commit_list *seen, int num_rev)
|
|
|
|
{
|
|
|
|
int all_mask = ((1u << (REV_SHIFT + num_rev)) - 1);
|
|
|
|
int all_revs = all_mask & ~((1u << REV_SHIFT) - 1);
|
2005-09-08 21:15:52 +02:00
|
|
|
int exit_status = 1;
|
2005-08-21 11:51:10 +02:00
|
|
|
|
|
|
|
while (seen) {
|
2015-10-24 18:21:31 +02:00
|
|
|
struct commit *commit = pop_commit(&seen);
|
2005-08-21 11:51:10 +02:00
|
|
|
int flags = commit->object.flags & all_mask;
|
|
|
|
if (!(flags & UNINTERESTING) &&
|
|
|
|
((flags & all_revs) == all_revs)) {
|
2015-11-10 03:22:28 +01:00
|
|
|
puts(oid_to_hex(&commit->object.oid));
|
2005-09-08 21:15:52 +02:00
|
|
|
exit_status = 0;
|
|
|
|
commit->object.flags |= UNINTERESTING;
|
2005-08-21 11:51:10 +02:00
|
|
|
}
|
|
|
|
}
|
2005-09-08 21:15:52 +02:00
|
|
|
return exit_status;
|
2005-08-21 11:51:10 +02:00
|
|
|
}
|
|
|
|
|
2005-09-10 00:40:45 +02:00
|
|
|
static int show_independent(struct commit **rev,
|
|
|
|
int num_rev,
|
|
|
|
char **ref_name,
|
|
|
|
unsigned int *rev_mask)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < num_rev; i++) {
|
|
|
|
struct commit *commit = rev[i];
|
|
|
|
unsigned int flag = rev_mask[i];
|
|
|
|
|
|
|
|
if (commit->object.flags == flag)
|
2015-11-10 03:22:28 +01:00
|
|
|
puts(oid_to_hex(&commit->object.oid));
|
2005-09-10 00:40:45 +02:00
|
|
|
commit->object.flags |= UNINTERESTING;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-12-05 00:58:50 +01:00
|
|
|
static void append_one_rev(const char *av)
|
|
|
|
{
|
2015-05-25 20:38:47 +02:00
|
|
|
struct object_id revkey;
|
sha1_name: convert get_sha1* to get_oid*
Now that all the callers of get_sha1 directly or indirectly use struct
object_id, rename the functions starting with get_sha1 to start with
get_oid. Convert the internals in sha1_name.c to use struct object_id
as well, and eliminate explicit length checks where possible. Convert a
use of 40 in get_oid_basic to GIT_SHA1_HEXSZ.
Outside of sha1_name.c and cache.h, this transition was made with the
following semantic patch:
@@
expression E1, E2;
@@
- get_sha1(E1, E2.hash)
+ get_oid(E1, &E2)
@@
expression E1, E2;
@@
- get_sha1(E1, E2->hash)
+ get_oid(E1, E2)
@@
expression E1, E2;
@@
- get_sha1_committish(E1, E2.hash)
+ get_oid_committish(E1, &E2)
@@
expression E1, E2;
@@
- get_sha1_committish(E1, E2->hash)
+ get_oid_committish(E1, E2)
@@
expression E1, E2;
@@
- get_sha1_treeish(E1, E2.hash)
+ get_oid_treeish(E1, &E2)
@@
expression E1, E2;
@@
- get_sha1_treeish(E1, E2->hash)
+ get_oid_treeish(E1, E2)
@@
expression E1, E2;
@@
- get_sha1_commit(E1, E2.hash)
+ get_oid_commit(E1, &E2)
@@
expression E1, E2;
@@
- get_sha1_commit(E1, E2->hash)
+ get_oid_commit(E1, E2)
@@
expression E1, E2;
@@
- get_sha1_tree(E1, E2.hash)
+ get_oid_tree(E1, &E2)
@@
expression E1, E2;
@@
- get_sha1_tree(E1, E2->hash)
+ get_oid_tree(E1, E2)
@@
expression E1, E2;
@@
- get_sha1_blob(E1, E2.hash)
+ get_oid_blob(E1, &E2)
@@
expression E1, E2;
@@
- get_sha1_blob(E1, E2->hash)
+ get_oid_blob(E1, E2)
@@
expression E1, E2, E3, E4;
@@
- get_sha1_with_context(E1, E2, E3.hash, E4)
+ get_oid_with_context(E1, E2, &E3, E4)
@@
expression E1, E2, E3, E4;
@@
- get_sha1_with_context(E1, E2, E3->hash, E4)
+ get_oid_with_context(E1, E2, E3, E4)
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-07-14 01:49:28 +02:00
|
|
|
if (!get_oid(av, &revkey)) {
|
2015-05-25 20:38:48 +02:00
|
|
|
append_ref(av, &revkey, 0);
|
2005-12-05 00:58:50 +01:00
|
|
|
return;
|
|
|
|
}
|
2006-01-11 09:20:25 +01:00
|
|
|
if (strchr(av, '*') || strchr(av, '?') || strchr(av, '[')) {
|
2005-12-05 00:58:50 +01:00
|
|
|
/* glob style match */
|
|
|
|
int saved_matches = ref_name_cnt;
|
2015-05-25 20:38:28 +02:00
|
|
|
|
2005-12-05 00:58:50 +01:00
|
|
|
match_ref_pattern = av;
|
2017-06-08 20:08:12 +02:00
|
|
|
match_ref_slash = count_slashes(av);
|
2015-05-25 20:38:45 +02:00
|
|
|
for_each_ref(append_matching_ref, NULL);
|
2005-12-05 00:58:50 +01:00
|
|
|
if (saved_matches == ref_name_cnt &&
|
|
|
|
ref_name_cnt < MAX_REVS)
|
2016-09-15 16:59:06 +02:00
|
|
|
error(_("no matching refs with %s"), av);
|
2016-10-01 18:19:48 +02:00
|
|
|
sort_ref_range(saved_matches, ref_name_cnt);
|
2005-12-05 00:58:50 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
die("bad sha1 reference %s", av);
|
|
|
|
}
|
|
|
|
|
2008-05-14 19:46:53 +02:00
|
|
|
static int git_show_branch_config(const char *var, const char *value, void *cb)
|
2006-01-09 22:29:23 +01:00
|
|
|
{
|
|
|
|
if (!strcmp(var, "showbranch.default")) {
|
2008-02-11 19:51:03 +01:00
|
|
|
if (!value)
|
|
|
|
return config_error_nonbool(var);
|
2009-06-09 08:26:44 +02:00
|
|
|
/*
|
|
|
|
* default_arg is now passed to parse_options(), so we need to
|
2010-02-04 06:23:18 +01:00
|
|
|
* mimic the real argv a bit better.
|
2009-06-09 08:26:44 +02:00
|
|
|
*/
|
2015-10-31 20:06:45 +01:00
|
|
|
if (!default_args.argc)
|
|
|
|
argv_array_push(&default_args, "show-branch");
|
|
|
|
argv_array_push(&default_args, value);
|
2006-01-09 22:29:23 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-04-22 23:41:25 +02:00
|
|
|
if (!strcmp(var, "color.showbranch")) {
|
2011-08-18 07:03:48 +02:00
|
|
|
showbranch_use_color = git_config_colorbool(var, value);
|
2009-04-22 23:41:25 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-10-13 19:24:31 +02:00
|
|
|
return git_color_default_config(var, value, cb);
|
2006-01-09 22:29:23 +01:00
|
|
|
}
|
|
|
|
|
2006-05-02 02:12:26 +02:00
|
|
|
static int omit_in_dense(struct commit *commit, struct commit **rev, int n)
|
|
|
|
{
|
|
|
|
/* If the commit is tip of the named branches, do not
|
|
|
|
* omit it.
|
|
|
|
* Otherwise, if it is a merge that is reachable from only one
|
|
|
|
* tip, it is not that interesting.
|
|
|
|
*/
|
|
|
|
int i, flag, count;
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
if (rev[i] == commit)
|
|
|
|
return 0;
|
|
|
|
flag = commit->object.flags;
|
|
|
|
for (i = count = 0; i < n; i++) {
|
|
|
|
if (flag & (1u << (i + REV_SHIFT)))
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
if (count == 1)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-05-21 09:33:18 +02:00
|
|
|
static int reflog = 0;
|
|
|
|
|
|
|
|
static int parse_reflog_param(const struct option *opt, const char *arg,
|
|
|
|
int unset)
|
show-branch --reflog: show the reflog message at the top.
This changes the output so the list at the top shows the reflog
message, along with their relative timestamps.
You can use --reflog=<n> to show <n> most recent log entries, or
use --reflog=<n>,<b> to show <n> entries going back from the
entry <b>. <b> can be either a number (so --reflog=4,20 shows 4
records starting from @{20}) or a timestamp (e.g. --reflog='4,1 day').
Here is a sample output (with --list option):
$ git show-branch --reflog=10 --list jc/show-reflog
[jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
[jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
[jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow retrievi
[jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
[jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --reflog: use
This shows what I did more cleanly:
$ git show-branch --reflog=10 jc/show-reflog
! [jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
! [jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
! [jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_
! [jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read
! [jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend rea
! [jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow
! [jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
! [jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --r
----------
+ [jc/show-reflog@{0}] show-branch --reflog: show the reflog
+ [jc/show-reflog@{2}] show-branch --reflog: show the reflog
+++ [jc/show-reflog@{1}] show-branch --reflog: show the reflog
+++++ [jc/show-reflog@{4}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{5}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{6}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{7}] read_ref_at(): allow retrieving the r
+ [jc/show-reflog@{9}] show-branch --reflog: use updated rea
+ [jc/show-reflog@{9}^] read_ref_at(): allow reporting the c
+ [jc/show-reflog@{9}~2] show-branch --reflog: show the refl
+ [jc/show-reflog@{9}~3] read_ref_at(): allow retrieving the
++++++++++ [jc/show-reflog@{8}] dwim_ref(): Separate name-to-ref DWIM
At @{9}, I had a commit to complete 5 patch series, but I wanted
to consolidate two commits that enhances read_ref_at() into one
(they were @{9}^ and @{9}~3), and another two that touch show-branch
into one (@{9} and @{9}~2).
I first saved them with "format-patch -4", and then did a reset
at @{8}. At @{7}, I applied one of them with "am", and then
used "git-apply" on the other one, and amended the commit at
@{6} (so @{6} and @{7} has the same parent). I did not like the
log message, so I amended again at @{5}.
Then I cherry-picked @{9}~2 to create @{3} (the log message
shows that it needs to learn to set GIT_REFLOG_ACTION -- it uses
"git-commit" and the log entry is attributed for it). Another
cherry-pick built @{2} out of @{9}, but what I wanted to do was
to squash these two into one, so I did a "reset HEAD^" at @{1}
and then made the final commit by amending what was at the top.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-19 10:20:23 +01:00
|
|
|
{
|
|
|
|
char *ep;
|
2009-05-21 09:33:18 +02:00
|
|
|
const char **base = (const char **)opt->value;
|
|
|
|
if (!arg)
|
|
|
|
arg = "";
|
|
|
|
reflog = strtoul(arg, &ep, 10);
|
show-branch --reflog: show the reflog message at the top.
This changes the output so the list at the top shows the reflog
message, along with their relative timestamps.
You can use --reflog=<n> to show <n> most recent log entries, or
use --reflog=<n>,<b> to show <n> entries going back from the
entry <b>. <b> can be either a number (so --reflog=4,20 shows 4
records starting from @{20}) or a timestamp (e.g. --reflog='4,1 day').
Here is a sample output (with --list option):
$ git show-branch --reflog=10 --list jc/show-reflog
[jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
[jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
[jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow retrievi
[jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
[jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --reflog: use
This shows what I did more cleanly:
$ git show-branch --reflog=10 jc/show-reflog
! [jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
! [jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
! [jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_
! [jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read
! [jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend rea
! [jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow
! [jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
! [jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --r
----------
+ [jc/show-reflog@{0}] show-branch --reflog: show the reflog
+ [jc/show-reflog@{2}] show-branch --reflog: show the reflog
+++ [jc/show-reflog@{1}] show-branch --reflog: show the reflog
+++++ [jc/show-reflog@{4}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{5}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{6}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{7}] read_ref_at(): allow retrieving the r
+ [jc/show-reflog@{9}] show-branch --reflog: use updated rea
+ [jc/show-reflog@{9}^] read_ref_at(): allow reporting the c
+ [jc/show-reflog@{9}~2] show-branch --reflog: show the refl
+ [jc/show-reflog@{9}~3] read_ref_at(): allow retrieving the
++++++++++ [jc/show-reflog@{8}] dwim_ref(): Separate name-to-ref DWIM
At @{9}, I had a commit to complete 5 patch series, but I wanted
to consolidate two commits that enhances read_ref_at() into one
(they were @{9}^ and @{9}~3), and another two that touch show-branch
into one (@{9} and @{9}~2).
I first saved them with "format-patch -4", and then did a reset
at @{8}. At @{7}, I applied one of them with "am", and then
used "git-apply" on the other one, and amended the commit at
@{6} (so @{6} and @{7} has the same parent). I did not like the
log message, so I amended again at @{5}.
Then I cherry-picked @{9}~2 to create @{3} (the log message
shows that it needs to learn to set GIT_REFLOG_ACTION -- it uses
"git-commit" and the log entry is attributed for it). Another
cherry-pick built @{2} out of @{9}, but what I wanted to do was
to squash these two into one, so I did a "reset HEAD^" at @{1}
and then made the final commit by amending what was at the top.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-19 10:20:23 +01:00
|
|
|
if (*ep == ',')
|
|
|
|
*base = ep + 1;
|
|
|
|
else if (*ep)
|
2009-05-21 09:33:18 +02:00
|
|
|
return error("unrecognized reflog param '%s'", arg);
|
show-branch --reflog: show the reflog message at the top.
This changes the output so the list at the top shows the reflog
message, along with their relative timestamps.
You can use --reflog=<n> to show <n> most recent log entries, or
use --reflog=<n>,<b> to show <n> entries going back from the
entry <b>. <b> can be either a number (so --reflog=4,20 shows 4
records starting from @{20}) or a timestamp (e.g. --reflog='4,1 day').
Here is a sample output (with --list option):
$ git show-branch --reflog=10 --list jc/show-reflog
[jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
[jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
[jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow retrievi
[jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
[jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --reflog: use
This shows what I did more cleanly:
$ git show-branch --reflog=10 jc/show-reflog
! [jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
! [jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
! [jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_
! [jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read
! [jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend rea
! [jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow
! [jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
! [jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --r
----------
+ [jc/show-reflog@{0}] show-branch --reflog: show the reflog
+ [jc/show-reflog@{2}] show-branch --reflog: show the reflog
+++ [jc/show-reflog@{1}] show-branch --reflog: show the reflog
+++++ [jc/show-reflog@{4}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{5}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{6}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{7}] read_ref_at(): allow retrieving the r
+ [jc/show-reflog@{9}] show-branch --reflog: use updated rea
+ [jc/show-reflog@{9}^] read_ref_at(): allow reporting the c
+ [jc/show-reflog@{9}~2] show-branch --reflog: show the refl
+ [jc/show-reflog@{9}~3] read_ref_at(): allow retrieving the
++++++++++ [jc/show-reflog@{8}] dwim_ref(): Separate name-to-ref DWIM
At @{9}, I had a commit to complete 5 patch series, but I wanted
to consolidate two commits that enhances read_ref_at() into one
(they were @{9}^ and @{9}~3), and another two that touch show-branch
into one (@{9} and @{9}~2).
I first saved them with "format-patch -4", and then did a reset
at @{8}. At @{7}, I applied one of them with "am", and then
used "git-apply" on the other one, and amended the commit at
@{6} (so @{6} and @{7} has the same parent). I did not like the
log message, so I amended again at @{5}.
Then I cherry-picked @{9}~2 to create @{3} (the log message
shows that it needs to learn to set GIT_REFLOG_ACTION -- it uses
"git-commit" and the log entry is attributed for it). Another
cherry-pick built @{2} out of @{9}, but what I wanted to do was
to squash these two into one, so I did a "reset HEAD^" at @{1}
and then made the final commit by amending what was at the top.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-19 10:20:23 +01:00
|
|
|
else
|
|
|
|
*base = NULL;
|
2009-05-21 09:33:18 +02:00
|
|
|
if (reflog <= 0)
|
|
|
|
reflog = DEFAULT_REFLOG;
|
|
|
|
return 0;
|
show-branch --reflog: show the reflog message at the top.
This changes the output so the list at the top shows the reflog
message, along with their relative timestamps.
You can use --reflog=<n> to show <n> most recent log entries, or
use --reflog=<n>,<b> to show <n> entries going back from the
entry <b>. <b> can be either a number (so --reflog=4,20 shows 4
records starting from @{20}) or a timestamp (e.g. --reflog='4,1 day').
Here is a sample output (with --list option):
$ git show-branch --reflog=10 --list jc/show-reflog
[jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
[jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
[jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow retrievi
[jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
[jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --reflog: use
This shows what I did more cleanly:
$ git show-branch --reflog=10 jc/show-reflog
! [jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
! [jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
! [jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_
! [jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read
! [jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend rea
! [jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow
! [jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
! [jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --r
----------
+ [jc/show-reflog@{0}] show-branch --reflog: show the reflog
+ [jc/show-reflog@{2}] show-branch --reflog: show the reflog
+++ [jc/show-reflog@{1}] show-branch --reflog: show the reflog
+++++ [jc/show-reflog@{4}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{5}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{6}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{7}] read_ref_at(): allow retrieving the r
+ [jc/show-reflog@{9}] show-branch --reflog: use updated rea
+ [jc/show-reflog@{9}^] read_ref_at(): allow reporting the c
+ [jc/show-reflog@{9}~2] show-branch --reflog: show the refl
+ [jc/show-reflog@{9}~3] read_ref_at(): allow retrieving the
++++++++++ [jc/show-reflog@{8}] dwim_ref(): Separate name-to-ref DWIM
At @{9}, I had a commit to complete 5 patch series, but I wanted
to consolidate two commits that enhances read_ref_at() into one
(they were @{9}^ and @{9}~3), and another two that touch show-branch
into one (@{9} and @{9}~2).
I first saved them with "format-patch -4", and then did a reset
at @{8}. At @{7}, I applied one of them with "am", and then
used "git-apply" on the other one, and amended the commit at
@{6} (so @{6} and @{7} has the same parent). I did not like the
log message, so I amended again at @{5}.
Then I cherry-picked @{9}~2 to create @{3} (the log message
shows that it needs to learn to set GIT_REFLOG_ACTION -- it uses
"git-commit" and the log entry is attributed for it). Another
cherry-pick built @{2} out of @{9}, but what I wanted to do was
to squash these two into one, so I did a "reset HEAD^" at @{1}
and then made the final commit by amending what was at the top.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-19 10:20:23 +01:00
|
|
|
}
|
|
|
|
|
2006-07-29 07:44:25 +02:00
|
|
|
int cmd_show_branch(int ac, const char **av, const char *prefix)
|
2005-08-21 11:51:10 +02:00
|
|
|
{
|
|
|
|
struct commit *rev[MAX_REVS], *commit;
|
show-branch --reflog: show the reflog message at the top.
This changes the output so the list at the top shows the reflog
message, along with their relative timestamps.
You can use --reflog=<n> to show <n> most recent log entries, or
use --reflog=<n>,<b> to show <n> entries going back from the
entry <b>. <b> can be either a number (so --reflog=4,20 shows 4
records starting from @{20}) or a timestamp (e.g. --reflog='4,1 day').
Here is a sample output (with --list option):
$ git show-branch --reflog=10 --list jc/show-reflog
[jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
[jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
[jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow retrievi
[jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
[jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --reflog: use
This shows what I did more cleanly:
$ git show-branch --reflog=10 jc/show-reflog
! [jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
! [jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
! [jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_
! [jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read
! [jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend rea
! [jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow
! [jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
! [jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --r
----------
+ [jc/show-reflog@{0}] show-branch --reflog: show the reflog
+ [jc/show-reflog@{2}] show-branch --reflog: show the reflog
+++ [jc/show-reflog@{1}] show-branch --reflog: show the reflog
+++++ [jc/show-reflog@{4}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{5}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{6}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{7}] read_ref_at(): allow retrieving the r
+ [jc/show-reflog@{9}] show-branch --reflog: use updated rea
+ [jc/show-reflog@{9}^] read_ref_at(): allow reporting the c
+ [jc/show-reflog@{9}~2] show-branch --reflog: show the refl
+ [jc/show-reflog@{9}~3] read_ref_at(): allow retrieving the
++++++++++ [jc/show-reflog@{8}] dwim_ref(): Separate name-to-ref DWIM
At @{9}, I had a commit to complete 5 patch series, but I wanted
to consolidate two commits that enhances read_ref_at() into one
(they were @{9}^ and @{9}~3), and another two that touch show-branch
into one (@{9} and @{9}~2).
I first saved them with "format-patch -4", and then did a reset
at @{8}. At @{7}, I applied one of them with "am", and then
used "git-apply" on the other one, and amended the commit at
@{6} (so @{6} and @{7} has the same parent). I did not like the
log message, so I amended again at @{5}.
Then I cherry-picked @{9}~2 to create @{3} (the log message
shows that it needs to learn to set GIT_REFLOG_ACTION -- it uses
"git-commit" and the log entry is attributed for it). Another
cherry-pick built @{2} out of @{9}, but what I wanted to do was
to squash these two into one, so I did a "reset HEAD^" at @{1}
and then made the final commit by amending what was at the top.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-19 10:20:23 +01:00
|
|
|
char *reflog_msg[MAX_REVS];
|
2005-08-21 11:51:10 +02:00
|
|
|
struct commit_list *list = NULL, *seen = NULL;
|
2005-09-10 00:40:45 +02:00
|
|
|
unsigned int rev_mask[MAX_REVS];
|
2005-08-21 11:51:10 +02:00
|
|
|
int num_rev, i, extra = 0;
|
2006-12-22 14:58:39 +01:00
|
|
|
int all_heads = 0, all_remotes = 0;
|
2005-11-11 00:47:58 +01:00
|
|
|
int all_mask, all_revs;
|
toposort: rename "lifo" field
The primary invariant of sort_in_topological_order() is that a
parent commit is not emitted until all children of it are. When
traversing a forked history like this with "git log C E":
A----B----C
\
D----E
we ensure that A is emitted after all of B, C, D, and E are done, B
has to wait until C is done, and D has to wait until E is done.
In some applications, however, we would further want to control how
these child commits B, C, D and E on two parallel ancestry chains
are shown.
Most of the time, we would want to see C and B emitted together, and
then E and D, and finally A (i.e. the --topo-order output). The
"lifo" parameter of the sort_in_topological_order() function is used
to control this behaviour. We start the traversal by knowing two
commits, C and E. While keeping in mind that we also need to
inspect E later, we pick C first to inspect, and we notice and
record that B needs to be inspected. By structuring the "work to be
done" set as a LIFO stack, we ensure that B is inspected next,
before other in-flight commits we had known that we will need to
inspect, e.g. E.
When showing in --date-order, we would want to see commits ordered
by timestamps, i.e. show C, E, B and D in this order before showing
A, possibly mixing commits from two parallel histories together.
When "lifo" parameter is set to false, the function keeps the "work
to be done" set sorted in the date order to realize this semantics.
After inspecting C, we add B to the "work to be done" set, but the
next commit we inspect from the set is E which is newer than B.
The name "lifo", however, is too strongly tied to the way how the
function implements its behaviour, and does not describe what the
behaviour _means_.
Replace this field with an enum rev_sort_order, with two possible
values: REV_SORT_IN_GRAPH_ORDER and REV_SORT_BY_COMMIT_DATE, and
update the existing code. The mechanical replacement rule is:
"lifo == 0" is equivalent to "sort_order == REV_SORT_BY_COMMIT_DATE"
"lifo == 1" is equivalent to "sort_order == REV_SORT_IN_GRAPH_ORDER"
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-06-07 01:07:14 +02:00
|
|
|
enum rev_sort_order sort_order = REV_SORT_IN_GRAPH_ORDER;
|
2017-02-14 18:27:45 +01:00
|
|
|
char *head;
|
2015-05-25 20:38:48 +02:00
|
|
|
struct object_id head_oid;
|
2005-08-21 11:51:10 +02:00
|
|
|
int merge_base = 0;
|
2005-09-10 00:40:45 +02:00
|
|
|
int independent = 0;
|
2005-10-12 00:22:48 +02:00
|
|
|
int no_name = 0;
|
|
|
|
int sha1_name = 0;
|
2005-11-11 00:47:58 +01:00
|
|
|
int shown_merge_point = 0;
|
2006-01-11 09:16:42 +01:00
|
|
|
int with_current_branch = 0;
|
2006-01-11 23:02:38 +01:00
|
|
|
int head_at = -1;
|
2006-03-03 02:14:00 +01:00
|
|
|
int topics = 0;
|
2006-05-02 02:12:26 +02:00
|
|
|
int dense = 1;
|
show-branch --reflog: show the reflog message at the top.
This changes the output so the list at the top shows the reflog
message, along with their relative timestamps.
You can use --reflog=<n> to show <n> most recent log entries, or
use --reflog=<n>,<b> to show <n> entries going back from the
entry <b>. <b> can be either a number (so --reflog=4,20 shows 4
records starting from @{20}) or a timestamp (e.g. --reflog='4,1 day').
Here is a sample output (with --list option):
$ git show-branch --reflog=10 --list jc/show-reflog
[jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
[jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
[jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow retrievi
[jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
[jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --reflog: use
This shows what I did more cleanly:
$ git show-branch --reflog=10 jc/show-reflog
! [jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
! [jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
! [jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_
! [jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read
! [jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend rea
! [jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow
! [jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
! [jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --r
----------
+ [jc/show-reflog@{0}] show-branch --reflog: show the reflog
+ [jc/show-reflog@{2}] show-branch --reflog: show the reflog
+++ [jc/show-reflog@{1}] show-branch --reflog: show the reflog
+++++ [jc/show-reflog@{4}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{5}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{6}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{7}] read_ref_at(): allow retrieving the r
+ [jc/show-reflog@{9}] show-branch --reflog: use updated rea
+ [jc/show-reflog@{9}^] read_ref_at(): allow reporting the c
+ [jc/show-reflog@{9}~2] show-branch --reflog: show the refl
+ [jc/show-reflog@{9}~3] read_ref_at(): allow retrieving the
++++++++++ [jc/show-reflog@{8}] dwim_ref(): Separate name-to-ref DWIM
At @{9}, I had a commit to complete 5 patch series, but I wanted
to consolidate two commits that enhances read_ref_at() into one
(they were @{9}^ and @{9}~3), and another two that touch show-branch
into one (@{9} and @{9}~2).
I first saved them with "format-patch -4", and then did a reset
at @{8}. At @{7}, I applied one of them with "am", and then
used "git-apply" on the other one, and amended the commit at
@{6} (so @{6} and @{7} has the same parent). I did not like the
log message, so I amended again at @{5}.
Then I cherry-picked @{9}~2 to create @{3} (the log message
shows that it needs to learn to set GIT_REFLOG_ACTION -- it uses
"git-commit" and the log entry is attributed for it). Another
cherry-pick built @{2} out of @{9}, but what I wanted to do was
to squash these two into one, so I did a "reset HEAD^" at @{1}
and then made the final commit by amending what was at the top.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-19 10:20:23 +01:00
|
|
|
const char *reflog_base = NULL;
|
2009-05-21 09:33:18 +02:00
|
|
|
struct option builtin_show_branch_options[] = {
|
2013-08-03 13:51:19 +02:00
|
|
|
OPT_BOOL('a', "all", &all_heads,
|
|
|
|
N_("show remote-tracking and local branches")),
|
|
|
|
OPT_BOOL('r', "remotes", &all_remotes,
|
|
|
|
N_("show remote-tracking branches")),
|
Add an optional argument for --color options
Make git-branch, git-show-branch, git-grep, and all the diff-based
programs accept an optional argument <when> for --color. The argument
is a colorbool: "always", "never", or "auto". If no argument is given,
"always" is used; --no-color is an alias for --color=never. This makes
the command-line interface consistent with other GNU tools, such as `ls'
and `grep', and with the git-config color options. Note that, without
an argument, --color and --no-color work exactly as before.
To implement this, two internal changes were made:
1. Allow the first argument of git_config_colorbool() to be NULL,
in which case it returns -1 if the argument isn't "always", "never",
or "auto".
2. Add OPT_COLOR_FLAG(), OPT__COLOR(), and parse_opt_color_flag_cb()
to the option parsing library. The callback uses
git_config_colorbool(), so color.h is now a dependency
of parse-options.c.
Signed-off-by: Mark Lodato <lodatom@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-17 05:55:58 +01:00
|
|
|
OPT__COLOR(&showbranch_use_color,
|
2012-08-20 14:32:44 +02:00
|
|
|
N_("color '*!+-' corresponding to the branch")),
|
|
|
|
{ OPTION_INTEGER, 0, "more", &extra, N_("n"),
|
|
|
|
N_("show <n> more commits after the common ancestor"),
|
2009-06-08 01:39:15 +02:00
|
|
|
PARSE_OPT_OPTARG, NULL, (intptr_t)1 },
|
2012-08-20 14:32:44 +02:00
|
|
|
OPT_SET_INT(0, "list", &extra, N_("synonym to more=-1"), -1),
|
2013-08-03 13:51:19 +02:00
|
|
|
OPT_BOOL(0, "no-name", &no_name, N_("suppress naming strings")),
|
|
|
|
OPT_BOOL(0, "current", &with_current_branch,
|
|
|
|
N_("include the current branch")),
|
|
|
|
OPT_BOOL(0, "sha1-name", &sha1_name,
|
|
|
|
N_("name commits with their object names")),
|
|
|
|
OPT_BOOL(0, "merge-base", &merge_base,
|
|
|
|
N_("show possible merge bases")),
|
|
|
|
OPT_BOOL(0, "independent", &independent,
|
2012-08-20 14:32:44 +02:00
|
|
|
N_("show refs unreachable from any other ref")),
|
toposort: rename "lifo" field
The primary invariant of sort_in_topological_order() is that a
parent commit is not emitted until all children of it are. When
traversing a forked history like this with "git log C E":
A----B----C
\
D----E
we ensure that A is emitted after all of B, C, D, and E are done, B
has to wait until C is done, and D has to wait until E is done.
In some applications, however, we would further want to control how
these child commits B, C, D and E on two parallel ancestry chains
are shown.
Most of the time, we would want to see C and B emitted together, and
then E and D, and finally A (i.e. the --topo-order output). The
"lifo" parameter of the sort_in_topological_order() function is used
to control this behaviour. We start the traversal by knowing two
commits, C and E. While keeping in mind that we also need to
inspect E later, we pick C first to inspect, and we notice and
record that B needs to be inspected. By structuring the "work to be
done" set as a LIFO stack, we ensure that B is inspected next,
before other in-flight commits we had known that we will need to
inspect, e.g. E.
When showing in --date-order, we would want to see commits ordered
by timestamps, i.e. show C, E, B and D in this order before showing
A, possibly mixing commits from two parallel histories together.
When "lifo" parameter is set to false, the function keeps the "work
to be done" set sorted in the date order to realize this semantics.
After inspecting C, we add B to the "work to be done" set, but the
next commit we inspect from the set is E which is newer than B.
The name "lifo", however, is too strongly tied to the way how the
function implements its behaviour, and does not describe what the
behaviour _means_.
Replace this field with an enum rev_sort_order, with two possible
values: REV_SORT_IN_GRAPH_ORDER and REV_SORT_BY_COMMIT_DATE, and
update the existing code. The mechanical replacement rule is:
"lifo == 0" is equivalent to "sort_order == REV_SORT_BY_COMMIT_DATE"
"lifo == 1" is equivalent to "sort_order == REV_SORT_IN_GRAPH_ORDER"
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-06-07 01:07:14 +02:00
|
|
|
OPT_SET_INT(0, "topo-order", &sort_order,
|
|
|
|
N_("show commits in topological order"),
|
|
|
|
REV_SORT_IN_GRAPH_ORDER),
|
2013-08-03 13:51:19 +02:00
|
|
|
OPT_BOOL(0, "topics", &topics,
|
|
|
|
N_("show only commits not on the first branch")),
|
2009-05-21 09:33:18 +02:00
|
|
|
OPT_SET_INT(0, "sparse", &dense,
|
2012-08-20 14:32:44 +02:00
|
|
|
N_("show merges reachable from only one tip"), 0),
|
toposort: rename "lifo" field
The primary invariant of sort_in_topological_order() is that a
parent commit is not emitted until all children of it are. When
traversing a forked history like this with "git log C E":
A----B----C
\
D----E
we ensure that A is emitted after all of B, C, D, and E are done, B
has to wait until C is done, and D has to wait until E is done.
In some applications, however, we would further want to control how
these child commits B, C, D and E on two parallel ancestry chains
are shown.
Most of the time, we would want to see C and B emitted together, and
then E and D, and finally A (i.e. the --topo-order output). The
"lifo" parameter of the sort_in_topological_order() function is used
to control this behaviour. We start the traversal by knowing two
commits, C and E. While keeping in mind that we also need to
inspect E later, we pick C first to inspect, and we notice and
record that B needs to be inspected. By structuring the "work to be
done" set as a LIFO stack, we ensure that B is inspected next,
before other in-flight commits we had known that we will need to
inspect, e.g. E.
When showing in --date-order, we would want to see commits ordered
by timestamps, i.e. show C, E, B and D in this order before showing
A, possibly mixing commits from two parallel histories together.
When "lifo" parameter is set to false, the function keeps the "work
to be done" set sorted in the date order to realize this semantics.
After inspecting C, we add B to the "work to be done" set, but the
next commit we inspect from the set is E which is newer than B.
The name "lifo", however, is too strongly tied to the way how the
function implements its behaviour, and does not describe what the
behaviour _means_.
Replace this field with an enum rev_sort_order, with two possible
values: REV_SORT_IN_GRAPH_ORDER and REV_SORT_BY_COMMIT_DATE, and
update the existing code. The mechanical replacement rule is:
"lifo == 0" is equivalent to "sort_order == REV_SORT_BY_COMMIT_DATE"
"lifo == 1" is equivalent to "sort_order == REV_SORT_IN_GRAPH_ORDER"
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-06-07 01:07:14 +02:00
|
|
|
OPT_SET_INT(0, "date-order", &sort_order,
|
2013-07-18 14:26:56 +02:00
|
|
|
N_("topologically sort, maintaining date order "
|
2013-07-22 20:23:30 +02:00
|
|
|
"where possible"),
|
toposort: rename "lifo" field
The primary invariant of sort_in_topological_order() is that a
parent commit is not emitted until all children of it are. When
traversing a forked history like this with "git log C E":
A----B----C
\
D----E
we ensure that A is emitted after all of B, C, D, and E are done, B
has to wait until C is done, and D has to wait until E is done.
In some applications, however, we would further want to control how
these child commits B, C, D and E on two parallel ancestry chains
are shown.
Most of the time, we would want to see C and B emitted together, and
then E and D, and finally A (i.e. the --topo-order output). The
"lifo" parameter of the sort_in_topological_order() function is used
to control this behaviour. We start the traversal by knowing two
commits, C and E. While keeping in mind that we also need to
inspect E later, we pick C first to inspect, and we notice and
record that B needs to be inspected. By structuring the "work to be
done" set as a LIFO stack, we ensure that B is inspected next,
before other in-flight commits we had known that we will need to
inspect, e.g. E.
When showing in --date-order, we would want to see commits ordered
by timestamps, i.e. show C, E, B and D in this order before showing
A, possibly mixing commits from two parallel histories together.
When "lifo" parameter is set to false, the function keeps the "work
to be done" set sorted in the date order to realize this semantics.
After inspecting C, we add B to the "work to be done" set, but the
next commit we inspect from the set is E which is newer than B.
The name "lifo", however, is too strongly tied to the way how the
function implements its behaviour, and does not describe what the
behaviour _means_.
Replace this field with an enum rev_sort_order, with two possible
values: REV_SORT_IN_GRAPH_ORDER and REV_SORT_BY_COMMIT_DATE, and
update the existing code. The mechanical replacement rule is:
"lifo == 0" is equivalent to "sort_order == REV_SORT_BY_COMMIT_DATE"
"lifo == 1" is equivalent to "sort_order == REV_SORT_IN_GRAPH_ORDER"
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-06-07 01:07:14 +02:00
|
|
|
REV_SORT_BY_COMMIT_DATE),
|
2012-08-20 14:32:44 +02:00
|
|
|
{ OPTION_CALLBACK, 'g', "reflog", &reflog_base, N_("<n>[,<base>]"),
|
|
|
|
N_("show <n> most recent ref-log entries starting at "
|
|
|
|
"base"),
|
2009-05-21 09:33:18 +02:00
|
|
|
PARSE_OPT_OPTARG | PARSE_OPT_LITERAL_ARGHELP,
|
|
|
|
parse_reflog_param },
|
|
|
|
OPT_END()
|
|
|
|
};
|
2005-08-21 11:51:10 +02:00
|
|
|
|
2018-05-19 07:28:27 +02:00
|
|
|
init_commit_name_slab(&name_slab);
|
|
|
|
|
2008-05-14 19:46:53 +02:00
|
|
|
git_config(git_show_branch_config, NULL);
|
2005-08-31 01:59:37 +02:00
|
|
|
|
2006-01-09 22:29:23 +01:00
|
|
|
/* If nothing is specified, try the default first */
|
2015-10-31 20:06:45 +01:00
|
|
|
if (ac == 1 && default_args.argc) {
|
|
|
|
ac = default_args.argc;
|
|
|
|
av = default_args.argv;
|
2006-01-09 22:29:23 +01:00
|
|
|
}
|
|
|
|
|
2009-05-23 20:53:12 +02:00
|
|
|
ac = parse_options(ac, av, prefix, builtin_show_branch_options,
|
2009-05-21 09:33:18 +02:00
|
|
|
show_branch_usage, PARSE_OPT_STOP_AT_NON_OPTION);
|
|
|
|
if (all_heads)
|
|
|
|
all_remotes = 1;
|
2005-08-21 11:51:10 +02:00
|
|
|
|
2007-01-26 07:14:45 +01:00
|
|
|
if (extra || reflog) {
|
show-branch --reflog: show the reflog message at the top.
This changes the output so the list at the top shows the reflog
message, along with their relative timestamps.
You can use --reflog=<n> to show <n> most recent log entries, or
use --reflog=<n>,<b> to show <n> entries going back from the
entry <b>. <b> can be either a number (so --reflog=4,20 shows 4
records starting from @{20}) or a timestamp (e.g. --reflog='4,1 day').
Here is a sample output (with --list option):
$ git show-branch --reflog=10 --list jc/show-reflog
[jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
[jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
[jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow retrievi
[jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
[jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --reflog: use
This shows what I did more cleanly:
$ git show-branch --reflog=10 jc/show-reflog
! [jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
! [jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
! [jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_
! [jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read
! [jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend rea
! [jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow
! [jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
! [jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --r
----------
+ [jc/show-reflog@{0}] show-branch --reflog: show the reflog
+ [jc/show-reflog@{2}] show-branch --reflog: show the reflog
+++ [jc/show-reflog@{1}] show-branch --reflog: show the reflog
+++++ [jc/show-reflog@{4}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{5}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{6}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{7}] read_ref_at(): allow retrieving the r
+ [jc/show-reflog@{9}] show-branch --reflog: use updated rea
+ [jc/show-reflog@{9}^] read_ref_at(): allow reporting the c
+ [jc/show-reflog@{9}~2] show-branch --reflog: show the refl
+ [jc/show-reflog@{9}~3] read_ref_at(): allow retrieving the
++++++++++ [jc/show-reflog@{8}] dwim_ref(): Separate name-to-ref DWIM
At @{9}, I had a commit to complete 5 patch series, but I wanted
to consolidate two commits that enhances read_ref_at() into one
(they were @{9}^ and @{9}~3), and another two that touch show-branch
into one (@{9} and @{9}~2).
I first saved them with "format-patch -4", and then did a reset
at @{8}. At @{7}, I applied one of them with "am", and then
used "git-apply" on the other one, and amended the commit at
@{6} (so @{6} and @{7} has the same parent). I did not like the
log message, so I amended again at @{5}.
Then I cherry-picked @{9}~2 to create @{3} (the log message
shows that it needs to learn to set GIT_REFLOG_ACTION -- it uses
"git-commit" and the log entry is attributed for it). Another
cherry-pick built @{2} out of @{9}, but what I wanted to do was
to squash these two into one, so I did a "reset HEAD^" at @{1}
and then made the final commit by amending what was at the top.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-19 10:20:23 +01:00
|
|
|
/* "listing" mode is incompatible with
|
|
|
|
* independent nor merge-base modes.
|
|
|
|
*/
|
|
|
|
if (independent || merge_base)
|
2009-05-21 09:33:18 +02:00
|
|
|
usage_with_options(show_branch_usage,
|
|
|
|
builtin_show_branch_options);
|
2007-01-26 07:14:45 +01:00
|
|
|
if (reflog && ((0 < extra) || all_heads || all_remotes))
|
show-branch --reflog: show the reflog message at the top.
This changes the output so the list at the top shows the reflog
message, along with their relative timestamps.
You can use --reflog=<n> to show <n> most recent log entries, or
use --reflog=<n>,<b> to show <n> entries going back from the
entry <b>. <b> can be either a number (so --reflog=4,20 shows 4
records starting from @{20}) or a timestamp (e.g. --reflog='4,1 day').
Here is a sample output (with --list option):
$ git show-branch --reflog=10 --list jc/show-reflog
[jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
[jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
[jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow retrievi
[jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
[jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --reflog: use
This shows what I did more cleanly:
$ git show-branch --reflog=10 jc/show-reflog
! [jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
! [jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
! [jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_
! [jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read
! [jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend rea
! [jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow
! [jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
! [jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --r
----------
+ [jc/show-reflog@{0}] show-branch --reflog: show the reflog
+ [jc/show-reflog@{2}] show-branch --reflog: show the reflog
+++ [jc/show-reflog@{1}] show-branch --reflog: show the reflog
+++++ [jc/show-reflog@{4}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{5}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{6}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{7}] read_ref_at(): allow retrieving the r
+ [jc/show-reflog@{9}] show-branch --reflog: use updated rea
+ [jc/show-reflog@{9}^] read_ref_at(): allow reporting the c
+ [jc/show-reflog@{9}~2] show-branch --reflog: show the refl
+ [jc/show-reflog@{9}~3] read_ref_at(): allow retrieving the
++++++++++ [jc/show-reflog@{8}] dwim_ref(): Separate name-to-ref DWIM
At @{9}, I had a commit to complete 5 patch series, but I wanted
to consolidate two commits that enhances read_ref_at() into one
(they were @{9}^ and @{9}~3), and another two that touch show-branch
into one (@{9} and @{9}~2).
I first saved them with "format-patch -4", and then did a reset
at @{8}. At @{7}, I applied one of them with "am", and then
used "git-apply" on the other one, and amended the commit at
@{6} (so @{6} and @{7} has the same parent). I did not like the
log message, so I amended again at @{5}.
Then I cherry-picked @{9}~2 to create @{3} (the log message
shows that it needs to learn to set GIT_REFLOG_ACTION -- it uses
"git-commit" and the log entry is attributed for it). Another
cherry-pick built @{2} out of @{9}, but what I wanted to do was
to squash these two into one, so I did a "reset HEAD^" at @{1}
and then made the final commit by amending what was at the top.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-19 10:20:23 +01:00
|
|
|
/*
|
|
|
|
* Asking for --more in reflog mode does not
|
2007-01-20 07:51:49 +01:00
|
|
|
* make sense. --list is Ok.
|
|
|
|
*
|
|
|
|
* Also --all and --remotes do not make sense either.
|
show-branch --reflog: show the reflog message at the top.
This changes the output so the list at the top shows the reflog
message, along with their relative timestamps.
You can use --reflog=<n> to show <n> most recent log entries, or
use --reflog=<n>,<b> to show <n> entries going back from the
entry <b>. <b> can be either a number (so --reflog=4,20 shows 4
records starting from @{20}) or a timestamp (e.g. --reflog='4,1 day').
Here is a sample output (with --list option):
$ git show-branch --reflog=10 --list jc/show-reflog
[jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
[jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
[jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow retrievi
[jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
[jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --reflog: use
This shows what I did more cleanly:
$ git show-branch --reflog=10 jc/show-reflog
! [jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
! [jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
! [jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_
! [jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read
! [jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend rea
! [jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow
! [jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
! [jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --r
----------
+ [jc/show-reflog@{0}] show-branch --reflog: show the reflog
+ [jc/show-reflog@{2}] show-branch --reflog: show the reflog
+++ [jc/show-reflog@{1}] show-branch --reflog: show the reflog
+++++ [jc/show-reflog@{4}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{5}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{6}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{7}] read_ref_at(): allow retrieving the r
+ [jc/show-reflog@{9}] show-branch --reflog: use updated rea
+ [jc/show-reflog@{9}^] read_ref_at(): allow reporting the c
+ [jc/show-reflog@{9}~2] show-branch --reflog: show the refl
+ [jc/show-reflog@{9}~3] read_ref_at(): allow retrieving the
++++++++++ [jc/show-reflog@{8}] dwim_ref(): Separate name-to-ref DWIM
At @{9}, I had a commit to complete 5 patch series, but I wanted
to consolidate two commits that enhances read_ref_at() into one
(they were @{9}^ and @{9}~3), and another two that touch show-branch
into one (@{9} and @{9}~2).
I first saved them with "format-patch -4", and then did a reset
at @{8}. At @{7}, I applied one of them with "am", and then
used "git-apply" on the other one, and amended the commit at
@{6} (so @{6} and @{7} has the same parent). I did not like the
log message, so I amended again at @{5}.
Then I cherry-picked @{9}~2 to create @{3} (the log message
shows that it needs to learn to set GIT_REFLOG_ACTION -- it uses
"git-commit" and the log entry is attributed for it). Another
cherry-pick built @{2} out of @{9}, but what I wanted to do was
to squash these two into one, so I did a "reset HEAD^" at @{1}
and then made the final commit by amending what was at the top.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-19 10:20:23 +01:00
|
|
|
*/
|
2016-09-15 16:59:06 +02:00
|
|
|
die(_("--reflog is incompatible with --all, --remotes, "
|
|
|
|
"--independent or --merge-base"));
|
show-branch --reflog: show the reflog message at the top.
This changes the output so the list at the top shows the reflog
message, along with their relative timestamps.
You can use --reflog=<n> to show <n> most recent log entries, or
use --reflog=<n>,<b> to show <n> entries going back from the
entry <b>. <b> can be either a number (so --reflog=4,20 shows 4
records starting from @{20}) or a timestamp (e.g. --reflog='4,1 day').
Here is a sample output (with --list option):
$ git show-branch --reflog=10 --list jc/show-reflog
[jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
[jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
[jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow retrievi
[jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
[jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --reflog: use
This shows what I did more cleanly:
$ git show-branch --reflog=10 jc/show-reflog
! [jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
! [jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
! [jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_
! [jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read
! [jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend rea
! [jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow
! [jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
! [jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --r
----------
+ [jc/show-reflog@{0}] show-branch --reflog: show the reflog
+ [jc/show-reflog@{2}] show-branch --reflog: show the reflog
+++ [jc/show-reflog@{1}] show-branch --reflog: show the reflog
+++++ [jc/show-reflog@{4}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{5}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{6}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{7}] read_ref_at(): allow retrieving the r
+ [jc/show-reflog@{9}] show-branch --reflog: use updated rea
+ [jc/show-reflog@{9}^] read_ref_at(): allow reporting the c
+ [jc/show-reflog@{9}~2] show-branch --reflog: show the refl
+ [jc/show-reflog@{9}~3] read_ref_at(): allow retrieving the
++++++++++ [jc/show-reflog@{8}] dwim_ref(): Separate name-to-ref DWIM
At @{9}, I had a commit to complete 5 patch series, but I wanted
to consolidate two commits that enhances read_ref_at() into one
(they were @{9}^ and @{9}~3), and another two that touch show-branch
into one (@{9} and @{9}~2).
I first saved them with "format-patch -4", and then did a reset
at @{8}. At @{7}, I applied one of them with "am", and then
used "git-apply" on the other one, and amended the commit at
@{6} (so @{6} and @{7} has the same parent). I did not like the
log message, so I amended again at @{5}.
Then I cherry-picked @{9}~2 to create @{3} (the log message
shows that it needs to learn to set GIT_REFLOG_ACTION -- it uses
"git-commit" and the log entry is attributed for it). Another
cherry-pick built @{2} out of @{9}, but what I wanted to do was
to squash these two into one, so I did a "reset HEAD^" at @{1}
and then made the final commit by amending what was at the top.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-19 10:20:23 +01:00
|
|
|
}
|
2005-09-10 00:40:45 +02:00
|
|
|
|
2005-12-23 21:47:18 +01:00
|
|
|
/* If nothing is specified, show all branches by default */
|
show-branch: show all local heads when only giving one rev along --topics
"git show-branch --topics <rev> <revs>..." displays ancestry graph, only
considering commits that are in all given revs, except the first one.
"git show-branch" displays ancestry graph for all local branches.
Unfortunately, "git show-branch --topics <rev>" only prints out the rev
info for the given rev, and nothing else, e.g.:
$ git show-branch --topics origin/master
[origin/master] Sync with 2.3.3
While there is an option to add all remote-tracking branches (-r), and
another to add all local+remote branches (-a), there is no option to add
only local branches. Adding such an option could be considered, but a
user would likely already expect that the above command line considers
the lack of rev other than for --topics as meaning all local branches,
like when there is no argument at all.
Moreover, when using -r and -a along with --topics, the first local or
remote-tracking branch, depending on alphabetic order is used instead of
the one given after --topics (any rev given on the command line is
actually simply ignored when either -r or -a is given). And if no rev is
given at all, the fact that the first alphetical branch is the base of
topics is probably not expected by users (Maybe --topics should always
require one rev on the command line?)
This change makes
"show-branch --topics $rev"
act as
"show-branch --topics $rev $(git for-each-ref refs/heads
--format='%(refname:short)')"
"show-branch -r --topics $rev ..."
act as
"show-branch --topics $rev ... $(git for-each-ref refs/remotes
--format='%(refname:short)')"
instead of
"show-branch --topics $(git for-each-ref refs/remotes
--format='%(refname:short)')"
and
"show-branch -a --topics $rev ..."
act as
"show-branch --topics $rev ... $(git for-each-ref refs/heads refs/remotes
--format='%(refname:short)')"
instead of
"show-branch --topics $(git for-each-ref refs/heads refs/remotes
--format='%(refname:short)')"
Signed-off-by: Mike Hommey <mh@glandium.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-03-31 00:12:23 +02:00
|
|
|
if (ac <= topics && all_heads + all_remotes == 0)
|
2005-12-23 21:47:18 +01:00
|
|
|
all_heads = 1;
|
|
|
|
|
2006-12-15 00:58:56 +01:00
|
|
|
if (reflog) {
|
2015-05-25 20:38:48 +02:00
|
|
|
struct object_id oid;
|
show-branch --reflog: show the reflog message at the top.
This changes the output so the list at the top shows the reflog
message, along with their relative timestamps.
You can use --reflog=<n> to show <n> most recent log entries, or
use --reflog=<n>,<b> to show <n> entries going back from the
entry <b>. <b> can be either a number (so --reflog=4,20 shows 4
records starting from @{20}) or a timestamp (e.g. --reflog='4,1 day').
Here is a sample output (with --list option):
$ git show-branch --reflog=10 --list jc/show-reflog
[jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
[jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
[jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow retrievi
[jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
[jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --reflog: use
This shows what I did more cleanly:
$ git show-branch --reflog=10 jc/show-reflog
! [jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
! [jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
! [jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_
! [jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read
! [jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend rea
! [jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow
! [jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
! [jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --r
----------
+ [jc/show-reflog@{0}] show-branch --reflog: show the reflog
+ [jc/show-reflog@{2}] show-branch --reflog: show the reflog
+++ [jc/show-reflog@{1}] show-branch --reflog: show the reflog
+++++ [jc/show-reflog@{4}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{5}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{6}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{7}] read_ref_at(): allow retrieving the r
+ [jc/show-reflog@{9}] show-branch --reflog: use updated rea
+ [jc/show-reflog@{9}^] read_ref_at(): allow reporting the c
+ [jc/show-reflog@{9}~2] show-branch --reflog: show the refl
+ [jc/show-reflog@{9}~3] read_ref_at(): allow retrieving the
++++++++++ [jc/show-reflog@{8}] dwim_ref(): Separate name-to-ref DWIM
At @{9}, I had a commit to complete 5 patch series, but I wanted
to consolidate two commits that enhances read_ref_at() into one
(they were @{9}^ and @{9}~3), and another two that touch show-branch
into one (@{9} and @{9}~2).
I first saved them with "format-patch -4", and then did a reset
at @{8}. At @{7}, I applied one of them with "am", and then
used "git-apply" on the other one, and amended the commit at
@{6} (so @{6} and @{7} has the same parent). I did not like the
log message, so I amended again at @{5}.
Then I cherry-picked @{9}~2 to create @{3} (the log message
shows that it needs to learn to set GIT_REFLOG_ACTION -- it uses
"git-commit" and the log entry is attributed for it). Another
cherry-pick built @{2} out of @{9}, but what I wanted to do was
to squash these two into one, so I did a "reset HEAD^" at @{1}
and then made the final commit by amending what was at the top.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-19 10:20:23 +01:00
|
|
|
char *ref;
|
|
|
|
int base = 0;
|
2014-09-19 05:45:37 +02:00
|
|
|
unsigned int flags = 0;
|
2007-01-26 07:14:45 +01:00
|
|
|
|
|
|
|
if (ac == 0) {
|
|
|
|
static const char *fake_av[2];
|
2007-02-04 08:31:47 +01:00
|
|
|
|
2014-07-15 21:59:36 +02:00
|
|
|
fake_av[0] = resolve_refdup("HEAD",
|
refs: convert resolve_refdup and refs_resolve_refdup to struct object_id
All of the callers already pass the hash member of struct object_id, so
update them to pass a pointer to the struct directly,
This transformation was done with an update to declaration and
definition and the following semantic patch:
@@
expression E1, E2, E3, E4;
@@
- resolve_refdup(E1, E2, E3.hash, E4)
+ resolve_refdup(E1, E2, &E3, E4)
@@
expression E1, E2, E3, E4;
@@
- resolve_refdup(E1, E2, E3->hash, E4)
+ resolve_refdup(E1, E2, E3, E4)
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-10-16 00:06:55 +02:00
|
|
|
RESOLVE_REF_READING, &oid,
|
|
|
|
NULL);
|
2007-01-26 07:14:45 +01:00
|
|
|
fake_av[1] = NULL;
|
|
|
|
av = fake_av;
|
|
|
|
ac = 1;
|
2015-09-24 23:02:54 +02:00
|
|
|
if (!*av)
|
2016-09-15 16:59:06 +02:00
|
|
|
die(_("no branches given, and HEAD is not valid"));
|
2007-01-26 07:14:45 +01:00
|
|
|
}
|
show-branch --reflog: show the reflog message at the top.
This changes the output so the list at the top shows the reflog
message, along with their relative timestamps.
You can use --reflog=<n> to show <n> most recent log entries, or
use --reflog=<n>,<b> to show <n> entries going back from the
entry <b>. <b> can be either a number (so --reflog=4,20 shows 4
records starting from @{20}) or a timestamp (e.g. --reflog='4,1 day').
Here is a sample output (with --list option):
$ git show-branch --reflog=10 --list jc/show-reflog
[jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
[jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
[jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow retrievi
[jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
[jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --reflog: use
This shows what I did more cleanly:
$ git show-branch --reflog=10 jc/show-reflog
! [jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
! [jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
! [jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_
! [jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read
! [jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend rea
! [jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow
! [jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
! [jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --r
----------
+ [jc/show-reflog@{0}] show-branch --reflog: show the reflog
+ [jc/show-reflog@{2}] show-branch --reflog: show the reflog
+++ [jc/show-reflog@{1}] show-branch --reflog: show the reflog
+++++ [jc/show-reflog@{4}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{5}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{6}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{7}] read_ref_at(): allow retrieving the r
+ [jc/show-reflog@{9}] show-branch --reflog: use updated rea
+ [jc/show-reflog@{9}^] read_ref_at(): allow reporting the c
+ [jc/show-reflog@{9}~2] show-branch --reflog: show the refl
+ [jc/show-reflog@{9}~3] read_ref_at(): allow retrieving the
++++++++++ [jc/show-reflog@{8}] dwim_ref(): Separate name-to-ref DWIM
At @{9}, I had a commit to complete 5 patch series, but I wanted
to consolidate two commits that enhances read_ref_at() into one
(they were @{9}^ and @{9}~3), and another two that touch show-branch
into one (@{9} and @{9}~2).
I first saved them with "format-patch -4", and then did a reset
at @{8}. At @{7}, I applied one of them with "am", and then
used "git-apply" on the other one, and amended the commit at
@{6} (so @{6} and @{7} has the same parent). I did not like the
log message, so I amended again at @{5}.
Then I cherry-picked @{9}~2 to create @{3} (the log message
shows that it needs to learn to set GIT_REFLOG_ACTION -- it uses
"git-commit" and the log entry is attributed for it). Another
cherry-pick built @{2} out of @{9}, but what I wanted to do was
to squash these two into one, so I did a "reset HEAD^" at @{1}
and then made the final commit by amending what was at the top.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-19 10:20:23 +01:00
|
|
|
if (ac != 1)
|
2016-09-15 16:59:06 +02:00
|
|
|
die(_("--reflog option needs one branch name"));
|
2007-01-26 07:14:45 +01:00
|
|
|
|
2007-01-20 07:51:49 +01:00
|
|
|
if (MAX_REVS < reflog)
|
2016-09-15 16:59:07 +02:00
|
|
|
die(Q_("only %d entry can be shown at one time.",
|
|
|
|
"only %d entries can be shown at one time.",
|
|
|
|
MAX_REVS), MAX_REVS);
|
2017-10-16 00:06:57 +02:00
|
|
|
if (!dwim_ref(*av, strlen(*av), &oid, &ref))
|
2016-09-15 16:59:06 +02:00
|
|
|
die(_("no such ref %s"), *av);
|
show-branch --reflog: show the reflog message at the top.
This changes the output so the list at the top shows the reflog
message, along with their relative timestamps.
You can use --reflog=<n> to show <n> most recent log entries, or
use --reflog=<n>,<b> to show <n> entries going back from the
entry <b>. <b> can be either a number (so --reflog=4,20 shows 4
records starting from @{20}) or a timestamp (e.g. --reflog='4,1 day').
Here is a sample output (with --list option):
$ git show-branch --reflog=10 --list jc/show-reflog
[jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
[jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
[jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow retrievi
[jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
[jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --reflog: use
This shows what I did more cleanly:
$ git show-branch --reflog=10 jc/show-reflog
! [jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
! [jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
! [jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_
! [jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read
! [jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend rea
! [jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow
! [jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
! [jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --r
----------
+ [jc/show-reflog@{0}] show-branch --reflog: show the reflog
+ [jc/show-reflog@{2}] show-branch --reflog: show the reflog
+++ [jc/show-reflog@{1}] show-branch --reflog: show the reflog
+++++ [jc/show-reflog@{4}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{5}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{6}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{7}] read_ref_at(): allow retrieving the r
+ [jc/show-reflog@{9}] show-branch --reflog: use updated rea
+ [jc/show-reflog@{9}^] read_ref_at(): allow reporting the c
+ [jc/show-reflog@{9}~2] show-branch --reflog: show the refl
+ [jc/show-reflog@{9}~3] read_ref_at(): allow retrieving the
++++++++++ [jc/show-reflog@{8}] dwim_ref(): Separate name-to-ref DWIM
At @{9}, I had a commit to complete 5 patch series, but I wanted
to consolidate two commits that enhances read_ref_at() into one
(they were @{9}^ and @{9}~3), and another two that touch show-branch
into one (@{9} and @{9}~2).
I first saved them with "format-patch -4", and then did a reset
at @{8}. At @{7}, I applied one of them with "am", and then
used "git-apply" on the other one, and amended the commit at
@{6} (so @{6} and @{7} has the same parent). I did not like the
log message, so I amended again at @{5}.
Then I cherry-picked @{9}~2 to create @{3} (the log message
shows that it needs to learn to set GIT_REFLOG_ACTION -- it uses
"git-commit" and the log entry is attributed for it). Another
cherry-pick built @{2} out of @{9}, but what I wanted to do was
to squash these two into one, so I did a "reset HEAD^" at @{1}
and then made the final commit by amending what was at the top.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-19 10:20:23 +01:00
|
|
|
|
|
|
|
/* Has the base been specified? */
|
|
|
|
if (reflog_base) {
|
|
|
|
char *ep;
|
|
|
|
base = strtoul(reflog_base, &ep, 10);
|
|
|
|
if (*ep) {
|
|
|
|
/* Ah, that is a date spec... */
|
2017-04-26 21:29:31 +02:00
|
|
|
timestamp_t at;
|
show-branch --reflog: show the reflog message at the top.
This changes the output so the list at the top shows the reflog
message, along with their relative timestamps.
You can use --reflog=<n> to show <n> most recent log entries, or
use --reflog=<n>,<b> to show <n> entries going back from the
entry <b>. <b> can be either a number (so --reflog=4,20 shows 4
records starting from @{20}) or a timestamp (e.g. --reflog='4,1 day').
Here is a sample output (with --list option):
$ git show-branch --reflog=10 --list jc/show-reflog
[jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
[jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
[jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow retrievi
[jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
[jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --reflog: use
This shows what I did more cleanly:
$ git show-branch --reflog=10 jc/show-reflog
! [jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
! [jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
! [jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_
! [jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read
! [jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend rea
! [jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow
! [jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
! [jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --r
----------
+ [jc/show-reflog@{0}] show-branch --reflog: show the reflog
+ [jc/show-reflog@{2}] show-branch --reflog: show the reflog
+++ [jc/show-reflog@{1}] show-branch --reflog: show the reflog
+++++ [jc/show-reflog@{4}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{5}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{6}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{7}] read_ref_at(): allow retrieving the r
+ [jc/show-reflog@{9}] show-branch --reflog: use updated rea
+ [jc/show-reflog@{9}^] read_ref_at(): allow reporting the c
+ [jc/show-reflog@{9}~2] show-branch --reflog: show the refl
+ [jc/show-reflog@{9}~3] read_ref_at(): allow retrieving the
++++++++++ [jc/show-reflog@{8}] dwim_ref(): Separate name-to-ref DWIM
At @{9}, I had a commit to complete 5 patch series, but I wanted
to consolidate two commits that enhances read_ref_at() into one
(they were @{9}^ and @{9}~3), and another two that touch show-branch
into one (@{9} and @{9}~2).
I first saved them with "format-patch -4", and then did a reset
at @{8}. At @{7}, I applied one of them with "am", and then
used "git-apply" on the other one, and amended the commit at
@{6} (so @{6} and @{7} has the same parent). I did not like the
log message, so I amended again at @{5}.
Then I cherry-picked @{9}~2 to create @{3} (the log message
shows that it needs to learn to set GIT_REFLOG_ACTION -- it uses
"git-commit" and the log entry is attributed for it). Another
cherry-pick built @{2} out of @{9}, but what I wanted to do was
to squash these two into one, so I did a "reset HEAD^" at @{1}
and then made the final commit by amending what was at the top.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-19 10:20:23 +01:00
|
|
|
at = approxidate(reflog_base);
|
2017-10-16 00:07:03 +02:00
|
|
|
read_ref_at(ref, flags, at, -1, &oid, NULL,
|
show-branch --reflog: show the reflog message at the top.
This changes the output so the list at the top shows the reflog
message, along with their relative timestamps.
You can use --reflog=<n> to show <n> most recent log entries, or
use --reflog=<n>,<b> to show <n> entries going back from the
entry <b>. <b> can be either a number (so --reflog=4,20 shows 4
records starting from @{20}) or a timestamp (e.g. --reflog='4,1 day').
Here is a sample output (with --list option):
$ git show-branch --reflog=10 --list jc/show-reflog
[jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
[jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
[jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow retrievi
[jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
[jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --reflog: use
This shows what I did more cleanly:
$ git show-branch --reflog=10 jc/show-reflog
! [jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
! [jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
! [jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_
! [jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read
! [jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend rea
! [jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow
! [jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
! [jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --r
----------
+ [jc/show-reflog@{0}] show-branch --reflog: show the reflog
+ [jc/show-reflog@{2}] show-branch --reflog: show the reflog
+++ [jc/show-reflog@{1}] show-branch --reflog: show the reflog
+++++ [jc/show-reflog@{4}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{5}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{6}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{7}] read_ref_at(): allow retrieving the r
+ [jc/show-reflog@{9}] show-branch --reflog: use updated rea
+ [jc/show-reflog@{9}^] read_ref_at(): allow reporting the c
+ [jc/show-reflog@{9}~2] show-branch --reflog: show the refl
+ [jc/show-reflog@{9}~3] read_ref_at(): allow retrieving the
++++++++++ [jc/show-reflog@{8}] dwim_ref(): Separate name-to-ref DWIM
At @{9}, I had a commit to complete 5 patch series, but I wanted
to consolidate two commits that enhances read_ref_at() into one
(they were @{9}^ and @{9}~3), and another two that touch show-branch
into one (@{9} and @{9}~2).
I first saved them with "format-patch -4", and then did a reset
at @{8}. At @{7}, I applied one of them with "am", and then
used "git-apply" on the other one, and amended the commit at
@{6} (so @{6} and @{7} has the same parent). I did not like the
log message, so I amended again at @{5}.
Then I cherry-picked @{9}~2 to create @{3} (the log message
shows that it needs to learn to set GIT_REFLOG_ACTION -- it uses
"git-commit" and the log entry is attributed for it). Another
cherry-pick built @{2} out of @{9}, but what I wanted to do was
to squash these two into one, so I did a "reset HEAD^" at @{1}
and then made the final commit by amending what was at the top.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-19 10:20:23 +01:00
|
|
|
NULL, NULL, &base);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-15 00:58:56 +01:00
|
|
|
for (i = 0; i < reflog; i++) {
|
2014-06-19 23:24:33 +02:00
|
|
|
char *logmsg;
|
2015-08-19 20:12:48 +02:00
|
|
|
char *nth_desc;
|
2007-03-07 02:44:17 +01:00
|
|
|
const char *msg;
|
2017-04-26 21:29:31 +02:00
|
|
|
timestamp_t timestamp;
|
show-branch --reflog: show the reflog message at the top.
This changes the output so the list at the top shows the reflog
message, along with their relative timestamps.
You can use --reflog=<n> to show <n> most recent log entries, or
use --reflog=<n>,<b> to show <n> entries going back from the
entry <b>. <b> can be either a number (so --reflog=4,20 shows 4
records starting from @{20}) or a timestamp (e.g. --reflog='4,1 day').
Here is a sample output (with --list option):
$ git show-branch --reflog=10 --list jc/show-reflog
[jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
[jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
[jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow retrievi
[jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
[jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --reflog: use
This shows what I did more cleanly:
$ git show-branch --reflog=10 jc/show-reflog
! [jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
! [jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
! [jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_
! [jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read
! [jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend rea
! [jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow
! [jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
! [jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --r
----------
+ [jc/show-reflog@{0}] show-branch --reflog: show the reflog
+ [jc/show-reflog@{2}] show-branch --reflog: show the reflog
+++ [jc/show-reflog@{1}] show-branch --reflog: show the reflog
+++++ [jc/show-reflog@{4}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{5}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{6}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{7}] read_ref_at(): allow retrieving the r
+ [jc/show-reflog@{9}] show-branch --reflog: use updated rea
+ [jc/show-reflog@{9}^] read_ref_at(): allow reporting the c
+ [jc/show-reflog@{9}~2] show-branch --reflog: show the refl
+ [jc/show-reflog@{9}~3] read_ref_at(): allow retrieving the
++++++++++ [jc/show-reflog@{8}] dwim_ref(): Separate name-to-ref DWIM
At @{9}, I had a commit to complete 5 patch series, but I wanted
to consolidate two commits that enhances read_ref_at() into one
(they were @{9}^ and @{9}~3), and another two that touch show-branch
into one (@{9} and @{9}~2).
I first saved them with "format-patch -4", and then did a reset
at @{8}. At @{7}, I applied one of them with "am", and then
used "git-apply" on the other one, and amended the commit at
@{6} (so @{6} and @{7} has the same parent). I did not like the
log message, so I amended again at @{5}.
Then I cherry-picked @{9}~2 to create @{3} (the log message
shows that it needs to learn to set GIT_REFLOG_ACTION -- it uses
"git-commit" and the log entry is attributed for it). Another
cherry-pick built @{2} out of @{9}, but what I wanted to do was
to squash these two into one, so I did a "reset HEAD^" at @{1}
and then made the final commit by amending what was at the top.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-19 10:20:23 +01:00
|
|
|
int tz;
|
|
|
|
|
2017-10-16 00:07:03 +02:00
|
|
|
if (read_ref_at(ref, flags, 0, base + i, &oid, &logmsg,
|
show-branch --reflog: show the reflog message at the top.
This changes the output so the list at the top shows the reflog
message, along with their relative timestamps.
You can use --reflog=<n> to show <n> most recent log entries, or
use --reflog=<n>,<b> to show <n> entries going back from the
entry <b>. <b> can be either a number (so --reflog=4,20 shows 4
records starting from @{20}) or a timestamp (e.g. --reflog='4,1 day').
Here is a sample output (with --list option):
$ git show-branch --reflog=10 --list jc/show-reflog
[jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
[jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
[jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow retrievi
[jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
[jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --reflog: use
This shows what I did more cleanly:
$ git show-branch --reflog=10 jc/show-reflog
! [jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
! [jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
! [jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_
! [jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read
! [jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend rea
! [jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow
! [jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
! [jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --r
----------
+ [jc/show-reflog@{0}] show-branch --reflog: show the reflog
+ [jc/show-reflog@{2}] show-branch --reflog: show the reflog
+++ [jc/show-reflog@{1}] show-branch --reflog: show the reflog
+++++ [jc/show-reflog@{4}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{5}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{6}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{7}] read_ref_at(): allow retrieving the r
+ [jc/show-reflog@{9}] show-branch --reflog: use updated rea
+ [jc/show-reflog@{9}^] read_ref_at(): allow reporting the c
+ [jc/show-reflog@{9}~2] show-branch --reflog: show the refl
+ [jc/show-reflog@{9}~3] read_ref_at(): allow retrieving the
++++++++++ [jc/show-reflog@{8}] dwim_ref(): Separate name-to-ref DWIM
At @{9}, I had a commit to complete 5 patch series, but I wanted
to consolidate two commits that enhances read_ref_at() into one
(they were @{9}^ and @{9}~3), and another two that touch show-branch
into one (@{9} and @{9}~2).
I first saved them with "format-patch -4", and then did a reset
at @{8}. At @{7}, I applied one of them with "am", and then
used "git-apply" on the other one, and amended the commit at
@{6} (so @{6} and @{7} has the same parent). I did not like the
log message, so I amended again at @{5}.
Then I cherry-picked @{9}~2 to create @{3} (the log message
shows that it needs to learn to set GIT_REFLOG_ACTION -- it uses
"git-commit" and the log entry is attributed for it). Another
cherry-pick built @{2} out of @{9}, but what I wanted to do was
to squash these two into one, so I did a "reset HEAD^" at @{1}
and then made the final commit by amending what was at the top.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-19 10:20:23 +01:00
|
|
|
×tamp, &tz, NULL)) {
|
|
|
|
reflog = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
msg = strchr(logmsg, '\t');
|
|
|
|
if (!msg)
|
|
|
|
msg = "(none)";
|
|
|
|
else
|
|
|
|
msg++;
|
2014-06-19 23:24:33 +02:00
|
|
|
reflog_msg[i] = xstrfmt("(%s) %s",
|
convert "enum date_mode" into a struct
In preparation for adding date modes that may carry extra
information beyond the mode itself, this patch converts the
date_mode enum into a struct.
Most of the conversion is fairly straightforward; we pass
the struct as a pointer and dereference the type field where
necessary. Locations that declare a date_mode can use a "{}"
constructor. However, the tricky case is where we use the
enum labels as constants, like:
show_date(t, tz, DATE_NORMAL);
Ideally we could say:
show_date(t, tz, &{ DATE_NORMAL });
but of course C does not allow that. Likewise, we cannot
cast the constant to a struct, because we need to pass an
actual address. Our options are basically:
1. Manually add a "struct date_mode d = { DATE_NORMAL }"
definition to each caller, and pass "&d". This makes
the callers uglier, because they sometimes do not even
have their own scope (e.g., they are inside a switch
statement).
2. Provide a pre-made global "date_normal" struct that can
be passed by address. We'd also need "date_rfc2822",
"date_iso8601", and so forth. But at least the ugliness
is defined in one place.
3. Provide a wrapper that generates the correct struct on
the fly. The big downside is that we end up pointing to
a single global, which makes our wrapper non-reentrant.
But show_date is already not reentrant, so it does not
matter.
This patch implements 3, along with a minor macro to keep
the size of the callers sane.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-06-25 18:55:02 +02:00
|
|
|
show_date(timestamp, tz,
|
|
|
|
DATE_MODE(RELATIVE)),
|
2014-06-19 23:24:33 +02:00
|
|
|
msg);
|
show-branch --reflog: show the reflog message at the top.
This changes the output so the list at the top shows the reflog
message, along with their relative timestamps.
You can use --reflog=<n> to show <n> most recent log entries, or
use --reflog=<n>,<b> to show <n> entries going back from the
entry <b>. <b> can be either a number (so --reflog=4,20 shows 4
records starting from @{20}) or a timestamp (e.g. --reflog='4,1 day').
Here is a sample output (with --list option):
$ git show-branch --reflog=10 --list jc/show-reflog
[jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
[jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
[jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow retrievi
[jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
[jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --reflog: use
This shows what I did more cleanly:
$ git show-branch --reflog=10 jc/show-reflog
! [jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
! [jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
! [jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_
! [jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read
! [jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend rea
! [jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow
! [jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
! [jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --r
----------
+ [jc/show-reflog@{0}] show-branch --reflog: show the reflog
+ [jc/show-reflog@{2}] show-branch --reflog: show the reflog
+++ [jc/show-reflog@{1}] show-branch --reflog: show the reflog
+++++ [jc/show-reflog@{4}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{5}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{6}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{7}] read_ref_at(): allow retrieving the r
+ [jc/show-reflog@{9}] show-branch --reflog: use updated rea
+ [jc/show-reflog@{9}^] read_ref_at(): allow reporting the c
+ [jc/show-reflog@{9}~2] show-branch --reflog: show the refl
+ [jc/show-reflog@{9}~3] read_ref_at(): allow retrieving the
++++++++++ [jc/show-reflog@{8}] dwim_ref(): Separate name-to-ref DWIM
At @{9}, I had a commit to complete 5 patch series, but I wanted
to consolidate two commits that enhances read_ref_at() into one
(they were @{9}^ and @{9}~3), and another two that touch show-branch
into one (@{9} and @{9}~2).
I first saved them with "format-patch -4", and then did a reset
at @{8}. At @{7}, I applied one of them with "am", and then
used "git-apply" on the other one, and amended the commit at
@{6} (so @{6} and @{7} has the same parent). I did not like the
log message, so I amended again at @{5}.
Then I cherry-picked @{9}~2 to create @{3} (the log message
shows that it needs to learn to set GIT_REFLOG_ACTION -- it uses
"git-commit" and the log entry is attributed for it). Another
cherry-pick built @{2} out of @{9}, but what I wanted to do was
to squash these two into one, so I did a "reset HEAD^" at @{1}
and then made the final commit by amending what was at the top.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-19 10:20:23 +01:00
|
|
|
free(logmsg);
|
2015-08-19 20:12:48 +02:00
|
|
|
|
|
|
|
nth_desc = xstrfmt("%s@{%d}", *av, base+i);
|
2015-05-25 20:38:48 +02:00
|
|
|
append_ref(nth_desc, &oid, 1);
|
2015-08-19 20:12:48 +02:00
|
|
|
free(nth_desc);
|
2006-12-15 00:58:56 +01:00
|
|
|
}
|
2014-07-24 06:41:11 +02:00
|
|
|
free(ref);
|
2006-12-15 00:58:56 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
while (0 < ac) {
|
|
|
|
append_one_rev(*av);
|
|
|
|
ac--; av++;
|
|
|
|
}
|
show-branch: show all local heads when only giving one rev along --topics
"git show-branch --topics <rev> <revs>..." displays ancestry graph, only
considering commits that are in all given revs, except the first one.
"git show-branch" displays ancestry graph for all local branches.
Unfortunately, "git show-branch --topics <rev>" only prints out the rev
info for the given rev, and nothing else, e.g.:
$ git show-branch --topics origin/master
[origin/master] Sync with 2.3.3
While there is an option to add all remote-tracking branches (-r), and
another to add all local+remote branches (-a), there is no option to add
only local branches. Adding such an option could be considered, but a
user would likely already expect that the above command line considers
the lack of rev other than for --topics as meaning all local branches,
like when there is no argument at all.
Moreover, when using -r and -a along with --topics, the first local or
remote-tracking branch, depending on alphabetic order is used instead of
the one given after --topics (any rev given on the command line is
actually simply ignored when either -r or -a is given). And if no rev is
given at all, the fact that the first alphetical branch is the base of
topics is probably not expected by users (Maybe --topics should always
require one rev on the command line?)
This change makes
"show-branch --topics $rev"
act as
"show-branch --topics $rev $(git for-each-ref refs/heads
--format='%(refname:short)')"
"show-branch -r --topics $rev ..."
act as
"show-branch --topics $rev ... $(git for-each-ref refs/remotes
--format='%(refname:short)')"
instead of
"show-branch --topics $(git for-each-ref refs/remotes
--format='%(refname:short)')"
and
"show-branch -a --topics $rev ..."
act as
"show-branch --topics $rev ... $(git for-each-ref refs/heads refs/remotes
--format='%(refname:short)')"
instead of
"show-branch --topics $(git for-each-ref refs/heads refs/remotes
--format='%(refname:short)')"
Signed-off-by: Mike Hommey <mh@glandium.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-03-31 00:12:23 +02:00
|
|
|
if (all_heads + all_remotes)
|
|
|
|
snarf_refs(all_heads, all_remotes);
|
2005-12-05 00:58:50 +01:00
|
|
|
}
|
2005-12-23 21:47:18 +01:00
|
|
|
|
2017-02-14 18:27:45 +01:00
|
|
|
head = resolve_refdup("HEAD", RESOLVE_REF_READING,
|
refs: convert resolve_refdup and refs_resolve_refdup to struct object_id
All of the callers already pass the hash member of struct object_id, so
update them to pass a pointer to the struct directly,
This transformation was done with an update to declaration and
definition and the following semantic patch:
@@
expression E1, E2, E3, E4;
@@
- resolve_refdup(E1, E2, E3.hash, E4)
+ resolve_refdup(E1, E2, &E3, E4)
@@
expression E1, E2, E3, E4;
@@
- resolve_refdup(E1, E2, E3->hash, E4)
+ resolve_refdup(E1, E2, E3, E4)
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-10-16 00:06:55 +02:00
|
|
|
&head_oid, NULL);
|
2006-01-11 09:16:42 +01:00
|
|
|
|
2017-02-14 18:27:45 +01:00
|
|
|
if (with_current_branch && head) {
|
2006-01-11 09:16:42 +01:00
|
|
|
int has_head = 0;
|
|
|
|
for (i = 0; !has_head && i < ref_name_cnt; i++) {
|
|
|
|
/* We are only interested in adding the branch
|
|
|
|
* HEAD points at.
|
|
|
|
*/
|
2006-09-12 05:17:35 +02:00
|
|
|
if (rev_is_head(head,
|
2006-01-11 09:16:42 +01:00
|
|
|
ref_name[i],
|
2015-05-25 20:38:48 +02:00
|
|
|
head_oid.hash, NULL))
|
2006-01-11 09:16:42 +01:00
|
|
|
has_head++;
|
|
|
|
}
|
|
|
|
if (!has_head) {
|
2017-02-15 22:40:52 +01:00
|
|
|
const char *name = head;
|
|
|
|
skip_prefix(name, "refs/heads/", &name);
|
|
|
|
append_one_rev(name);
|
2006-01-11 09:16:42 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-12-05 00:58:50 +01:00
|
|
|
if (!ref_name_cnt) {
|
|
|
|
fprintf(stderr, "No revs to be shown.\n");
|
|
|
|
exit(0);
|
|
|
|
}
|
2005-08-21 11:51:10 +02:00
|
|
|
|
|
|
|
for (num_rev = 0; ref_name[num_rev]; num_rev++) {
|
2015-05-25 20:38:48 +02:00
|
|
|
struct object_id revkey;
|
2005-09-10 00:40:45 +02:00
|
|
|
unsigned int flag = 1u << (num_rev + REV_SHIFT);
|
2005-08-21 11:51:10 +02:00
|
|
|
|
|
|
|
if (MAX_REVS <= num_rev)
|
2016-09-15 16:59:07 +02:00
|
|
|
die(Q_("cannot handle more than %d rev.",
|
|
|
|
"cannot handle more than %d revs.",
|
|
|
|
MAX_REVS), MAX_REVS);
|
sha1_name: convert get_sha1* to get_oid*
Now that all the callers of get_sha1 directly or indirectly use struct
object_id, rename the functions starting with get_sha1 to start with
get_oid. Convert the internals in sha1_name.c to use struct object_id
as well, and eliminate explicit length checks where possible. Convert a
use of 40 in get_oid_basic to GIT_SHA1_HEXSZ.
Outside of sha1_name.c and cache.h, this transition was made with the
following semantic patch:
@@
expression E1, E2;
@@
- get_sha1(E1, E2.hash)
+ get_oid(E1, &E2)
@@
expression E1, E2;
@@
- get_sha1(E1, E2->hash)
+ get_oid(E1, E2)
@@
expression E1, E2;
@@
- get_sha1_committish(E1, E2.hash)
+ get_oid_committish(E1, &E2)
@@
expression E1, E2;
@@
- get_sha1_committish(E1, E2->hash)
+ get_oid_committish(E1, E2)
@@
expression E1, E2;
@@
- get_sha1_treeish(E1, E2.hash)
+ get_oid_treeish(E1, &E2)
@@
expression E1, E2;
@@
- get_sha1_treeish(E1, E2->hash)
+ get_oid_treeish(E1, E2)
@@
expression E1, E2;
@@
- get_sha1_commit(E1, E2.hash)
+ get_oid_commit(E1, &E2)
@@
expression E1, E2;
@@
- get_sha1_commit(E1, E2->hash)
+ get_oid_commit(E1, E2)
@@
expression E1, E2;
@@
- get_sha1_tree(E1, E2.hash)
+ get_oid_tree(E1, &E2)
@@
expression E1, E2;
@@
- get_sha1_tree(E1, E2->hash)
+ get_oid_tree(E1, E2)
@@
expression E1, E2;
@@
- get_sha1_blob(E1, E2.hash)
+ get_oid_blob(E1, &E2)
@@
expression E1, E2;
@@
- get_sha1_blob(E1, E2->hash)
+ get_oid_blob(E1, E2)
@@
expression E1, E2, E3, E4;
@@
- get_sha1_with_context(E1, E2, E3.hash, E4)
+ get_oid_with_context(E1, E2, &E3, E4)
@@
expression E1, E2, E3, E4;
@@
- get_sha1_with_context(E1, E2, E3->hash, E4)
+ get_oid_with_context(E1, E2, E3, E4)
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-07-14 01:49:28 +02:00
|
|
|
if (get_oid(ref_name[num_rev], &revkey))
|
2016-09-15 16:59:06 +02:00
|
|
|
die(_("'%s' is not a valid ref."), ref_name[num_rev]);
|
Convert lookup_commit* to struct object_id
Convert lookup_commit, lookup_commit_or_die,
lookup_commit_reference, and lookup_commit_reference_gently to take
struct object_id arguments.
Introduce a temporary in parse_object buffer in order to convert this
function. This is required since in order to convert parse_object and
parse_object_buffer, lookup_commit_reference_gently and
lookup_commit_or_die would need to be converted. Not introducing a
temporary would therefore require that lookup_commit_or_die take a
struct object_id *, but lookup_commit would take unsigned char *,
leaving a confusing and hard-to-use interface.
parse_object_buffer will lose this temporary in a later patch.
This commit was created with manual changes to commit.c, commit.h, and
object.c, plus the following semantic patch:
@@
expression E1, E2;
@@
- lookup_commit_reference_gently(E1.hash, E2)
+ lookup_commit_reference_gently(&E1, E2)
@@
expression E1, E2;
@@
- lookup_commit_reference_gently(E1->hash, E2)
+ lookup_commit_reference_gently(E1, E2)
@@
expression E1;
@@
- lookup_commit_reference(E1.hash)
+ lookup_commit_reference(&E1)
@@
expression E1;
@@
- lookup_commit_reference(E1->hash)
+ lookup_commit_reference(E1)
@@
expression E1;
@@
- lookup_commit(E1.hash)
+ lookup_commit(&E1)
@@
expression E1;
@@
- lookup_commit(E1->hash)
+ lookup_commit(E1)
@@
expression E1, E2;
@@
- lookup_commit_or_die(E1.hash, E2)
+ lookup_commit_or_die(&E1, E2)
@@
expression E1, E2;
@@
- lookup_commit_or_die(E1->hash, E2)
+ lookup_commit_or_die(E1, E2)
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-05-07 00:10:10 +02:00
|
|
|
commit = lookup_commit_reference(&revkey);
|
2005-08-21 11:51:10 +02:00
|
|
|
if (!commit)
|
2016-09-15 16:59:06 +02:00
|
|
|
die(_("cannot find commit %s (%s)"),
|
2015-05-25 20:38:49 +02:00
|
|
|
ref_name[num_rev], oid_to_hex(&revkey));
|
2005-08-21 11:51:10 +02:00
|
|
|
parse_commit(commit);
|
|
|
|
mark_seen(commit, &seen);
|
|
|
|
|
|
|
|
/* rev#0 uses bit REV_SHIFT, rev#1 uses bit REV_SHIFT+1,
|
|
|
|
* and so on. REV_SHIFT bits from bit 0 are used for
|
|
|
|
* internal bookkeeping.
|
|
|
|
*/
|
2005-09-10 00:40:45 +02:00
|
|
|
commit->object.flags |= flag;
|
|
|
|
if (commit->object.flags == flag)
|
2010-11-27 02:58:14 +01:00
|
|
|
commit_list_insert_by_date(commit, &list);
|
2005-08-21 11:51:10 +02:00
|
|
|
rev[num_rev] = commit;
|
|
|
|
}
|
2005-09-10 00:40:45 +02:00
|
|
|
for (i = 0; i < num_rev; i++)
|
|
|
|
rev_mask[i] = rev[i]->object.flags;
|
|
|
|
|
|
|
|
if (0 <= extra)
|
|
|
|
join_revs(&list, &seen, num_rev, extra);
|
2005-08-21 11:51:10 +02:00
|
|
|
|
2010-11-27 02:58:14 +01:00
|
|
|
commit_list_sort_by_date(&seen);
|
2006-07-16 09:00:09 +02:00
|
|
|
|
2005-08-21 11:51:10 +02:00
|
|
|
if (merge_base)
|
|
|
|
return show_merge_base(seen, num_rev);
|
|
|
|
|
2005-09-10 00:40:45 +02:00
|
|
|
if (independent)
|
|
|
|
return show_independent(rev, num_rev, ref_name, rev_mask);
|
|
|
|
|
|
|
|
/* Show list; --more=-1 means list-only */
|
2005-09-11 03:24:46 +02:00
|
|
|
if (1 < num_rev || extra < 0) {
|
2005-08-21 11:51:10 +02:00
|
|
|
for (i = 0; i < num_rev; i++) {
|
|
|
|
int j;
|
2006-09-12 05:17:35 +02:00
|
|
|
int is_head = rev_is_head(head,
|
2005-08-21 11:51:10 +02:00
|
|
|
ref_name[i],
|
2015-05-25 20:38:48 +02:00
|
|
|
head_oid.hash,
|
2015-11-10 03:22:29 +01:00
|
|
|
rev[i]->object.oid.hash);
|
2005-09-10 00:40:45 +02:00
|
|
|
if (extra < 0)
|
|
|
|
printf("%c [%s] ",
|
|
|
|
is_head ? '*' : ' ', ref_name[i]);
|
|
|
|
else {
|
|
|
|
for (j = 0; j < i; j++)
|
|
|
|
putchar(' ');
|
2009-04-22 23:41:25 +02:00
|
|
|
printf("%s%c%s [%s] ",
|
2011-04-05 07:40:23 +02:00
|
|
|
get_color_code(i),
|
2009-04-22 23:41:25 +02:00
|
|
|
is_head ? '*' : '!',
|
|
|
|
get_color_reset_code(), ref_name[i]);
|
2005-09-10 00:40:45 +02:00
|
|
|
}
|
show-branch --reflog: show the reflog message at the top.
This changes the output so the list at the top shows the reflog
message, along with their relative timestamps.
You can use --reflog=<n> to show <n> most recent log entries, or
use --reflog=<n>,<b> to show <n> entries going back from the
entry <b>. <b> can be either a number (so --reflog=4,20 shows 4
records starting from @{20}) or a timestamp (e.g. --reflog='4,1 day').
Here is a sample output (with --list option):
$ git show-branch --reflog=10 --list jc/show-reflog
[jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
[jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
[jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog: sho
[jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend read_ref_a
[jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow retrievi
[jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
[jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --reflog: use
This shows what I did more cleanly:
$ git show-branch --reflog=10 jc/show-reflog
! [jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
! [jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
! [jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog:
! [jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_
! [jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read
! [jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend rea
! [jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow
! [jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
! [jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --r
----------
+ [jc/show-reflog@{0}] show-branch --reflog: show the reflog
+ [jc/show-reflog@{2}] show-branch --reflog: show the reflog
+++ [jc/show-reflog@{1}] show-branch --reflog: show the reflog
+++++ [jc/show-reflog@{4}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{5}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{6}] Extend read_ref_at() to be usable fro
+ [jc/show-reflog@{7}] read_ref_at(): allow retrieving the r
+ [jc/show-reflog@{9}] show-branch --reflog: use updated rea
+ [jc/show-reflog@{9}^] read_ref_at(): allow reporting the c
+ [jc/show-reflog@{9}~2] show-branch --reflog: show the refl
+ [jc/show-reflog@{9}~3] read_ref_at(): allow retrieving the
++++++++++ [jc/show-reflog@{8}] dwim_ref(): Separate name-to-ref DWIM
At @{9}, I had a commit to complete 5 patch series, but I wanted
to consolidate two commits that enhances read_ref_at() into one
(they were @{9}^ and @{9}~3), and another two that touch show-branch
into one (@{9} and @{9}~2).
I first saved them with "format-patch -4", and then did a reset
at @{8}. At @{7}, I applied one of them with "am", and then
used "git-apply" on the other one, and amended the commit at
@{6} (so @{6} and @{7} has the same parent). I did not like the
log message, so I amended again at @{5}.
Then I cherry-picked @{9}~2 to create @{3} (the log message
shows that it needs to learn to set GIT_REFLOG_ACTION -- it uses
"git-commit" and the log entry is attributed for it). Another
cherry-pick built @{2} out of @{9}, but what I wanted to do was
to squash these two into one, so I did a "reset HEAD^" at @{1}
and then made the final commit by amending what was at the top.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-19 10:20:23 +01:00
|
|
|
|
|
|
|
if (!reflog) {
|
|
|
|
/* header lines never need name */
|
|
|
|
show_one_commit(rev[i], 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
puts(reflog_msg[i]);
|
|
|
|
|
2006-01-11 23:02:38 +01:00
|
|
|
if (is_head)
|
|
|
|
head_at = i;
|
2005-08-21 11:51:10 +02:00
|
|
|
}
|
2005-09-10 00:40:45 +02:00
|
|
|
if (0 <= extra) {
|
|
|
|
for (i = 0; i < num_rev; i++)
|
|
|
|
putchar('-');
|
|
|
|
putchar('\n');
|
|
|
|
}
|
2005-08-23 08:16:46 +02:00
|
|
|
}
|
2005-09-10 00:40:45 +02:00
|
|
|
if (extra < 0)
|
|
|
|
exit(0);
|
2005-08-23 08:16:46 +02:00
|
|
|
|
2005-08-30 02:19:47 +02:00
|
|
|
/* Sort topologically */
|
toposort: rename "lifo" field
The primary invariant of sort_in_topological_order() is that a
parent commit is not emitted until all children of it are. When
traversing a forked history like this with "git log C E":
A----B----C
\
D----E
we ensure that A is emitted after all of B, C, D, and E are done, B
has to wait until C is done, and D has to wait until E is done.
In some applications, however, we would further want to control how
these child commits B, C, D and E on two parallel ancestry chains
are shown.
Most of the time, we would want to see C and B emitted together, and
then E and D, and finally A (i.e. the --topo-order output). The
"lifo" parameter of the sort_in_topological_order() function is used
to control this behaviour. We start the traversal by knowing two
commits, C and E. While keeping in mind that we also need to
inspect E later, we pick C first to inspect, and we notice and
record that B needs to be inspected. By structuring the "work to be
done" set as a LIFO stack, we ensure that B is inspected next,
before other in-flight commits we had known that we will need to
inspect, e.g. E.
When showing in --date-order, we would want to see commits ordered
by timestamps, i.e. show C, E, B and D in this order before showing
A, possibly mixing commits from two parallel histories together.
When "lifo" parameter is set to false, the function keeps the "work
to be done" set sorted in the date order to realize this semantics.
After inspecting C, we add B to the "work to be done" set, but the
next commit we inspect from the set is E which is newer than B.
The name "lifo", however, is too strongly tied to the way how the
function implements its behaviour, and does not describe what the
behaviour _means_.
Replace this field with an enum rev_sort_order, with two possible
values: REV_SORT_IN_GRAPH_ORDER and REV_SORT_BY_COMMIT_DATE, and
update the existing code. The mechanical replacement rule is:
"lifo == 0" is equivalent to "sort_order == REV_SORT_BY_COMMIT_DATE"
"lifo == 1" is equivalent to "sort_order == REV_SORT_IN_GRAPH_ORDER"
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-06-07 01:07:14 +02:00
|
|
|
sort_in_topological_order(&seen, sort_order);
|
2005-08-30 02:19:47 +02:00
|
|
|
|
|
|
|
/* Give names to commits */
|
2005-10-12 00:22:48 +02:00
|
|
|
if (!sha1_name && !no_name)
|
|
|
|
name_commits(seen, rev, ref_name, num_rev);
|
2005-08-30 02:19:47 +02:00
|
|
|
|
|
|
|
all_mask = ((1u << (REV_SHIFT + num_rev)) - 1);
|
|
|
|
all_revs = all_mask & ~((1u << REV_SHIFT) - 1);
|
|
|
|
|
2005-08-21 11:51:10 +02:00
|
|
|
while (seen) {
|
2015-10-24 18:21:31 +02:00
|
|
|
struct commit *commit = pop_commit(&seen);
|
2005-08-21 11:51:10 +02:00
|
|
|
int this_flag = commit->object.flags;
|
2006-03-03 23:34:40 +01:00
|
|
|
int is_merge_point = ((this_flag & all_revs) == all_revs);
|
2005-08-23 08:16:46 +02:00
|
|
|
|
2006-03-03 23:34:40 +01:00
|
|
|
shown_merge_point |= is_merge_point;
|
2005-08-30 02:19:47 +02:00
|
|
|
|
2005-08-23 08:16:46 +02:00
|
|
|
if (1 < num_rev) {
|
2006-05-02 02:12:26 +02:00
|
|
|
int is_merge = !!(commit->parents &&
|
|
|
|
commit->parents->next);
|
2006-03-03 23:34:40 +01:00
|
|
|
if (topics &&
|
|
|
|
!is_merge_point &&
|
|
|
|
(this_flag & (1u << REV_SHIFT)))
|
|
|
|
continue;
|
2006-05-02 02:12:26 +02:00
|
|
|
if (dense && is_merge &&
|
|
|
|
omit_in_dense(commit, rev, num_rev))
|
|
|
|
continue;
|
2006-01-11 23:02:38 +01:00
|
|
|
for (i = 0; i < num_rev; i++) {
|
|
|
|
int mark;
|
|
|
|
if (!(this_flag & (1u << (i + REV_SHIFT))))
|
|
|
|
mark = ' ';
|
|
|
|
else if (is_merge)
|
|
|
|
mark = '-';
|
|
|
|
else if (i == head_at)
|
|
|
|
mark = '*';
|
|
|
|
else
|
|
|
|
mark = '+';
|
2009-04-22 23:41:25 +02:00
|
|
|
printf("%s%c%s",
|
2011-04-05 07:40:23 +02:00
|
|
|
get_color_code(i),
|
2009-04-22 23:41:25 +02:00
|
|
|
mark, get_color_reset_code());
|
2006-01-11 23:02:38 +01:00
|
|
|
}
|
2005-08-23 08:16:46 +02:00
|
|
|
putchar(' ');
|
|
|
|
}
|
2005-10-12 00:22:48 +02:00
|
|
|
show_one_commit(commit, no_name);
|
2005-11-11 00:47:58 +01:00
|
|
|
|
|
|
|
if (shown_merge_point && --extra < 0)
|
|
|
|
break;
|
2005-08-21 11:51:10 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|