1. 28 Aug, 2019 38 commits
    • Duy Nguyen's avatar
    • Duy Nguyen's avatar
      5e3b0120
    • Duy Nguyen's avatar
      rm: add --staged as alias for --cached · 89c837b6
      Duy Nguyen authored
      After the last patch, "git status" now suggests
      
      - add                  to stage some changes
      - restore [--worktree] to undo worktree changes
      - restore --staged     to undo index changes
      - rm --cached          to remove files from the index
      
      This change is to make the suggestions for more consistent by using
      --staged across all suggested commands instead of the
      still-a-bit-hard-to-understand --cached.
      
      PS. Should we suggest "git stage" instead of "git add"? Maybe that's
      going too far?
      89c837b6
    • Duy Nguyen's avatar
      restore: add --intent-to-add (restoring worktree only) · e973f601
      Duy Nguyen authored
      "git restore --source" (without --staged) could create new files
      (i.e. not present in index) on worktree to match the given source. But
      the new files are not tracked, so both "git diff" and "git diff
      <source>" ignore new files. "git commit -a" will not recreate a commit
      exactly as the given source either.
      
      Add --intent-to-add to help track new files in this case, which is the
      default on the least surprise principle.
      e973f601
    • Duy Nguyen's avatar
      4ef1e8b6
    • Duy Nguyen's avatar
      FIXME · eeaf15d0
      Duy Nguyen authored
      eeaf15d0
    • Duy Nguyen's avatar
    • Duy Nguyen's avatar
      18346f35
    • Duy Nguyen's avatar
      checkout -f: keep backup of overwritten files · 4b3c3bec
      Duy Nguyen authored
      4b3c3bec
    • Duy Nguyen's avatar
      7292e856
    • Duy Nguyen's avatar
      unpack-trees.c: keep backup of ignored files being overwritten · bd82e28b
      Duy Nguyen authored
      Ignored files are usually machine generated (e.g. *.o) and not worth
      keeping, so when a merge or branch switch happens and need to
      overwrite them, we just go ahead and do it. Occasionally though
      ignored files _can_ have valuable content.
      
      We will likely have a separate mechanism to protect these "precious"
      ignored files, but a surprise is still a surprise. Keep a backup of
      ignored files when they are overwritten (until we are explicitly told
      "rubbish" by said mechanism). This lets the user recover the content
      and start telling git that the file is precious so it won't happen
      again.
      bd82e28b
    • Duy Nguyen's avatar
      refs: keep backup of deleted reflog · e3e99d1b
      Duy Nguyen authored
      As noted in git-backup-log.txt a long time ago, this is mostly meant
      for recovering a branch immediately after an accidental deletion.
      
      References from the deleted reflog will not be included in
      reachability tests and they will be deleted at the next gc. At that
      point, this deleted reflog becomes useless.
      e3e99d1b
    • Duy Nguyen's avatar
      config --edit: support backup log · f6bd968e
      Duy Nguyen authored
      f6bd968e
    • Duy Nguyen's avatar
      sha1-file.c: let index_path() accept NULL istate · 9c57ccf3
      Duy Nguyen authored
      istate is needed for content conversion. Allow to pass NULL istate
      (which implies that the caller does not care at all about file content
      conversion).
      9c57ccf3
    • Duy Nguyen's avatar
      backup-log: keep all blob references around · fa036a2f
      Duy Nguyen authored
      The four commands prune, rev-list, pack-objects and repack are updated
      to not consider backup-log's blobs as unreachable and either delete
      them outright or not repack them.
      fa036a2f
    • Duy Nguyen's avatar
      gc: prune backup logs · 0beadf9c
      Duy Nguyen authored
      0beadf9c
    • Duy Nguyen's avatar
      backup-log: add prune command · 13b29d49
      Duy Nguyen authored
      13b29d49
    • Duy Nguyen's avatar
      backup-log: add log command · dcf40bf5
      Duy Nguyen authored
      One note about the default relative mode. Since this is mostly used
      after a panic moment "oops I did it again!". The user would most
      likely look for latest changes of a certain path and relative dates
      make it easier to spot if the change is within a time frame.
      
      Default to --patch too because the output is pretty useless otherwise.
      dcf40bf5
    • Duy Nguyen's avatar
      backup-log: add diff command · 6bf1a9d4
      Duy Nguyen authored
      This gives you a patch so you can apply if you want.
      
      FIXME pathspec support?
      
      PS. the file list in diff queue is not sorted like a normal "git
      diff". If this is a big deal, we probably can sort it later.
      6bf1a9d4
    • Duy Nguyen's avatar
      backup-log: add cat command · 863eab91
      Duy Nguyen authored
      This command introduces a new concept, "change id". This is similar to
      "n" in reflog sha-1 extended syntax @{n}. I'm trying to group changes of
      the same second together, and this timestamp becomes "change id", so
      you view roughly a snapshot of changes. Of course it's not 100%
      accurate. But it works most of the time and it keeps log update low.
      863eab91
    • Duy Nguyen's avatar
      backup-log.c: add API for walking backup log · d3bd3322
      Duy Nguyen authored
      d3bd3322
    • Duy Nguyen's avatar
      add--interactive: support backup log · 83286d0f
      Duy Nguyen authored
      83286d0f
    • Duy Nguyen's avatar
      apply: support backup log with --keep-backup · affebf85
      Duy Nguyen authored
      Normally changes from git-apply are not worth logging because they
      come from a file and can be recovered from there. This option will
      mostly be used by add--interactive.pl where patches are generated
      during an interactive add session and are very much worth logging.
      
      The logging is a bit more complicated because an update is done in two
      phases. The old version of all patches is removed first then the new
      one added. We need to keep track of the old version in order to make a
      backup.
      affebf85
    • Duy Nguyen's avatar
      commit: support backup log · ea282e1c
      Duy Nguyen authored
      ea282e1c
    • Duy Nguyen's avatar
      update-index: support backup log with --keep-backup · c946f573
      Duy Nguyen authored
      Since this is a plumbing command, backup log support remains off by
      default and only active when both --keep-backup and core.backupLog=true
      are specified.
      
      The check of core.backupLog is mostly for convenient, the calling script
      does not have to explicitly check core.backupLog every time it executes
      update-index. Truly disabling backup log must be done with something
      like
      
          git -c core.backupLog=false update-index ...
      c946f573
    • Duy Nguyen's avatar
      add: support backup log · 024b7724
      Duy Nguyen authored
      There is not much to say about the actual change in this patch, which
      is straightforward. There is something to say about the lack of change
      though.
      
      The definition of "interesting" changes to keep in backup log
      previously is "file modification, except file removal". It is further
      refined: only changes coming from worktree (for from the user to be
      more accurate) are interesting. Changes in the index from object
      database (e.g. merging, switching branches, resetting...) are not
      interesting because the actual content is already in the object
      database and can be recovered (provided that you still have the
      history of commands you used, of course)
      024b7724
    • Duy Nguyen's avatar
      read-cache.c: new flag for add_index_entry() to write to backup log · cfad72ca
      Duy Nguyen authored
      Index update API is updated to write to backup log if requested. The
      entry deletion API is not updated because file removal is not
      "interesting" from the undo point of view.
      
      Note, we do double locking when writing $GIT_DIR/index now:
      
      - $GIT_DIR/index.lock is created
      - then $GIT_DIR/index.bkl.lock is created
      
      Nobody will lock these in reverse order so no chance for dead lock
      (yet)
      cfad72ca
    • Duy Nguyen's avatar
      backup-log: add "update" subcommand · 0f19510a
      Duy Nguyen authored
      This defines backup log file format and adds basic support for writing
      new entries to backup log files. The format is the same as reflog
      except that "message" field becomes "path".
      
      Similar to reflog, updating is done by appending to the end of the file
      instead of creating a branch new file and do an atomic rename. If the
      backup log file gets large, regenerating whole file could take longer,
      and we should keep backup log overhead to minimum since it will be
      called by a bunch of commands later.
      0f19510a
    • Duy Nguyen's avatar
      doc: introduce new "backup log" concept · c5165e2c
      Duy Nguyen authored
      A reflog file records changes of a certain ref over time. A backup log
      file does a similar job, but it records changes of some files over time.
      This is the main idea of it.
      
      This is added so that we can support undoing certain changes. For
      example, if you have carefully prepared your index with "git add -p"
      then accidentally do "git commit -a", your well crafted index is lost
      with no easy way to recover it. We could go the other way and make
      "git commit -a" complain loudly, but that has other bad side effects,
      the big one is we may complain too loudly at the wrong time and too
      often. This "do the right things (most of the time) but allow the
      user to undo when we get it wrong" approach seems more inline with how
      git handles other things.
      
      The current plan is to have three backup log files:
      
      - $GIT_DIR/index.bkl contains "interesting" changes made in the index.
      
      - $GIT_DIR/worktree.bkl contains "interesting" changes made in
        worktree.
      
      - $GIT_DIR/common/gitdir.bkl contains changes made in other files
        inside $GIT_DIR such as config, those in info/ directory, or reflog
        file deletion (aka the mystical reflog graveyard)
      
      All these only record "interesting" changes which will be defined
      later. But a few examples of them are: "git add -p" is interesting,
      but "git reset HEAD" is not. Similarly changes made in $GIT_DIR/config
      are usually interesting.
      
      This patch does none of that! It adds a new man page for a new
      plumbing command "git backup-log" which does show what this
      functionality looks like.
      c5165e2c
    • Duy Nguyen's avatar
      rebase: no branch switch · f109f969
      Duy Nguyen authored
      f109f969
    • Duy Nguyen's avatar
      9e831d46
    • Duy Nguyen's avatar
    • Duy Nguyen's avatar
      rm: add --staged as alias for --cached · a5863d0d
      Duy Nguyen authored
      After the last patch, "git status" now suggests
      
      - add                  to stage some changes
      - restore [--worktree] to undo worktree changes
      - restore --staged     to undo index changes
      - rm --cached          to remove files from the index
      
      This change is to make the suggestions for more consistent by using
      --staged across all suggested commands instead of the
      still-a-bit-hard-to-understand --cached.
      
      PS. Should we suggest "git stage" instead of "git add"? Maybe that's
      going too far?
      a5863d0d
    • Duy Nguyen's avatar
      restore: add --intent-to-add (restoring worktree only) · 582e7839
      Duy Nguyen authored
      "git restore --source" (without --staged) could create new files
      (i.e. not present in index) on worktree to match the given source. But
      the new files are not tracked, so both "git diff" and "git diff
      <source>" ignore new files. "git commit -a" will not recreate a commit
      exactly as the given source either.
      
      Add --intent-to-add to help track new files in this case, which is the
      default on the least surprise principle.
      582e7839
    • Duy Nguyen's avatar
    • Duy Nguyen's avatar
    • Duy Nguyen's avatar
    • Duy Nguyen's avatar
  2. 22 Aug, 2019 2 commits