Skip to content

Commit b133308

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 60873f7 + de4db86 commit b133308

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
@@ -737,8 +737,8 @@ TEST_BUILTINS_OBJS += test-revision-walking.o
737737
TEST_BUILTINS_OBJS += test-run-command.o
738738
TEST_BUILTINS_OBJS += test-scrap-cache-tree.o
739739
TEST_BUILTINS_OBJS += test-serve-v2.o
740-
TEST_BUILTINS_OBJS += test-sha1.o
741740
TEST_BUILTINS_OBJS += test-sha1-array.o
741+
TEST_BUILTINS_OBJS += test-sha1.o
742742
TEST_BUILTINS_OBJS += test-sha256.o
743743
TEST_BUILTINS_OBJS += test-sigchain.o
744744
TEST_BUILTINS_OBJS += test-strcmp-offset.o
@@ -748,10 +748,10 @@ TEST_BUILTINS_OBJS += test-submodule-nested-repo-config.o
748748
TEST_BUILTINS_OBJS += test-subprocess.o
749749
TEST_BUILTINS_OBJS += test-trace2.o
750750
TEST_BUILTINS_OBJS += test-urlmatch-normalization.o
751-
TEST_BUILTINS_OBJS += test-xml-encode.o
752751
TEST_BUILTINS_OBJS += test-wildmatch.o
753752
TEST_BUILTINS_OBJS += test-windows-named-pipe.o
754753
TEST_BUILTINS_OBJS += test-write-cache.o
754+
TEST_BUILTINS_OBJS += test-xml-encode.o
755755

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

789789
# what test wrappers are needed and 'install' will install, in bindir
790790
BINDIR_PROGRAMS_NEED_X += git
791-
BINDIR_PROGRAMS_NEED_X += git-upload-pack
792791
BINDIR_PROGRAMS_NEED_X += git-receive-pack
793-
BINDIR_PROGRAMS_NEED_X += git-upload-archive
794792
BINDIR_PROGRAMS_NEED_X += git-shell
793+
BINDIR_PROGRAMS_NEED_X += git-upload-archive
794+
BINDIR_PROGRAMS_NEED_X += git-upload-pack
795795

796796
BINDIR_PROGRAMS_NO_X += git-cvsserver
797797

