Skip to content

Teach the builtin rebase about the builtin interactive rebase #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
9342046
rebase -i: implement the main part of interactive rebase as a builtin
agrn Aug 28, 2018
adb4f8f
rebase--interactive2: rewrite the submodes of interactive rebase in C
agrn Aug 28, 2018
99a3836
rebase -i: remove git-rebase--interactive.sh
agrn Aug 28, 2018
b3fe2e1
rebase -i: move rebase--helper modes to rebase--interactive
agrn Aug 28, 2018
28a02c5
builtin rebase: support `--gpg-sign` option
prertik Sep 4, 2018
c7ee213
builtin rebase: support `-C` and `--whitespace=<type>`
prertik Sep 4, 2018
7debdaa
builtin rebase: support `--autostash` option
prertik Sep 4, 2018
08ae0ed
builtin rebase: support `--exec`
prertik Sep 4, 2018
ed42752
builtin rebase: support `--allow-empty-message` option
prertik Sep 4, 2018
0073df2
builtin rebase: support --rebase-merges[=[no-]rebase-cousins]
prertik Sep 4, 2018
7103b3b
merge-base --fork-point: extract libified function
prertik Sep 4, 2018
447f5e7
builtin rebase: support `fork-point` option
prertik Sep 4, 2018
399a505
builtin rebase: add support for custom merge strategies
prertik Sep 4, 2018
bfa5147
builtin rebase: support --root
prertik Sep 4, 2018
cbb2811
builtin rebase: optionally auto-detect the upstream
prertik Aug 8, 2018
5b7b27a
builtin rebase: optionally pass custom reflogs to reset_head()
prertik Aug 8, 2018
62fddd5
builtin rebase: fast-forward to onto if it is a proper descendant
prertik Aug 8, 2018
6dc7317
builtin rebase: show progress when connected to a terminal
prertik Aug 8, 2018
fa67fc8
builtin rebase: use no-op editor when interactive is "implied"
prertik Aug 8, 2018
0766416
builtin rebase: error out on incompatible option/mode combinations
prertik Aug 8, 2018
67e0df2
Merge branch 'ag/rebase-i-in-c' into js/rebase-in-c-5.5-work-with-reb…
gitster Sep 6, 2018
db1652e
builtin rebase: prepare for builtin rebase -i
dscho Aug 29, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@
/git-rebase
/git-rebase--am
/git-rebase--common
/git-rebase--helper
/git-rebase--interactive
/git-rebase--merge
/git-rebase--preserve-merges
Expand Down
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,6 @@ SCRIPT_LIB += git-mergetool--lib
SCRIPT_LIB += git-parse-remote
SCRIPT_LIB += git-rebase--am
SCRIPT_LIB += git-rebase--common
SCRIPT_LIB += git-rebase--interactive
SCRIPT_LIB += git-rebase--preserve-merges
SCRIPT_LIB += git-rebase--merge
SCRIPT_LIB += git-sh-setup
Expand Down Expand Up @@ -927,6 +926,7 @@ LIB_OBJS += protocol.o
LIB_OBJS += quote.o
LIB_OBJS += reachable.o
LIB_OBJS += read-cache.o
LIB_OBJS += rebase-interactive.o
LIB_OBJS += reflog-walk.o
LIB_OBJS += refs.o
LIB_OBJS += refs/files-backend.o
Expand Down Expand Up @@ -1065,7 +1065,7 @@ BUILTIN_OBJS += builtin/pull.o
BUILTIN_OBJS += builtin/push.o
BUILTIN_OBJS += builtin/read-tree.o
BUILTIN_OBJS += builtin/rebase.o
BUILTIN_OBJS += builtin/rebase--helper.o
BUILTIN_OBJS += builtin/rebase--interactive.o
BUILTIN_OBJS += builtin/receive-pack.o
BUILTIN_OBJS += builtin/reflog.o
BUILTIN_OBJS += builtin/remote.o
Expand Down Expand Up @@ -2404,7 +2404,6 @@ XGETTEXT_FLAGS_PERL = $(XGETTEXT_FLAGS) --language=Perl \
LOCALIZED_C = $(C_OBJ:o=c) $(LIB_H) $(GENERATED_H)
LOCALIZED_SH = $(SCRIPT_SH)
LOCALIZED_SH += git-parse-remote.sh
LOCALIZED_SH += git-rebase--interactive.sh
LOCALIZED_SH += git-rebase--preserve-merges.sh
LOCALIZED_SH += git-sh-setup.sh
LOCALIZED_PERL = $(SCRIPT_PERL)
Expand Down
2 changes: 1 addition & 1 deletion builtin.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ extern int cmd_pull(int argc, const char **argv, const char *prefix);
extern int cmd_push(int argc, const char **argv, const char *prefix);
extern int cmd_read_tree(int argc, const char **argv, const char *prefix);
extern int cmd_rebase(int argc, const char **argv, const char *prefix);
extern int cmd_rebase__helper(int argc, const char **argv, const char *prefix);
extern int cmd_rebase__interactive(int argc, const char **argv, const char *prefix);
extern int cmd_receive_pack(int argc, const char **argv, const char *prefix);
extern int cmd_reflog(int argc, const char **argv, const char *prefix);
extern int cmd_remote(int argc, const char **argv, const char *prefix);
Expand Down
81 changes: 6 additions & 75 deletions builtin/merge-base.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,54 +110,12 @@ static int handle_is_ancestor(int argc, const char **argv)
return 1;
}

