1. 07 5月, 2019 2 次提交
    • N
      restore: take tree-ish from --source option instead · c9c935f6
      Nguyễn Thái Ngọc Duy 提交于
      This is another departure from 'git checkout' syntax, which uses -- to
      separate ref and pathspec. The observation is restore (or "git
      checkout -- <pathspec>") is most often used to restore some files from
      the index. If this is correct, we can simplify it by taking away the
      ref, so that we can write
      
          git restore some-file
      
      without worrying about some-file being a ref and whether we need to do
      
          git restore -- some-file
      
      for safety. If the source of the restore comes from a tree, it will be
      in the form of an option with value, e.g.
      
          git restore --source=this-tree some-file
      
      This is of course longer to type than using "--". But hopefully it
      will not be used as often, and it is clearly easier to understand.
      
      dwim_new_local_branch is no longer set (or unset) in cmd_restore_files()
      because it's irrelevant because we don't really care about dwim-ing.
      With accept_ref being unset, dwim can't happen.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c9c935f6
    • N
      checkout: split part of it to new command 'restore' · 46e91b66
      Nguyễn Thái Ngọc Duy 提交于
      Previously the switching branch business of 'git checkout' becomes a
      new command 'switch'. This adds the restore command for the checking
      out paths path.
      
      Similar to git-switch, a new man page is added to describe what the
      command will become. The implementation will be updated shortly to
      match the man page.
      
      A couple main differences from 'git checkout <paths>':
      
      - 'restore' by default will only update worktree. This matters more
        when --source is specified ('checkout <tree> <paths>' updates both
        worktree and index).
      
      - 'restore --staged' can be used to restore the index. This command
        overlaps with 'git reset <paths>'.
      
      - both worktree and index could also be restored at the same time
        (from a tree) when both --staged and --worktree are specified. This
        overlaps with 'git checkout <tree> <paths>'
      
      - default source for restoring worktree and index is the index and
        HEAD respectively. A different (tree) source could be specified as
        with --source (*).
      
      - when both index and worktree are restored, --source must be
        specified since the default source for these two individual targets
        are different (**)
      
      - --no-overlay is enabled by default, if an entry is missing in the
        source, restoring means deleting the entry
      
      (*) I originally went with --from instead of --source. I still think
        --from is a better name. The short option -f however is already
        taken by force. And I do think short option is good to have, e.g. to
        write -s@ or -s@^ instead of --source=HEAD.
      
      (**) If you sit down and think about it, moving worktree's source from
        the index to HEAD makes sense, but nobody is really thinking it
        through when they type the commands.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      46e91b66
  2. 02 4月, 2019 27 次提交
  3. 11 3月, 2019 11 次提交