@@ -831,9 +831,9 @@ LIB_OBJS += advice.o
831831
LIB_OBJS += alias.o
832832
LIB_OBJS += alloc.o
833833
LIB_OBJS += apply.o
834-
LIB_OBJS += archive.o
835834
LIB_OBJS += archive-tar.o
836835
LIB_OBJS += archive-zip.o
836+
LIB_OBJS += archive.o
837837
LIB_OBJS += argv-array.o
838838
LIB_OBJS += attr.o
839839
LIB_OBJS += base85.o
@@ -849,9 +849,9 @@ LIB_OBJS += checkout.o
849849
LIB_OBJS += color.o
850850
LIB_OBJS += column.o
851851
LIB_OBJS += combine-diff.o
852-
LIB_OBJS += commit.o
853852
LIB_OBJS += commit-graph.o
854853
LIB_OBJS += commit-reach.o
854+
LIB_OBJS += commit.o
855855
LIB_OBJS += compat/obstack.o
856856
LIB_OBJS += compat/terminal.o
857857
LIB_OBJS += config.o
@@ -865,17 +865,17 @@ LIB_OBJS += ctype.o
865865
LIB_OBJS += date.o
866866
LIB_OBJS += decorate.o
867867
LIB_OBJS += delta-islands.o
868+
LIB_OBJS += diff-delta.o
869+
LIB_OBJS += diff-lib.o
870+
LIB_OBJS += diff-no-index.o
871+
LIB_OBJS += diff.o
868872
LIB_OBJS += diffcore-break.o
869873
LIB_OBJS += diffcore-delta.o
870874
LIB_OBJS += diffcore-order.o
871875
LIB_OBJS += diffcore-pickaxe.o
872876
LIB_OBJS += diffcore-rename.o
873-
LIB_OBJS += diff-delta.o
874-
LIB_OBJS += diff-lib.o
875-
LIB_OBJS += diff-no-index.o
876-
LIB_OBJS += diff.o
877-
LIB_OBJS += dir.o
878877
LIB_OBJS += dir-iterator.o
878+
LIB_OBJS += dir.o
879879
LIB_OBJS += editor.o
880880
LIB_OBJS += entry.o
881881
LIB_OBJS += environment.o
@@ -893,7 +893,6 @@ LIB_OBJS += gpg-interface.o
893893
LIB_OBJS += graph.o
894894
LIB_OBJS += grep.o
895895
LIB_OBJS += hashmap.o
896-
LIB_OBJS += linear-assignment.o
897896
LIB_OBJS += help.o
898897
LIB_OBJS += hex.o
899898
LIB_OBJS += ident.o
@@ -903,9 +902,10 @@ LIB_OBJS += kwset.o
903902
LIB_OBJS += levenshtein.o
904903
LIB_OBJS += line-log.o
905904
LIB_OBJS += line-range.o
906-
LIB_OBJS += list-objects.o
907-
LIB_OBJS += list-objects-filter.o
905+
LIB_OBJS += linear-assignment.o
908906
LIB_OBJS += list-objects-filter-options.o
907+
LIB_OBJS += list-objects-filter.o
908+
LIB_OBJS += list-objects.o
909909
LIB_OBJS += ll-merge.o
910910
LIB_OBJS += lockfile.o
911911
LIB_OBJS += log-tree.o
@@ -914,31 +914,31 @@ LIB_OBJS += mailinfo.o
914914
LIB_OBJS += mailmap.o
915915
LIB_OBJS += match-trees.o
916916
LIB_OBJS += mem-pool.o
917-
LIB_OBJS += merge.o
918917
LIB_OBJS += merge-blobs.o
919918
LIB_OBJS += merge-recursive.o
919+
LIB_OBJS += merge.o
920920
LIB_OBJS += mergesort.o
921921
LIB_OBJS += midx.o
922922
LIB_OBJS += name-hash.o
923923
LIB_OBJS += negotiator/default.o
924924
LIB_OBJS += negotiator/skipping.o
925-
LIB_OBJS += notes.o
926925
LIB_OBJS += notes-cache.o
927926
LIB_OBJS += notes-merge.o
928927
LIB_OBJS += notes-utils.o
928+
LIB_OBJS += notes.o
929929
LIB_OBJS += object.o
930930
LIB_OBJS += oidmap.o
931931
LIB_OBJS += oidset.o
932-
LIB_OBJS += packfile.o
933-
LIB_OBJS += pack-bitmap.o
934932
LIB_OBJS += pack-bitmap-write.o
933+
LIB_OBJS += pack-bitmap.o
935934
LIB_OBJS += pack-check.o
936935
LIB_OBJS += pack-objects.o
937936
LIB_OBJS += pack-revindex.o
938937
LIB_OBJS += pack-write.o
938+
LIB_OBJS += packfile.o
939939
LIB_OBJS += pager.o
940-
LIB_OBJS += parse-options.o
941940
LIB_OBJS += parse-options-cb.o
941+
LIB_OBJS += parse-options.o
942942
LIB_OBJS += patch-delta.o
943943
LIB_OBJS += patch-ids.o
944944
LIB_OBJS += path.o
@@ -957,19 +957,20 @@ LIB_OBJS += reachable.o
957957
LIB_OBJS += read-cache.o
958958
LIB_OBJS += rebase.o
959959
LIB_OBJS += rebase-interactive.o
960+
LIB_OBJS += ref-filter.o
960961
LIB_OBJS += reflog-walk.o
961962
LIB_OBJS += refs.o
962963
LIB_OBJS += refs/files-backend.o
963964
LIB_OBJS += refs/iterator.o
964965
LIB_OBJS += refs/packed-backend.o
965966
LIB_OBJS += refs/ref-cache.o
966967
LIB_OBJS += refspec.o
967-
LIB_OBJS += ref-filter.o
968968
LIB_OBJS += remote.o
969969
LIB_OBJS += replace-object.o
970970
LIB_OBJS += repo-settings.o
971971
LIB_OBJS += repository.o
972972
LIB_OBJS += rerere.o
973+
LIB_OBJS += reset.o
973974
LIB_OBJS += resolve-undo.o
974975
LIB_OBJS += revision.o
975976
LIB_OBJS += run-command.o
@@ -979,8 +980,8 @@ LIB_OBJS += serve.o
979980
LIB_OBJS += server-info.o
980981
LIB_OBJS += setup.o
981982
LIB_OBJS += sha1-array.o
982-
LIB_OBJS += sha1-lookup.o
983983
LIB_OBJS += sha1-file.o
984+
LIB_OBJS += sha1-lookup.o
984985
LIB_OBJS += sha1-name.o
985986
LIB_OBJS += shallow.o
986987
LIB_OBJS += sideband.o
@@ -990,9 +991,9 @@ LIB_OBJS += stable-qsort.o
990991
LIB_OBJS += strbuf.o
991992
LIB_OBJS += streaming.o
992993
LIB_OBJS += string-list.o
993-
LIB_OBJS += submodule.o
994-
LIB_OBJS += submodule-config.o
995994
LIB_OBJS += sub-process.o
995+
LIB_OBJS += submodule-config.o
996+
LIB_OBJS += submodule.o
996997
LIB_OBJS += symlinks.o
997998
LIB_OBJS += tag.o
998999
LIB_OBJS += tempfile.o
@@ -1011,11 +1012,11 @@ LIB_OBJS += trace2/tr2_tgt_normal.o
10111012
LIB_OBJS += trace2/tr2_tgt_perf.o
10121013
LIB_OBJS += trace2/tr2_tls.o
10131014
LIB_OBJS += trailer.o
1014-
LIB_OBJS += transport.o
10151015
LIB_OBJS += transport-helper.o
1016+
LIB_OBJS += transport.o
10161017
LIB_OBJS += tree-diff.o
1017-
LIB_OBJS += tree.o
10181018
LIB_OBJS += tree-walk.o
1019+
LIB_OBJS += tree.o
10191020
LIB_OBJS += unpack-trees.o
10201021
LIB_OBJS += upload-pack.o
10211022
LIB_OBJS += url.o
@@ -1055,9 +1056,9 @@ BUILTIN_OBJS += builtin/checkout.o
10551056
BUILTIN_OBJS += builtin/clean.o
10561057
BUILTIN_OBJS += builtin/clone.o
10571058
BUILTIN_OBJS += builtin/column.o
1059+
BUILTIN_OBJS += builtin/commit-graph.o
10581060
BUILTIN_OBJS += builtin/commit-tree.o
10591061
BUILTIN_OBJS += builtin/commit.o
1060-
BUILTIN_OBJS += builtin/commit-graph.o
10611062
BUILTIN_OBJS += builtin/config.o
10621063
BUILTIN_OBJS += builtin/count-objects.o
10631064
BUILTIN_OBJS += builtin/credential.o
@@ -1088,13 +1089,13 @@ BUILTIN_OBJS += builtin/ls-remote.o
10881089
BUILTIN_OBJS += builtin/ls-tree.o
10891090
BUILTIN_OBJS += builtin/mailinfo.o
10901091
BUILTIN_OBJS += builtin/mailsplit.o
1091-
BUILTIN_OBJS += builtin/merge.o
10921092
BUILTIN_OBJS += builtin/merge-base.o
10931093
BUILTIN_OBJS += builtin/merge-file.o
10941094
BUILTIN_OBJS += builtin/merge-index.o
10951095
BUILTIN_OBJS += builtin/merge-ours.o
10961096
BUILTIN_OBJS += builtin/merge-recursive.o
10971097
BUILTIN_OBJS += builtin/merge-tree.o
1098+
BUILTIN_OBJS += builtin/merge.o
10981099
BUILTIN_OBJS += builtin/mktag.o
10991100
BUILTIN_OBJS += builtin/mktree.o
11001101
BUILTIN_OBJS += builtin/multi-pack-index.o
@@ -1114,9 +1115,9 @@ BUILTIN_OBJS += builtin/read-tree.o
11141115
BUILTIN_OBJS += builtin/rebase.o
11151116
BUILTIN_OBJS += builtin/receive-pack.o
11161117
BUILTIN_OBJS += builtin/reflog.o
1117-
BUILTIN_OBJS += builtin/remote.o
11181118
BUILTIN_OBJS += builtin/remote-ext.o
11191119
BUILTIN_OBJS += builtin/remote-fd.o
1120+
BUILTIN_OBJS += builtin/remote.o
11201121
BUILTIN_OBJS += builtin/repack.o
11211122
BUILTIN_OBJS += builtin/replace.o
11221123
BUILTIN_OBJS += builtin/rerere.o
@@ -2335,16 +2336,16 @@ reconfigure config.mak.autogen: config.status
23352336
endif
23362337