struct rev_collect {
struct commit **commit;
int nr;
int alloc;
unsigned int initial : 1;
};

static void add_one_commit(struct object_id *oid, struct rev_collect *revs)
{
struct commit *commit;

if (is_null_oid(oid))
return;

commit = lookup_commit(the_repository, oid);
if (!commit ||
(commit->object.flags & TMP_MARK) ||
parse_commit(commit))
return;

ALLOC_GROW(revs->commit, revs->nr + 1, revs->alloc);
revs->commit[revs->nr++] = commit;
commit->object.flags |= TMP_MARK;
}

static int collect_one_reflog_ent(struct object_id *ooid, struct object_id *noid,
const char *ident, timestamp_t timestamp,
int tz, const char *message, void *cbdata)
{
struct rev_collect *revs = cbdata;

if (revs->initial) {
revs->initial = 0;
add_one_commit(ooid, revs);
}
add_one_commit(noid, revs);
return 0;
}

static int handle_fork_point(int argc, const char **argv)
{
struct object_id oid;
char *refname;
struct commit *derived, *fork_point;
const char *commitname;
struct rev_collect revs;
struct commit *derived;
struct commit_list *bases;
int i, ret = 0;

switch (dwim_ref(argv[0], strlen(argv[0]), &oid, &refname)) {
case 0:
Expand All @@ -173,41 +131,14 @@ static int handle_fork_point(int argc, const char **argv)
die("Not a valid object name: '%s'", commitname);

derived = lookup_commit_reference(the_repository, &oid);
memset(&revs, 0, sizeof(revs));
revs.initial = 1;
for_each_reflog_ent(refname, collect_one_reflog_ent, &revs);

if (!revs.nr && !get_oid(refname, &oid))
add_one_commit(&oid, &revs);
fork_point = get_fork_point(refname, derived);

for (i = 0; i < revs.nr; i++)
revs.commit[i]->object.flags &= ~TMP_MARK;

bases = get_merge_bases_many_dirty(derived, revs.nr, revs.commit);

/*
* There should be one and only one merge base, when we found
* a common ancestor among reflog entries.
*/
if (!bases || bases->next) {
ret = 1;
goto cleanup_return;
}

/* And the found one must be one of the reflog entries */
for (i = 0; i < revs.nr; i++)
if (&bases->item->object == &revs.commit[i]->object)
break; /* found */
if (revs.nr <= i) {
ret = 1; /* not found */
goto cleanup_return;
}

printf("%s\n", oid_to_hex(&bases->item->object.oid));
if (!fork_point)
return 1;

cleanup_return:
free_commit_list(bases);
return ret;
printf("%s\n", oid_to_hex(&fork_point->object.oid));
return 0;
}

int cmd_merge_base(int argc, const char **argv, const char *prefix)
Expand Down
88 changes: 0 additions & 88 deletions builtin/rebase--helper.c

This file was deleted.

Loading