git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Piotr Krukowiecki <piotr.krukowiecki@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: git stash: status from current dir not top dir?
Date: Fri, 11 Mar 2011 17:32:32 -0500	[thread overview]
Message-ID: <20110311223232.GA21410@sigill.intra.peff.net> (raw)
In-Reply-To: <4D7A8AC9.1030506@gmail.com>

On Fri, Mar 11, 2011 at 09:49:13PM +0100, Piotr Krukowiecki wrote:

> But "git stash apply" shows status from root of git repository.
> This is misleading because you can't copy and paste the paths.

Yeah, I am inclined to call it a bug. git-status will show the status of
the whole tree from wherever you are, and people who want full paths
will have status.relativePaths turned off, anyway. So I think your
proposed semantics are more natural.

> This patch tries to fix git-stash.sh to show status relative to 
> current directory. I can resend the patch with better commit message.

Yes, please. There is lots of nice discussion in your email but none of
it in the commit message. :)

> diff --git a/git-stash.sh b/git-stash.sh
> index 7561b37..586c12f 100755
> --- a/git-stash.sh
> +++ b/git-stash.sh
> @@ -12,6 +12,7 @@ USAGE="list [<options>]
>  
>  SUBDIRECTORY_OK=Yes
>  OPTIONS_SPEC=
> +START_DIR=`pwd`
>  . git-sh-setup
>  require_work_tree
>  cd_to_toplevel
> @@ -394,7 +395,7 @@ apply_stash () {
>  		then
>  			squelch='>/dev/null 2>&1'
>  		fi
> -		eval "git status $squelch" || :
> +		(cd "$START_DIR" && eval "git status $squelch") || :
>  	else
>  		# Merge conflict; keep the exit status from merge-recursive
>  		status=$?

This fix looks reasonable to me. The other option would be to avoid
cd_to_toplevel at the beginning (which I am not sure why we really need
in the first place, but presumably some code paths rely on it), but it's
probably not worth the risk of introducing new confusing bugs.

-Peff

  reply	other threads:[~2011-03-11 22:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-11 20:49 git stash: status from current dir not top dir? Piotr Krukowiecki
2011-03-11 22:32 ` Jeff King [this message]
2011-03-12  8:57   ` Piotr Krukowiecki
2011-03-14  7:29     ` Junio C Hamano
2011-03-14 19:45       ` Piotr Krukowiecki
2011-03-17 18:13         ` Piotr Krukowiecki
2011-03-17 19:30           ` Junio C Hamano
2011-03-19  9:24             ` Piotr Krukowiecki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110311223232.GA21410@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=piotr.krukowiecki@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).