Skip to content

Commit bd265ff

Browse files
committed
Merge branch 'dl/merge-autostash' into pu
"git merge" learns the "--autostash" option. * dl/merge-autostash: pull: pass --autostash to merge t5520: make test_pull_autostash() accept expect_parent_num merge: teach --autostash option sequencer: unlink autostash in apply_autostash() sequencer: extract perform_autostash() from rebase rebase: generify create_autostash() rebase: extract create_autostash() reset: extract reset_head() from rebase rebase: generify reset_head() rebase: use apply_autostash() from sequencer.c sequencer: make apply_rebase() accept a path rebase: use read_oneliner() sequencer: make read_oneliner() extern sequencer: configurably warn on non-existent files sequencer: use file strbuf for read_oneliner() t7600: use test_write_lines() Makefile: alphabetically sort += lists
2 parents a15346e + d0146bd commit bd265ff

File tree

18 files changed

+523
-380
lines changed

18 files changed

+523
-380
lines changed

Documentation/config/merge.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ merge.stat::
7070
Whether to print the diffstat between ORIG_HEAD and the merge result
7171
at the end of the merge. True by default.
7272

73+
merge.autoStash::
74+
When set to true, automatically create a temporary stash entry
75+
before the operation begins, and apply it after the operation
76+
ends. This means that you can run rebase on a dirty worktree.
77+
However, use with care: the final stash application after a
78+
successful rebase might result in non-trivial conflicts.
79+
This option can be overridden by the `--no-autostash` and
80+
`--autostash` options of linkgit:git-merge[1].
81+
Defaults to false.
82+
7383
merge.tool::
7484
Controls which merge tool is used by linkgit:git-mergetool[1].
7585
The list below shows the valid built-in values.

Documentation/git-pull.txt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,6 @@ unless you have read linkgit:git-rebase[1] carefully.
133133
--no-rebase::
134134
Override earlier --rebase.
135135

136-
--autostash::
137-
--no-autostash::
138-
Before starting rebase, stash local modifications away (see
139-
linkgit:git-stash[1]) if needed, and apply the stash entry when
140-
done. `--no-autostash` is useful to override the `rebase.autoStash`
141-
configuration variable (see linkgit:git-config[1]).
142-
+
143-
This option is only valid when "--rebase" is used.
144-
145136
Options related to fetching
146137
~~~~~~~~~~~~~~~~~~~~~~~~~~~
147138

Documentation/merge-options.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,14 @@ ifndef::git-pull[]
157157

158158
endif::git-pull[]
159159

160+
--autostash::
161+
--no-autostash::
162+
Automatically create a temporary stash entry before the operation
163+
begins, and apply it after the operation ends. This means
164+
that you can run rebase on a dirty worktree. However, use
165+
with care: the final stash application after a successful
166+
rebase might result in non-trivial conflicts.
167+
160168
--allow-unrelated-histories::
161169
By default, `git merge` command refuses to merge histories
162170
that do not share a common ancestor. This option can be

Makefile

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -604,21 +604,21 @@ unexport CDPATH
604604
SCRIPT_SH += git-bisect.sh
605605
SCRIPT_SH += git-difftool--helper.sh
606606
SCRIPT_SH += git-filter-branch.sh
607+
SCRIPT_SH += git-legacy-stash.sh
607608
SCRIPT_SH += git-merge-octopus.sh
608609
SCRIPT_SH += git-merge-one-file.sh
609610
SCRIPT_SH += git-merge-resolve.sh
610611
SCRIPT_SH += git-mergetool.sh
611612
SCRIPT_SH += git-quiltimport.sh
612-
SCRIPT_SH += git-legacy-stash.sh
613613
SCRIPT_SH += git-request-pull.sh
614614
SCRIPT_SH += git-submodule.sh
615615
SCRIPT_SH += git-web--browse.sh
616616

617617
SCRIPT_LIB += git-mergetool--lib
618618
SCRIPT_LIB += git-parse-remote
619619
SCRIPT_LIB += git-rebase--preserve-merges
620-
SCRIPT_LIB += git-sh-setup
621620
SCRIPT_LIB += git-sh-i18n
621+
SCRIPT_LIB += git-sh-setup
622622

