Skip to content

Commit 8ebaee4

Browse files
committed
Don't just trash local changes
1 parent d3cb9c1 commit 8ebaee4

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

msfupdate

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,17 @@ end
101101
if is_git
102102
remote = @git_remote || "origin"
103103
branch = @git_branch || "master"
104-
# Always lose any local changes, but not unchecked files
105-
# This is actually safer than the old svn way of msfupdate
106-
# which would happily just generate conflicts over changes.
107-
# TODO: Allow for git stash and git stash pop
108-
res = system("git", "reset", "HEAD", "--hard")
104+
# This will save local changes in a stash, but won't
105+
# attempt to reapply them. If the user wants them back
106+
# they can always git stash pop them, and that presumes
107+
# they know what they're doing when they're editing local
108+
# checkout, which presumes they're not using msfupdate
109+
# to begin with.
110+
#
111+
# Note, this requires at least user.name and user.email
112+
# to be configured in the global git config. Installers should
113+
# take care that this is done. TODO: Enforce this in msfupdate
114+
res = system("git", "stash")
109115
if res.nil?
110116
$stderr.puts "[-] ERROR: Failed to run git"
111117
$stderr.puts ""
@@ -115,6 +121,7 @@ if is_git
115121
exit 1
116122
end
117123

124+
system("git", "reset", "HEAD", "--hard")
118125
system("git", "checkout", branch)
119126
system("git", "fetch")
120127
system("git", "merge", "#{remote}/#{branch}")

0 commit comments

Comments
 (0)