Skip to content

Commit 6cbf663

Browse files
jamilldscho
authored andcommitted
Merge 'builtin-stash-rebase-v3'
To avoid having to play tricks as in earlier rounds, we bit the sour apple and rebased the `builtin-stash-rebase-v3` branch thicket onto the commit starting Git for Windows' merging-rebase. (The merging-rebase pulls in the previous branch thicket via a "fake merge", i.e. a merge commit that does not actually apply any changes from the merged commit history. This has the unfortunate side effect of confusing `merge` into thinking that any branch that was merged into an earlier round does not need to be merged again.) Signed-off-by: Johannes Schindelin <[email protected]>
2 parents 18d4918 + 52240eb commit 6cbf663

30 files changed

+4521
-391
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@
7878
/git-init-db
7979
/git-interpret-trailers
8080
/git-instaweb
81+
/git-legacy-rebase
82+
/git-legacy-rebase--interactive
83+
/git-legacy-stash
8184
/git-log
8285
/git-ls-files
8386
/git-ls-remote
@@ -117,7 +120,7 @@
117120
/git-read-tree
118121
/git-rebase
119122
/git-rebase--am
120-
/git-rebase--helper
123+
/git-rebase--common
121124
/git-rebase--interactive
122125
/git-rebase--merge
123126
/git-rebase--preserve-merges

Documentation/git-stash.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ SYNOPSIS
99
--------
1010
[verse]
1111
'git stash' list [<options>]
12-
'git stash' show [<stash>]
12+
'git stash' show [<options>] [<stash>]
1313
'git stash' drop [-q|--quiet] [<stash>]
1414
'git stash' ( pop | apply ) [--index] [-q|--quiet] [<stash>]
1515
'git stash' branch <branchname> [<stash>]
@@ -106,7 +106,7 @@ stash@{1}: On master: 9cc0589... Add git-stash
106106
The command takes options applicable to the 'git log'
107107
command to control what is shown and how. See linkgit:git-log[1].
108108

109-
show [<stash>]::
109+
show [<options>] [<stash>]::
110110

111111
Show the changes recorded in the stash entry as a diff between the
112112
stashed contents and the commit back when the stash entry was first

Makefile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -614,17 +614,18 @@ SCRIPT_SH += git-merge-one-file.sh
614614
SCRIPT_SH += git-merge-resolve.sh
615615
SCRIPT_SH += git-mergetool.sh
616616
SCRIPT_SH += git-quiltimport.sh
617-
SCRIPT_SH += git-rebase.sh
617+
SCRIPT_SH += git-legacy-rebase.sh
618+
SCRIPT_SH += git-legacy-stash.sh
618619
SCRIPT_SH += git-remote-testgit.sh
619620
SCRIPT_SH += git-request-pull.sh
620-
SCRIPT_SH += git-stash.sh
621621
SCRIPT_SH += git-submodule.sh
622622
SCRIPT_SH += git-web--browse.sh
623623

624+
SCRIPT_LIB += git-legacy-rebase--interactive
624625
SCRIPT_LIB += git-mergetool--lib
625626
SCRIPT_LIB += git-parse-remote
626627
SCRIPT_LIB += git-rebase--am
627-
SCRIPT_LIB += git-rebase--interactive
628+
SCRIPT_LIB += git-rebase--common
628629
SCRIPT_LIB += git-rebase--preserve-merges
629630
SCRIPT_LIB += git-rebase--merge
630631
SCRIPT_LIB += git-sh-setup
@@ -937,6 +938,7 @@ LIB_OBJS += quote.o
937938
LIB_OBJS += range-diff.o
938939
LIB_OBJS += reachable.o
939940
LIB_OBJS += read-cache.o
941+
LIB_OBJS += rebase-interactive.o
940942
LIB_OBJS += reflog-walk.o
941943
LIB_OBJS += refs.o
942944
LIB_OBJS += refs/files-backend.o
@@ -1075,7 +1077,8 @@ BUILTIN_OBJS += builtin/pull.o
10751077
BUILTIN_OBJS += builtin/push.o
10761078
BUILTIN_OBJS += builtin/range-diff.o
10771079
BUILTIN_OBJS += builtin/read-tree.o
1078-
BUILTIN_OBJS += builtin/rebase--helper.o
1080+
BUILTIN_OBJS += builtin/rebase.o
1081+
BUILTIN_OBJS += builtin/rebase--interactive.o
10791082
BUILTIN_OBJS += builtin/receive-pack.o
10801083
BUILTIN_OBJS += builtin/reflog.o
10811084
BUILTIN_OBJS += builtin/remote.o
@@ -1095,6 +1098,7 @@ BUILTIN_OBJS += builtin/shortlog.o
10951098
BUILTIN_OBJS += builtin/show-branch.o
10961099
BUILTIN_OBJS += builtin/show-index.o
10971100
BUILTIN_OBJS += builtin/show-ref.o
1101+
BUILTIN_OBJS += builtin/stash.o
10981102
BUILTIN_OBJS += builtin/stripspace.o
10991103
BUILTIN_OBJS += builtin/submodule--helper.o
11001104
BUILTIN_OBJS += builtin/symbolic-ref.o
@@ -2414,7 +2418,6 @@ XGETTEXT_FLAGS_PERL = $(XGETTEXT_FLAGS) --language=Perl \
24142418
LOCALIZED_C = $(C_OBJ:o=c) $(LIB_H) $(GENERATED_H)
24152419
LOCALIZED_SH = $(SCRIPT_SH)
24162420
LOCALIZED_SH += git-parse-remote.sh
2417-
LOCALIZED_SH += git-rebase--interactive.sh
24182421
LOCALIZED_SH += git-rebase--preserve-merges.sh
24192422
LOCALIZED_SH += git-sh-setup.sh
24202423
LOCALIZED_PERL = $(SCRIPT_PERL)

