Merge branch 'es/restore-staged-from-head-by-default'

"git restore --staged --worktree" now defaults to take the contents
out of "HEAD", instead of erring out.

* es/restore-staged-from-head-by-default:
  restore: default to HEAD when combining --staged and --worktree
This commit is contained in:
Junio C Hamano
2020-05-08 14:25:08 -07:00
3 changed files with 18 additions and 10 deletions

View File

@ -1609,10 +1609,10 @@ static int checkout_main(int argc, const char **argv, const char *prefix,
if (opts->checkout_index < 0 || opts->checkout_worktree < 0)
BUG("these flags should be non-negative by now");
/*
* convenient shortcut: "git restore --staged" equals
* "git restore --staged --source HEAD"
* convenient shortcut: "git restore --staged [--worktree]" equals
* "git restore --staged [--worktree] --source HEAD"
*/
if (!opts->from_treeish && opts->checkout_index && !opts->checkout_worktree)
if (!opts->from_treeish && opts->checkout_index)
opts->from_treeish = "HEAD";
/*