mirror of
https://github.com/git/git
synced 2024-08-27 03:29:21 +00:00
Merge branch 'rs/pending' into next
* rs/pending: commit: factor out clear_commit_marks_for_object_array checkout: use leak_pending flag bundle: use leak_pending flag bisect: use leak_pending flag revision: add leak_pending flag checkout: use add_pending_{object,sha1} in orphan check revision: factor out add_pending_sha1 checkout: check for "Previous HEAD" notice in t2020 Conflicts: builtin/checkout.c revision.c
This commit is contained in:
commit
998462b832
20
bisect.c
20
bisect.c
|
@ -800,25 +800,25 @@ static int check_ancestors(const char *prefix)
|
||||||
{
|
{
|
||||||
struct rev_info revs;
|
struct rev_info revs;
|
||||||
struct object_array pending_copy;
|
struct object_array pending_copy;
|
||||||
int i, res;
|
int res;
|
||||||
|
|
||||||
bisect_rev_setup(&revs, prefix, "^%s", "%s", 0);
|
bisect_rev_setup(&revs, prefix, "^%s", "%s", 0);
|
||||||
|
|
||||||
/* Save pending objects, so they can be cleaned up later. */
|
/* Save pending objects, so they can be cleaned up later. */
|
||||||
memset(&pending_copy, 0, sizeof(pending_copy));
|
pending_copy = revs.pending;
|
||||||
for (i = 0; i < revs.pending.nr; i++)
|
revs.leak_pending = 1;
|
||||||
add_object_array(revs.pending.objects[i].item,
|
|
||||||
revs.pending.objects[i].name,
|
|
||||||
&pending_copy);
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* bisect_common calls prepare_revision_walk right away, which
|
||||||
|
* (together with .leak_pending = 1) makes us the sole owner of
|
||||||
|
* the list of pending objects.
|
||||||
|
*/
|
||||||
bisect_common(&revs);
|
bisect_common(&revs);
|
||||||
res = (revs.commits != NULL);
|
res = (revs.commits != NULL);
|
||||||
|
|
||||||
/* Clean up objects used, as they will be reused. */
|
/* Clean up objects used, as they will be reused. */
|
||||||
for (i = 0; i < pending_copy.nr; i++) {
|
clear_commit_marks_for_object_array(&pending_copy, ALL_REV_FLAGS);
|
||||||
struct object *o = pending_copy.objects[i].item;
|
free(pending_copy.objects);
|
||||||
clear_commit_marks((struct commit *)o, ALL_REV_FLAGS);
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -593,23 +593,11 @@ static void update_refs_for_switch(struct checkout_opts *opts,
|
||||||
report_tracking(new);
|
report_tracking(new);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int add_one_ref_to_rev_list_arg(const char *refname,
|
static int add_pending_uninteresting_ref(const char *refname,
|
||||||
const unsigned char *sha1,
|
const unsigned char *sha1,
|
||||||
int flags,
|
int flags, void *cb_data)
|
||||||
void *cb_data)
|
|
||||||
{
|
{
|
||||||
argv_array_push(cb_data, refname);
|
add_pending_sha1(cb_data, refname, sha1, flags | UNINTERESTING);
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int clear_commit_marks_from_one_ref(const char *refname,
|
|
||||||
const unsigned char *sha1,
|
|
||||||
int flags,
|
|
||||||
void *cb_data)
|
|
||||||
{
|
|
||||||
struct commit *commit = lookup_commit_reference_gently(sha1, 1);
|
|
||||||
if (commit)
|
|
||||||
clear_commit_marks(commit, -1);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -678,18 +666,21 @@ static void suggest_reattach(struct commit *commit, struct rev_info *revs)
|
||||||
*/
|
*/
|
||||||
static void orphaned_commit_warning(struct commit *commit)
|
static void orphaned_commit_warning(struct commit *commit)
|
||||||
{
|
{
|
||||||
struct argv_array args = ARGV_ARRAY_INIT;
|
|
||||||
struct rev_info revs;
|
struct rev_info revs;
|
||||||
|
struct object *object = &commit->object;
|
||||||
argv_array_push(&args, "(internal)");
|
struct object_array refs;
|
||||||
argv_array_push(&args, sha1_to_hex(commit->object.sha1));
|
|
||||||
argv_array_push(&args, "--not");
|
|
||||||
for_each_ref(add_one_ref_to_rev_list_arg, &args);
|
|
||||||
argv_array_push(&args, "--");
|
|
||||||
|
|
||||||
init_revisions(&revs, NULL);
|
init_revisions(&revs, NULL);
|
||||||
if (setup_revisions(args.argc - 1, args.argv, &revs, NULL) != 1)
|
setup_revisions(0, NULL, &revs, NULL);
|
||||||
die(_("internal error: only -- alone should have been left"));
|
|
||||||
|
object->flags &= ~UNINTERESTING;
|
||||||
|
add_pending_object(&revs, object, sha1_to_hex(object->sha1));
|
||||||
|
|
||||||
|
for_each_ref(add_pending_uninteresting_ref, &revs);
|
||||||
|
|
||||||
|
refs = revs.pending;
|
||||||
|
revs.leak_pending = 1;
|
||||||
|
|
||||||
if (prepare_revision_walk(&revs))
|
if (prepare_revision_walk(&revs))
|
||||||
die(_("internal error in revision walk"));
|
die(_("internal error in revision walk"));
|
||||||
if (!(commit->object.flags & UNINTERESTING))
|
if (!(commit->object.flags & UNINTERESTING))
|
||||||
|
@ -697,9 +688,8 @@ static void orphaned_commit_warning(struct commit *commit)
|
||||||
else
|
else
|
||||||
describe_detached_head(_("Previous HEAD position was"), commit);
|
describe_detached_head(_("Previous HEAD position was"), commit);
|
||||||
|
|
||||||
argv_array_clear(&args);
|
clear_commit_marks_for_object_array(&refs, ALL_REV_FLAGS);
|
||||||
clear_commit_marks(commit, -1);
|
free(refs.objects);
|
||||||
for_each_ref(clear_commit_marks_from_one_ref, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int switch_branches(struct checkout_opts *opts, struct branch_info *new)
|
static int switch_branches(struct checkout_opts *opts, struct branch_info *new)
|
||||||
|
|
11
bundle.c
11
bundle.c
|
@ -122,11 +122,8 @@ int verify_bundle(struct bundle_header *header, int verbose)
|
||||||
req_nr = revs.pending.nr;
|
req_nr = revs.pending.nr;
|
||||||
setup_revisions(2, argv, &revs, NULL);
|
setup_revisions(2, argv, &revs, NULL);
|
||||||
|
|
||||||
memset(&refs, 0, sizeof(struct object_array));
|
refs = revs.pending;
|
||||||
for (i = 0; i < revs.pending.nr; i++) {
|
revs.leak_pending = 1;
|
||||||
struct object_array_entry *e = revs.pending.objects + i;
|
|
||||||
add_object_array(e->item, e->name, &refs);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (prepare_revision_walk(&revs))
|
if (prepare_revision_walk(&revs))
|
||||||
die("revision walk setup failed");
|
die("revision walk setup failed");
|
||||||
|
@ -144,8 +141,8 @@ int verify_bundle(struct bundle_header *header, int verbose)
|
||||||
refs.objects[i].name);
|
refs.objects[i].name);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < refs.nr; i++)
|
clear_commit_marks_for_object_array(&refs, ALL_REV_FLAGS);
|
||||||
clear_commit_marks((struct commit *)refs.objects[i].item, -1);
|
free(refs.objects);
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
struct ref_list *r;
|
struct ref_list *r;
|
||||||
|
|
14
commit.c
14
commit.c
|
@ -442,6 +442,20 @@ void clear_commit_marks(struct commit *commit, unsigned int mark)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void clear_commit_marks_for_object_array(struct object_array *a, unsigned mark)
|
||||||
|
{
|
||||||
|
struct object *object;
|
||||||
|
struct commit *commit;
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
for (i = 0; i < a->nr; i++) {
|
||||||
|
object = a->objects[i].item;
|
||||||
|
commit = lookup_commit_reference_gently(object->sha1, 1);
|
||||||
|
if (commit)
|
||||||
|
clear_commit_marks(commit, mark);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct commit *pop_commit(struct commit_list **stack)
|
struct commit *pop_commit(struct commit_list **stack)
|
||||||
{
|
{
|
||||||
struct commit_list *top = *stack;
|
struct commit_list *top = *stack;
|
||||||
|
|
1
commit.h
1
commit.h
|
@ -133,6 +133,7 @@ struct commit *pop_most_recent_commit(struct commit_list **list,
|
||||||
struct commit *pop_commit(struct commit_list **stack);
|
struct commit *pop_commit(struct commit_list **stack);
|
||||||
|
|
||||||
void clear_commit_marks(struct commit *commit, unsigned int mark);
|
void clear_commit_marks(struct commit *commit, unsigned int mark);
|
||||||
|
void clear_commit_marks_for_object_array(struct object_array *a, unsigned mark);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Performs an in-place topological sort of list supplied.
|
* Performs an in-place topological sort of list supplied.
|
||||||
|
|
12
revision.c
12
revision.c
|
@ -226,6 +226,13 @@ static struct object *get_reference(struct rev_info *revs, const char *name, con
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void add_pending_sha1(struct rev_info *revs, const char *name,
|
||||||
|
const unsigned char *sha1, unsigned int flags)
|
||||||
|
{
|
||||||
|
struct object *object = get_reference(revs, name, sha1, flags);
|
||||||
|
add_pending_object(revs, object, name);
|
||||||
|
}
|
||||||
|
|
||||||
static struct commit *handle_commit(struct rev_info *revs, struct object *object, const char *name)
|
static struct commit *handle_commit(struct rev_info *revs, struct object *object, const char *name)
|
||||||
{
|
{
|
||||||
unsigned long flags = object->flags;
|
unsigned long flags = object->flags;
|
||||||
|
@ -897,7 +904,7 @@ static int handle_one_ref(const char *path, const unsigned char *sha1, int flag,
|
||||||
struct object *object = get_reference(cb->all_revs, path, sha1,
|
struct object *object = get_reference(cb->all_revs, path, sha1,
|
||||||
cb->all_flags);
|
cb->all_flags);
|
||||||
add_rev_cmdline(cb->all_revs, object, path, REV_CMD_REF, cb->all_flags);
|
add_rev_cmdline(cb->all_revs, object, path, REV_CMD_REF, cb->all_flags);
|
||||||
add_pending_object(cb->all_revs, object, path);
|
add_pending_sha1(cb->all_revs, path, sha1, cb->all_flags);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2050,7 +2057,8 @@ int prepare_revision_walk(struct rev_info *revs)
|
||||||
}
|
}
|
||||||
e++;
|
e++;
|
||||||
}
|
}
|
||||||
free(list);
|
if (!revs->leak_pending)
|
||||||
|
free(list);
|
||||||
|
|
||||||
if (revs->no_walk)
|
if (revs->no_walk)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -118,6 +118,7 @@ struct rev_info {
|
||||||
date_mode_explicit:1,
|
date_mode_explicit:1,
|
||||||
preserve_subject:1;
|
preserve_subject:1;
|
||||||
unsigned int disable_stdin:1;
|
unsigned int disable_stdin:1;
|
||||||
|
unsigned int leak_pending:1;
|
||||||
|
|
||||||
enum date_mode date_mode;
|
enum date_mode date_mode;
|
||||||
|
|
||||||
|
@ -214,6 +215,7 @@ extern void add_object(struct object *obj,
|
||||||
const char *name);
|
const char *name);
|
||||||
|
|
||||||
extern void add_pending_object(struct rev_info *revs, struct object *obj, const char *name);
|
extern void add_pending_object(struct rev_info *revs, struct object *obj, const char *name);
|
||||||
|
extern void add_pending_sha1(struct rev_info *revs, const char *name, const unsigned char *sha1, unsigned int flags);
|
||||||
|
|
||||||
extern void add_head_to_pending(struct rev_info *);
|
extern void add_head_to_pending(struct rev_info *);
|
||||||
|
|
||||||
|
|
|
@ -12,11 +12,14 @@ check_not_detached () {
|
||||||
}
|
}
|
||||||
|
|
||||||
ORPHAN_WARNING='you are leaving .* commit.*behind'
|
ORPHAN_WARNING='you are leaving .* commit.*behind'
|
||||||
|
PREV_HEAD_DESC='Previous HEAD position was'
|
||||||
check_orphan_warning() {
|
check_orphan_warning() {
|
||||||
test_i18ngrep "$ORPHAN_WARNING" "$1"
|
test_i18ngrep "$ORPHAN_WARNING" "$1" &&
|
||||||
|
test_i18ngrep ! "$PREV_HEAD_DESC" "$1"
|
||||||
}
|
}
|
||||||
check_no_orphan_warning() {
|
check_no_orphan_warning() {
|
||||||
test_i18ngrep ! "$ORPHAN_WARNING" "$1"
|
test_i18ngrep ! "$ORPHAN_WARNING" "$1" &&
|
||||||
|
test_i18ngrep "$PREV_HEAD_DESC" "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
reset () {
|
reset () {
|
||||||
|
|
Loading…
Reference in a new issue