builtin.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,8 @@ extern int cmd_pull(int argc, const char **argv, const char *prefix);
203203
extern int cmd_push(int argc, const char **argv, const char *prefix);
204204
extern int cmd_range_diff(int argc, const char **argv, const char *prefix);
205205
extern int cmd_read_tree(int argc, const char **argv, const char *prefix);
206-
extern int cmd_rebase__helper(int argc, const char **argv, const char *prefix);
206+
extern int cmd_rebase(int argc, const char **argv, const char *prefix);
207+
extern int cmd_rebase__interactive(int argc, const char **argv, const char *prefix);
207208
extern int cmd_receive_pack(int argc, const char **argv, const char *prefix);
208209
extern int cmd_reflog(int argc, const char **argv, const char *prefix);
209210
extern int cmd_remote(int argc, const char **argv, const char *prefix);
@@ -223,6 +224,7 @@ extern int cmd_show(int argc, const char **argv, const char *prefix);
223224
extern int cmd_show_branch(int argc, const char **argv, const char *prefix);
224225
extern int cmd_show_index(int argc, const char **argv, const char *prefix);
225226
extern int cmd_status(int argc, const char **argv, const char *prefix);
227+
extern int cmd_stash(int argc, const char **argv, const char *prefix);
226228
extern int cmd_stripspace(int argc, const char **argv, const char *prefix);
227229
extern int cmd_submodule__helper(int argc, const char **argv, const char *prefix);
228230
extern int cmd_symbolic_ref(int argc, const char **argv, const char *prefix);

builtin/merge-base.c

Lines changed: 6 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -110,54 +110,12 @@ static int handle_is_ancestor(int argc, const char **argv)
110110
return 1;
111111
}
112112

113-
struct rev_collect {
114-
struct commit **commit;
115-
int nr;
116-
int alloc;
117-
unsigned int initial : 1;
118-
};
119-
120-
static void add_one_commit(struct object_id *oid, struct rev_collect *revs)
121-
{
122-
struct commit *commit;
123-
124-
if (is_null_oid(oid))
125-
return;
126-
127-
commit = lookup_commit(the_repository, oid);
128-
if (!commit ||
129-
(commit->object.flags & TMP_MARK) ||
130-
parse_commit(commit))
131-
return;
132-
133-
ALLOC_GROW(revs->commit, revs->nr + 1, revs->alloc);
134-
revs->commit[revs->nr++] = commit;
135-
commit->object.flags |= TMP_MARK;
136-
}
137-
138-
static int collect_one_reflog_ent(struct object_id *ooid, struct object_id *noid,
139-
const char *ident, timestamp_t timestamp,
140-
int tz, const char *message, void *cbdata)
141-
{
142-
struct rev_collect *revs = cbdata;
143-
144-
if (revs->initial) {
145-
revs->initial = 0;
146-
add_one_commit(ooid, revs);
147-
}
148-
add_one_commit(noid, revs);
149-
return 0;
150-
}
151-
152113
static int handle_fork_point(int argc, const char **argv)
153114
{
154115
struct object_id oid;
155116
char *refname;
117+
struct commit *derived, *fork_point;
156118
const char *commitname;
157-
struct rev_collect revs;
158-
struct commit *derived;
159-
struct commit_list *bases;
160-
int i, ret = 0;
161119

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

175133
derived = lookup_commit_reference(the_repository, &oid);
176-
memset(&revs, 0, sizeof(revs));
177-
revs.initial = 1;
178-
for_each_reflog_ent(refname, collect_one_reflog_ent, &revs);
179134

180-
if (!revs.nr && !get_oid(refname, &oid))
181-
add_one_commit(&oid, &revs);
135+
fork_point = get_fork_point(refname, derived);
182136

183-
for (i = 0; i < revs.nr; i++)
184-
revs.commit[i]->object.flags &= ~TMP_MARK;
185-
186-
bases = get_merge_bases_many_dirty(derived, revs.nr, revs.commit);
187-
188-
/*
189-
* There should be one and only one merge base, when we found
190-
* a common ancestor among reflog entries.
191-
*/
192-
if (!bases || bases->next) {
193-
ret = 1;
194-
goto cleanup_return;
195-
}
196-
197-
/* And the found one must be one of the reflog entries */
198-
for (i = 0; i < revs.nr; i++)
199-
if (&bases->item->object == &revs.commit[i]->object)
200-
break; /* found */
201-
if (revs.nr <= i) {
202-
ret = 1; /* not found */
203-
goto cleanup_return;
204-
}
205-
206-
printf("%s\n", oid_to_hex(&bases->item->object.oid));
137+
if (!fork_point)
138+
return 1;
207139

208-
cleanup_return:
209-
free_commit_list(bases);
210-
return ret;
140+
printf("%s\n", oid_to_hex(&fork_point->object.oid));
141+
return 0;
211142
}
212143

213144
int cmd_merge_base(int argc, const char **argv, const char *prefix)

builtin/rebase--helper.c

Lines changed: 0 additions & 88 deletions
This file was deleted.

0 commit comments

Comments
 (0)