Skip to contentSkip to conversation

update gitcancel.sh to handle modes as well

PATCH In review Martin Schlemmer 2 participants 7 messages Jun 15, 2016 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 update gitcancel.sh to handle modes as well

Hi,

gitcancel.sh do not handle mode changes:

----

$ chmod -x Makefile
$ git cancel
patch: **** Only garbage was found in the patch input.
----

Rather use checkout-cache to sync our tree, as should do the right thing instead of diffing (cancel imply just blow away everything).

gittrack.sh: 03d6db1fb3a70605ef249c632c04e542457f0808

gittrack.sh +2 -0
@@ -51,6 +51,7 @@
 
        read-tree $(tree-id "$name")
        gitdiff.sh local "$name" | gitapply.sh
+       update-cache --refresh
 
 else
        [ "$tracking" ] || \
@@ -61,6 +62,7 @@
        if [ -s ".git/HEAD.local" ]; then
                gitdiff.sh "$tracking" local | gitapply.sh
                read-tree $(tree-id local)
+               update-cache --refresh
 
                head=$(cat .git/HEAD)
                branchhead=$(cat .git/heads/$tracking)
Signature · 1 line
Martin Schlemmer

gittrack.sh: 03d6db1fb3a70605ef249c632c04e542457f0808

gittrack.sh +2 -0
@@ -51,6 +51,7 @@
 
 	read-tree $(tree-id "$name")
 	gitdiff.sh local "$name" | gitapply.sh
+	update-cache --refresh
 
 else
 	[ "$tracking" ] || \
@@ -61,6 +62,7 @@
 	if [ -s ".git/HEAD.local" ]; then
 		gitdiff.sh "$tracking" local | gitapply.sh
 		read-tree $(tree-id local)
+		update-cache --refresh
 
 		head=$(cat .git/HEAD)
 		branchhead=$(cat .git/heads/$tracking)
#1 lore raw
Quoted 27 lines · Martin Schlemmer

Hi,

gitcancel.sh do not handle mode changes:

----

$ chmod -x Makefile
$ git cancel
patch: **** Only garbage was found in the patch input.
----

Rather use checkout-cache to sync our tree, as should do the right thing instead of diffing (cancel imply just blow away everything).

gittrack.sh: 03d6db1fb3a70605ef249c632c04e542457f0808

gittrack.sh +1 -0
@@ -51,6 +51,7 @@
 
        read-tree $(tree-id "$name")
        gitdiff.sh local "$name" | gitapply.sh
+       update-cache --refresh
 
 else
        [ "$tracking" ] || \

gittrack.sh line 68

Quoted 7 lines
gittrack.sh +1 -0
@@ -61,6 +62,7 @@
        if [ -s ".git/HEAD.local" ]; then
                gitdiff.sh "$tracking" local | gitapply.sh
                read-tree $(tree-id local)
+               update-cache --refresh
 
                head=$(cat .git/HEAD)
                branchhead=$(cat .git/heads/$tracking)

Yes, I am an idiot, and its past 1am already here.

Rather use checkout-cache to sync our tree, as should do the right thing instead of diffing (cancel imply just blow away everything).

gitcancel.sh: 839b3c58f20f6eb8412f499a891e007e2e67d114

gitcancel.sh +1 -2
@@ -10,9 +10,8 @@
 #
 # Takes no arguments. Takes the evil changes from the tree.
 
-# FIXME: Does not revert mode changes!
 
-show-diff | patch -p0 -R
 rm -f .git/add-queue .git/rm-queue
+checkout-cache -q -f -a
 
 update-cache --refresh
Signature · 1 line
Martin Schlemmer

gitcancel.sh: 839b3c58f20f6eb8412f499a891e007e2e67d114

gitcancel.sh +1 -2
@@ -10,9 +10,8 @@
 #
 # Takes no arguments. Takes the evil changes from the tree.
 
-# FIXME: Does not revert mode changes!
 
-show-diff | patch -p0 -R
 rm -f .git/add-queue .git/rm-queue
+checkout-cache -q -f -a
 
 update-cache --refresh
#2 lore raw

Dear diary, on Fri, Apr 15, 2005 at 01:04:50AM CEST, I got a letter where Martin Schlemmer <[email protected]> told me that...

Quoted 9 lines

Rather use checkout-cache to sync our tree, as should do the right thing instead of diffing (cancel imply just blow away everything).

gitcancel.sh: 839b3c58f20f6eb8412f499a891e007e2e67d114

gitcancel.sh line 17

Quoted 10 lines
gitcancel.sh +1 -2
@@ -10,9 +10,8 @@
 #
 # Takes no arguments. Takes the evil changes from the tree.
 
-# FIXME: Does not revert mode changes!
 
-show-diff | patch -p0 -R
 rm -f .git/add-queue .git/rm-queue
+checkout-cache -q -f -a
 
 update-cache --refresh

Why -q?

Never make things silent unless you really know what are you doing and why. The same goes for popular throwing of -f to rm's of files which should always exist or 2>/dev/null for cats.

