Re: [PATCH] git-commit: Allow partial commit of file removal.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Junio C Hamano <gitster@xxxxxxxxx> writes:

> Gerrit Pape <pape@xxxxxxxxxxx> 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

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux