Merge branch 'nk/stash-show-config'
authorJunio C Hamano <gitster@pobox.com>
Mon, 5 Oct 2015 19:30:10 +0000 (12:30 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 5 Oct 2015 19:30:10 +0000 (12:30 -0700)
Users who are too busy to type three extra keystrokes to ask for
"git stash show -p" can now set stash.showPatch configuration
varible to true to always see the actual patch, not just the list
of paths affected with feel for the extent of damage via diffstat.

* nk/stash-show-config:
stash: allow "stash show" diff output configurable

1  2 
Documentation/config.txt
git-stash.sh
diff --combined Documentation/config.txt
index 0cc87a6f6565bbe794420bc47be8407e4ac47f22,c2f08aa18b97626352ebeeed466063dda5c0a06f..e935cbdc0058ce0ff629237d0f928bf5b5815bb3
@@@ -769,14 -769,6 +769,14 @@@ am.keepcr:
        by giving '--no-keep-cr' from the command line.
        See linkgit:git-am[1], linkgit:git-mailsplit[1].
  
 +am.threeWay::
 +      By default, `git am` will fail if the patch does not apply cleanly. When
 +      set to true, this setting tells `git am` to fall back on 3-way merge if
 +      the patch records the identity of blobs it is supposed to apply to and
 +      we have those blobs available locally (equivalent to giving the `--3way`
 +      option from the command line). Defaults to `false`.
 +      See linkgit:git-am[1].
 +
  apply.ignoreWhitespace::
        When set to 'change', tells 'git apply' to ignore changes in
        whitespace, in the same way as the '--ignore-space-change'
@@@ -866,9 -858,9 +866,9 @@@ branch.<name>.rebase:
        "git pull" is run. See "pull.rebase" for doing this in a non
        branch-specific manner.
  +
 -      When preserve, also pass `--preserve-merges` along to 'git rebase'
 -      so that locally committed merge commits will not be flattened
 -      by running 'git pull'.
 +When preserve, also pass `--preserve-merges` along to 'git rebase'
 +so that locally committed merge commits will not be flattened
 +by running 'git pull'.
  +
  *NOTE*: this is a possibly dangerous operation; do *not* use
  it unless you understand the implications (see linkgit:git-rebase[1]
@@@ -1250,25 -1242,6 +1250,25 @@@ filter.<driver>.smudge:
        object to a worktree file upon checkout.  See
        linkgit:gitattributes[5] for details.
  
 +fsck.<msg-id>::
 +      Allows overriding the message type (error, warn or ignore) of a
 +      specific message ID such as `missingEmail`.
 ++
 +For convenience, fsck prefixes the error/warning with the message ID,
 +e.g.  "missingEmail: invalid author/committer line - missing email" means
 +that setting `fsck.missingEmail = ignore` will hide that issue.
 ++
 +This feature is intended to support working with legacy repositories
 +which cannot be repaired without disruptive changes.
 +
 +fsck.skipList::
 +      The path to a sorted list of object names (i.e. one SHA-1 per
 +      line) that are known to be broken in a non-fatal way and should
 +      be ignored. This feature is useful when an established project
 +      should be accepted despite early commits containing errors that
 +      can be safely ignored such as invalid committer email addresses.
 +      Note: corrupt objects cannot be skipped with this setting.
 +
  gc.aggressiveDepth::
        The depth parameter used in the delta compression
        algorithm used by 'git gc --aggressive'.  This defaults
@@@ -1307,34 -1280,28 +1307,34 @@@ gc.packRefs:
  gc.pruneExpire::
        When 'git gc' is run, it will call 'prune --expire 2.weeks.ago'.
        Override the grace period with this config variable.  The value
 -      "now" may be used to disable this  grace period and always prune
 -      unreachable objects immediately.
 -
 -gc.pruneWorktreesExpire::
 -      When 'git gc' is run, it will call
 -      'prune --worktrees --expire 3.months.ago'.
 -      Override the grace period with this config variable. The value
 -      "now" may be used to disable the grace period and prune
 -      $GIT_DIR/worktrees immediately.
 +      "now" may be used to disable this grace period and always prune
 +      unreachable objects immediately, or "never" may be used to
 +      suppress pruning.
 +
 +gc.worktreePruneExpire::
 +      When 'git gc' is run, it calls
 +      'git worktree prune --expire 3.months.ago'.
 +      This config variable can be used to set a different grace
 +      period. The value "now" may be used to disable the grace
 +      period and prune $GIT_DIR/worktrees immediately, or "never"
 +      may be used to suppress pruning.
  
  gc.reflogExpire::
  gc.<pattern>.reflogExpire::
        'git reflog expire' removes reflog entries older than
 -      this time; defaults to 90 days.  With "<pattern>" (e.g.
 +      this time; defaults to 90 days. The value "now" expires all
 +      entries immediately, and "never" suppresses expiration
 +      altogether. With "<pattern>" (e.g.
        "refs/stash") in the middle the setting applies only to
        the refs that match the <pattern>.
  
  gc.reflogExpireUnreachable::
 -gc.<ref>.reflogExpireUnreachable::
 +gc.<pattern>.reflogExpireUnreachable::
        'git reflog expire' removes reflog entries older than
        this time and are not reachable from the current tip;
 -      defaults to 30 days.  With "<pattern>" (e.g. "refs/stash")
 +      defaults to 30 days. The value "now" expires all entries
 +      immediately, and "never" suppresses expiration altogether.
 +      With "<pattern>" (e.g. "refs/stash")
        in the middle, the setting applies only to the refs that
        match the <pattern>.
  
@@@ -1609,29 -1576,6 +1609,29 @@@ http.saveCookies:
        If set, store cookies received during requests to the file specified by
        http.cookieFile. Has no effect if http.cookieFile is unset.
  
 +http.sslVersion::
 +      The SSL version to use when negotiating an SSL connection, if you
 +      want to force the default.  The available and default version
 +      depend on whether libcurl was built against NSS or OpenSSL and the
 +      particular configuration of the crypto library in use. Internally
 +      this sets the 'CURLOPT_SSL_VERSION' option; see the libcurl
 +      documentation for more details on the format of this option and
 +      for the ssl version supported. Actually the possible values of
 +      this option are:
 +
 +      - sslv2
 +      - sslv3
 +      - tlsv1
 +      - tlsv1.0
 +      - tlsv1.1
 +      - tlsv1.2
 +
 ++
 +Can be overridden by the 'GIT_SSL_VERSION' environment variable.
 +To force git to use libcurl's default ssl version and ignore any
 +explicit http.sslversion option, set 'GIT_SSL_VERSION' to the
 +empty string.
 +
  http.sslCipherList::
    A list of SSL ciphers to use when negotiating an SSL connection.
    The available ciphers depend on whether libcurl was built against
@@@ -1942,18 -1886,6 +1942,18 @@@ mergetool.writeToTemp:
  mergetool.prompt::
        Prompt before each invocation of the merge resolution program.
  
 +notes.mergeStrategy::
 +      Which merge strategy to choose by default when resolving notes
 +      conflicts.  Must be one of `manual`, `ours`, `theirs`, `union`, or
 +      `cat_sort_uniq`.  Defaults to `manual`.  See "NOTES MERGE STRATEGIES"
 +      section of linkgit:git-notes[1] for more information on each strategy.
 +
 +notes.<name>.mergeStrategy::
 +      Which merge strategy to choose when doing a notes merge into
 +      refs/notes/<name>.  This overrides the more general
 +      "notes.mergeStrategy".  See the "NOTES MERGE STRATEGIES" section in
 +      linkgit:git-notes[1] for more information on the available strategies.
 +
  notes.displayRef::
        The (fully qualified) refname from which to show notes when
        showing commit messages.  The value of this variable can be set
@@@ -1982,8 -1914,8 +1982,8 @@@ notes.rewriteMode:
        When copying notes during a rewrite (see the
        "notes.rewrite.<command>" option), determines what to do if
        the target commit already has a note.  Must be one of
 -      `overwrite`, `concatenate`, or `ignore`.  Defaults to
 -      `concatenate`.
 +      `overwrite`, `concatenate`, `cat_sort_uniq`, or `ignore`.
 +      Defaults to `concatenate`.
  +
  This setting can be overridden with the `GIT_NOTES_REWRITE_MODE`
  environment variable.
@@@ -2138,9 -2070,9 +2138,9 @@@ pull.rebase:
        pull" is run. See "branch.<name>.rebase" for setting this on a
        per-branch basis.
  +
 -      When preserve, also pass `--preserve-merges` along to 'git rebase'
 -      so that locally committed merge commits will not be flattened
 -      by running 'git pull'.
 +When preserve, also pass `--preserve-merges` along to 'git rebase'
 +so that locally committed merge commits will not be flattened
 +by running 'git pull'.
  +
  *NOTE*: this is a possibly dangerous operation; do *not* use
  it unless you understand the implications (see linkgit:git-rebase[1]
@@@ -2213,14 -2145,6 +2213,14 @@@ push.followTags:
        may override this configuration at time of push by specifying
        '--no-follow-tags'.
  
 +push.gpgSign::
 +      May be set to a boolean value, or the string 'if-asked'. A true
 +      value causes all pushes to be GPG signed, as if '--signed' is
 +      passed to linkgit:git-push[1]. The string 'if-asked' causes
 +      pushes to be signed if the server supports it, as if
 +      '--signed=if-asked' is passed to 'git push'. A false value may
 +      override a value from a lower-priority config file. An explicit
 +      command-line flag always overrides this config option.
  
  rebase.stat::
        Whether to show a diffstat of what changed upstream since the last
@@@ -2237,22 -2161,6 +2237,22 @@@ rebase.autoStash:
        successful rebase might result in non-trivial conflicts.
        Defaults to false.
  
 +rebase.missingCommitsCheck::
 +      If set to "warn", git rebase -i will print a warning if some
 +      commits are removed (e.g. a line was deleted), however the
 +      rebase will still proceed. If set to "error", it will print
 +      the previous warning and stop the rebase, 'git rebase
 +      --edit-todo' can then be used to correct the error. If set to
 +      "ignore", no checking is done.
 +      To drop a commit without warning or error, use the `drop`
 +      command in the todo-list.
 +      Defaults to "ignore".
 +
 +rebase.instructionFormat
 +      A format string, as specified in linkgit:git-log[1], to be used for
 +      the instruction list during an interactive rebase.  The format will automatically
 +      have the long commit hash prepended to the format.
 +
  receive.advertiseAtomic::
        By default, git-receive-pack will advertise the atomic push
        capability to its clients. If you don't want to this capability
@@@ -2289,28 -2197,6 +2289,28 @@@ receive.fsckObjects:
        Defaults to false. If not set, the value of `transfer.fsckObjects`
        is used instead.
  
 +receive.fsck.<msg-id>::
 +      When `receive.fsckObjects` is set to true, errors can be switched
 +      to warnings and vice versa by configuring the `receive.fsck.<msg-id>`
 +      setting where the `<msg-id>` is the fsck message ID and the value
 +      is one of `error`, `warn` or `ignore`. For convenience, fsck prefixes
 +      the error/warning with the message ID, e.g. "missingEmail: invalid
 +      author/committer line - missing email" means that setting
 +      `receive.fsck.missingEmail = ignore` will hide that issue.
 ++
 +This feature is intended to support working with legacy repositories
 +which would not pass pushing when `receive.fsckObjects = true`, allowing
 +the host to accept repositories with certain known issues but still catch
 +other issues.
 +
 +receive.fsck.skipList::
 +      The path to a sorted list of object names (i.e. one SHA-1 per
 +      line) that are known to be broken in a non-fatal way and should
 +      be ignored. This feature is useful when an established project
 +      should be accepted despite early commits containing errors that
 +      can be safely ignored such as invalid committer email addresses.
 +      Note: corrupt objects cannot be skipped with this setting.
 +
  receive.unpackLimit::
        If the number of objects received in a push is below this
        limit then the objects will be unpacked into loose object
@@@ -2356,10 -2242,13 +2356,10 @@@ receive.denyNonFastForwards:
        set when initializing a shared repository.
  
  receive.hideRefs::
 -      String(s) `receive-pack` uses to decide which refs to omit
 -      from its initial advertisement.  Use more than one
 -      definitions to specify multiple prefix strings. A ref that
 -      are under the hierarchies listed on the value of this
 -      variable is excluded, and is hidden when responding to `git
 -      push`, and an attempt to update or delete a hidden ref by
 -      `git push` is rejected.
 +      This variable is the same as `transfer.hideRefs`, but applies
 +      only to `receive-pack` (and so affects pushes, but not fetches).
 +      An attempt to update or delete a hidden ref by `git push` is
 +      rejected.
  
  receive.updateServerInfo::
        If set to true, git-receive-pack will run git-update-server-info
@@@ -2587,6 -2476,16 +2587,16 @@@ status.submoduleSummary:
        submodule summary' command, which shows a similar output but does
        not honor these settings.
  
+ stash.showPatch::
+       If this is set to true, the `git stash show` command without an
+       option will show the stash in patch form.  Defaults to false.
+       See description of 'show' command in linkgit:git-stash[1].
+ stash.showStat::
+       If this is set to true, the `git stash show` command without an
+       option will show diffstat of the stash.  Defaults to true.
+       See description of 'show' command in linkgit:git-stash[1].
  submodule.<name>.path::
  submodule.<name>.url::
        The path within this project and URL for a submodule. These
@@@ -2647,18 -2546,9 +2657,18 @@@ transfer.fsckObjects:
        Defaults to false.
  
  transfer.hideRefs::
 -      This variable can be used to set both `receive.hideRefs`
 -      and `uploadpack.hideRefs` at the same time to the same
 -      values.  See entries for these other variables.
 +      String(s) `receive-pack` and `upload-pack` use to decide which
 +      refs to omit from their initial advertisements.  Use more than
 +      one definition to specify multiple prefix strings. A ref that is
 +      under the hierarchies listed in the value of this variable is
 +      excluded, and is hidden when responding to `git push` or `git
 +      fetch`.  See `receive.hideRefs` and `uploadpack.hideRefs` for
 +      program-specific versions of this config.
 ++
 +You may also include a `!` in front of the ref name to negate the entry,
 +explicitly exposing it, even if an earlier entry marked it as hidden.
 +If you have multiple hideRefs values, later entries override earlier ones
 +(and entries in more-specific config files override less-specific ones).
  
  transfer.unpackLimit::
        When `fetch.unpackLimit` or `receive.unpackLimit` are
@@@ -2673,10 -2563,13 +2683,10 @@@ uploadarchive.allowUnreachable:
        `false`.
  
  uploadpack.hideRefs::
 -      String(s) `upload-pack` uses to decide which refs to omit
 -      from its initial advertisement.  Use more than one
 -      definitions to specify multiple prefix strings. A ref that
 -      are under the hierarchies listed on the value of this
 -      variable is excluded, and is hidden from `git ls-remote`,
 -      `git fetch`, etc.  An attempt to fetch a hidden ref by `git
 -      fetch` will fail.  See also `uploadpack.allowTipSHA1InWant`.
 +      This variable is the same as `transfer.hideRefs`, but applies
 +      only to `upload-pack` (and so affects only fetches, not pushes).
 +      An attempt to fetch a hidden ref by `git fetch` will fail.  See
 +      also `uploadpack.allowTipSHA1InWant`.
  
  uploadpack.allowTipSHA1InWant::
        When `uploadpack.hideRefs` is in effect, allow `upload-pack`
diff --combined git-stash.sh
index 1d5ba7a4f935fd08572c235b7c5d4390eb8d6528,92bc0e1ad821291512604d1e931e57e1a4a5d0f5..c7c65e25f50e7b558952a5180081ad499f2a90fc
@@@ -183,7 -183,9 +183,7 @@@ store_stash () 
                stash_msg="Created via \"git stash store\"."
        fi
  
 -      # Make sure the reflog for stash is kept.
 -      : >>"$(git rev-parse --git-path logs/$ref_stash)"
 -      git update-ref -m "$stash_msg" $ref_stash $w_commit
 +      git update-ref --create-reflog -m "$stash_msg" $ref_stash $w_commit
        ret=$?
        test $ret != 0 && test -z $quiet &&
        die "$(eval_gettext "Cannot update \$ref_stash with \$w_commit")"
@@@ -260,7 -262,7 +260,7 @@@ save_stash () 
                say "$(gettext "No local changes to save")"
                exit 0
        fi
 -      test -f "$(git rev-parse --git-path logs/$ref_stash)" ||
 +      git reflog exists $ref_stash ||
                clear_stash || die "$(gettext "Cannot initialize stash")"
  
        create_stash "$stash_msg" $untracked
@@@ -305,7 -307,25 +305,25 @@@ show_stash () 
        ALLOW_UNKNOWN_FLAGS=t
        assert_stash_like "$@"
  
-       git diff ${FLAGS:---stat} $b_commit $w_commit
+       if test -z "$FLAGS"
+       then
+               if test "$(git config --bool stash.showStat || echo true)" = "true"
+               then
+                       FLAGS=--stat
+               fi
+               if test "$(git config --bool stash.showPatch || echo false)" = "true"
+               then
+                       FLAGS=${FLAGS}${FLAGS:+ }-p
+               fi
+               if test -z "$FLAGS"
+               then
+                       return 0
+               fi
+       fi
+       git diff ${FLAGS} $b_commit $w_commit
  }
  
  show_help () {