23372338
XDIFF_OBJS += xdiff/xdiffi.o
2338-
XDIFF_OBJS += xdiff/xprepare.o
2339-
XDIFF_OBJS += xdiff/xutils.o
23402339
XDIFF_OBJS += xdiff/xemit.o
2340+
XDIFF_OBJS += xdiff/xhistogram.o
23412341
XDIFF_OBJS += xdiff/xmerge.o
23422342
XDIFF_OBJS += xdiff/xpatience.o
2343-
XDIFF_OBJS += xdiff/xhistogram.o
2343+
XDIFF_OBJS += xdiff/xprepare.o
2344+
XDIFF_OBJS += xdiff/xutils.o
23442345

2346+
VCSSVN_OBJS += vcs-svn/fast_export.o
23452347
VCSSVN_OBJS += vcs-svn/line_buffer.o
23462348
VCSSVN_OBJS += vcs-svn/sliding_window.o
2347-
VCSSVN_OBJS += vcs-svn/fast_export.o
23482349
VCSSVN_OBJS += vcs-svn/svndiff.o
23492350
VCSSVN_OBJS += vcs-svn/svndump.o
23502351

@@ -3152,9 +3153,10 @@ endif
31523153
#
31533154
ALL_COMMANDS = $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS)
31543155
ALL_COMMANDS += git
3156+
ALL_COMMANDS += git-citool
3157+
ALL_COMMANDS += git-gui
31553158
ALL_COMMANDS += gitk
31563159
ALL_COMMANDS += gitweb
3157-
ALL_COMMANDS += git-gui git-citool
31583160

31593161
.PHONY: check-docs
31603162
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)