1. 08 Mar, 2019 1 commit
    • Johannes Schindelin's avatar
      legacy stash: fix "rudimentary backport of -q" · 7b556aa4
      Johannes Schindelin authored
      When this developer backported support for `--quiet` to the scripted
      version of `git stash` in 80590055ea (stash: optionally use the scripted
      version again, 2018-12-20), it looked like a sane choice to use `eval`
      to execute the command line passed in via the parameter list of
      However, that is not what we should have done, as that command-line was
      already in the correct shape.
      This can be seen very clearly when passing arguments with special
      characters, like
      	git stash -- ':(glob)**/*.txt'
      Since this is exactly what we want to test in the next commit (where we
      fix this very incantation with the built-in stash), let's fix the legacy
      scripted version of `git stash` first.
      Signed-off-by: Johannes Schindelin's avatarJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  2. 07 Mar, 2019 13 commits
  3. 18 Nov, 2018 1 commit
    • Slavica Djukic's avatar
      stash: tolerate missing user identity · 3bc2111f
      Slavica Djukic authored
      The "git stash" command insists on having a usable user identity to
      the same degree as the "git commit-tree" and "git commit" commands
      do, because it uses the same codepath that creates commit objects
      as these commands.
      It is not strictly necesary to do so. Check if we will barf before
      creating commit objects and then supply fake identity to please the
      machinery that creates commits.
      Add test to document that stash executes correctly both with and
      without valid ident.
      This is not that much of usability improvement, as the users who run
      "git stash" would eventually want to record their changes that are
      temporarily stored in the stashes in a more permanent history by
      committing, and they must do "git config user.{name,email}" at that
      point anyway, so arguably this change is only delaying a step that
      is necessary to work in the repository.
      Helped-by: default avatarJunio C Hamano <gitster@pobox.com>
      Signed-off-by: default avatarSlavica Djukic <slawica92@hotmail.com>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  4. 21 Mar, 2018 1 commit
  5. 20 Mar, 2018 3 commits
    • Thomas Gummerer's avatar
      stash push -u: don't create empty stash · d319bb18
      Thomas Gummerer authored
      When introducing the stash push feature, and thus allowing users to pass
      in a pathspec to limit the files that would get stashed in
      df6bba09 ("stash: teach 'push' (and 'create_stash') to honor
      pathspec", 2017-02-28), this developer missed one place where the
      pathspec should be passed in.
      Namely in the call to the 'untracked_files()' function in the
      'no_changes()' function.  This resulted in 'git stash push -u --
      <non-existant>' creating an empty stash when there are untracked files
      in the repository other that don't match the pathspec.
      As 'git stash' never creates empty stashes, this behaviour is wrong and
      confusing for users.  Instead it should just show a message "No local
      changes to save", and not create a stash.
      Luckily the 'untracked_files()' function already correctly respects
      pathspecs that are passed to it, so the fix is simply to pass the
      pathspec along to the function.
      Reported-by: default avatarMarc Strapetz <marc.strapetz@syntevo.com>
      Signed-off-by: default avatarThomas Gummerer <t.gummerer@gmail.com>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    • Thomas Gummerer's avatar
      stash push: avoid printing errors · 833622a9
      Thomas Gummerer authored
      'git stash push -u -- <pathspec>' prints the following errors if
      <pathspec> only matches untracked files:
          fatal: pathspec 'untracked' did not match any files
          error: unrecognized input
      This is because we first clean up the untracked files using 'git clean
      <pathspec>', and then use a command chain involving 'git add -u
      <pathspec>' and 'git apply' to clear the changes to files that are in
      the index and were stashed.
      As the <pathspec> only includes untracked files that were already
      removed by 'git clean', the 'git add' call will barf, and so will 'git
      apply', as there are no changes that need to be applied.
      Fix this by avoiding the 'git clean' if a pathspec is given, and use the
      pipeline that's used for pathspec mode to get rid of the untracked files
      as well.
      Reported-by: default avatarMarc Strapetz <marc.strapetz@syntevo.com>
      Signed-off-by: default avatarThomas Gummerer <t.gummerer@gmail.com>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    • Junio C Hamano's avatar
      stash: fix nonsense pipeline · d97e4fa7
      Junio C Hamano authored
      An earlier change bba067d2 ("stash: don't delete untracked files
      that match pathspec", 2018-01-06) was made by taking a suggestion in
      a list discussion [1] but did not copy the suggested snippet
      correctly.  And the bug was unnoticed during the review and slipped
      This fixes it.
      [1] https://public-inbox.org/git/xmqqpo7byjwb.fsf@gitster.mtv.corp.google.com/Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  6. 08 Jan, 2018 1 commit
    • Thomas Gummerer's avatar
      stash: don't delete untracked files that match pathspec · bba067d2
      Thomas Gummerer authored
      Currently when 'git stash push -- <pathspec>' is used, untracked files
      that match the pathspec will be deleted, even though they do not end up
      in a stash anywhere.
      This is because the original commit introducing the pathspec feature in
      git stash push (df6bba09 ("stash: teach 'push' (and 'create_stash') to
      honor pathspec", 2017-02-28)) used the sequence of 'git reset <pathspec>
      && git ls-files --modified <pathspec> | git checkout-index && git clean
      The intention was to emulate what 'git reset --hard -- <pathspec>' would
      do.  The call to 'git clean' was supposed to clean up the files that
      were unstaged by 'git reset'.  This would work fine if the pathspec
      doesn't match any files that were untracked before 'git stash push --
      <pathspec>'.  However if <pathspec> matches a file that was untracked
      before invoking the 'stash' command, all untracked files matching the
      pathspec would inadvertently be deleted as well, even though they
      wouldn't end up in the stash, and are therefore lost.
      This behaviour was never what was intended, only blobs that also end up
      in the stash should be reset to their state in HEAD, previously
      untracked files should be left alone.
      To achieve this, first match what's in the index and what's in the
      working tree by adding all changes to the index, ask diff-index what
      changed between HEAD and the current index, and then apply that patch in
      reverse to get rid of the changes, which includes removal of added
      files and resurrection of removed files.
      Reported-by: default avatarReid Price <reid.price@gmail.com>
      Helped-by: default avatarJunio C Hamano <gitster@pobox.com>
      Signed-off-by: default avatarThomas Gummerer <t.gummerer@gmail.com>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  7. 24 Nov, 2017 1 commit
    • Phil Hord's avatar
      stash: learn to parse -m/--message like commit does · 5675473f
      Phil Hord authored
      `git stash push -m foo` uses "foo" as the message for the stash. But
      `git stash push -m"foo"` does not parse successfully.  Similarly
      `git stash push --message="My stash message"` also fails.  The stash
      documentation doesn't suggest this syntax should work, but gitcli
      does and my fingers have learned this pattern long ago for `commit`.
      Teach `git stash` to parse -mFoo and --message=Foo the same as `git
      commit` would do.  Even though it's an internal function, add
      similar support to create_stash() for consistency.
      Signed-off-by: Phil Hord's avatarPhil Hord <phil.hord@gmail.com>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  8. 27 Oct, 2017 2 commits
    • Thomas Gummerer's avatar
      stash: remove now superfluos help for "stash push" · c0c0c825
      Thomas Gummerer authored
      With the 'git stash save' interface, it was easily possible for users to
      try to add a message which would start with "-", which 'git stash save'
      would interpret as a command line argument, and fail.  For this case we
      added some extra help on how to create a stash with a message starting
      with "-".
      For 'stash push', messages are passed with the -m flag, avoiding this
      potential pitfall.  Now only pathspecs starting with "-" would have to
      be distinguished from command line parameters by using
      "-- --<pathspec>".  This is fairly common in the git command line
      interface, and we don't try to guess what the users wanted in the other
      Because this way of passing pathspecs is quite common in other git
      commands, and we don't provide any extra help there, do the same in the
      error message for 'git stash push'.
      Signed-off-by: default avatarThomas Gummerer <t.gummerer@gmail.com>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    • Thomas Gummerer's avatar
      stash: replace "git stash save" with "git stash push" in the documentation · db37745e
      Thomas Gummerer authored
      "git stash push" is the newer interface for creating a stash.  While we
      are still keeping "git stash save" around for the time being, it's better
      to point new users of "git stash" to the more modern (and more feature
      rich) interface, instead of teaching them the older version that we
      might want to phase out in the future.
      Signed-off-by: default avatarThomas Gummerer <t.gummerer@gmail.com>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  9. 14 Aug, 2017 1 commit
    • Kevin Daudt's avatar
      stash: prevent warning about null bytes in input · 5fc92f88
      Kevin Daudt authored
      The `no_changes` function calls the `untracked_files` function through
      command substitution. `untracked_files` will return null bytes because it
      runs ls-files with the '-z' option.
      Bash since version 4.4 warns about these null bytes. As they are not
      required for the test that is being done, make sure `untracked_files`
      does not output null bytes when not required.
      This is achieved by adding a parameter to the `untracked_files` function to
      specify wither `-z` should be passed to ls-files or not.
      This warning is triggered when running git stash save -u resulting in
      two warnings:
          git-stash: line 43: warning: command substitution: ignored null byte
          in input
      Signed-off-by: default avatarKevin Daudt <me@ikke.info>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  10. 11 Aug, 2017 1 commit
  11. 07 Aug, 2017 1 commit
  12. 19 Jun, 2017 1 commit
  13. 13 Jun, 2017 1 commit
    • Patrick Steinhardt's avatar
      git-stash: fix pushing stash with pathspec from subdir · 22fc703e
      Patrick Steinhardt authored
      The `git stash push` command recently gained the ability to get a
      pathspec as its argument to only stash matching files. Calling this
      command from a subdirectory does not work, though, as one of the first
      things we do is changing to the top level directory without keeping
      track of the prefix from which the command is being run.
      Fix the shortcoming by storing the prefix previous to the call to
      `cd_to_toplevel` and then subsequently using `git rev-parse --prefix` to
      correctly resolve the pathspec. Add a test to catch future breakage of
      this usecase.
      Signed-off-by: default avatarPatrick Steinhardt <ps@pks.im>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  14. 22 Mar, 2017 3 commits
  15. 28 Feb, 2017 3 commits
  16. 20 Feb, 2017 2 commits
  17. 06 Dec, 2016 1 commit
    • Jeff King's avatar
      stash: prefer plumbing over git-diff · 9d4e28ea
      Jeff King authored
      When creating a stash, we need to look at the diff between
      the working tree and HEAD, and do so using the git-diff
      porcelain.  Because git-diff enables porcelain config like
      renames by default, this causes at least one problem. The
      --name-only format will not mention the source side of a
      rename, meaning we will fail to stash a deletion that is
      part of a rename.
      We could fix that case by passing --no-renames, but this is
      a symptom of a larger problem. We should be using the
      diff-index plumbing here, which does not have renames
      enabled by default, and also does not respect any
      potentially confusing config options.
      Reported-by: default avatarMatthew Patey <matthew.patey2167@gmail.com>
      Signed-off-by: default avatarJeff King <peff@peff.net>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  18. 26 Oct, 2016 1 commit
    • Aaron M Watson's avatar
      stash: allow stashes to be referenced by index only · a56c8f5a
      Aaron M Watson authored
      Instead of referencing "stash@{n}" explicitly, make it possible to
      simply reference as "n".  Most users only reference stashes by their
      position in the stash stack (what I refer to as the "index" here).
      The syntax for the typical stash (stash@{n}) is slightly annoying and
      easy to forget, and sometimes difficult to escape properly in a
      script. Because of this the capability to do things with the stash by
      simply referencing the index is desirable.
      This patch includes the superior implementation provided by Øsse Walle
      (thanks for that), with a slight change to fix a broken test in the test
      suite. I also merged the test scripts as suggested by Jeff King, and
      un-wrapped the documentation as suggested by Junio Hamano.
      Signed-off-by: default avatarAaron M Watson <watsona4@gmail.com>
      Reviewed-by: default avatarJeff King <peff@peff.net>
  19. 21 Sep, 2016 1 commit
  20. 10 Aug, 2016 1 commit