Signature · 3 lines
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
#3 lore raw
Quoted 20 lines · Petr Baudis

Dear diary, on Fri, Apr 15, 2005 at 01:04:50AM CEST, I got a letter where Martin Schlemmer <[email protected]> told me that...

Quoted 18 lines

Rather use checkout-cache to sync our tree, as should do the right thing instead of diffing (cancel imply just blow away everything).

gitcancel.sh: 839b3c58f20f6eb8412f499a891e007e2e67d114

gitcancel.sh +1 -2
@@ -10,9 +10,8 @@
 #
 # Takes no arguments. Takes the evil changes from the tree.
 
-# FIXME: Does not revert mode changes!
 
-show-diff | patch -p0 -R
 rm -f .git/add-queue .git/rm-queue
+checkout-cache -q -f -a
 
Quoted 8 lines

gitcancel.sh line 17

Quoted 1 line
gitcancel.sh +0 -0
 update-cache --refresh

Why -q?

Never make things silent unless you really know what are you doing and why. The same goes for popular throwing of -f to rm's of files which should always exist or 2>/dev/null for cats.

Uhm, no particular reason (other than perhaps working usually on stuff where too much info just confuses the user). If its fine in spirit, the -q can go.

Signature · 1 line
Martin Schlemmer

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw
Quoted 14 lines · Petr Baudis

Dear diary, on Fri, Apr 15, 2005 at 01:04:50AM CEST, I got a letter where Martin Schlemmer <[email protected]> told me that...

Quoted 12 lines

Rather use checkout-cache to sync our tree, as should do the right thing instead of diffing (cancel imply just blow away everything).

gitcancel.sh: 839b3c58f20f6eb8412f499a891e007e2e67d114

gitcancel.sh +0 -0
@@ -10,9 +10,8 @@
 #
 # Takes no arguments. Takes the evil changes from the tree.
 
Quoted 8 lines

gitcancel.sh line 17

Quoted 7 lines
gitcancel.sh +1 -2
-# FIXME: Does not revert mode changes!
 
-show-diff | patch -p0 -R
 rm -f .git/add-queue .git/rm-queue
+checkout-cache -q -f -a
 
 update-cache --refresh

PS, shouldn't we add a read-tree $(tree-id) before the checkout-cache?

Signature · 1 line
Martin Schlemmer
#6 lore raw

Dear diary, on Fri, Apr 15, 2005 at 01:39:06AM CEST, I got a letter where Martin Schlemmer <[email protected]> told me that...

Quoted 17 lines · Petr Baudis
Quoted 16 lines

Dear diary, on Fri, Apr 15, 2005 at 01:04:50AM CEST, I got a letter where Martin Schlemmer <[email protected]> told me that...

Quoted 14 lines

Rather use checkout-cache to sync our tree, as should do the right thing instead of diffing (cancel imply just blow away everything).

gitcancel.sh: 839b3c58f20f6eb8412f499a891e007e2e67d114

gitcancel.sh +0 -1
@@ -10,9 +10,8 @@
 #
 # Takes no arguments. Takes the evil changes from the tree.
 
-# FIXME: Does not revert mode changes!
 
Quoted 8 lines
Quoted 6 lines

gitcancel.sh line 17

Quoted 5 lines
gitcancel.sh +1 -1
-show-diff | patch -p0 -R
 rm -f .git/add-queue .git/rm-queue
+checkout-cache -q -f -a
 
 update-cache --refresh

PS, shouldn't we add a read-tree $(tree-id) before the checkout-cache?

A correct tree should be in the index. And if for any completely weird and smelly reason it isn't, I'm pondering if we should back that out and always reread-tree (takes some time, but do you do git cancel all the time?), or rather comply to it and adjust to the loaded tree, whichever it is.

Signature · 3 lines
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
#7 lore raw
In reply to Martin Schlemmer

Dear diary, on Fri, Apr 15, 2005 at 12:57:25AM CEST, I got a letter where Martin Schlemmer <[email protected]> told me that...

Quoted 27 lines

Hi,

gitcancel.sh do not handle mode changes:

----

$ chmod -x Makefile
$ git cancel
patch: **** Only garbage was found in the patch input.
----

Rather use checkout-cache to sync our tree, as should do the right thing instead of diffing (cancel imply just blow away everything).

gittrack.sh: 03d6db1fb3a70605ef249c632c04e542457f0808

gittrack.sh +1 -0
@@ -51,6 +51,7 @@
 
        read-tree $(tree-id "$name")
        gitdiff.sh local "$name" | gitapply.sh
+       update-cache --refresh
 
 else
        [ "$tracking" ] || \

gittrack.sh line 68

Quoted 7 lines
gittrack.sh +1 -0
@@ -61,6 +62,7 @@
        if [ -s ".git/HEAD.local" ]; then
                gitdiff.sh "$tracking" local | gitapply.sh
                read-tree $(tree-id local)
+               update-cache --refresh
 
                head=$(cat .git/HEAD)
                branchhead=$(cat .git/heads/$tracking)

The patch looks familiar, but not right. ;-)

Signature · 3 lines
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor