git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] git-commit: Allow partial commit of file removal.
       [not found]       ` <7vzlzqieko.fsf@gitster.siamese.dyndns.org>
@ 2007-09-14 23:34         ` Junio C Hamano
  0 siblings, 0 replies; only message in thread
From: Junio C Hamano @ 2007-09-14 23:34 UTC (permalink / raw)
  To: Gerrit Pape; +Cc: Martin Koegler, git

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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2007-09-14 23:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20070909173324.GA9205@auto.tuwien.ac.at>
     [not found] ` <7vzlzvrlj6.fsf@gitster.siamese.dyndns.org>
     [not found]   ` <7v4phzlc3t.fsf_-_@gitster.siamese.dyndns.org>
     [not found]     ` <20070913112957.10057.qmail@565d4e4908fbe9.315fe32.mid.smarden.org>
     [not found]       ` <7vzlzqieko.fsf@gitster.siamese.dyndns.org>
2007-09-14 23:34         ` [PATCH] git-commit: Allow partial commit of file removal Junio C Hamano

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).