623623
SCRIPT_PERL += git-add--interactive.perl
624624
SCRIPT_PERL += git-archimport.perl
@@ -686,9 +686,9 @@ PROGRAM_OBJS += daemon.o
686686
PROGRAM_OBJS += fast-import.o
687687
PROGRAM_OBJS += http-backend.o
688688
PROGRAM_OBJS += imap-send.o
689+
PROGRAM_OBJS += remote-testsvn.o
689690
PROGRAM_OBJS += sh-i18n--envsubst.o
690691
PROGRAM_OBJS += shell.o
691-
PROGRAM_OBJS += remote-testsvn.o
692692

693693
# Binary suffix, set to .exe for Windows builds
694694
X =
@@ -709,9 +709,9 @@ TEST_BUILTINS_OBJS += test-dump-untracked-cache.o
709709
TEST_BUILTINS_OBJS += test-example-decorate.o
710710
TEST_BUILTINS_OBJS += test-genrandom.o
711711
TEST_BUILTINS_OBJS += test-genzeros.o
712+
TEST_BUILTINS_OBJS += test-hash-speed.o
712713
TEST_BUILTINS_OBJS += test-hash.o
713714
TEST_BUILTINS_OBJS += test-hashmap.o
714-
TEST_BUILTINS_OBJS += test-hash-speed.o
715715
TEST_BUILTINS_OBJS += test-index-version.o
716716
TEST_BUILTINS_OBJS += test-json-writer.o
717717
TEST_BUILTINS_OBJS += test-lazy-init-name-hash.o
@@ -736,8 +736,8 @@ TEST_BUILTINS_OBJS += test-revision-walking.o
736736
TEST_BUILTINS_OBJS += test-run-command.o
737737
TEST_BUILTINS_OBJS += test-scrap-cache-tree.o
738738
TEST_BUILTINS_OBJS += test-serve-v2.o
739-
TEST_BUILTINS_OBJS += test-sha1.o
740739
TEST_BUILTINS_OBJS += test-sha1-array.o
740+
TEST_BUILTINS_OBJS += test-sha1.o
741741
TEST_BUILTINS_OBJS += test-sha256.o
742742
TEST_BUILTINS_OBJS += test-sigchain.o
743743
TEST_BUILTINS_OBJS += test-strcmp-offset.o
@@ -747,10 +747,10 @@ TEST_BUILTINS_OBJS += test-submodule-nested-repo-config.o
747747
TEST_BUILTINS_OBJS += test-subprocess.o
748748
TEST_BUILTINS_OBJS += test-trace2.o
749749
TEST_BUILTINS_OBJS += test-urlmatch-normalization.o
750-
TEST_BUILTINS_OBJS += test-xml-encode.o
751750
TEST_BUILTINS_OBJS += test-wildmatch.o
752751
TEST_BUILTINS_OBJS += test-windows-named-pipe.o
753752
TEST_BUILTINS_OBJS += test-write-cache.o
753+
TEST_BUILTINS_OBJS += test-xml-encode.o
754754

755755
# Do not add more tests here unless they have extra dependencies. Add
756756
# them in TEST_BUILTINS_OBJS above.
@@ -787,10 +787,10 @@ OTHER_PROGRAMS = git$X
787787

788788
# what test wrappers are needed and 'install' will install, in bindir
789789
BINDIR_PROGRAMS_NEED_X += git
790-
BINDIR_PROGRAMS_NEED_X += git-upload-pack
791790
BINDIR_PROGRAMS_NEED_X += git-receive-pack
792-
BINDIR_PROGRAMS_NEED_X += git-upload-archive
793791
BINDIR_PROGRAMS_NEED_X += git-shell
792+
BINDIR_PROGRAMS_NEED_X += git-upload-archive
793+
BINDIR_PROGRAMS_NEED_X += git-upload-pack
794794

795795
BINDIR_PROGRAMS_NO_X += git-cvsserver
796796

