git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: git@vger.kernel.org, Paul Tan <pyokagan@gmail.com>
Subject: Re: [PATCH] pull: drop confusing prefix parameter of die_on_unclean_work_tree()
Date: Mon, 14 Mar 2016 09:20:23 -0700	[thread overview]
Message-ID: <xmqqfuvtav5k.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <alpine.DEB.2.20.1603141410590.4690@virtualbox> (Johannes Schindelin's message of "Mon, 14 Mar 2016 14:42:32 +0100 (CET)")

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

>> Another reason why it is more sensible to keep the prefix available,
>> but not use it to limit the extent of diff, to has_*_changes()
>> functions is that it would be easier for us to change our mind later
>> to allow the users to ask for more detailed output.  Instead of
>> "Cannot pull with rebase: You have unstaged changes, period.", you
>> may be asked to list which paths are dirty in such a case, and in
>> order to present the list relative to the directory where the user
>> started the command, you would need "prefix" available to the code
>> that calls into diff machinery somehow.
>
> Let me summarize.
>
> First, you argue that the prefix is a documented way to say: "This
> function needs to be called from the top-level directory".

It tells the reader of this function that the caller has already
moved to the top-level and as a633fca0 (Call setup_git_directory()
much earlier, 2006-07-28) says, gives you the "prefix" (i.e.
pathname of $PWD relative to the project root level).  When you read
the function, hence, you know "prefix" can be used to tell where
originally the command was run from, if you want to learn it.

In other words, I didn't mean to argue anything like what you are
saying.  Either I phrased poorly, or you misread it.

For the purpose of letting "git pull --rebase" make sure that there
is no difference between the index and the working tree, we'd want a
tree-wide diff, so we do not want to limit the diff with pathspec.
Not passing "prefix" to init_revisions() _is_ the right thing.
Again, I think I said that in the message you are responding to, and
either I phrased poorly, or you misread it.

In any case, that call to init_revisions() should have imitated what
index_differs_from() and do_diff_cache() in diff-lib.c do, i.e.
pass NULL as the prefix to say "I do not want any path/subdirectory
limitation".

> P.S.: The idea that a rebasing pull might, at some stage in the future,
> want to require only part of the working directory to be clean, this idea
> also makes little sense to me.

And there is no such idea.  Again, perhaps I phrased the whole thing
poorly or you misread it under the assumption that whenever I disagree
with what you say, it is more likely what I say is incorrect.

I was talking about this sequence:

    $ edit rerere.c
    ... time passes ...
    $ cd Documentation/
    $ git pull --rebase
    error: Cannot pull with rebase: You have unstaged changes.
    ... oh, where do I have changes?
    $ git status -suno
     M ../rerere.c

which you may want to optimize the human-end-user experience by
allowing 'pull --rebase' to say "You have unstaged changes in
../rerere.c" or something along that line [*1*] so that the user
does not have to give a separate "git status" there.

And for that, the code that gives the error message needs to be able
to access the "prefix" (i.e. pathname of $PWD relative to the
project root level) to make that path relative in the output.


[Footnote]

*1* By "something along that line" I mean that you'd need to work
out the details of what to do when there are too many of them, for
example you wouldn't list everything but indicate that the list is
truncated in some way.

  reply	other threads:[~2016-03-14 16:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-10 13:24 [PATCH] pull: drop confusing prefix parameter of die_on_unclean_work_tree() Johannes Schindelin
2016-03-10 17:54 ` Junio C Hamano
2016-03-10 18:09   ` Junio C Hamano
2016-03-14 13:42     ` Johannes Schindelin
2016-03-14 16:20       ` Junio C Hamano [this message]
2016-03-14 17:11         ` Junio C Hamano

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=xmqqfuvtav5k.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=pyokagan@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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).