1. 06 8月, 2019 1 次提交
  2. 21 6月, 2019 3 次提交
    • N
      completion: disable dwim on "git switch -d" · 97ed6857
      Nguyễn Thái Ngọc Duy 提交于
      Even though dwim is enabled by default, it will never be done when
      --detached is specified. If you force "-d --guess" you will get an error
      because --guess then implies -c which cannot be used with -d. So we can
      disable dwim in "switch -d". It makes the completion list in this case a
      bit shorter.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      97ed6857
    • N
      switch: allow to switch in the middle of bisect · d16dc428
      Nguyễn Thái Ngọc Duy 提交于
      In c45f0f52 (switch: reject if some operation is in progress,
      2019-03-29), a check is added to prevent switching when some operation
      is in progress. The reason is it's often not safe to do so.
      
      This is true for merge, am, rebase, cherry-pick and revert, but not so
      much for bisect because bisecting is basically jumping/switching between
      a bunch of commits to pin point the first bad one. git-bisect suggests
      the next commit to test, but it's not wrong for the user to test a
      different commit because git-bisect cannot have the knowledge to know
      better.
      
      For this reason, allow to switch when bisecting (*). I considered if we
      should still prevent switching by default and allow it with
      --ignore-in-progress. But I don't think the prevention really adds
      anything much.
      
      If the user switches away by mistake, since we print the previous HEAD
      value, even if they don't know about the "-" shortcut, switching back is
      still possible.
      
      The warning will be printed on every switch while bisect is still
      ongoing, not the first time you switch away from bisect's suggested
      commit, so it could become a bit annoying.
      
      (*) of course when it's safe to do so, i.e. no loss of local changes and
      stuff.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d16dc428
    • N
      bcba4065
  3. 07 5月, 2019 16 次提交
    • N
      Declare both git-switch and git-restore experimental · 4e43b7ff
      Nguyễn Thái Ngọc Duy 提交于
      These two commands are basically redesigned git-checkout. We will not
      have that many opportunities to redo (because we run out of verbs, and
      that would also increase maintenance cost).
      
      To play it safe, let's declare the two commands experimental in one or
      two releases. If there is a serious flaw in the UI, we could still fix
      it. If everything goes well and nobody complains loudly, we can remove
      the experimental status by reverting this patch.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4e43b7ff
    • N
      help: move git-diff and git-reset to different groups · 12358755
      Nguyễn Thái Ngọc Duy 提交于
      The third column in command-list.txt determines what group a common
      command is printed in 'git help'.
      
      "git reset" is currently in the "work on the current change (see also:
      git help everyday)" group. While it's true that "git reset" can
      manipulate the index and can be in this group, its unique
      functionality is resetting HEAD, which should be the "grow, mark,
      tweak history" group.
      
      Moving it there will also avoid the confusion because both 'restore'
      and 'reset' are in the same group, next to each other.
      
      While looking at the 'group, mark, tweak history', I realize "git
      diff" should not be there. All the commands in this group is about
      _changing_ the commit history while "git diff" is a read-only
      operation. It fits better in the "examine the history and state" group
      (especially when "git status", its close friend, is already there).
      
      This is what we have after the reorganization:
      
          work on the current change (see also: git help everyday)
             add       Add file contents to the index
             mv        Move or rename a file, a directory, or a symlink
             restore   Restore working tree files
             rm        Remove files from the working tree and from the index
      
          examine the history and state (see also: git help revisions)
             bisect    Use binary search to find the commit that introduced a bug
             diff      Show changes between commits, commit and working tree, etc
             grep      Print lines matching a pattern
             log       Show commit logs
             show      Show various types of objects
             status    Show the working tree status
      
          grow, mark and tweak your common history
             branch    List, create, or delete branches
             commit    Record changes to the repository
             merge     Join two or more development histories together
             rebase    Reapply commits on top of another base tip
             reset     Reset current HEAD to the specified state
             switch    Switch branches
             tag       Create, list, delete or verify a tag object signed with GPG
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      12358755
    • N
      doc: promote "git restore" · 80f537f7
      Nguyễn Thái Ngọc Duy 提交于
      The new command "git restore" (together with "git switch") are added
      to avoid the confusion of one-command-do-all "git checkout" for new
      users. They are also helpful to avoid ambiguous context.
      
      For these reasons, promote it everywhere possible. This includes
      documentation, suggestions/advice from other commands.
      
      One nice thing about git-restore is the ability to restore
      "everything", so it can be used in "git status" advice instead of both
      "git checkout" and "git reset".  The three commands suggested by "git
      status" are add, rm and restore.
      
      "git checkout" is also removed from "git help" (i.e. it's no longer
      considered a commonly used command)
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      80f537f7
    • N
      user-manual.txt: prefer 'merge --abort' over 'reset --hard' · fc991b43
      Nguyễn Thái Ngọc Duy 提交于
      Since the operation in progress is merge, stick to the 'git merge'
      variant of aborting. 'git reset --hard' does not really tell you about
      aborting the merge by just looking, longer to type, and even though I
      know by heart what --hard do, I still dislike it when I need to consider
      whether --hard, --mixed or --soft.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      fc991b43
    • N
      completion: support restore · 75f4c7c1
      Nguyễn Thái Ngọc Duy 提交于
      Completion for restore is straightforward. We could still do better
      though by giving the list of just tracked files instead of all present
      ones. But let's leave it for later.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      75f4c7c1
    • N
      4df3ec63
    • N
      restore: support --patch · 2f0896ec
      Nguyễn Thái Ngọc Duy 提交于
      git-restore is different from git-checkout that it only restores the
      worktree by default, not both worktree and index. add--interactive
      needs some update to support this mode.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2f0896ec
    • N
      restore: replace --force with --ignore-unmerged · a5e5f399
      Nguyễn Thái Ngọc Duy 提交于
      Use a more specific option name to express its purpose. --force may come
      back as an alias of --ignore-unmerged and possibly more. But since this
      is a destructive operation, I don't see why we need to "force" anything
      more. We already don't hold back.
      
      When 'checkout --force' or 'restore --ignore-unmerged' is used, we may
      also print warnings about unmerged entries being ignore. Since this is
      not exactly warning (people tell us to do so), more informational, let
      it be suppressed if --quiet is given. This is a behavior change for
      git-checkout.
      
      PS. The diff looks a bit iffy since --force is moved to
      add_common_switch_branch_options() (i.e. for switching). But
      git-checkout is also doing switching and inherits this --force.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a5e5f399
    • N
      restore: default to --source=HEAD when only --staged is specified · 3a733ce5
      Nguyễn Thái Ngọc Duy 提交于
      "git restore --staged" without --source does not make much sense since
      by default we restore from the index.  Instead of copying the index to
      itself, set the default source to HEAD in this case, yielding behavior
      that matches "git reset -- <paths>".
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      3a733ce5
    • N
      restore: reject invalid combinations with --staged · e3ddd3b5
      Nguyễn Thái Ngọc Duy 提交于
      git-checkout rejects plenty of invalid option combinations. Since
      git-checkout is equivalent of either
      
          git restore --source --staged --worktree
      
      or
      
          git restore --worktree
      
      that still leaves the new mode 'git restore --index' unprotected. Reject
      some more invalid option combinations.
      
      The other new mode 'restore --source --worktree' does not need anything
      else.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e3ddd3b5
    • N
      restore: add --worktree and --staged · 183fb44f
      Nguyễn Thái Ngọc Duy 提交于
      'git checkout <tree-ish> <pathspec>' updates both index and
      worktree. But updating the index when you want to restore worktree
      files is non-intuitive. The index contains the data ready for the next
      commit, and there's no indication that the user will want to commit
      the restored versions.
      
      'git restore' therefore by default only touches worktree. The user has
      the option to update either the index with
      
          git restore --staged --source=<tree> <path>  (1)
      
      or update both with
      
          git restore --staged --worktree --source=<tree> <path> (2)
      
      PS. Orignally I wanted to make worktree update default and form (1)
      would add index update while also updating the worktree, and the user
      would need to do "--staged --no-worktree" to update index only. But it
      looks really confusing that "--staged" option alone updates both. So
      now form (2) is used for both, which reads much more obvious.
      
      PPS. Yes form (1) overlaps with "git reset <rev> <path>". I don't know
      if we can ever turn "git reset" back to "_always_ reset HEAD and
      optionally do something else".
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      183fb44f
    • N
    • N
      restore: disable overlay mode by default · a6cfb9ba
      Nguyễn Thái Ngọc Duy 提交于
      Overlay mode is considered confusing when the command is about
      restoring files on worktree. Disable it by default. The user can still
      turn it on, or use 'git checkout' which still has overlay mode on by
      default.
      
      While at it, make the check in checkout_branch() stricter. Neither
      --overlay or --no-overlay should be accepted in branch switching mode.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a6cfb9ba
    • N
      restore: make pathspec mandatory · be8ed502
      Nguyễn Thái Ngọc Duy 提交于
      "git restore" without arguments does not make much sense when
      it's about restoring files (what files now?). We could default to
      either
      
          git restore .
      
      or
      
          git restore :/
      
      Neither is intuitive. Make the user always give pathspec, force the
      user to think the scope of restore they want because this is a
      destructive operation.
      
      "git restore -p" without pathspec is an exception to this
      because it really is a separate mode. It will be treated as running
      patch mode on the whole worktree.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      be8ed502
    • 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
  4. 02 4月, 2019 20 次提交