@@ -830,9 +830,9 @@ LIB_OBJS += advice.o
830830
LIB_OBJS += alias.o
831831
LIB_OBJS += alloc.o
832832
LIB_OBJS += apply.o
833-
LIB_OBJS += archive.o
834833
LIB_OBJS += archive-tar.o
835834
LIB_OBJS += archive-zip.o
835+
LIB_OBJS += archive.o
836836
LIB_OBJS += argv-array.o
837837
LIB_OBJS += attr.o
838838
LIB_OBJS += base85.o
@@ -848,9 +848,9 @@ LIB_OBJS += checkout.o
848848
LIB_OBJS += color.o
849849
LIB_OBJS += column.o
850850
LIB_OBJS += combine-diff.o
851-
LIB_OBJS += commit.o
852851
LIB_OBJS += commit-graph.o
853852
LIB_OBJS += commit-reach.o
853+
LIB_OBJS += commit.o
854854
LIB_OBJS += compat/obstack.o
855855
LIB_OBJS += compat/terminal.o
856856
LIB_OBJS += config.o
@@ -864,17 +864,17 @@ LIB_OBJS += ctype.o
864864
LIB_OBJS += date.o
865865
LIB_OBJS += decorate.o
866866
LIB_OBJS += delta-islands.o
867+
LIB_OBJS += diff-delta.o
868+
LIB_OBJS += diff-lib.o
869+
LIB_OBJS += diff-no-index.o
870+
LIB_OBJS += diff.o
867871
LIB_OBJS += diffcore-break.o
868872
LIB_OBJS += diffcore-delta.o
869873
LIB_OBJS += diffcore-order.o
870874
LIB_OBJS += diffcore-pickaxe.o
871875
LIB_OBJS += diffcore-rename.o
872-
LIB_OBJS += diff-delta.o
873-
LIB_OBJS += diff-lib.o
874-
LIB_OBJS += diff-no-index.o
875-
LIB_OBJS += diff.o
876-
LIB_OBJS += dir.o
877876
LIB_OBJS += dir-iterator.o
877+
LIB_OBJS += dir.o
878878
LIB_OBJS += editor.o
879879
LIB_OBJS += entry.o
880880
LIB_OBJS += environment.o
@@ -892,7 +892,6 @@ LIB_OBJS += gpg-interface.o
892892
LIB_OBJS += graph.o
893893
LIB_OBJS += grep.o
894894
LIB_OBJS += hashmap.o
895-
LIB_OBJS += linear-assignment.o
896895
LIB_OBJS += help.o
897896
LIB_OBJS += hex.o
898897
LIB_OBJS += ident.o
@@ -902,9 +901,10 @@ LIB_OBJS += kwset.o
902901
LIB_OBJS += levenshtein.o
903902
LIB_OBJS += line-log.o
904903
LIB_OBJS += line-range.o
905-
LIB_OBJS += list-objects.o
906-
LIB_OBJS += list-objects-filter.o
904+
LIB_OBJS += linear-assignment.o
907905
LIB_OBJS += list-objects-filter-options.o
906+
LIB_OBJS += list-objects-filter.o
907+
LIB_OBJS += list-objects.o
908908
LIB_OBJS += ll-merge.o
909909
LIB_OBJS += lockfile.o
910910
LIB_OBJS += log-tree.o
@@ -913,31 +913,31 @@ LIB_OBJS += mailinfo.o
913913
LIB_OBJS += mailmap.o
914914
LIB_OBJS += match-trees.o
915915
LIB_OBJS += mem-pool.o
916-
LIB_OBJS += merge.o
917916
LIB_OBJS += merge-blobs.o
918917
LIB_OBJS += merge-recursive.o
918+
LIB_OBJS += merge.o
919919
LIB_OBJS += mergesort.o
920920
LIB_OBJS += midx.o
921921
LIB_OBJS += name-hash.o
922922
LIB_OBJS += negotiator/default.o
923923
LIB_OBJS += negotiator/skipping.o
924-
LIB_OBJS += notes.o
925924
LIB_OBJS += notes-cache.o
926925
LIB_OBJS += notes-merge.o
927926
LIB_OBJS += notes-utils.o
927+
LIB_OBJS += notes.o
928928
LIB_OBJS += object.o
929929
LIB_OBJS += oidmap.o
930930
LIB_OBJS += oidset.o
931-
LIB_OBJS += packfile.o
932-
LIB_OBJS += pack-bitmap.o
933931
LIB_OBJS += pack-bitmap-write.o
932+
LIB_OBJS += pack-bitmap.o
934933
LIB_OBJS += pack-check.o
935934
LIB_OBJS += pack-objects.o
936935
LIB_OBJS += pack-revindex.o
937936
LIB_OBJS += pack-write.o
937+
LIB_OBJS += packfile.o
938938
LIB_OBJS += pager.o
939-
LIB_OBJS += parse-options.o
940939
LIB_OBJS += parse-options-cb.o
940+
LIB_OBJS += parse-options.o
941941
LIB_OBJS += patch-delta.o
942942
LIB_OBJS += patch-ids.o
943943
LIB_OBJS += path.o
@@ -955,19 +955,20 @@ LIB_OBJS += range-diff.o
955955
LIB_OBJS += reachable.o
956956
LIB_OBJS += read-cache.o
957957
LIB_OBJS += rebase-interactive.o
958+
LIB_OBJS += ref-filter.o
958959
LIB_OBJS += reflog-walk.o
959960
LIB_OBJS += refs.o
960961
LIB_OBJS += refs/files-backend.o
961962
LIB_OBJS += refs/iterator.o
962963
LIB_OBJS += refs/packed-backend.o
963964
LIB_OBJS += refs/ref-cache.o
964965
LIB_OBJS += refspec.o
965-
LIB_OBJS += ref-filter.o
966966
LIB_OBJS += remote.o
967967
LIB_OBJS += replace-object.o
968968
LIB_OBJS += repo-settings.o
969969
LIB_OBJS += repository.o
970970
LIB_OBJS += rerere.o
971+
LIB_OBJS += reset.o
971972
LIB_OBJS += resolve-undo.o
972973
LIB_OBJS += revision.o
973974
LIB_OBJS += run-command.o
@@ -977,8 +978,8 @@ LIB_OBJS += serve.o
977978
LIB_OBJS += server-info.o
978979
LIB_OBJS += setup.o
979980
LIB_OBJS += sha1-array.o
980-
LIB_OBJS += sha1-lookup.o
981981
LIB_OBJS += sha1-file.o
982+
LIB_OBJS += sha1-lookup.o
982983
LIB_OBJS += sha1-name.o
983984
LIB_OBJS += shallow.o
984985
LIB_OBJS += sideband.o
@@ -988,9 +989,9 @@ LIB_OBJS += stable-qsort.o
988989
LIB_OBJS += strbuf.o
989990
LIB_OBJS += streaming.o
990991
LIB_OBJS += string-list.o
991-
LIB_OBJS += submodule.o
992-
LIB_OBJS += submodule-config.o
993992
LIB_OBJS += sub-process.o
993+
LIB_OBJS += submodule-config.o
994+
LIB_OBJS += submodule.o
994995
LIB_OBJS += symlinks.o
995996
LIB_OBJS += tag.o
996997
LIB_OBJS += tempfile.o
@@ -1009,11 +1010,11 @@ LIB_OBJS += trace2/tr2_tgt_normal.o
10091010
LIB_OBJS += trace2/tr2_tgt_perf.o
10101011
LIB_OBJS += trace2/tr2_tls.o
10111012
LIB_OBJS += trailer.o
1012-
LIB_OBJS += transport.o
10131013
LIB_OBJS += transport-helper.o
1014+
LIB_OBJS += transport.o
10141015
LIB_OBJS += tree-diff.o
1015-
LIB_OBJS += tree.o
10161016
LIB_OBJS += tree-walk.o
1017+
LIB_OBJS += tree.o
10171018
LIB_OBJS += unpack-trees.o
10181019
LIB_OBJS += upload-pack.o
10191020
LIB_OBJS += url.o
@@ -1053,9 +1054,9 @@ BUILTIN_OBJS += builtin/checkout.o
10531054
BUILTIN_OBJS += builtin/clean.o
10541055
BUILTIN_OBJS += builtin/clone.o
10551056
BUILTIN_OBJS += builtin/column.o
1057+
BUILTIN_OBJS += builtin/commit-graph.o
10561058
BUILTIN_OBJS += builtin/commit-tree.o
10571059
BUILTIN_OBJS += builtin/commit.o
1058-
BUILTIN_OBJS += builtin/commit-graph.o
10591060
BUILTIN_OBJS += builtin/config.o
10601061
BUILTIN_OBJS += builtin/count-objects.o
10611062
BUILTIN_OBJS += builtin/credential.o
@@ -1086,13 +1087,13 @@ BUILTIN_OBJS += builtin/ls-remote.o
10861087
BUILTIN_OBJS += builtin/ls-tree.o
10871088
BUILTIN_OBJS += builtin/mailinfo.o
10881089
BUILTIN_OBJS += builtin/mailsplit.o
1089-
BUILTIN_OBJS += builtin/merge.o
10901090
BUILTIN_OBJS += builtin/merge-base.o
10911091
BUILTIN_OBJS += builtin/merge-file.o
10921092
BUILTIN_OBJS += builtin/merge-index.o
10931093
BUILTIN_OBJS += builtin/merge-ours.o
10941094
BUILTIN_OBJS += builtin/merge-recursive.o
10951095
BUILTIN_OBJS += builtin/merge-tree.o
1096+
BUILTIN_OBJS += builtin/merge.o
10961097
BUILTIN_OBJS += builtin/mktag.o
10971098
BUILTIN_OBJS += builtin/mktree.o
10981099
BUILTIN_OBJS += builtin/multi-pack-index.o
@@ -1112,9 +1113,9 @@ BUILTIN_OBJS += builtin/read-tree.o
11121113
BUILTIN_OBJS += builtin/rebase.o
11131114
BUILTIN_OBJS += builtin/receive-pack.o
11141115
BUILTIN_OBJS += builtin/reflog.o
1115-
BUILTIN_OBJS += builtin/remote.o
11161116
BUILTIN_OBJS += builtin/remote-ext.o
11171117
BUILTIN_OBJS += builtin/remote-fd.o
1118+
BUILTIN_OBJS += builtin/remote.o
11181119
BUILTIN_OBJS += builtin/repack.o
11191120
BUILTIN_OBJS += builtin/replace.o
11201121
BUILTIN_OBJS += builtin/rerere.o
@@ -2330,16 +2331,16 @@ reconfigure config.mak.autogen: config.status
23302331
endif
23312332

