From: Junio C Hamano <gitster@pobox.com>
To: Gerrit Pape <pape@smarden.org>
Cc: Martin Koegler <mkoegler@auto.tuwien.ac.at>, git@vger.kernel.org
Subject: Re: [PATCH] git-commit: Allow partial commit of file removal.
Date: Fri, 14 Sep 2007 16:34:33 -0700 [thread overview]
Message-ID: <7vveac95yu.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <7vzlzqieko.fsf@gitster.siamese.dyndns.org> (Junio C. Hamano's message of "Thu, 13 Sep 2007 11:51:35 -0700")
Junio C Hamano <gitster@pobox.com> writes:
> Gerrit Pape <pape@smarden.org> writes:
>
>> On Wed, Sep 12, 2007 at 04:04:22PM -0700, Junio C Hamano wrote:
>>> * In my earlier reply to Gerrit, I hinted that we need to
>>> update the pathspec semantics in ls-tree to properly fix this
>>> issue. I cheated here and have ls-files apply its pathspec
>>> semantics to the entries from HEAD as well.
>>
>> This fixes the problem reported through http://bugs.debian.org/437817
>> just fine, thanks. Is this an interims-fix, or should the new option
>> be documented?
>
> I honestly am not convinced it is the right fix. It has a few
> holes in the logic.
>
> Most notably, I think "git rm --cached A; git commit A" would
> not work.
I managed to convince myself that not committing the removal of
A in that case is a _good_ thing, unless somebody comes up with
a good counterexample this will most likely go to 'master' over
the weekend and then to 'maint'.
Any partial commit "git commit <paths>..." is saying:
I might have changed stuff in the index and also have
changes in the working tree. But I do not care about
the changes between HEAD and the index. Honestly, I do
not understand the index at all, and I do not care about
what I staged earlier to the named paths either. Take
the current state of these paths from my work tree and
make a commit relative to the HEAD.
So, if you do:
$ edit new-file old-file
$ rm gone-file
$ git rm missing-file
$ git rm --cached disappeared-file
$ git add new-file ;# was not in HEAD
$ edit new-file old-file
Then:
$ git commit new-file old-file
honors what is in the work tree and picks up the later edits,
largely ignoring the changes to the index.
Removal should work the same way to be consistent.
$ git commit gone-file
$ git commit missing-file
$ git commit disappeared-file
should remove the former two but leave the last one alone, as
you _do_ still have disappeared-file in the work tree.
As it happens, the version I sent will error out on the last one
(disappeared-file case). I think the following patch on top of
it "fixes" it, by adding it back to the index and including its
contents in the resulting commit.
---
diff --git a/git-commit.sh b/git-commit.sh
index 5ea3fd0..bb113e8 100755
--- a/git-commit.sh
+++ b/git-commit.sh
@@ -404,7 +404,7 @@ t,)
(
GIT_INDEX_FILE="$NEXT_INDEX"
export GIT_INDEX_FILE
- git update-index --remove --stdin
+ git update-index --add --remove --stdin
) || exit
;;
esac
parent reply other threads:[~2007-09-14 23:34 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <7vzlzqieko.fsf@gitster.siamese.dyndns.org>]
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=7vveac95yu.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=mkoegler@auto.tuwien.ac.at \
--cc=pape@smarden.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).