From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Matthieu Moy <Matthieu.Moy@imag.fr>
Cc: git@vger.kernel.org, Jan Hudec <bulb@ucw.cz>,
Yann Dirson <ydirson@altern.org>,
Christian Jaeger <christian@jaeger.mine.nu>
Subject: Re: [RFC][PATCH] Re: git-rm isn't the inverse action of git-add
Date: Sun, 8 Jul 2007 22:49:10 +0100 (BST) [thread overview]
Message-ID: <Pine.LNX.4.64.0707082240510.4248@racer.site> (raw)
In-Reply-To: <vpq1wfi8wjl.fsf@bauges.imag.fr>
Hi,
On Sun, 8 Jul 2007, Matthieu Moy wrote:
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>
> >> This patch proposes a saner behavior. When there are no difference at
> >> all between file, index and HEAD, the file is removed both from the
> >> index and the tree, as before.
> >>
> >> Otherwise, if the index matches either the file on disk or the HEAD,
> >> the file is removed from the index, but the file is kept on disk, it
> >> may contain important data.
> >
> > However, if some of the files are of the first kind, and some are of
> > the second kind, you happily apply with mixed strategies. IMO that is
> > wrong.
>
> I'm not sure whether this is really wrong. The things git should
> really care about are the index and the repository itself, and the
> proposed behavior is consistant regarding that (either remove all
> files from the index, or remove none).
Well, I think it is wrong for the same reason as it is wrong to apply the
changes to _any_ file when one would fail. And since "git apply" shares
my understanding, I think "git rm" should, too.
> >> static struct {
> >> int nr, alloc;
> >> - const char **name;
> >> + struct file_info * files;
> >> } list;
> >>
> >> static void add_list(const char *name)
> >> {
> >> if (list.nr >= list.alloc) {
> >> list.alloc = alloc_nr(list.alloc);
> >> - list.name = xrealloc(list.name, list.alloc * sizeof(const char *));
> >> + list.files = xrealloc(list.files, list.alloc * sizeof(const char *));
> >
> > This is wrong, too. Yes, it works. But it really should be
> > "sizeof(struct file_info *)". Remember, code is also documentation.
>
> You don't need to argue, that was a typo. My code is definitely wrong,
> but you're wrong too ;-). That's actually sizeof(struct file_info).
Heh, right.
> >> + if (!quiet)
> >> + fprintf(stderr,
> >> + "note: file '%s' not removed "
> >> + "(doesn't match %s).\n",
> >> + path,
> >> + fi.local_changes?"the index":"HEAD");
> >> + return 0;
> >> + }
> >> +}
> >
> > I suspect that this case does never fail. 0 means success for
> > remove_file(). Not good. You should at least have a way to ensure that
> > it removed the files from the working tree from a script. Otherwise there
> > is not much point in returning a value to begin with.
>
> I've changed it to have exit_status = 1 if git-rm aborted before
> starting, and 2 if git-rm skiped some file removals (and of course, 0
> if everything is done as expected).
Oh, so you do not take the return value of this function to determine if
it has or has not done something with the files? That's a bit confusing.
Besides, it would be all the more a reason for a test case, so that I can
see that I am actually wrong.
> > Additionally, since this changes semantics, you better provide test
> > cases to show what is expected to work, and _ensure_ that it actually
> > works.
>
> Sure. I forgot to mention it in my message, but I wanted to have
> feedback before getting into the testsuite stuff.
I think it should be the other way. If you change semantics with the
patch, but another revision changes semantics _differently_, it is really
easy to get lost. In order to demonstrate what should be true, you have
to provide examples. And if you are already providing examples, just wrap
them into
test_description <description>
. ./test-lib.sh
...
test_done
and prefix each test with "test_expect_success", and you're done. It is
really not something requiring a wizard.
> I'm posting the updated patch for info, but it should anyway not be
> merged until
>
> * We agree on the behavior when different files have different kinds
> of changes
I'd understand better what you wish to accomplish with the...
> * I add a testcase.
... testcase. So those are not two distinct points.
> >From f39ae646049b95b055e34da378ea470ef3f3caef Mon Sep 17 00:00:00 2001
> From: Matthieu Moy <Matthieu.Moy@imag.fr>
> Date: Sun, 8 Jul 2007 19:27:44 +0200
> Subject: [PATCH] Change the behavior of git-rm to let it obey in more circumstances without -f.
Please do not do this.
I meant to complain about your OP, but this time it is even worse. The
best way to guarantee that a patch gets lost in a thread is to move it _at
the end_ of a reply.
Please follow the form that you change the subject, still reply, but but
the quoted mail with your answers to that text between the "---" and the
diffstat.
If that text is too long, you should use a separate email for the patch.
Ciao,
Dscho
next prev parent reply other threads:[~2007-07-08 21:56 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-02 18:09 git-rm isn't the inverse action of git-add Christian Jaeger
2007-07-02 19:42 ` Yann Dirson
2007-07-02 20:23 ` Christian Jaeger
2007-07-02 20:40 ` Yann Dirson
2007-07-02 20:54 ` Matthieu Moy
2007-07-02 21:05 ` Johannes Schindelin
2007-07-03 10:37 ` Matthieu Moy
2007-07-03 12:09 ` Johannes Schindelin
2007-07-03 13:40 ` Matthieu Moy
2007-07-03 14:21 ` Johannes Schindelin
2007-07-04 20:08 ` Jan Hudec
2007-07-05 13:44 ` Matthieu Moy
2007-07-05 14:00 ` David Kastrup
2007-07-08 17:36 ` [RFC][PATCH] " Matthieu Moy
2007-07-08 18:10 ` Johannes Schindelin
2007-07-08 20:34 ` Matthieu Moy
2007-07-08 21:49 ` Johannes Schindelin [this message]
2007-07-09 9:45 ` Matthieu Moy
2007-07-13 17:36 ` Matthieu Moy
2007-07-13 17:41 ` [PATCH] More permissive "git-rm --cached" behavior without -f Matthieu Moy
2007-07-13 17:57 ` Jeff King
2007-07-13 18:53 ` Matthieu Moy
2007-07-14 3:42 ` Jeff King
2007-07-14 0:44 ` Jakub Narebski
2007-07-14 6:52 ` Junio C Hamano
2007-07-14 7:16 ` Junio C Hamano
2007-07-14 10:14 ` Matthieu Moy
2007-07-02 21:20 ` git-rm isn't the inverse action of git-add Christian Jaeger
2007-07-03 4:12 ` Jeff King
2007-07-03 4:47 ` Junio C Hamano
2007-07-03 4:59 ` Jeff King
2007-07-03 5:09 ` Junio C Hamano
2007-07-03 5:12 ` Jeff King
2007-07-03 6:26 ` Junio C Hamano
2007-07-11 12:20 ` Jakub Narebski
2007-07-11 18:56 ` Jan Hudec
2007-07-11 21:26 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.64.0707082240510.4248@racer.site \
--to=johannes.schindelin@gmx.de \
--cc=Matthieu.Moy@imag.fr \
--cc=bulb@ucw.cz \
--cc=christian@jaeger.mine.nu \
--cc=git@vger.kernel.org \
--cc=ydirson@altern.org \
/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).