23322333
XDIFF_OBJS += xdiff/xdiffi.o
2333-
XDIFF_OBJS += xdiff/xprepare.o
2334-
XDIFF_OBJS += xdiff/xutils.o
23352334
XDIFF_OBJS += xdiff/xemit.o
2335+
XDIFF_OBJS += xdiff/xhistogram.o
23362336
XDIFF_OBJS += xdiff/xmerge.o
23372337
XDIFF_OBJS += xdiff/xpatience.o
2338-
XDIFF_OBJS += xdiff/xhistogram.o
2338+
XDIFF_OBJS += xdiff/xprepare.o
2339+
XDIFF_OBJS += xdiff/xutils.o
23392340

2341+
VCSSVN_OBJS += vcs-svn/fast_export.o
23402342
VCSSVN_OBJS += vcs-svn/line_buffer.o
23412343
VCSSVN_OBJS += vcs-svn/sliding_window.o
2342-
VCSSVN_OBJS += vcs-svn/fast_export.o
23432344
VCSSVN_OBJS += vcs-svn/svndiff.o
23442345
VCSSVN_OBJS += vcs-svn/svndump.o
23452346

@@ -3147,9 +3148,10 @@ endif
31473148
#
31483149
ALL_COMMANDS = $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS)
31493150
ALL_COMMANDS += git
3151+
ALL_COMMANDS += git-citool
3152+
ALL_COMMANDS += git-gui
31503153
ALL_COMMANDS += gitk
31513154
ALL_COMMANDS += gitweb
3152-
ALL_COMMANDS += git-gui git-citool
31533155

31543156
.PHONY: check-docs
31553157
check-docs::

branch.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ void remove_merge_branch_state(struct repository *r)
344344
unlink(git_path_merge_rr(r));
345345
unlink(git_path_merge_msg(r));
346346
unlink(git_path_merge_mode(r));
347+
apply_autostash(git_path_merge_autostash(r));
347348
}
348349

349350
void remove_branch_state(struct repository *r, int verbose)

builtin/commit.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,6 +1719,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
17191719
unlink(git_path_merge_mode(the_repository));
17201720
unlink(git_path_squash_msg(the_repository));
17211721

1722+
apply_autostash(git_path_merge_autostash(the_repository));
1723+
17221724
if (commit_index_files())
17231725
die(_("repository has been updated, but unable to write\n"
17241726
"new_index file. Check that disk is not full and quota is\n"

0 commit comments

Comments
 (0)