Skip to content
  • Thomas Gummerer's avatar
    stash push -u: don't create empty stash · d319bb18
    Thomas Gummerer authored and Junio C Hamano's avatar Junio C Hamano committed
    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>
    d319bb18